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_MESH_
00025 #define _PB_MESH_
00026
00027 #include <Inventor/SbBox.h>
00028 #include <Inventor/SbLinear.h>
00029 #include <Inventor/SbString.h>
00030 #include <Inventor/STL/set>
00031
00032 #include <MeshViz/nodes/PoMeshProperty.h>
00033 #include <MeshViz/graph/PbBase.h>
00034 #include <MeshViz/misc/PbArrayOfInt.h>
00035
00036 class PbCell;
00037 template <class _T> class PiSetOfDataSet;
00038
00039
00084 class PbMesh : public PbBase {
00085
00086
00087 public:
00088
00094 enum DataBinding {
00096 PER_CELL = PoMeshProperty::PER_CELL,
00098 PER_NODE = PoMeshProperty::PER_NODE
00099 };
00100
00101
00107 PbMesh(SbBool is_data_duplicated=TRUE) ;
00108
00112 PbMesh(const PbMesh &mesh);
00113
00117 ~PbMesh() ;
00118
00122 PbMesh& operator=(const PbMesh &mesh) ;
00123
00127 int getNumNodes() const;
00128
00132 int getNumCells() const;
00133
00137 virtual SbVec3f getNodeCoord(int nod_index) const=0;
00138
00142 SbBox3f getBoundingBox() const;
00143
00151 SbBool isDataDuplicated() const { return isDataDuplicate; }
00152
00164 virtual void addValuesSet(int set_index, const float *val, const SbString &set_name = "");
00165
00187 void addValuesSet(int set_index, const float *val, DataBinding binding, const SbString &set_name = "");
00188
00195 DataBinding getValuesBinding(int set_index) const;
00196
00203 virtual void addStringsSet(int set_index, const SbString *val, const SbString &set_name = "");
00204
00211 virtual void addVecsSet(int set_index, const SbVec3f *val, const SbString &set_name = "");
00212
00218 virtual const SbString* getValuesSetName(int set_index) const ;
00219
00225 virtual const SbString* getStringsSetName(int set_index) const ;
00226
00232 virtual const SbString* getVecsSetName(int set_index) const ;
00233
00239 virtual const float* getValuesSet(int set_index) const;
00240
00246 virtual const SbString* getStringsSet(int set_index) const;
00247
00253 virtual const SbVec3f* getVecsSet(int set_index) const;
00254
00260 virtual SbBool removeValuesSet(int set_index);
00261
00267 virtual SbBool removeStringsSet(int set_index);
00268
00274 virtual SbBool removeVecsSet(int set_index);
00275
00279 virtual void removeAllValuesSet();
00280
00284 virtual void removeAllStringsSet();
00285
00289 virtual void removeAllVecsSet();
00290
00294 virtual int getNumValuesSet() const;
00295
00299 virtual int getNumStringsSet() const;
00300
00304 virtual int getNumVecsSet() const;
00305
00312 virtual SbBool getMinValuesSet(int set_index, float &min) const;
00313
00320 virtual SbBool getMinVecsSet(int set_index, float &min) const;
00321
00328 virtual SbBool getMaxValuesSet(int set_index, float &max) const;
00329
00336 virtual SbBool getMaxVecsSet(int set_index, float &max) const;
00337
00341 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const=0;
00342
00349 virtual void getNodesOwnerCellsInd(const PbArrayOfInt &nod_indices, PbArrayOfInt &owner_cells) const;
00350
00355 virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const;
00356
00361 virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const;
00362
00368 virtual const PbCell *getCell(int cell_index) const=0;
00369
00375 virtual SbBox3f getSmallestCellBox(int &cell_index) const;
00376
00382 virtual SbBox3f getBiggestCellBox(int &cell_index) const;
00383
00387 virtual float getVolume() const=0;
00388
00392 virtual float getArea() const=0;
00393
00398 virtual const PbCell* findContainingCell(const SbVec3f &point, float tolerance, SbVec3f &pcoord, const PbCell *adjacent_cell) const;
00399
00414 virtual const PbCell* findContainingCell(const SbVec3f &point, float tolerance, SbVec3f &pcoord) const;
00415
00421 virtual void setCoordinates(const float *x_nod, const float *y_nod, const float *z_nod);
00422
00434 virtual void getCoordinates(const float* &xnod, const float* &ynod, const float* &znod,
00435 int &size_xnod, int &size_ynod, int &size_znod) const;
00436
00437
00438 private:
00439
00440
00441 void addVecsSet(int set_index, const SbVec3f *val, DataBinding binding, const SbString &set_name = "");
00442 DataBinding getVecsBinding(int set_index) const;
00443
00444
00445 virtual float getLongestEdgeLength();
00446 virtual void print(FILE *fp) const;
00447 void printInfo() const {print(stdout);};
00448 virtual SbBool isEmpty() const;
00449
00450 virtual const PbCell *getTopoCell(int cell_index) const;
00451
00452 uint32_t getGeometryId() const { return m_geometryId; }
00453 uint32_t getTopologyId() const { return m_topologyId; }
00454 uint32_t getFltDataSetId(int index) const;
00455 uint32_t getVecDataSetId(int index) const;
00456 uint32_t getStrDataSetId(int index) const;
00457
00458
00459 private:
00460 virtual void updateBoundingBox()const=0;
00461 virtual void updateCellBoundingBox() const;
00462 virtual const PbCell* findContainingCellProtected(const SbVec3f &point, float tolerance, SbVec3f &pcoord, PbArrayOfInt &test_cell) const=0;
00463
00464 void updateGeometryId();
00465 void updateTopologyId();
00466 void updateFltDataId(uint32_t &id);
00467 void updateVecDataId(uint32_t &id);
00468 void updateStrDataId(uint32_t &id);
00469
00470 SbBool isDataDuplicate;
00471 int numMeshNodes;
00472 int m_numMeshCells;
00473
00474
00475 SbBool m_longestEdgeLengthIsUpdated;
00476 float m_longestEdgeLength;
00477
00478 mutable SbBox3f m_meshBoundingBox;
00479
00480 PiSetOfDataSet<float> *m_meshValuesSet;
00481 PiSetOfDataSet<SbString> *m_meshStringsSet;
00482 PiSetOfDataSet<SbVec3f> *m_meshVecsSet;
00483
00484 mutable SbBool m_meshBoundingBoxIsUpdated;
00485 mutable SbBool m_cellBoundingBoxIsUpdated;
00486 mutable SbBox3f m_smallestCellBoundingBox;
00487 mutable SbBox3f m_biggestCellBoundingBox;
00488 mutable int m_smallestCellInd;
00489 mutable int m_biggestCellInd;
00490
00491
00492 private:
00493
00494 uint32_t m_geometryId;
00495 uint32_t m_topologyId;
00496
00497
00498 static uint32_t sm_nextGeometryId;
00499 static uint32_t sm_nextTopologyId;
00500 static uint32_t sm_nextFltDataId;
00501 static uint32_t sm_nextVecDataId;
00502 static uint32_t sm_nextStrDataId;
00503
00504 mutable PbArrayOfInt m_CellsAlreadyTested;
00505
00506 void copy(const PbMesh &mesh) ;
00507 void destroy();
00508 };
00509
00510
00511
00512 inline int
00513 PbMesh::getNumNodes() const
00514 { return numMeshNodes; }
00515
00516 inline int
00517 PbMesh::getNumCells() const
00518 { return m_numMeshCells; }
00519
00520 inline SbBox3f
00521 PbMesh::getBoundingBox() const
00522 {
00523 updateBoundingBox();
00524 return m_meshBoundingBox;
00525 }
00526
00527 inline void
00528 PbMesh::setCoordinates(const float *, const float *, const float *)
00529 {}
00530
00531 inline void
00532 PbMesh::getCoordinates(const float* &, const float* &, const float* &, int &, int &, int &) const
00533 {}
00534
00535 inline const PbCell *
00536 PbMesh::getTopoCell(int) const
00537 { return NULL; }
00538
00539
00540 #endif
00541
00542
00543
00544
00545
00546
00547
00548