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_INDEXEDMESH2D_
00025 #define _PB_INDEXEDMESH2D_
00026
00027 #include <Inventor/STL/vector>
00028
00029 #include <MeshViz/3Ddata/PbMesh2D.h>
00030 class PiContouring;
00031 class PiEdgeList;
00032 class PiEdge;
00033 class PbQuadrangleCell;
00034 class PbTriangleCell;
00035
00064 class PbIndexedMesh2D : public PbMesh2D {
00065
00066
00067 public:
00068
00069
00070
00074 PbIndexedMesh2D(SbBool is_data_duplicate=TRUE);
00075
00079 PbIndexedMesh2D(const PbIndexedMesh2D &mesh);
00080
00085 PbIndexedMesh2D(int num_nodes, const float *x_nod, const float *y_nod,
00086 int num_cells, const int *cell_index, const int *cell_type,
00087 SbBool is_data_duplicate=TRUE) ;
00088
00093 PbIndexedMesh2D(int num_nodes, const float *x_nod, const float *y_nod, const float *z_nod,
00094 int num_cells, const int *cell_index, const int *cell_type,
00095 SbBool is_data_duplicate=TRUE) ;
00096
00100 ~PbIndexedMesh2D() ;
00101
00105 PbIndexedMesh2D& operator=(const PbIndexedMesh2D &mesh) ;
00106
00110 friend int operator ==(const PbIndexedMesh2D &m1, const PbIndexedMesh2D &m2);
00111
00115 friend int operator !=(const PbIndexedMesh2D &m1, const PbIndexedMesh2D &m2)
00116 { return !(m1 == m2); }
00117
00121 void setGeometry(int num_nodes, const float *x_nod, const float *y_nod,
00122 int num_cells, const int *cell_index, const int *cell_type);
00123
00127 void setGeometry(int num_nodes, const float *x_nod, const float *y_nod, const float *z_nod,
00128 int num_cells, const int *cell_index, const int *cell_type);
00129
00135 void getGeometry(int &numNode, const float* &x_nod, const float* &y_nod, const float* &z_nod,
00136 int &num_cells, const int32_t *&cell_index, const int32_t *&cell_type) const ;
00137
00143 void getGeometry(int &numNode, const float* &x_nod, const float* &y_nod,
00144 int &num_cells, const int32_t *&cell_index, const int32_t *&cell_type) const ;
00145
00151 void getNodes(int &num_nodes, const float* &x_nod, const float* &y_nod, const float* &z_nod) const;
00152
00158 void getNodes(int &num_nodes, const float* &x_nod, const float* &y_nod) const;
00159
00163 virtual SbVec3f getNodeCoord(int nod_index) const;
00164
00168 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const;
00169
00175 virtual const PbCell *getCell(int cell_index) const;
00176
00180 enum ElemOrientation {
00184 ORIENTATION_AS_IS,
00188 ORIENTATION_ZPOS,
00192 ORIENTATION_ZNEG
00193 } ;
00194
00195
00196
00205 virtual void setElemOrientation(ElemOrientation cell_orient);
00206
00207
00208
00209
00210 private:
00211
00212 void meshLines(PoMeshLines *_PoMeshLines) const;
00213 void meshFilled(PoMeshFilled *_PoMeshFilled) const;
00214 void meshContouring(PiContouring *_PiContouring, const float *z) const;
00215 void mesh2DVec(PoMesh2DVec *mesh_vec) const ;
00216 SbBool isEmpty() const;
00217
00218 void print(FILE *fp) const;
00219 void printInfo() const {print(stdout);};
00220
00221 ElemOrientation getElemOrientation() const;
00222 const SbBool * getOrientFlags() const;
00223 virtual SbVec3f getFirstCellNormal() const;
00224
00225 void getNodesCoord(const float *z, SoMFVec3f &vertices) const;
00226
00227 virtual void getLimitIndices(PbArrayOfInt &nodesIndex, PbArrayOfInt &limitSizes) const;
00228
00229 private:
00230 PbIndexedMesh2D(int num_z, const float *z, SbBool is_data_duplicate=TRUE);
00231
00232 virtual const PbCell* findContainingCellProtected(const SbVec3f &point, float tolerance, SbVec3f &pcoord, PbArrayOfInt &test_cell) const;
00233 void updateCellBoundingBox() const;
00234 virtual void updateOwnerCellsList() const;
00235 virtual void deleteOwnerCellsList() const;
00236 void updateBoundingBox() const;
00237
00238 ElemOrientation elemOrientation;
00239 SbBool *elemOrientFlags;
00240 int allocNodes;
00241 float *xNodes, *yNodes;
00242 int32_t allocElemIndex, *elemIndex, elemIndexSize;
00243 int32_t allocElem, *elemType;
00244
00245 void setVertices(int num_nodes, const float *x_nod, const float *y_nod);
00246
00247 mutable std::vector<PbArrayOfInt> m_ownerCellsList;
00248
00249 private:
00250
00251 void constructDefaultMesh();
00252 void constructXYGeometry(int num_nodes, const float *x_nod, const float *y_nod,
00253 int num_cells, const int *cell_index, const int *cell_type,
00254 SbBool is_data_duplicate);
00255 void setXYGeometry(int num_nodes, const float *xNode, const float *yNode,
00256 int num_cells, const int *cell_index, const int *cell_type);
00257
00258 void copy(const PbIndexedMesh2D &mesh) ;
00259 void destroy();
00260
00261 PbQuadrangleCell *m_quadrangle;
00262 PbTriangleCell *m_triangle;
00263 } ;
00264
00265
00266
00267 #endif
00268
00269
00270
00271
00272
00273
00274
00275