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 _PO_MESH_
00025 #define _PO_MESH_
00026
00027 #include <Inventor/fields/SoSFEnum.h>
00028 #include <Inventor/fields/SoSFShort.h>
00029 #include <Inventor/fields/SoSFInt32.h>
00030 #include <Inventor/nodes/SoGroup.h>
00031 #include <Inventor/nodes/SoCoordinate3.h>
00032 #include <Inventor/nodes/SoMaterial.h>
00033 #include <Inventor/nodes/SoMaterialBinding.h>
00034 #include <Inventor/nodes/SoNormal.h>
00035 #include <Inventor/nodes/SoNormalBinding.h>
00036 #include <Inventor/nodes/SoTextureCoordinateBinding.h>
00037 #include <Inventor/nodes/SoTextureCoordinate2.h>
00038 #include <Inventor/nodes/SoTexture2.h>
00039 #include <Inventor/nodes/SoShapeHints.h>
00040 #include <Inventor/nodes/SoIndexedShape.h>
00041
00042 #include <MeshViz/3Ddata/Po3DdataMaster.h>
00043 #include <MeshViz/misc/PbArrayOfLong.h>
00044 #include <MeshViz/graph/PbLinearDataMapping.h>
00045 #include <MeshViz/graph/PbIsovaluesList.h>
00046
00047 #include <Inventor/STL/vector>
00048
00049 #ifdef _WIN32
00050 #pragma warning(push)
00051 #pragma warning(disable:4251)
00052 #endif
00053
00054 class PbMesh;
00055 class PbDataMapping;
00056 class PiContouringLines;
00057 class PiContouringFilled;
00058 class PiTextureContouring;
00059 class PoCellFilter;
00060
00110 class PoMesh : public Po3DdataMaster {
00111
00112 SO_KIT_HEADER(PoMesh) ;
00113
00114 public:
00115
00116
00117
00125 SoSFInt32 valuesIndex;
00126
00138 SoSFInt32 valuesIndexForCellFilter;
00139
00145 SoSFInt32 vecsIndex;
00146
00150 enum ColoringType {
00151 COLOR_INHERITED,
00152 COLOR_AVERAGE,
00153 COLOR_MAPPING,
00154 COLOR_CONTOURING,
00155 COLOR_TEXTURE_CONTOURING
00156 } ;
00157
00158
00159
00219 SoSFEnum coloringType;
00220
00226 SoSFNode moduleDataMapping;
00227
00234 SoSFBool smoothTextureContouring;
00235
00246 SoSFFloat creaseAngle;
00247
00248
00249
00250
00254 void setMesh(PbMesh *mesh);
00255
00260 void setDataMapping( PbDataMapping *data_mapping);
00261
00266 void setModuleDataMapping( PbDataMapping *mod_data_mapping);
00267
00273 void setIsovaluesList(PbIsovaluesList *isovalues_list);
00274
00275
00276
00277
00278
00282 const PbMesh * getMesh() const;
00283
00287 const PbDataMapping * getDataMapping() const;
00288
00293 const PbDataMapping * getModuleDataMapping() const;
00294
00298 const PbIsovaluesList *getIsovaluesList() const;
00299
00300
00301
00302
00303 private:
00304 static void initClass() ;
00305 static void exitClass() ;
00306
00307 const PoCellFilter* getCellFilter() const;
00308
00309 void push_back_value(float v) {
00310 if (m_numValues == m_allocPointValues) {
00311 m_allocPointValues *= 2;
00312 m_pointValues = (float *)realloc(m_pointValues, m_allocPointValues*sizeof(float));
00313 }
00314 m_pointValues[m_numValues] = v;
00315 m_numValues++;
00316 }
00317 void push_back_coord_index(int32_t id) {
00318 m_coordIndexArray.push_back(id);
00319 }
00320 void push_back_cell_index(int32_t id) {
00321 m_cellIndexArray.push_back(id);
00322 }
00323
00324 void update_coord_index(SoIndexedShape *shape) {
00325 SoMFInt32 *coord_index = &(shape->coordIndex);
00326 if (m_coordIndexArray.size() == 0)
00327 coord_index->setNum(0);
00328 else
00329 coord_index->setValuesPointer((int)m_coordIndexArray.size(),&*(m_coordIndexArray.begin()));
00330 }
00331
00335 virtual size_t getMemorySize();
00336
00340 static size_t getClassMemorySize();
00341
00342
00343 private:
00344
00345 PoMesh() ;
00346
00347 virtual ~PoMesh() ;
00348
00349 void clearOivNodes();
00350 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00351 virtual void basicObjectChange(PbBase *basicObj);
00352 virtual void setDefaultOnNonWritingFields();
00353 virtual void addElementsAllCaches() ;
00354 virtual void preRebuild();
00355 virtual void postRebuild() ;
00356 virtual void insertDefaultShapeHints();
00357
00358
00359 int TAllocAdjIsovalues;
00360 int TAdjNumIsovalues;
00361 float *TAdjIsovalues;
00362 int TIsovalAdj;
00363
00364 void adjustIsovalList (int num_v0, const float* v0,
00365 int num_v1, const float* v1,
00366 int num_v2, const float* v2 );
00367 void adjustIsoval (int num_values, const float *values, float &iso_value);
00368 void adjustIsovalMultiple (int num_v0, const float* v0,
00369 int num_v1, const float* v1,
00370 int num_v2, const float* v2,
00371 float &iso_value);
00372
00373
00374 SbVec3f *newSbVec3f(int numVec3f) ;
00375
00376
00377 SoCoordinate3 *meshCoordinates;
00378
00379
00380 SoMaterial *meshMaterial;
00381 SoMaterialBinding *m_materialBinding;
00382 SbBool m_meshMaterialJustAllocated;
00383
00384
00385 SoShape *m_shape;
00386
00387
00388 SoNormal *m_normal;
00389 SoNormalBinding *m_normalBinding;
00390
00391
00392 SoTextureCoordinate2 *m_meshTexCoordinates ;
00393 SbBool m_meshTexCoordinatesJustAllocated;
00394 SoTexture2 *m_meshTexture ;
00395 SoTextureCoordinateBinding *m_textureBinding;
00396
00397 SoGroup *groupNode;
00398 SoShapeHints *shapeHints;
00399
00400
00401 PiTextureContouring *m_textureContouring ;
00402 PiContouringFilled *contouringFilled;
00403 PiContouringLines *contouringLines;
00404
00405
00406 PbLinearDataMapping defDataMapping;
00407
00408 static int m_numPoints;
00409 static int m_allocPoints;
00410 static float (*m_points)[3];
00411 static int m_numValues;
00412 static int m_allocPointValues;
00413 static float *m_pointValues;
00414
00415 std::vector< int > m_coordIndexArray;
00416 std::vector< int > m_cellIndexArray;
00417
00418 const PbDataMapping *dataMapping;
00419 const PbDataMapping *m_moduleDataMapping;
00420 const PbIsovaluesList *isovaluesList;
00421
00422 const PbMesh *m_mesh;
00423 ColoringType m_coloringType;
00424 SbBool m_isVertexBinding;
00425 const float *m_mappedValues;
00426 std::vector< int > m_cellIds;
00427
00428 void addDataMappingInCache();
00429 void addIsovaluesListInCache(SbBool alwaysAdd=FALSE);
00430
00431 void mapColor(int num_val=0, const float *from_values=NULL,
00432 SbBool newMat=TRUE);
00433 void computeNormal(SoIndexedShape *shape, SoCoordinate3 *coord);
00434
00435
00436 uint32_t m_geometryId;
00437 uint32_t m_topologyId;
00438 int m_mappedDataSetIndex;
00439 uint32_t m_mappedDataSetId;
00440 uint64_t m_cellFilterId;
00441 uint32_t m_dataFilterId;
00442 uint32_t m_dataMappingId;
00443 int m_isoDataSetIndex;
00444 uint32_t m_isoDataSetId;
00445 float m_isovalueId;
00446 ColoringType m_previousColoringType;
00447
00448
00449 private:
00450 PbMesh *m_meshSet;
00451 PbDataMapping *m_dataMappingSet;
00452 PbDataMapping *m_moduleDataMappingSet;
00453 PbIsovaluesList *m_isovaluesListSet;
00454
00455
00456 FieldSensorList m_fieldSensorList ;
00457
00458
00459 SoFieldList m_fieldList ;
00460
00461
00462 SbVec3f *arraySbVec3f;
00463 int arrayLenSbVec3f;
00464
00465
00466 PbIsovaluesList defIsovaluesList;
00467 } ;
00468
00469
00470 #ifdef _WIN32
00471 #pragma warning(pop)
00472 #endif
00473
00474 #endif
00475
00476