00001 #ifndef _HPARENT_HPP_
00002 #define _HPARENT_HPP_
00003
00004 #include "../Common.h"
00005 #include "hObj.h"
00006 #include "../Field.hpp"
00007 #include <algorithm>
00008
00009 class hHybridMesh;
00010
00011
00012 using Memory::Field;
00013
00020
00021 template <int I, int nTVerts, int nTComponents, class TComponents = BYTE,
00022 int nTFlags=0,int nTSons=0,int nTCoords=0, int nTNeighs=0>
00023 class hParent : public hObj
00024 {
00025 public:
00026 static const uTind myType = I;
00027 static const uTind nVerts = nTVerts;
00028 static const uTind nComponents = nTComponents;
00029 static const uTind nSons = nTSons;
00030 static const uTind nFlags = nTFlags;
00031 static const uTind nNeighs = nTNeighs;
00032 static const uTind nNodes = nVerts+nComponents+nFlags+nNeighs+nSons;
00033 static const uTind nCoords = nTCoords;
00034
00035 hParent(hHybridMesh* myMesh, const uTind vertices[],const uTind posID)
00036 : hObj(posID, eTable[myType])
00037 {
00038
00039 nodes_=nodesArr_;
00040 mySize_ = sizeof( *this );
00041 clear();
00042
00043 if(vertices != NULL)
00044 {
00045 mf_check_debug(std::count(vertices,vertices+nVerts,0)==0, "Incorrect vertex number during elem creation!");
00046 memcpy(nodesArr_,vertices,sizeof(uTind)*typeSpecyfic_.nVerts_);
00047
00048
00049
00050
00051
00052
00053
00054
00055 }
00056 init(myMesh);
00057 }
00058
00059
00060 ~hParent(){}
00061
00062 void init(hHybridMesh *myMesh);
00063
00064
00065
00066
00067
00068
00069 void setComponentsPerPos(const Tind pos[])
00070 {
00071 for(uTind i(0); i < nComponents; ++i)
00072 {
00073 components(i) = hObj::makeId(pos[i],TComponents::myType);
00074 }
00075 }
00076
00077 bool checkPointers() const
00078 {
00079 assert(nodes_ == nodesArr_);
00080 return (nodes_ == nodesArr_);
00081 }
00082
00083
00084 void print() const
00085 {
00086 hObj::print();
00087 }
00088
00089 private:
00090 ID nodesArr_[nNodes];
00091
00092 void clear()
00093 {
00094 memset(nodesArr_,0,sizeof(ID)*nNodes);
00095 }
00096
00097
00098
00099 hParent(const hParent & other);
00100 hParent & operator=(const hParent & other);
00101
00102
00103
00104 public:
00105 Field<nCoords,double> coords_;
00106 };
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 typedef hParent<0,0,0> EmptyHParent;
00124
00125
00126 namespace EmptyHParentSpace
00127 {
00128 void mark2Ref(hHybridMesh* myMesh,hObj* ,const int );
00129 void mark2Deref(hHybridMesh* myMesh,hObj* );
00130 void mark2Delete(hHybridMesh* myMesh,hObj* );
00131 int refine(hHybridMesh* myMesh,hObj* ,const int );
00132 void derefine(hHybridMesh* myMesh,hObj* );
00133 bool test(const hHybridMesh* myMesh,const hObj* );
00134 ID components(hHybridMesh* myMesh,const hObj* obj,const int i);
00135
00136 const uTind nVertices=0;
00137 const uTind nEdges=0;
00138 const uTind nFaces=0;
00139 };
00140
00141 #define MMT_H_MESH_TYPE(NAME,TYPE_ID,N_COMP,COMP_TYPE,N_VERT,N_FLAGS,N_NEIGS,N_SONS,N_EDGES,N_FACES,N_COORDS) \
00142 const EntityAttributes shared(TYPE_ID,N_COMP,N_VERT,N_FLAGS,N_NEIGS,N_SONS,N_EDGES,N_FACES,N_COORDS, \
00143 &mark2Ref,&mark2Deref,&mark2Delete,&refine,&derefine,&test); \
00144 typedef hParent<TYPE_ID,N_VERT, N_COMP,COMP_TYPE,N_FLAGS,0,N_COORDS,N_NEIGS> NAME; \
00145 typedef hParent<TYPE_ID,N_VERT, N_COMP,COMP_TYPE,N_FLAGS,N_SONS,N_COORDS,N_NEIGS> NAME##D;
00146
00149 #endif // _HPARENT_HPP_