0020095: EDF 896 SMESH : Advanced Mesh info on a group

This commit is contained in:
ptv 2009-08-21 05:41:59 +00:00
parent 4aab533cbd
commit 79c00fe8dd
37 changed files with 479 additions and 81 deletions

View File

@ -143,6 +143,37 @@ module SMESH
ORDER_QUADRATIC /*! entities of 2nd order */ 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) * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods)
*/ */
@ -220,6 +251,12 @@ module SMESH
* Returns a sequence of all element IDs * Returns a sequence of all element IDs
*/ */
long_array GetIDs(); long_array GetIDs();
/*!
* Returns statistic of mesh elements
* Result array of number enityties
*/
long_array GetMeshInfo();
}; };
interface SMESH_Group; interface SMESH_Group;

View File

@ -66,4 +66,32 @@ enum SMDSAbs_ElementOrder {
ORDER_QUADRATIC /*! entities of 2nd order */ 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 #endif

View File

@ -181,3 +181,7 @@ const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const
return 0; return 0;
} }
SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const
{
return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
}

View File

@ -46,6 +46,7 @@ class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace
const SMDS_MeshEdge* edge4); const SMDS_MeshEdge* edge4);
SMDSAbs_ElementType GetType() const; SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
int NbNodes() const; int NbNodes() const;
int NbEdges() const; int NbEdges() const;
int NbFaces() const; int NbFaces() const;

View File

@ -174,3 +174,8 @@ const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const
{ {
return myNodes[ ind ]; return myNodes[ ind ];
} }
SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const
{
return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
}

View File

@ -56,6 +56,8 @@ class SMDS_EXPORT SMDS_FaceOfNodes:public SMDS_MeshFace
*/ */
virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual SMDSAbs_EntityType GetEntityType() const;
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -40,6 +40,7 @@ class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshElement
void Print (std::ostream & OS) const; void Print (std::ostream & OS) const;
SMDSAbs_ElementType GetType() const; SMDSAbs_ElementType GetType() const;
SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_0D;}
int NbNodes() const; int NbNodes() const;
int NbEdges() const; int NbEdges() const;
friend bool operator< (const SMDS_Mesh0DElement& e1, const SMDS_Mesh0DElement& e2); friend bool operator< (const SMDS_Mesh0DElement& e1, const SMDS_Mesh0DElement& e2);

View File

@ -156,4 +156,3 @@ bool SMDS_MeshEdge::ChangeNodes(const SMDS_MeshNode * node1,
myNodes[1]=node2; myNodes[1]=node2;
return true; return true;
} }

View File

@ -41,7 +41,8 @@ class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshElement
const SMDS_MeshNode * node2); const SMDS_MeshNode * node2);
void Print(std::ostream & OS) const; 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 NbNodes() const;
int NbEdges() const; int NbEdges() const;
friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2); friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2);

View File

@ -64,6 +64,8 @@ public:
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
virtual bool IsPoly() const { return false; }; virtual bool IsPoly() const { return false; };
virtual bool IsQuadratic() const; virtual bool IsQuadratic() const;
//! Return type of entity
virtual SMDSAbs_EntityType GetEntityType() const = 0;
virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual bool IsMediumNode(const SMDS_MeshNode* node) const;

View File

@ -41,6 +41,7 @@ public:
int NbNodes() const { return myNbNodes; } int NbNodes() const { return myNbNodes; }
inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
inline int NbEntities(SMDSAbs_EntityType type) const;
int Nb0DElements() const { return myNb0DElements; } int Nb0DElements() const { return myNb0DElements; }
inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const;
@ -254,4 +255,71 @@ SMDS_MeshInfo::NbElements(SMDSAbs_ElementType type) const
} }
return nb; 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 #endif

View File

@ -50,6 +50,7 @@ class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement
void SetPosition(const SMDS_PositionPtr& aPos); void SetPosition(const SMDS_PositionPtr& aPos);
const SMDS_PositionPtr& GetPosition() const; const SMDS_PositionPtr& GetPosition() const;
SMDSAbs_ElementType GetType() const; SMDSAbs_ElementType GetType() const;
SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;}
int NbNodes() const; int NbNodes() const;
void setXYZ(double x, double y, double z); void setXYZ(double x, double y, double z);
friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2); friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);

View File

@ -196,4 +196,3 @@ const SMDS_MeshNode* SMDS_PolygonalFaceOfNodes::GetNode(const int ind) const
{ {
return myNodes[ WrappedIndex( ind )]; return myNodes[ WrappedIndex( ind )];
} }

View File

@ -40,6 +40,7 @@ class SMDS_EXPORT SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
SMDS_PolygonalFaceOfNodes (std::vector<const SMDS_MeshNode *> nodes); SMDS_PolygonalFaceOfNodes (std::vector<const SMDS_MeshNode *> nodes);
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polygon; }
virtual bool IsPoly() const { return true; }; virtual bool IsPoly() const { return true; };
bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes); bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes);

View File

@ -39,6 +39,7 @@ class SMDS_EXPORT SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes
//virtual ~SMDS_PolyhedralVolumeOfNodes(); //virtual ~SMDS_PolyhedralVolumeOfNodes();
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Polyhedra; }
virtual bool IsPoly() const { return true; }; virtual bool IsPoly() const { return true; };
bool ChangeNodes (const std::vector<const SMDS_MeshNode *> & nodes, bool ChangeNodes (const std::vector<const SMDS_MeshNode *> & nodes,

View File

@ -182,4 +182,3 @@ SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType ty
(this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes)))); (this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes))));
} }
} }

View File

@ -47,6 +47,8 @@ public:
int NbNodes() const; int NbNodes() const;
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Quad_Edge; }
virtual bool IsQuadratic() const { return true; } virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual bool IsMediumNode(const SMDS_MeshNode* node) const;

View File

@ -306,3 +306,7 @@ const SMDS_MeshNode* SMDS_QuadraticFaceOfNodes::GetNode(const int ind) const
return myNodes[ ind ]; return myNodes[ ind ];
} }
SMDSAbs_EntityType SMDS_QuadraticFaceOfNodes::GetEntityType() const
{
return NbNodes() == 6 ? SMDSEntity_Quad_Triangle : SMDSEntity_Quad_Quadrangle;
}

View File

@ -49,6 +49,7 @@ public:
const SMDS_MeshNode * n34, const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41); const SMDS_MeshNode * n41);
virtual SMDSAbs_EntityType GetEntityType() const;
virtual bool IsQuadratic() const { return true; } virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual bool IsMediumNode(const SMDS_MeshNode* node) const;

View File

@ -368,3 +368,16 @@ const SMDS_MeshNode* SMDS_QuadraticVolumeOfNodes::GetNode(const int ind) const
return myNodes[ ind ]; 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;
}

View File

@ -99,6 +99,7 @@ public:
const SMDS_MeshNode * n37, const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48); const SMDS_MeshNode * n48);
virtual SMDSAbs_EntityType GetEntityType() const;
virtual bool IsQuadratic() const { return true; } virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const; virtual bool IsMediumNode(const SMDS_MeshNode* node) const;

View File

@ -135,3 +135,16 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
myFaces[5]=face6; 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;
}

View File

@ -54,6 +54,7 @@ class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume
const SMDS_MeshFace * face5, const SMDS_MeshFace * face5,
const SMDS_MeshFace * face6); const SMDS_MeshFace * face6);
virtual SMDSAbs_EntityType GetEntityType() const;
void Print(std::ostream & OS) const; void Print(std::ostream & OS) const;
int NbFaces() const; int NbFaces() const;

View File

@ -246,3 +246,17 @@ const SMDS_MeshNode* SMDS_VolumeOfNodes::GetNode(const int ind) const
{ {
return myNodes[ ind ]; 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;
}

View File

@ -69,7 +69,8 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
int NbFaces() const; int NbFaces() const;
int NbNodes() const; int NbNodes() const;
int NbEdges() const; int NbEdges() const;
SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
/*! /*!
* \brief Return node by its index * \brief Return node by its index

View File

@ -477,81 +477,78 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
//CORBA::Object_var anObject = aSO->GetObject(); //CORBA::Object_var anObject = aSO->GetObject();
CORBA::Object_var anObject = SMESH::SObjectToObject(aSO); CORBA::Object_var anObject = SMESH::SObjectToObject(aSO);
if (!CORBA::is_nil(anObject)) { if (!CORBA::is_nil(anObject)) {
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject); SMESH::SMESH_IDSource_var anIDSource = SMESH::SMESH_IDSource::_narrow(anObject);
if (!aMesh->_is_nil()) { if (!anIDSource->_is_nil()) {
myWGStack->setCurrentWidget(myMeshWidget); myWGStack->setCurrentWidget(myMeshWidget);
setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]"); setWindowTitle(tr("SMESH_MESHINFO_TITLE") + " [" + tr("SMESH_OBJECT_MESH") + "]");
myMeshName->setText(aSO->GetName().c_str()); 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())); SMESH::long_array_var aMeshInfo = anIDSource->GetMeshInfo();
myGroupNb->setNum((int)aGroup->Size());
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; return;
} }
} }

View File

@ -32,6 +32,7 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
@ -2150,6 +2151,60 @@ GetElementsId( SMESH_Mesh_ptr theMesh )
return anArray._retn(); return anArray._retn();
} }
template<class TElement, class TIterator, class TPredicate>
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<const SMDS_MeshNode*>(aMesh->nodesIterator(),myPredicate,aRes);
break;
case SMDSAbs_Edge:
collectMeshInfo<const SMDS_MeshElement*>(aMesh->edgesIterator(),myPredicate,aRes);
break;
case SMDSAbs_Face:
collectMeshInfo<const SMDS_MeshElement*>(aMesh->facesIterator(),myPredicate,aRes);
break;
case SMDSAbs_Volume:
collectMeshInfo<const SMDS_MeshElement*>(aMesh->volumesIterator(),myPredicate,aRes);
break;
case SMDSAbs_All:
default:
collectMeshInfo<const SMDS_MeshElement*>(aMesh->elementsIterator(),myPredicate,aRes);
break;
}
}
return aRes._retn();
}
//======================================================================= //=======================================================================
// name : getCriteria // name : getCriteria
// Purpose : Retrieve criterions from predicate // Purpose : Retrieve criterions from predicate

View File

@ -785,6 +785,10 @@ namespace SMESH
SMESH::long_array* SMESH::long_array*
GetIDs(); GetIDs();
virtual
SMESH::long_array*
GetMeshInfo();
static static
void void
GetElementsId( Predicate_i*, GetElementsId( Predicate_i*,

View File

@ -1655,7 +1655,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
// call implementation compute // call implementation compute
::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
MapShapeNbElems aResMap; MapShapeNbElems aResMap;
CORBA::Boolean ret = myGen.Evaluate( myLocMesh, myLocShape, aResMap); /*CORBA::Boolean ret =*/ myGen.Evaluate( myLocMesh, myLocShape, aResMap);
MapShapeNbElemsItr anIt = aResMap.begin(); MapShapeNbElemsItr anIt = aResMap.begin();
vector<int> aResVec(17); vector<int> aResVec(17);
int i = 0; int i = 0;

View File

@ -487,3 +487,27 @@ void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color)
MESSAGE("set color number of a group"); MESSAGE("set color number of a group");
return ; 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();
}

View File

@ -64,6 +64,13 @@ class SMESH_I_EXPORT SMESH_GroupBase_i:
SMESH::long_array* GetListOfID(); SMESH::long_array* GetListOfID();
SMESH::SMESH_Mesh_ptr GetMesh(); 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 // Inherited from SMESH_IDSource interface
virtual SMESH::long_array* GetIDs(); virtual SMESH::long_array* GetIDs();

View File

@ -4226,8 +4226,10 @@ static void groupToSet(SMESH::SMESH_GroupBase_ptr theGrp,
const SMDSAbs_ElementType theType) const SMDSAbs_ElementType theType)
{ {
if ( !CORBA::is_nil( theGrp ) ) if ( CORBA::is_nil( theGrp ) )
arrayToSet( *theGrp->GetListOfID(), theMeshDS, theElemSet, theType); return;
SMESH::long_array_var anIDs = theGrp->GetIDs();
arrayToSet( anIDs, theMeshDS, theElemSet, theType);
} }
CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup( CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(
@ -4318,8 +4320,10 @@ static void listOfGroupToSet(const SMESH::ListOfGroups& theGrpList,
SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ]; SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
: 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 );
}
} }
} }

View File

@ -37,6 +37,7 @@
#include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_R_SMESHDS_Mesh.h"
#include "DriverMED_W_SMESHDS_Mesh.h" #include "DriverMED_W_SMESHDS_Mesh.h"
#include "SMDS_VolumeTool.hxx" #include "SMDS_VolumeTool.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMESHDS_Command.hxx" #include "SMESHDS_Command.hxx"
#include "SMESHDS_CommandType.hxx" #include "SMESHDS_CommandType.hxx"
#include "SMESHDS_GroupOnGeom.hxx" #include "SMESHDS_GroupOnGeom.hxx"
@ -3405,3 +3406,36 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters()
} }
return aResult._retn(); 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() ]++;
}

View File

@ -485,6 +485,21 @@ public:
* Returns list of notebook variables used for last Mesh operation * Returns list of notebook variables used for last Mesh operation
*/ */
SMESH::string_array* GetLastParameters(); 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<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI

View File

@ -515,3 +515,42 @@ SMESH::ElementType SMESH_subMesh_i::GetElementType( const CORBA::Long id, const
{ {
return GetFather()->GetElementType( id, iselem ); 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();
}

View File

@ -86,6 +86,13 @@ public:
virtual SMESH::long_array* GetIDs(); 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 SMESH_Mesh_i* _mesh_i; //NRI
protected: protected:

View File

@ -1588,6 +1588,19 @@ class Mesh:
# Get informations about mesh contents: # 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 ## Returns the number of nodes in the mesh
# @return an integer value # @return an integer value
# @ingroup l1_meshinfo # @ingroup l1_meshinfo