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_GRID2D_
00025 #define _PB_GRID2D_
00026
00027 #include <MeshViz/3Ddata/PbMesh2D.h>
00043 class PbGrid2D : public PbMesh2D {
00044
00045
00046 public:
00047
00051 PbGrid2D(SbBool is_data_duplicate=TRUE) : PbMesh2D(is_data_duplicate) {};
00052
00056 PbGrid2D(const PbGrid2D &mesh);
00057
00061 ~PbGrid2D();
00062
00066 PbGrid2D& operator=(const PbGrid2D &mesh) ;
00067
00073 void setGeometry(int num_x, int num_y, const float *x, const float *y);
00074
00081 void setGeometry(int num_x, int num_y, const float *x, const float *y, const float *z);
00082
00088 void getGeometry(int &num_x, int &num_y, const float* &x, const float* &y) const;
00089
00096 void getGeometry(int &num_x, int &num_y, const float* &x, const float* &y, const float* &z) const;
00097
00101 virtual SbVec3f getNodeCoord(int nod_index) const=0;
00102
00106 virtual SbVec3f getNodeCoord(int i, int j) const=0;
00107
00111 void getDim(int &num_x, int &num_y) const { num_x = numX; num_y = numY;};
00112
00116 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const;
00117
00122 virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const;
00123
00128 virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const;
00129
00133 void getNodeIndices(int nod_index, int &i, int &j) const;
00134
00138 void getCellIndices(int cell_index, int &i, int &j) const;
00139 private:
00140 int * getCellNodeIds(int i, int j) const;
00141 int * getCellNodeIds(int cell_index) const;
00142 virtual SbVec3f getFirstCellNormal() const;
00143
00144 void print(FILE *fp) const;
00145 virtual void getLimitIndices(PbArrayOfInt &nodesIndex, PbArrayOfInt &limitSizes) const;
00146
00147 private:
00148 virtual void updateCellBoundingBox() const;
00149 PbGrid2D(int num_x, int num_y, SbBool isDataDuplicate=TRUE) ;
00150 PbGrid2D(int num_x, int num_y, const float *z, SbBool isDataDuplicate=TRUE) ;
00151 void setDim(int num_x, int num_y);
00152 virtual void setXYGeometry(int num_x, int num_y, const float *x, const float *y)=0;
00153 virtual void getXYGeometry(const float* &x, const float* &y) const=0;
00154 void setZCoordMatrix(int num_x, int num_y, const float *z);
00155 int numX,numY;
00156 float **z;
00157
00158
00159
00160 mutable int m_cellNodeIds[4];
00161
00162 private:
00163
00164 void copy(const PbGrid2D &mesh) ;
00165 void destroy();
00166 } ;
00167
00168
00169
00170
00171 inline void
00172 PbGrid2D::getNodeIndices(int nod_index, int &i, int &j) const
00173 {
00174 j = nod_index % numY;
00175 i = (nod_index-j) / numY;
00176 }
00177
00178
00179 inline void
00180 PbGrid2D::getCellIndices(int cell_index, int &i, int &j) const
00181 {
00182 j = cell_index % (numY-1);
00183 i = (cell_index-j) / (numY-1);
00184 }
00185
00186
00187 inline void
00188 PbGrid2D::setDim(int num_x, int num_y)
00189 {
00190 numX = num_x;
00191 numY = num_y;
00192 numMeshNodes = numX * numY;
00193 if (num_x > 1 && num_y > 1)
00194 m_numMeshCells = (numX-1) * (numY-1);
00195 else
00196
00197 m_numMeshCells = 0;
00198 }
00199
00200 inline int *
00201 PbGrid2D::getCellNodeIds(int cell_index) const
00202 {
00203 int i, j;
00204 getCellIndices(cell_index, i, j);
00205 return getCellNodeIds(i,j);
00206 }
00207
00208 inline int *
00209 PbGrid2D::getCellNodeIds(int i, int j) const
00210 {
00211 m_cellNodeIds[0] = i*numY+j;
00212 m_cellNodeIds[1] = (i+1)*numY+j;
00213 m_cellNodeIds[2] = (i+1)*numY+j+1;
00214 m_cellNodeIds[3] = i*numY+j+1;
00215 return m_cellNodeIds;
00216 }
00217
00218 #endif
00219
00220
00221
00222
00223
00224
00225
00226