From: eap Date: Thu, 19 Jul 2012 13:06:39 +0000 (+0000) Subject: 0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes X-Git-Tag: V6_6_0a1~255 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=064c555726c83f9d9c9de3f59b178d556246f521;p=modules%2Fsmesh.git 0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes + virtual SMDSAbs_GeometryType GetGeomType() const; --- diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx index 63f42c382..a03bc0bf7 100644 --- a/src/SMDS/SMDS_FaceOfEdges.cxx +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -189,3 +189,8 @@ SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const { return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle; } + +SMDSAbs_GeometryType SMDS_FaceOfEdges::GetGeomType() const +{ + return myNbEdges == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE; +} diff --git a/src/SMDS/SMDS_FaceOfEdges.hxx b/src/SMDS/SMDS_FaceOfEdges.hxx index 9748dd852..9eb81b1f0 100644 --- a/src/SMDS/SMDS_FaceOfEdges.hxx +++ b/src/SMDS/SMDS_FaceOfEdges.hxx @@ -46,25 +46,18 @@ class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace const SMDS_MeshEdge* edge3, const SMDS_MeshEdge* edge4); - SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_EntityType GetEntityType() const; - virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;}; - int NbNodes() const; - int NbEdges() const; - int NbFaces() const; -// friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2); - - - /*! - * \brief Return node by its index - * \param ind - node index - * \retval const SMDS_MeshNode* - the node - */ - virtual const SMDS_MeshNode* GetNode(const int ind) const; + virtual SMDSAbs_GeometryType GetGeomType() const; + virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes) {return false;} + virtual int NbNodes() const; + virtual int NbEdges() const; + virtual int NbFaces() const; + virtual const SMDS_MeshNode* GetNode(const int ind) const; protected: - SMDS_ElemIteratorPtr - elementsIterator(SMDSAbs_ElementType type) const; + virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; private: const SMDS_MeshEdge* myEdges[4]; diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx index 054eeefdc..9d05d4505 100644 --- a/src/SMDS/SMDS_FaceOfNodes.cxx +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -180,5 +180,9 @@ const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const { - return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle; + return NbNodes() == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle; +} +SMDSAbs_GeometryType SMDS_FaceOfNodes::GetGeomType() const +{ + return NbNodes() == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE; } diff --git a/src/SMDS/SMDS_FaceOfNodes.hxx b/src/SMDS/SMDS_FaceOfNodes.hxx index 48242b10f..79b94ba05 100644 --- a/src/SMDS/SMDS_FaceOfNodes.hxx +++ b/src/SMDS/SMDS_FaceOfNodes.hxx @@ -58,6 +58,7 @@ class SMDS_EXPORT SMDS_FaceOfNodes:public SMDS_MeshFace virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_GeometryType GetGeomType() const; protected: SMDS_ElemIteratorPtr diff --git a/src/SMDS/SMDS_Mesh0DElement.cxx b/src/SMDS/SMDS_Mesh0DElement.cxx index fa61fb4fe..a1a244c6d 100644 --- a/src/SMDS/SMDS_Mesh0DElement.cxx +++ b/src/SMDS/SMDS_Mesh0DElement.cxx @@ -19,7 +19,6 @@ // SMESH SMDS : implementaion of Salome mesh data structure // File : SMDS_Mesh0DElement.cxx -// Author : Jean-Michel BOULCOURT // Module : SMESH // #ifdef _MSC_VER @@ -125,18 +124,6 @@ SMDS_ElemIteratorPtr SMDS_Mesh0DElement::elementsIterator (SMDSAbs_ElementType t } } -//======================================================================= -//function : operator< -//purpose : -//======================================================================= -bool operator< (const SMDS_Mesh0DElement & e1, const SMDS_Mesh0DElement & e2) -{ - int id1 = e1.myNode->getVtkId(); - int id2 = e2.myNode->getVtkId(); - - return (id1 < id2); -} - /*! * \brief Return node by its index * \param ind - node index diff --git a/src/SMDS/SMDS_Mesh0DElement.hxx b/src/SMDS/SMDS_Mesh0DElement.hxx index 106c5276d..81578a816 100644 --- a/src/SMDS/SMDS_Mesh0DElement.hxx +++ b/src/SMDS/SMDS_Mesh0DElement.hxx @@ -36,24 +36,18 @@ class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshCell SMDS_Mesh0DElement (const SMDS_MeshNode * node); bool ChangeNode (const SMDS_MeshNode * node); virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;}; - void Print (std::ostream & OS) const; - - SMDSAbs_ElementType GetType() const; - virtual vtkIdType GetVtkType() const; - SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_0D;} - int NbNodes() const; - int NbEdges() const; - friend bool operator< (const SMDS_Mesh0DElement& e1, const SMDS_Mesh0DElement& e2); - - /*! - * \brief Return node by its index - * \param ind - node index - * \retval const SMDS_MeshNode* - the node - */ + virtual void Print (std::ostream & OS) const; + + virtual SMDSAbs_ElementType GetType() const; + virtual vtkIdType GetVtkType() const; + virtual SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_0D;} + virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_POINT; } virtual const SMDS_MeshNode* GetNode (const int ind) const; + virtual int NbNodes() const; + virtual int NbEdges() const; protected: - SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; + virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; protected: const SMDS_MeshNode* myNode; diff --git a/src/SMDS/SMDS_MeshEdge.hxx b/src/SMDS/SMDS_MeshEdge.hxx index 54f426c96..63ae2f071 100644 --- a/src/SMDS/SMDS_MeshEdge.hxx +++ b/src/SMDS/SMDS_MeshEdge.hxx @@ -28,11 +28,12 @@ #include "SMDS_MeshCell.hxx" -class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshCell +class SMDS_EXPORT SMDS_MeshEdge: public SMDS_MeshCell { - public: - SMDSAbs_ElementType GetType() const; - virtual vtkIdType GetVtkType() const; + public: + virtual SMDSAbs_ElementType GetType() const; + virtual vtkIdType GetVtkType() const; + virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_EDGE; } }; #endif diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 4ec911359..918ebb668 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -80,11 +80,11 @@ public: ///Return the type of the current element virtual SMDSAbs_ElementType GetType() const = 0; + virtual SMDSAbs_EntityType GetEntityType() const = 0; + virtual SMDSAbs_GeometryType GetGeomType() const = 0; virtual vtkIdType GetVtkType() const = 0; - virtual bool IsPoly() const { return false; }; + virtual bool IsPoly() const { return false; } virtual bool IsQuadratic() const; - //! Return type of entity - virtual SMDSAbs_EntityType GetEntityType() const = 0; virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual int NbCornerNodes() const; @@ -140,10 +140,32 @@ public: */ int GetNodeIndex( const SMDS_MeshNode* node ) const; - inline ShortType getMeshId() const {return myMeshId; } - inline LongType getshapeId() const {return myShapeId; } - inline int getIdInShape() const { return myIdInShape; } - inline int getVtkId() const { return myVtkID; } + inline ShortType getMeshId() const { return myMeshId; } + inline LongType getshapeId() const { return myShapeId; } + inline int getIdInShape() const { return myIdInShape; } + inline int getVtkId() const { return myVtkID; } + + /*! + * \brief Filters of elements, to be used with SMDS_SetIterator + */ + struct TypeFilter + { + SMDSAbs_ElementType _type; + TypeFilter( SMDSAbs_ElementType t = SMDSAbs_NbElementTypes ):_type(t) {} + bool operator()(const SMDS_MeshElement* e) const { return e && e->GetType() == _type; } + }; + struct EntityFilter + { + SMDSAbs_EntityType _type; + EntityFilter( SMDSAbs_EntityType t = SMDSEntity_Last ):_type(t) {} + bool operator()(const SMDS_MeshElement* e) const { return e && e->GetEntityType() == _type; } + }; + struct GeomFilter + { + SMDSAbs_GeometryType _type; + GeomFilter( SMDSAbs_GeometryType t = SMDSGeom_NONE ):_type(t) {} + bool operator()(const SMDS_MeshElement* e) const { return e && e->GetGeomType() == _type; } + }; protected: inline void setId(int id) {myID = id; } diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index 483b01cb5..78966bc57 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -33,7 +33,7 @@ #include "SMDS_Position.hxx" #include "ObjectPool.hxx" -class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement +class SMDS_EXPORT SMDS_MeshNode: public SMDS_MeshElement { public: friend class SMESHDS_Mesh; @@ -49,12 +49,11 @@ public: SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const; int NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const; const SMDS_PositionPtr& GetPosition() const; - SMDSAbs_ElementType GetType() const; - virtual vtkIdType GetVtkType() const; - SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;} - int NbNodes() const; - - friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2); + virtual SMDSAbs_ElementType GetType() const; + virtual vtkIdType GetVtkType() const; + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Node;} + virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_NONE; } + virtual int NbNodes() const; void SetPosition(const SMDS_PositionPtr& aPos); void setXYZ(double x, double y, double z); diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx index aef6b777c..e5aa46096 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.cxx +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -153,3 +153,17 @@ SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const } return aType; } + +SMDSAbs_GeometryType SMDS_VolumeOfFaces::GetGeomType() const +{ + SMDSAbs_GeometryType aType = SMDSGeom_NONE; + switch(myNbFaces) + { + case 4: aType = SMDSGeom_TETRA; break; + case 5: aType = SMDSGeom_PYRAMID; break; + case 6: aType = SMDSGeom_PENTA; break; + case 8: + default: aType = SMDSGeom_HEXA; break; + } + return aType; +} diff --git a/src/SMDS/SMDS_VolumeOfFaces.hxx b/src/SMDS/SMDS_VolumeOfFaces.hxx index 5da8fc71f..a64d53ab5 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.hxx +++ b/src/SMDS/SMDS_VolumeOfFaces.hxx @@ -56,14 +56,15 @@ class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume const SMDS_MeshFace * face6); virtual SMDSAbs_EntityType GetEntityType() const; - virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;}; - void Print(std::ostream & OS) const; + virtual SMDSAbs_GeometryType GetGeomType() const; + virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes) {return false;} + virtual void Print(std::ostream & OS) const; - int NbFaces() const; + virtual int NbFaces() const; protected: - SMDS_ElemIteratorPtr - elementsIterator(SMDSAbs_ElementType type) const; + virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; const SMDS_MeshFace * myFaces[6]; int myNbFaces; }; diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index e38d61b2a..cb4cdfa34 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -254,4 +254,18 @@ SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const return aType; } +SMDSAbs_GeometryType SMDS_VolumeOfNodes::GetGeomType() const +{ + SMDSAbs_GeometryType aType = SMDSGeom_NONE; + switch(myNbNodes) + { + case 4: aType = SMDSGeom_TETRA; break; + case 5: aType = SMDSGeom_PYRAMID; break; + case 6: aType = SMDSGeom_PENTA; break; + case 12: aType = SMDSGeom_HEXAGONAL_PRISM; break; + case 8: + default: aType = SMDSGeom_HEXA; break; + } + return aType; +} diff --git a/src/SMDS/SMDS_VolumeOfNodes.hxx b/src/SMDS/SMDS_VolumeOfNodes.hxx index 420d855fc..86e22b622 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.hxx +++ b/src/SMDS/SMDS_VolumeOfNodes.hxx @@ -70,8 +70,9 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume int NbFaces() const; int NbNodes() const; int NbEdges() const; - virtual SMDSAbs_ElementType GetType() const; - virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_GeometryType GetGeomType() const; /*! * \brief Return node by its index diff --git a/src/SMDS/SMDS_VtkEdge.hxx b/src/SMDS/SMDS_VtkEdge.hxx index 226625861..c5f04300b 100644 --- a/src/SMDS/SMDS_VtkEdge.hxx +++ b/src/SMDS/SMDS_VtkEdge.hxx @@ -17,6 +17,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMDS : implementaion of Salome mesh data structure +// File : SMDS_VtkEdge.hxx +// Module : SMESH + #ifndef _SMDS_VTKEDGE_HXX_ #define _SMDS_VTKEDGE_HXX_ @@ -38,9 +42,9 @@ public: virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); virtual bool IsMediumNode(const SMDS_MeshNode* node) const; - void Print(std::ostream & OS) const; - int NbNodes() const; - int NbEdges() const; + virtual void Print(std::ostream & OS) const; + virtual int NbNodes() const; + virtual int NbEdges() const; virtual vtkIdType GetVtkType() const; virtual SMDSAbs_EntityType GetEntityType() const; diff --git a/src/SMDS/SMDS_VtkFace.cxx b/src/SMDS/SMDS_VtkFace.cxx index 338795e35..80644c7e2 100644 --- a/src/SMDS/SMDS_VtkFace.cxx +++ b/src/SMDS/SMDS_VtkFace.cxx @@ -238,6 +238,25 @@ SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const return SMDS_MeshCell::toSmdsType( VTKCellType( aVtkType )); } +SMDSAbs_GeometryType SMDS_VtkFace::GetGeomType() const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + switch ( aVtkType ) { + case VTK_TRIANGLE: + case VTK_QUADRATIC_TRIANGLE: + return SMDSGeom_TRIANGLE; + case VTK_QUAD: + case VTK_QUADRATIC_QUAD: + case VTK_BIQUADRATIC_QUAD: + return SMDSGeom_QUADRANGLE; + case VTK_POLYGON: + return SMDSGeom_POLYGON; + default:; + } + return SMDSGeom_NONE; +} + vtkIdType SMDS_VtkFace::GetVtkType() const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); diff --git a/src/SMDS/SMDS_VtkFace.hxx b/src/SMDS/SMDS_VtkFace.hxx index e9fda428b..f84192f3f 100644 --- a/src/SMDS/SMDS_VtkFace.hxx +++ b/src/SMDS/SMDS_VtkFace.hxx @@ -34,16 +34,20 @@ public: ~SMDS_VtkFace(); void init(const std::vector& nodeIds, SMDS_Mesh* mesh); void initPoly(const std::vector& nodeIds, SMDS_Mesh* mesh); + bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); void ChangeApex(SMDS_MeshNode* node); // to use only for tmp triangles - void Print(std::ostream & OS) const; - int NbEdges() const; - int NbFaces() const; - int NbNodes() const; - virtual vtkIdType GetVtkType() const; - virtual SMDSAbs_EntityType GetEntityType() const; + virtual void Print(std::ostream & OS) const; + virtual int NbEdges() const; + virtual int NbFaces() const; + virtual int NbNodes() const; + + virtual vtkIdType GetVtkType() const; + virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_GeometryType GetGeomType() const; virtual const SMDS_MeshNode* GetNode(const int ind) const; + virtual bool IsQuadratic() const; virtual bool IsPoly() const; virtual bool IsMediumNode(const SMDS_MeshNode* node) const; diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 640b44844..de9174e0b 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -571,6 +571,46 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const return aType; } +SMDSAbs_GeometryType SMDS_VtkVolume::GetGeomType() const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType aVtkType = grid->GetCellType(this->myVtkID); + + SMDSAbs_GeometryType aType = SMDSGeom_NONE; + switch (aVtkType) + { + case VTK_TETRA: + case VTK_QUADRATIC_TETRA: + aType = SMDSGeom_TETRA; + break; + case VTK_PYRAMID: + case VTK_QUADRATIC_PYRAMID: + aType = SMDSGeom_PYRAMID; + break; + case VTK_WEDGE: + case VTK_QUADRATIC_WEDGE: + aType = SMDSGeom_PENTA; + break; + case VTK_HEXAHEDRON: + case VTK_QUADRATIC_HEXAHEDRON: + case VTK_TRIQUADRATIC_HEXAHEDRON: + aType = SMDSGeom_HEXA; + break; + case VTK_HEXAGONAL_PRISM: + aType = SMDSGeom_HEXAGONAL_PRISM; + break; +//#ifdef VTK_HAVE_POLYHEDRON + case VTK_POLYHEDRON: + aType = SMDSGeom_POLYHEDRA; + break; +//#endif + default: + aType = SMDSGeom_POLYHEDRA; + break; + } + return aType; +} + vtkIdType SMDS_VtkVolume::GetVtkType() const { vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); diff --git a/src/SMDS/SMDS_VtkVolume.hxx b/src/SMDS/SMDS_VtkVolume.hxx index 5192c5d0a..5f3f62b31 100644 --- a/src/SMDS/SMDS_VtkVolume.hxx +++ b/src/SMDS/SMDS_VtkVolume.hxx @@ -40,10 +40,10 @@ public: virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes); - void Print(std::ostream & OS) const; - int NbFaces() const; - int NbNodes() const; - int NbEdges() const; + virtual void Print(std::ostream & OS) const; + virtual int NbFaces() const; + virtual int NbNodes() const; + virtual int NbEdges() const; // 1 <= face_ind <= NbFaces() int NbFaceNodes (const int face_ind) const; @@ -51,9 +51,10 @@ public: // 1 <= node_ind <= NbFaceNodes() const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const; - virtual SMDSAbs_ElementType GetType() const; - virtual vtkIdType GetVtkType() const; - virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_ElementType GetType() const; + virtual vtkIdType GetVtkType() const; + virtual SMDSAbs_EntityType GetEntityType() const; + virtual SMDSAbs_GeometryType GetGeomType() const; virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual bool IsQuadratic() const; virtual bool IsPoly() const;