From: ptv Date: Fri, 21 Aug 2009 05:41:59 +0000 (+0000) Subject: 0020095: EDF 896 SMESH : Advanced Mesh info on a group X-Git-Tag: V5_1_3rc1~113 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79c00fe8dda8de553bddf2c588ebdf5e4c0746c4;p=modules%2Fsmesh.git 0020095: EDF 896 SMESH : Advanced Mesh info on a group --- diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 00cecdadd..fff0c5120 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -143,6 +143,37 @@ module SMESH ORDER_QUADRATIC /*! entities of 2nd order */ }; + + /*! + * Enumeration of entity type uses in mesh info array, + * and should be synchronised with enum in SMDS + */ + enum EntityType + { + Entity_Node, + Entity_0D, + Entity_Edge, + Entity_Quad_Edge, + Entity_Triangle, + Entity_Quad_Triangle, + Entity_Quadrangle, + Entity_Quad_Quadrangle, + Entity_Polygon, + Entity_Quad_Polygon, + Entity_Tetra, + Entity_Quad_Tetra, + Entity_Pyramid, + Entity_Quad_Pyramid, + Entity_Hexa, + Entity_Quad_Hexa, + Entity_Penta, + Entity_Quad_Penta, + Entity_Polyhedra, + Entity_Quad_Polyhedra, + Entity_Last + }; + + /*! * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods) */ @@ -220,6 +251,12 @@ module SMESH * Returns a sequence of all element IDs */ long_array GetIDs(); + + /*! + * Returns statistic of mesh elements + * Result array of number enityties + */ + long_array GetMeshInfo(); }; interface SMESH_Group; diff --git a/src/SMDS/SMDSAbs_ElementType.hxx b/src/SMDS/SMDSAbs_ElementType.hxx index d907064cd..dc7c61435 100644 --- a/src/SMDS/SMDSAbs_ElementType.hxx +++ b/src/SMDS/SMDSAbs_ElementType.hxx @@ -66,4 +66,32 @@ enum SMDSAbs_ElementOrder { ORDER_QUADRATIC /*! entities of 2nd order */ }; +/*! +* Enumeration of entity type uses in mesh info array, +* and should be synchronised with enum in SMDS +*/ +enum SMDSAbs_EntityType { + SMDSEntity_Node, + SMDSEntity_0D, + SMDSEntity_Edge, + SMDSEntity_Quad_Edge, + SMDSEntity_Triangle, + SMDSEntity_Quad_Triangle, + SMDSEntity_Quadrangle, + SMDSEntity_Quad_Quadrangle, + SMDSEntity_Polygon, + SMDSEntity_Quad_Polygon, + SMDSEntity_Tetra, + SMDSEntity_Quad_Tetra, + SMDSEntity_Pyramid, + SMDSEntity_Quad_Pyramid, + SMDSEntity_Hexa, + SMDSEntity_Quad_Hexa, + SMDSEntity_Penta, + SMDSEntity_Quad_Penta, + SMDSEntity_Polyhedra, + SMDSEntity_Quad_Polyhedra, + SMDSEntity_Last +}; + #endif diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx index 926b6a446..87107a4c4 100644 --- a/src/SMDS/SMDS_FaceOfEdges.cxx +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -181,3 +181,7 @@ const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const return 0; } +SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const +{ + return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle; +} diff --git a/src/SMDS/SMDS_FaceOfEdges.hxx b/src/SMDS/SMDS_FaceOfEdges.hxx index 27cfe59e4..cd6521398 100644 --- a/src/SMDS/SMDS_FaceOfEdges.hxx +++ b/src/SMDS/SMDS_FaceOfEdges.hxx @@ -46,6 +46,7 @@ class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace const SMDS_MeshEdge* edge4); SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const; int NbNodes() const; int NbEdges() const; int NbFaces() const; diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx index f6ef320cd..aa52343b4 100644 --- a/src/SMDS/SMDS_FaceOfNodes.cxx +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -174,3 +174,8 @@ const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const { return myNodes[ ind ]; } + +SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const +{ + return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle; +} diff --git a/src/SMDS/SMDS_FaceOfNodes.hxx b/src/SMDS/SMDS_FaceOfNodes.hxx index 018d5778a..c00511851 100644 --- a/src/SMDS/SMDS_FaceOfNodes.hxx +++ b/src/SMDS/SMDS_FaceOfNodes.hxx @@ -56,6 +56,8 @@ class SMDS_EXPORT SMDS_FaceOfNodes:public SMDS_MeshFace */ virtual const SMDS_MeshNode* GetNode(const int ind) const; + virtual SMDSAbs_EntityType GetEntityType() const; + protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; diff --git a/src/SMDS/SMDS_Mesh0DElement.hxx b/src/SMDS/SMDS_Mesh0DElement.hxx index 93a204934..b1be0b28f 100644 --- a/src/SMDS/SMDS_Mesh0DElement.hxx +++ b/src/SMDS/SMDS_Mesh0DElement.hxx @@ -40,6 +40,7 @@ class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshElement void Print (std::ostream & OS) const; SMDSAbs_ElementType GetType() 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); diff --git a/src/SMDS/SMDS_MeshEdge.cxx b/src/SMDS/SMDS_MeshEdge.cxx index 924a6c2e7..526236e80 100644 --- a/src/SMDS/SMDS_MeshEdge.cxx +++ b/src/SMDS/SMDS_MeshEdge.cxx @@ -156,4 +156,3 @@ bool SMDS_MeshEdge::ChangeNodes(const SMDS_MeshNode * node1, myNodes[1]=node2; return true; } - diff --git a/src/SMDS/SMDS_MeshEdge.hxx b/src/SMDS/SMDS_MeshEdge.hxx index 84998e129..c0108c2e4 100644 --- a/src/SMDS/SMDS_MeshEdge.hxx +++ b/src/SMDS/SMDS_MeshEdge.hxx @@ -41,7 +41,8 @@ class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshElement const SMDS_MeshNode * node2); void Print(std::ostream & OS) const; - SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Edge; } int NbNodes() const; int NbEdges() const; friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2); diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 13498092a..5b52efbf7 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -64,6 +64,8 @@ public: virtual SMDSAbs_ElementType GetType() const = 0; 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; diff --git a/src/SMDS/SMDS_MeshInfo.hxx b/src/SMDS/SMDS_MeshInfo.hxx index ca0b5ab4c..66e7177d2 100644 --- a/src/SMDS/SMDS_MeshInfo.hxx +++ b/src/SMDS/SMDS_MeshInfo.hxx @@ -41,6 +41,7 @@ public: int NbNodes() const { return myNbNodes; } inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; + inline int NbEntities(SMDSAbs_EntityType type) const; int Nb0DElements() const { return myNb0DElements; } inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const; @@ -254,4 +255,71 @@ SMDS_MeshInfo::NbElements(SMDSAbs_ElementType type) const } return nb; } + +int // NbEntities +SMDS_MeshInfo::NbEntities(SMDSAbs_EntityType type) const +{ + switch (type) { + case SMDSEntity_Node: + return myNbNodes; + break; + case SMDSEntity_0D: + return myNb0DElements; + break; + case SMDSEntity_Edge: + return myNbEdges; + break; + case SMDSEntity_Quad_Edge: + return myNbQuadEdges; + break; + case SMDSEntity_Triangle: + return myNbTriangles; + break; + case SMDSEntity_Quad_Triangle: + return myNbQuadTriangles; + break; + case SMDSEntity_Quadrangle: + return myNbQuadrangles; + break; + case SMDSEntity_Quad_Quadrangle: + return myNbQuadQuadrangles; + break; + case SMDSEntity_Polygon: + return myNbPolygons; + break; + case SMDSEntity_Tetra: + return myNbTetras; + break; + case SMDSEntity_Quad_Tetra: + return myNbQuadTetras; + break; + case SMDSEntity_Pyramid: + return myNbPyramids; + break; + case SMDSEntity_Quad_Pyramid: + return myNbQuadPyramids; + break; + case SMDSEntity_Hexa: + return myNbHexas; + break; + case SMDSEntity_Quad_Hexa: + return myNbQuadHexas; + break; + case SMDSEntity_Penta: + return myNbPrisms; + break; + case SMDSEntity_Quad_Penta: + return myNbQuadPrisms; + break; + case SMDSEntity_Polyhedra: + return myNbPolyhedrons; + break; + case SMDSEntity_Quad_Polygon: + case SMDSEntity_Quad_Polyhedra: + default: + break; + } + return 0; +} + #endif diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index 2ee85d5db..68edc975f 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -50,6 +50,7 @@ class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement void SetPosition(const SMDS_PositionPtr& aPos); const SMDS_PositionPtr& GetPosition() const; SMDSAbs_ElementType GetType() const; + SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;} int NbNodes() const; void setXYZ(double x, double y, double z); friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2); diff --git a/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx index 96b7e261c..d6c8fb5b1 100644 --- a/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx +++ b/src/SMDS/SMDS_PolygonalFaceOfNodes.cxx @@ -196,4 +196,3 @@ const SMDS_MeshNode* SMDS_PolygonalFaceOfNodes::GetNode(const int ind) const { return myNodes[ WrappedIndex( ind )]; } - diff --git a/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx b/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx index 71b083a3f..34a7f4dab 100644 --- a/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx +++ b/src/SMDS/SMDS_PolygonalFaceOfNodes.hxx @@ -40,6 +40,7 @@ class SMDS_EXPORT SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace SMDS_PolygonalFaceOfNodes (std::vector nodes); virtual SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polygon; } virtual bool IsPoly() const { return true; }; bool ChangeNodes (std::vector nodes); diff --git a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx index 9cddb1f02..52d1358c1 100644 --- a/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx +++ b/src/SMDS/SMDS_PolyhedralVolumeOfNodes.hxx @@ -39,6 +39,7 @@ class SMDS_EXPORT SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes //virtual ~SMDS_PolyhedralVolumeOfNodes(); virtual SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polyhedra; } virtual bool IsPoly() const { return true; }; bool ChangeNodes (const std::vector & nodes, diff --git a/src/SMDS/SMDS_QuadraticEdge.cxx b/src/SMDS/SMDS_QuadraticEdge.cxx index d314cf281..147b62bf6 100644 --- a/src/SMDS/SMDS_QuadraticEdge.cxx +++ b/src/SMDS/SMDS_QuadraticEdge.cxx @@ -182,4 +182,3 @@ SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType ty (this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes)))); } } - diff --git a/src/SMDS/SMDS_QuadraticEdge.hxx b/src/SMDS/SMDS_QuadraticEdge.hxx index 83877d6a1..cdab680e2 100644 --- a/src/SMDS/SMDS_QuadraticEdge.hxx +++ b/src/SMDS/SMDS_QuadraticEdge.hxx @@ -47,6 +47,8 @@ public: int NbNodes() const; + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Quad_Edge; } + virtual bool IsQuadratic() const { return true; } virtual bool IsMediumNode(const SMDS_MeshNode* node) const; diff --git a/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx index 472759fb9..168457cf5 100644 --- a/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx +++ b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx @@ -306,3 +306,7 @@ const SMDS_MeshNode* SMDS_QuadraticFaceOfNodes::GetNode(const int ind) const return myNodes[ ind ]; } +SMDSAbs_EntityType SMDS_QuadraticFaceOfNodes::GetEntityType() const +{ + return NbNodes() == 6 ? SMDSEntity_Quad_Triangle : SMDSEntity_Quad_Quadrangle; +} diff --git a/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx b/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx index 58c709f22..2d374139b 100644 --- a/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx +++ b/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx @@ -49,6 +49,7 @@ public: const SMDS_MeshNode * n34, const SMDS_MeshNode * n41); + virtual SMDSAbs_EntityType GetEntityType() const; virtual bool IsQuadratic() const { return true; } virtual bool IsMediumNode(const SMDS_MeshNode* node) const; diff --git a/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx index 2225bdcda..8d68ee4d0 100644 --- a/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx +++ b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx @@ -368,3 +368,16 @@ const SMDS_MeshNode* SMDS_QuadraticVolumeOfNodes::GetNode(const int ind) const return myNodes[ ind ]; } +SMDSAbs_EntityType SMDS_QuadraticVolumeOfNodes::GetEntityType() const +{ + SMDSAbs_EntityType aType = SMDSEntity_Quad_Tetra; + switch(NbNodes()) + { + case 10: aType = SMDSEntity_Quad_Tetra; break; + case 13: aType = SMDSEntity_Quad_Pyramid; break; + case 15: aType = SMDSEntity_Quad_Penta; break; + case 20: + default: aType = SMDSEntity_Quad_Hexa; break; + } + return aType; +} diff --git a/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx b/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx index 3a004f448..f9ca633e4 100644 --- a/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx +++ b/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx @@ -99,6 +99,7 @@ public: const SMDS_MeshNode * n37, const SMDS_MeshNode * n48); + virtual SMDSAbs_EntityType GetEntityType() const; virtual bool IsQuadratic() const { return true; } virtual bool IsMediumNode(const SMDS_MeshNode* node) const; diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx index c993dcc66..76f47de39 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.cxx +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -135,3 +135,16 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1, myFaces[5]=face6; } +SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const +{ + SMDSAbs_EntityType aType = SMDSEntity_Tetra; + switch(myNbFaces) + { + case 4: aType = SMDSEntity_Tetra; break; + case 5: aType = SMDSEntity_Pyramid; break; + case 6: aType = SMDSEntity_Penta; break; + case 8: + default: aType = SMDSEntity_Hexa; break; + } + return aType; +} diff --git a/src/SMDS/SMDS_VolumeOfFaces.hxx b/src/SMDS/SMDS_VolumeOfFaces.hxx index 074fbec23..95b262faa 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.hxx +++ b/src/SMDS/SMDS_VolumeOfFaces.hxx @@ -54,6 +54,7 @@ class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume const SMDS_MeshFace * face5, const SMDS_MeshFace * face6); + virtual SMDSAbs_EntityType GetEntityType() const; void Print(std::ostream & OS) const; int NbFaces() const; diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index eb5101e7a..02e2661a3 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -246,3 +246,17 @@ const SMDS_MeshNode* SMDS_VolumeOfNodes::GetNode(const int ind) const { return myNodes[ ind ]; } + +SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const +{ + SMDSAbs_EntityType aType = SMDSEntity_Tetra; + switch(myNbNodes) + { + case 4: aType = SMDSEntity_Tetra; break; + case 5: aType = SMDSEntity_Pyramid; break; + case 6: aType = SMDSEntity_Penta; break; + case 8: + default: aType = SMDSEntity_Hexa; break; + } + return aType; +} diff --git a/src/SMDS/SMDS_VolumeOfNodes.hxx b/src/SMDS/SMDS_VolumeOfNodes.hxx index 7f35af2a4..ac62041f5 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.hxx +++ b/src/SMDS/SMDS_VolumeOfNodes.hxx @@ -69,7 +69,8 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume int NbFaces() const; int NbNodes() const; int NbEdges() const; - SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_ElementType GetType() const; + virtual SMDSAbs_EntityType GetEntityType() const; /*! * \brief Return node by its index diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx index c8c3072d3..044c55001 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx @@ -477,81 +477,78 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos() //CORBA::Object_var anObject = aSO->GetObject(); CORBA::Object_var anObject = SMESH::SObjectToObject(aSO); if (!CORBA::is_nil(anObject)) { - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject); - if (!aMesh->_is_nil()) { + SMESH::SMESH_IDSource_var anIDSource = SMESH::SMESH_IDSource::_narrow(anObject); + if (!anIDSource->_is_nil()) { myWGStack->setCurrentWidget(myMeshWidget); setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]"); myMeshName->setText(aSO->GetName().c_str()); - myMeshNbNodes->setNum((int)aMesh->NbNodes()); - myMeshNb0DElems->setNum((int)aMesh->Nb0DElements()); - myMeshNbEdges->setNum((int)aMesh->NbEdges()); - myMeshNbEdges1->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbEdges2->setNum((int)aMesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbFaces->setNum((int)aMesh->NbFaces()); - myMeshNbFaces1->setNum((int)aMesh->NbFacesOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbFaces2->setNum((int)aMesh->NbFacesOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbTriangles->setNum((int)aMesh->NbTriangles()); - myMeshNbTriangles1->setNum((int)aMesh->NbTrianglesOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbTriangles2->setNum((int)aMesh->NbTrianglesOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbQuadrangles->setNum((int)aMesh->NbQuadrangles()); - myMeshNbQuadrangles1->setNum((int)aMesh->NbQuadranglesOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbQuadrangles2->setNum((int)aMesh->NbQuadranglesOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbPolygones->setNum( (int)aMesh->NbPolygons() ); - myMeshNbVolumes->setNum((int)aMesh->NbVolumes()); - myMeshNbVolumes1->setNum((int)aMesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbVolumes2->setNum((int)aMesh->NbVolumesOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbTetra->setNum((int)aMesh->NbTetras()); - myMeshNbTetra1->setNum((int)aMesh->NbTetrasOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbTetra2->setNum((int)aMesh->NbTetrasOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbHexa->setNum((int)aMesh->NbHexas()); - myMeshNbHexa1->setNum((int)aMesh->NbHexasOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbHexa2->setNum((int)aMesh->NbHexasOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbPrism->setNum((int)aMesh->NbPrisms()); - myMeshNbPrism1->setNum((int)aMesh->NbPrismsOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbPrism2->setNum((int)aMesh->NbPrismsOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbPyra->setNum((int)aMesh->NbPyramids()); - myMeshNbPyra1->setNum((int)aMesh->NbPyramidsOfOrder(SMESH::ORDER_LINEAR)); - myMeshNbPyra2->setNum((int)aMesh->NbPyramidsOfOrder(SMESH::ORDER_QUADRATIC)); - myMeshNbPolyhedrones->setNum( (int)aMesh->NbPolyhedrons() ); - return; - } - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObject); - if (!aSubMesh->_is_nil()) { - myWGStack->setCurrentWidget(mySubMeshWidget); - setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_SUBMESH") + "]"); - mySubMeshName->setText(aSO->GetName().c_str()); - mySubMeshNbNodes->setNum((int)aSubMesh->GetNumberOfNodes(true)); - mySubMeshNbElements->setNum((int)aSubMesh->GetNumberOfElements()); - mySubMeshNb0DElems->setNum((int)(aSubMesh->GetElementsByType(SMESH::ELEM0D)->length())); - mySubMeshNbEdges->setNum((int)(aSubMesh->GetElementsByType(SMESH::EDGE)->length())); - mySubMeshNbFaces->setNum((int)(aSubMesh->GetElementsByType(SMESH::FACE)->length())); - mySubMeshNbVolumes->setNum((int)(aSubMesh->GetElementsByType(SMESH::VOLUME)->length())); - return; - } - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); - if (!aGroup->_is_nil()) { - myWGStack->setCurrentWidget(myGroupWidget); - setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_GROUP") + "]"); - myGroupName->setText(aSO->GetName().c_str()); - int aType = aGroup->GetType(); - QString strType; - switch (aType) { - case SMESH::NODE: - strType = "SMESH_MESHINFO_NODES"; break; - case SMESH::ELEM0D: - strType = "SMESH_MESHINFO_0DELEMS"; break; - case SMESH::EDGE: - strType = "SMESH_MESHINFO_EDGES"; break; - case SMESH::FACE: - strType = "SMESH_MESHINFO_FACES"; break; - case SMESH::VOLUME: - strType = "SMESH_MESHINFO_VOLUMES"; break; - default: - strType = "SMESH_MESHINFO_ALL_TYPES"; break; - } - - myGroupType->setText(tr(strType.toLatin1().data())); - myGroupNb->setNum((int)aGroup->Size()); + + SMESH::long_array_var aMeshInfo = anIDSource->GetMeshInfo(); + + myMeshNbNodes->setNum((int)aMeshInfo[SMESH::Entity_Node]); + myMeshNb0DElems->setNum((int)aMeshInfo[SMESH::Entity_0D]); + myMeshNbEdges->setNum((int)aMeshInfo[SMESH::Entity_Edge] + (int)aMeshInfo[SMESH::Entity_Quad_Edge]); + myMeshNbEdges1->setNum((int)aMeshInfo[SMESH::Entity_Edge]); + myMeshNbEdges2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Edge]); + myMeshNbFaces->setNum((int)aMeshInfo[SMESH::Entity_Triangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Triangle] + + (int)aMeshInfo[SMESH::Entity_Quadrangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Quadrangle] + + (int)aMeshInfo[SMESH::Entity_Polygon] + + (int)aMeshInfo[SMESH::Entity_Quad_Polygon]); + myMeshNbFaces1->setNum((int)aMeshInfo[SMESH::Entity_Triangle] + + (int)aMeshInfo[SMESH::Entity_Quadrangle] + + (int)aMeshInfo[SMESH::Entity_Polygon]); + myMeshNbFaces2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Triangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Quadrangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Polygon]); + + myMeshNbTriangles->setNum((int)aMeshInfo[SMESH::Entity_Triangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Triangle]); + myMeshNbTriangles1->setNum((int)aMeshInfo[SMESH::Entity_Triangle]); + myMeshNbTriangles2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Triangle]); + myMeshNbQuadrangles->setNum((int)aMeshInfo[SMESH::Entity_Quadrangle] + + (int)aMeshInfo[SMESH::Entity_Quad_Quadrangle]); + myMeshNbQuadrangles1->setNum((int)(int)aMeshInfo[SMESH::Entity_Quadrangle]); + myMeshNbQuadrangles2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Quadrangle]); + myMeshNbPolygones->setNum((int)aMeshInfo[SMESH::Entity_Polygon]); + myMeshNbVolumes->setNum((int)aMeshInfo[SMESH::Entity_Tetra] + + (int)aMeshInfo[SMESH::Entity_Quad_Tetra] + + (int)aMeshInfo[SMESH::Entity_Pyramid] + + (int)aMeshInfo[SMESH::Entity_Quad_Pyramid] + + (int)aMeshInfo[SMESH::Entity_Hexa] + + (int)aMeshInfo[SMESH::Entity_Quad_Hexa] + + (int)aMeshInfo[SMESH::Entity_Penta] + + (int)aMeshInfo[SMESH::Entity_Quad_Penta] + + (int)aMeshInfo[SMESH::Entity_Polyhedra] + + (int)aMeshInfo[SMESH::Entity_Quad_Polyhedra]); + myMeshNbVolumes1->setNum((int)aMeshInfo[SMESH::Entity_Tetra] + + (int)aMeshInfo[SMESH::Entity_Pyramid] + + (int)aMeshInfo[SMESH::Entity_Hexa] + + (int)aMeshInfo[SMESH::Entity_Penta] + + (int)aMeshInfo[SMESH::Entity_Polyhedra]); + myMeshNbVolumes2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Tetra] + + (int)aMeshInfo[SMESH::Entity_Quad_Pyramid] + + (int)aMeshInfo[SMESH::Entity_Quad_Hexa] + + (int)aMeshInfo[SMESH::Entity_Quad_Penta] + + (int)aMeshInfo[SMESH::Entity_Quad_Polyhedra]); + myMeshNbTetra->setNum((int)aMeshInfo[SMESH::Entity_Tetra] + + (int)aMeshInfo[SMESH::Entity_Quad_Tetra]); + myMeshNbTetra1->setNum((int)aMeshInfo[SMESH::Entity_Tetra]); + myMeshNbTetra2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Tetra]); + myMeshNbHexa->setNum((int)aMeshInfo[SMESH::Entity_Hexa] + + (int)aMeshInfo[SMESH::Entity_Quad_Hexa]); + myMeshNbHexa1->setNum((int)aMeshInfo[SMESH::Entity_Hexa]); + myMeshNbHexa2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Hexa]); + myMeshNbPrism->setNum((int)aMeshInfo[SMESH::Entity_Penta] + + (int)aMeshInfo[SMESH::Entity_Quad_Penta]); + myMeshNbPrism1->setNum((int)aMeshInfo[SMESH::Entity_Penta]); + myMeshNbPrism2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Penta]); + myMeshNbPyra->setNum((int)aMeshInfo[SMESH::Entity_Pyramid] + + (int)aMeshInfo[SMESH::Entity_Quad_Pyramid]); + myMeshNbPyra1->setNum((int)aMeshInfo[SMESH::Entity_Pyramid]); + myMeshNbPyra2->setNum((int)aMeshInfo[SMESH::Entity_Quad_Pyramid]); + myMeshNbPolyhedrones->setNum((int)aMeshInfo[SMESH::Entity_Polyhedra]); return; } } diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 40742a667..933239e59 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -32,6 +32,7 @@ #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_MeshElement.hxx" +#include "SMDS_ElemIterator.hxx" #include "SMESHDS_Mesh.hxx" @@ -2150,6 +2151,60 @@ GetElementsId( SMESH_Mesh_ptr theMesh ) return anArray._retn(); } +template +static void collectMeshInfo(const TIterator& theItr, + TPredicate& thePred, + SMESH::long_array& theRes) +{ + if (!theItr) + return; + while (theItr->more()) { + const SMDS_MeshElement* anElem = theItr->next(); + if ( thePred->IsSatisfy( anElem->GetID() ) ) + theRes[ anElem->GetEntityType() ]++; + } +} + +//============================================================================= +/*! + * \brief Returns statistic of mesh elements + */ +//============================================================================= +SMESH::long_array* ::Filter_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + if(!CORBA::is_nil(myMesh) && myPredicate) { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it; + switch( GetElementType() ) + { + case SMDSAbs_Node: + collectMeshInfo(aMesh->nodesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Edge: + collectMeshInfo(aMesh->edgesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Face: + collectMeshInfo(aMesh->facesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Volume: + collectMeshInfo(aMesh->volumesIterator(),myPredicate,aRes); + break; + case SMDSAbs_All: + default: + collectMeshInfo(aMesh->elementsIterator(),myPredicate,aRes); + break; + } + } + + + return aRes._retn(); +} + //======================================================================= // name : getCriteria // Purpose : Retrieve criterions from predicate diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 3b654e880..090705d05 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -785,6 +785,10 @@ namespace SMESH SMESH::long_array* GetIDs(); + virtual + SMESH::long_array* + GetMeshInfo(); + static void GetElementsId( Predicate_i*, diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index e12ba1e52..8bc0dc42d 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1655,7 +1655,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh, // call implementation compute ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); MapShapeNbElems aResMap; - CORBA::Boolean ret = myGen.Evaluate( myLocMesh, myLocShape, aResMap); + /*CORBA::Boolean ret =*/ myGen.Evaluate( myLocMesh, myLocShape, aResMap); MapShapeNbElemsItr anIt = aResMap.begin(); vector aResVec(17); int i = 0; diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 045e691b9..2f9a7f775 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -487,3 +487,27 @@ void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color) MESSAGE("set color number of a group"); return ; } + +//============================================================================= +/*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ +//============================================================================= +SMESH::long_array* SMESH_GroupBase_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + SMESHDS_GroupBase* aGrpDS = GetGroupDS(); + if ( !aGrpDS ) + return aRes._retn(); + if ( GetType() == NODE ) + aRes[ SMESH::Entity_Node ] = aGrpDS->Extent(); + else + SMESH_Mesh_i::CollectMeshInfo( aGrpDS->GetElements(), aRes); + return aRes._retn(); +} diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 5ad6b10c8..93f8354b9 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -64,6 +64,13 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: SMESH::long_array* GetListOfID(); SMESH::SMESH_Mesh_ptr GetMesh(); + /*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ + virtual SMESH::long_array* GetMeshInfo(); + // Inherited from SMESH_IDSource interface virtual SMESH::long_array* GetIDs(); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index f9a7ee08f..6d0002396 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -4226,8 +4226,10 @@ static void groupToSet(SMESH::SMESH_GroupBase_ptr theGrp, const SMDSAbs_ElementType theType) { - if ( !CORBA::is_nil( theGrp ) ) - arrayToSet( *theGrp->GetListOfID(), theMeshDS, theElemSet, theType); + if ( CORBA::is_nil( theGrp ) ) + return; + SMESH::long_array_var anIDs = theGrp->GetIDs(); + arrayToSet( anIDs, theMeshDS, theElemSet, theType); } CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup( @@ -4318,8 +4320,10 @@ static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList, SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ]; if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE : aGrp->GetType() != SMESH::NODE ) ) - arrayToSet( *aGrp->GetListOfID(), theMeshDS, theElemSet, - theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All ); + { + SMESH::long_array_var anIDs = aGrp->GetIDs(); + arrayToSet( anIDs, theMeshDS, theElemSet, theIsNodeGrp ? SMDSAbs_Node : SMDSAbs_All ); + } } } diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 6673da334..0e5a51e29 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -37,6 +37,7 @@ #include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_W_SMESHDS_Mesh.h" #include "SMDS_VolumeTool.hxx" +#include "SMDS_ElemIterator.hxx" #include "SMESHDS_Command.hxx" #include "SMESHDS_CommandType.hxx" #include "SMESHDS_GroupOnGeom.hxx" @@ -3405,3 +3406,36 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters() } return aResult._retn(); } + +//============================================================================= +/*! + * \brief Returns statistic of mesh elements + */ +//============================================================================= +SMESH::long_array* SMESH_Mesh_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS(); + if (!aMeshDS) + return aRes._retn(); + const SMDS_MeshInfo& aMeshInfo = aMeshDS->GetMeshInfo(); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = aMeshInfo.NbEntities((SMDSAbs_EntityType)i); + return aRes._retn(); +} + +//============================================================================= +/*! + * \brief Collect statistic of mesh elements given by iterator + */ +//============================================================================= +void SMESH_Mesh_i::CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, + SMESH::long_array& theInfo) +{ + if (!theItr) return; + while (theItr->more()) + theInfo[ theItr->next()->GetEntityType() ]++; +} diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index a79c3c21a..2c46676f6 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -485,6 +485,21 @@ public: * Returns list of notebook variables used for last Mesh operation */ SMESH::string_array* GetLastParameters(); + + + /*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ + virtual SMESH::long_array* GetMeshInfo(); + + /*! + * Collect statistic of mesh elements given by iterator + */ + static void CollectMeshInfo(const SMDS_ElemIteratorPtr theItr, + SMESH::long_array& theInfo); + std::map _mapSubMesh_i; //NRI std::map _mapSubMesh; //NRI diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index f90cb300a..2813ceb32 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -515,3 +515,42 @@ SMESH::ElementType SMESH_subMesh_i::GetElementType( const CORBA::Long id, const { return GetFather()->GetElementType( id, iselem ); } + + +//============================================================================= +/*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ +//============================================================================= +SMESH::long_array* SMESH_subMesh_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId]; + SMESHDS_SubMesh* aSubMeshDS = 0; + if (aSubMesh) aSubMeshDS = aSubMesh->GetSubMeshDS(); + if (!aSubMeshDS) + return aRes._retn(); + + // get own number of nodes + aRes[ SMESH::Entity_Node ] = aSubMeshDS->NbNodes(); + + // get own elements statistic + SMESH_Mesh_i::CollectMeshInfo( aSubMeshDS->GetElements(), aRes ); + + // get statistic from child sub-meshes + TListOfSubMeshes smList; + if ( getSubMeshes( aSubMesh, smList ) ) + for ( TListOfSubMeshes::iterator sm = smList.begin(); sm != smList.end(); ++sm ) + { + aRes[ SMESH::Entity_Node ]+= (*sm)->NbNodes(); + SMESH_Mesh_i::CollectMeshInfo( (*sm)->GetElements(), aRes ); + } + + return aRes._retn(); +} diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index 41c3add7f..26b37a753 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -86,6 +86,13 @@ public: virtual SMESH::long_array* GetIDs(); + /*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ + virtual SMESH::long_array* GetMeshInfo(); + SMESH_Mesh_i* _mesh_i; //NRI protected: diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index bfac0f4a6..05bbe9d05 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -1588,6 +1588,19 @@ class Mesh: # Get informations about mesh contents: # ------------------------------------ + ## Gets the mesh stattistic + # @return dictionary type element - count of elements + # @ingroup l1_meshinfo + def GetMeshInfo(self, obj = None): + if not obj: obj = self.mesh + d = {} + if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource): + values = obj.GetMeshInfo() + for i in range(SMESH.Entity_Last._v): + if i < len(values): d[SMESH.EntityType._item(i)]=values[i] + pass + return d + ## Returns the number of nodes in the mesh # @return an integer value # @ingroup l1_meshinfo