From 391cd4d010cefb8dc870c52cc4186a7caefd6b56 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 19 Jul 2012 13:12:33 +0000 Subject: [PATCH] 0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes +SMDSAbs_ElementType toSmdsType(SMDSAbs_EntityType entityType) +SMDSAbs_ElementType toSmdsType(SMDSAbs_GeometryType geomType) --- src/SMDS/SMDS_MeshCell.cxx | 80 +++++++++++++++++++++++++++++++++++++- src/SMDS/SMDS_MeshCell.hxx | 6 ++- 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/src/SMDS/SMDS_MeshCell.cxx b/src/SMDS/SMDS_MeshCell.cxx index 8150bf3fe..521c976ff 100644 --- a/src/SMDS/SMDS_MeshCell.cxx +++ b/src/SMDS/SMDS_MeshCell.cxx @@ -46,7 +46,7 @@ VTKCellType SMDS_MeshCell::toVtkType (SMDSAbs_EntityType smdsType) { vtkTypes.resize( SMDSEntity_Last+1, VTK_EMPTY_CELL ); vtkTypes[ SMDSEntity_Node ] = VTK_VERTEX; - vtkTypes[ SMDSEntity_0D ] = VTK_VERTEX; //VTK_POLY_VERTEX; // ?? + vtkTypes[ SMDSEntity_0D ] = VTK_VERTEX; vtkTypes[ SMDSEntity_Edge ] = VTK_LINE; vtkTypes[ SMDSEntity_Quad_Edge ] = VTK_QUADRATIC_EDGE; vtkTypes[ SMDSEntity_Triangle ] = VTK_TRIANGLE; @@ -68,6 +68,7 @@ VTKCellType SMDS_MeshCell::toVtkType (SMDSAbs_EntityType smdsType) vtkTypes[ SMDSEntity_Hexagonal_Prism ] = VTK_HEXAGONAL_PRISM; vtkTypes[ SMDSEntity_Polyhedra ] = VTK_POLYHEDRON; //vtkTypes[ SMDSEntity_Quad_Polyhedra ] = ; + vtkTypes[ SMDSEntity_Ball ] = VTK_POLY_VERTEX; } return vtkTypes[ smdsType ]; } @@ -179,6 +180,7 @@ const std::vector& SMDS_MeshCell::reverseSmdsOrder(SMDSAbs_EntityType smdsT const int ids[] = {0}; reverseInterlaces[SMDSEntity_0D].assign( &ids[0], &ids[0]+1 ); reverseInterlaces[SMDSEntity_Node].assign( &ids[0], &ids[0]+1 ); + reverseInterlaces[SMDSEntity_Ball].assign( &ids[0], &ids[0]+1 ); } { const int ids[] = {1,0}; @@ -300,6 +302,82 @@ SMDSAbs_EntityType SMDS_MeshCell::toSmdsType(VTKCellType vtkType) return smdsTypes[ vtkType ]; } +//================================================================================ +/*! + * \brief Return SMDSAbs_ElementType by SMDSAbs_GeometryType + */ +//================================================================================ + +SMDSAbs_ElementType SMDS_MeshCell::toSmdsType(SMDSAbs_GeometryType geomType) +{ + switch ( geomType ) { + case SMDSGeom_POINT: return SMDSAbs_0DElement; + + case SMDSGeom_EDGE: return SMDSAbs_Edge; + + case SMDSGeom_TRIANGLE: + case SMDSGeom_QUADRANGLE: + case SMDSGeom_POLYGON: return SMDSAbs_Face; + + case SMDSGeom_TETRA: + case SMDSGeom_PYRAMID: + case SMDSGeom_HEXA: + case SMDSGeom_PENTA: + case SMDSGeom_HEXAGONAL_PRISM: + case SMDSGeom_POLYHEDRA: return SMDSAbs_Volume; + + case SMDSGeom_BALL: return SMDSAbs_Ball; + + case SMDSGeom_NONE: ; + } + return SMDSAbs_All; +} + +//================================================================================ +/*! + * \brief Return SMDSAbs_ElementType by SMDSAbs_EntityType + */ +//================================================================================ + +SMDSAbs_ElementType SMDS_MeshCell::toSmdsType(SMDSAbs_EntityType entityType) +{ + switch ( entityType ) { + case SMDSEntity_Node: return SMDSAbs_Node; + + case SMDSEntity_0D: return SMDSAbs_0DElement; + + case SMDSEntity_Edge: + case SMDSEntity_Quad_Edge: return SMDSAbs_Edge; + + case SMDSEntity_Triangle: + case SMDSEntity_Quad_Triangle: + case SMDSEntity_Quadrangle: + case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_BiQuad_Quadrangle: + case SMDSEntity_Polygon: + case SMDSEntity_Quad_Polygon: return SMDSAbs_Face; + + case SMDSEntity_Tetra: + case SMDSEntity_Quad_Tetra: + case SMDSEntity_Pyramid: + case SMDSEntity_Quad_Pyramid: + case SMDSEntity_Hexa: + case SMDSEntity_Quad_Hexa: + case SMDSEntity_TriQuad_Hexa: + case SMDSEntity_Penta: + case SMDSEntity_Quad_Penta: + case SMDSEntity_Hexagonal_Prism: + case SMDSEntity_Polyhedra: + case SMDSEntity_Quad_Polyhedra: return SMDSAbs_Volume; + + case SMDSEntity_Ball: return SMDSAbs_Ball; + + case SMDSEntity_Last:; + } + return SMDSAbs_All; +} + + //================================================================================ /*! * \brief Return indices to transform cell connectivity from VTK to SMDS diff --git a/src/SMDS/SMDS_MeshCell.hxx b/src/SMDS/SMDS_MeshCell.hxx index 134b9e16b..ca006b5ff 100644 --- a/src/SMDS/SMDS_MeshCell.hxx +++ b/src/SMDS/SMDS_MeshCell.hxx @@ -35,8 +35,10 @@ public: virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)= 0; virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) {return true; } - static VTKCellType toVtkType (SMDSAbs_EntityType vtkType); - static SMDSAbs_EntityType toSmdsType(VTKCellType vtkType); + static VTKCellType toVtkType (SMDSAbs_EntityType vtkType); + static SMDSAbs_EntityType toSmdsType(VTKCellType vtkType); + static SMDSAbs_ElementType toSmdsType(SMDSAbs_GeometryType geomType); + static SMDSAbs_ElementType toSmdsType(SMDSAbs_EntityType entityType); static const std::vector& toVtkOrder(VTKCellType vtkType); static const std::vector& toVtkOrder(SMDSAbs_EntityType smdsType);