00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PB_GRID3D_
00025 #define _PB_GRID3D_
00026
00027 #include <MeshViz/3Ddata/PbMesh3D.h>
00028
00044 class PbGrid3D : public PbMesh3D {
00045
00046
00047 public:
00048
00052 PbGrid3D(SbBool is_data_duplicate=TRUE) : PbMesh3D(is_data_duplicate) {};
00053
00057 PbGrid3D(const PbGrid3D &mesh);
00058
00062 ~PbGrid3D();
00063
00067 PbGrid3D& operator=(const PbGrid3D &mesh) ;
00068
00074 void setGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z);
00075
00081 void getGeometry(int &num_x, int &num_y, int &num_z, const float* &x, const float* &y, const float* &z) const;
00082
00086 virtual SbVec3f getNodeCoord(int nod_index) const=0;
00087
00091 virtual SbVec3f getNodeCoord(int i, int j, int k) const=0;
00092
00096 void getDim(int &num_x, int &num_y, int &num_z) const { num_x = numX; num_y = numY; num_z = numZ;};
00097
00101 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const;
00102
00107 virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const;
00108
00113 virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const;
00114
00118 void getNodeIndices(int nod_index, int &i, int &j, int &k) const;
00119
00123 void getCellIndices(int cell_index, int &i, int &j, int &k) const;
00124
00125
00126 private:
00127 void meshSkin(PoMeshSkin *_PoMeshSkin) const;
00128
00129 virtual int evaluateSkinFacesNum() const {
00130 return 2*((numZ-1)*(numY-1) + (numZ-1)*(numX-1) + (numX-1)*(numY-1));
00131 }
00132
00133 int * getCellNodeIds(int i, int j, int k) const;
00134 int * getCellNodeIds(int cell_index) const;
00135
00136 void print(FILE *fp) const;
00137 void printInfo() const {print(stdout);};
00138
00139 private:
00140 virtual void grid3DSkin(PoMeshSkin *_PoMeshSkin) const = 0;
00141
00142 PbGrid3D(int num_x, int num_y, int num_z, SbBool isDataDuplicate=TRUE) ;
00143 void setDim(int num_x, int num_y, int num_z);
00144 virtual void setXYZGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z)=0;
00145 virtual void getXYZGeometry(const float* &x, const float* &y, const float* &z) const=0;
00146 int numX,numY,numZ;
00147
00148
00149
00150 mutable int m_cellNodeIds[8];
00151
00152 private:
00153 void copy(const PbGrid3D &mesh) ;
00154 void destroy();
00155 } ;
00156
00157
00158
00159
00160 inline void
00161 PbGrid3D::getNodeIndices(int nod_index, int &i, int &j, int &k) const
00162 {
00163 int tmp;
00164 k = nod_index % numZ;
00165 tmp = (nod_index-k) / numZ;
00166 j = tmp % numY;
00167 i = (tmp-j) / numY;
00168 }
00169
00170
00171 inline void
00172 PbGrid3D::getCellIndices(int cell_index, int &i, int &j, int &k) const
00173 {
00174 int ny=numY-1, nz=numZ-1;
00175 int tmp;
00176 k = cell_index % nz;
00177 tmp = (cell_index-k) / nz;
00178 j = tmp % ny;
00179 i = (tmp-j) / ny;
00180 }
00181
00182
00183 inline void
00184 PbGrid3D::setDim(int num_x, int num_y, int num_z)
00185 {
00186 numX = num_x;
00187 numY = num_y;
00188 numZ = num_z;
00189 numMeshNodes = numX * numY * numZ;
00190 m_numMeshCells = (numX-1) * (numY-1) * (numZ-1);
00191 updateTopologyId();
00192 }
00193
00194 inline int *
00195 PbGrid3D::getCellNodeIds(int cell_index) const
00196 {
00197 int i, j, k;
00198 getCellIndices(cell_index, i, j, k);
00199 return getCellNodeIds(i,j,k);
00200 }
00201
00202 #define NSI_(i,j,k) numZ*((j)+(i)*numY) + (k)
00203 inline int *
00204 PbGrid3D::getCellNodeIds(int i, int j, int k) const
00205 {
00206 m_cellNodeIds[4] = (m_cellNodeIds[0] = NSI_(i ,j ,k )) + 1;
00207 m_cellNodeIds[5] = (m_cellNodeIds[1] = NSI_(i+1,j ,k )) + 1;
00208 m_cellNodeIds[6] = (m_cellNodeIds[2] = NSI_(i+1,j+1,k )) + 1;
00209 m_cellNodeIds[7] = (m_cellNodeIds[3] = NSI_(i ,j+1,k )) + 1;
00210 return m_cellNodeIds;
00211 }
00212
00213 #endif
00214
00215
00216
00217
00218
00219
00220
00221