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
00138 private:
00139 virtual void grid3DSkin(PoMeshSkin *_PoMeshSkin) const = 0;
00140
00141 PbGrid3D(int num_x, int num_y, int num_z, SbBool isDataDuplicate=TRUE) ;
00142 void setDim(int num_x, int num_y, int num_z);
00143 virtual void setXYZGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z)=0;
00144 virtual void getXYZGeometry(const float* &x, const float* &y, const float* &z) const=0;
00145 int numX,numY,numZ;
00146
00147
00148
00149 mutable int m_cellNodeIds[8];
00150
00151 private:
00152 void copy(const PbGrid3D &mesh) ;
00153 void destroy();
00154 } ;
00155
00156
00157
00158
00159 inline void
00160 PbGrid3D::getNodeIndices(int nod_index, int &i, int &j, int &k) const
00161 {
00162 int tmp;
00163 k = nod_index % numZ;
00164 tmp = (nod_index-k) / numZ;
00165 j = tmp % numY;
00166 i = (tmp-j) / numY;
00167 }
00168
00169
00170 inline void
00171 PbGrid3D::getCellIndices(int cell_index, int &i, int &j, int &k) const
00172 {
00173 int ny=numY-1, nz=numZ-1;
00174 int tmp;
00175 k = cell_index % nz;
00176 tmp = (cell_index-k) / nz;
00177 j = tmp % ny;
00178 i = (tmp-j) / ny;
00179 }
00180
00181
00182 inline void
00183 PbGrid3D::setDim(int num_x, int num_y, int num_z)
00184 {
00185 numX = num_x;
00186 numY = num_y;
00187 numZ = num_z;
00188 numMeshNodes = numX * numY * numZ;
00189 m_numMeshCells = (numX-1) * (numY-1) * (numZ-1);
00190 updateTopologyId();
00191 }
00192
00193 inline int *
00194 PbGrid3D::getCellNodeIds(int cell_index) const
00195 {
00196 int i, j, k;
00197 getCellIndices(cell_index, i, j, k);
00198 return getCellNodeIds(i,j,k);
00199 }
00200
00201 #define NSI_(i,j,k) numZ*((j)+(i)*numY) + (k)
00202 inline int *
00203 PbGrid3D::getCellNodeIds(int i, int j, int k) const
00204 {
00205 m_cellNodeIds[4] = (m_cellNodeIds[0] = NSI_(i ,j ,k )) + 1;
00206 m_cellNodeIds[5] = (m_cellNodeIds[1] = NSI_(i+1,j ,k )) + 1;
00207 m_cellNodeIds[6] = (m_cellNodeIds[2] = NSI_(i+1,j+1,k )) + 1;
00208 m_cellNodeIds[7] = (m_cellNodeIds[3] = NSI_(i ,j+1,k )) + 1;
00209 return m_cellNodeIds;
00210 }
00211
00212 #endif
00213
00214
00215
00216
00217
00218
00219
00220