PAL14858 (The Mesh Info Dialog Box is too slow)

use SMDS_MeshInfo to nkow nb of entities
This commit is contained in:
eap 2007-09-25 08:40:00 +00:00
parent 179804804f
commit 11f9744ee7
2 changed files with 99 additions and 173 deletions

View File

@ -983,221 +983,156 @@ void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Ex
myWriter.Perform(); myWriter.Perform();
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Return number of nodes in the mesh
*/ */
//============================================================================= //================================================================================
int SMESH_Mesh::NbNodes() throw(SALOME_Exception) int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
return _myMeshDS->NbNodes(); return _myMeshDS->NbNodes();
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Return number of edges of given order in the mesh
*/ */
//============================================================================= //================================================================================
int SMESH_Mesh::NbEdges(ElementOrder order) throw(SALOME_Exception)
int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
if (order == ORDER_ANY) return _myMeshDS->GetMeshInfo().NbEdges(order);
return _myMeshDS->NbEdges();
int Nb = 0;
SMDS_EdgeIteratorPtr it = _myMeshDS->edgesIterator();
while (it->more()) {
const SMDS_MeshEdge* cur = it->next();
if ( order == ORDER_LINEAR && !cur->IsQuadratic() ||
order == ORDER_QUADRATIC && cur->IsQuadratic() )
Nb++;
}
return Nb;
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Return number of faces of given order in the mesh
*/ */
//============================================================================= //================================================================================
int SMESH_Mesh::NbFaces(ElementOrder order) throw(SALOME_Exception)
int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
if (order == ORDER_ANY) return _myMeshDS->GetMeshInfo().NbFaces(order);
return _myMeshDS->NbFaces();
int Nb = 0;
SMDS_FaceIteratorPtr it = _myMeshDS->facesIterator();
while (it->more()) {
const SMDS_MeshFace* cur = it->next();
if ( order == ORDER_LINEAR && !cur->IsQuadratic() ||
order == ORDER_QUADRATIC && cur->IsQuadratic() )
Nb++;
}
return Nb;
} }
/////////////////////////////////////////////////////////////////////////////// //================================================================================
/// Return the number of 3 nodes faces in the mesh. This method run in O(n) /*!
/////////////////////////////////////////////////////////////////////////////// * \brief Return the number of faces in the mesh
int SMESH_Mesh::NbTriangles(ElementOrder order) throw(SALOME_Exception) */
//================================================================================
int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbTriangles(order);
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while (itFaces->more()) {
const SMDS_MeshFace* curFace = itFaces->next();
int nbnod = curFace->NbNodes();
if ( !curFace->IsPoly() &&
( order == ORDER_ANY && (nbnod==3 || nbnod==6) ||
order == ORDER_LINEAR && nbnod==3 ||
order == ORDER_QUADRATIC && nbnod==6 ) )
Nb++;
}
return Nb;
} }
/////////////////////////////////////////////////////////////////////////////// //================================================================================
/// Return the number of 4 nodes faces in the mesh. This method run in O(n) /*!
/////////////////////////////////////////////////////////////////////////////// * \brief Return the number nodes faces in the mesh
int SMESH_Mesh::NbQuadrangles(ElementOrder order) throw(SALOME_Exception) */
//================================================================================
int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while (itFaces->more()) {
const SMDS_MeshFace* curFace = itFaces->next();
int nbnod = curFace->NbNodes();
if ( !curFace->IsPoly() &&
( order == ORDER_ANY && (nbnod==4 || nbnod==8) ||
order == ORDER_LINEAR && nbnod==4 ||
order == ORDER_QUADRATIC && nbnod==8 ) )
Nb++;
}
return Nb;
} }
/////////////////////////////////////////////////////////////////////////////// //================================================================================
/// Return the number of polygonal faces in the mesh. This method run in O(n) /*!
/////////////////////////////////////////////////////////////////////////////// * \brief Return the number of polygonal faces in the mesh
*/
//================================================================================
int SMESH_Mesh::NbPolygons() throw(SALOME_Exception) int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbPolygons();
SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator();
while (itFaces->more())
if (itFaces->next()->IsPoly()) Nb++;
return Nb;
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Return number of volumes of given order in the mesh
*/ */
//============================================================================= //================================================================================
int SMESH_Mesh::NbVolumes(ElementOrder order) throw(SALOME_Exception)
int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
if (order == ORDER_ANY) return _myMeshDS->GetMeshInfo().NbVolumes(order);
return _myMeshDS->NbVolumes();
int Nb = 0;
SMDS_VolumeIteratorPtr it = _myMeshDS->volumesIterator();
while (it->more()) {
const SMDS_MeshVolume* cur = it->next();
if ( order == ORDER_LINEAR && !cur->IsQuadratic() ||
order == ORDER_QUADRATIC && cur->IsQuadratic() )
Nb++;
}
return Nb;
} }
int SMESH_Mesh::NbTetras(ElementOrder order) throw(SALOME_Exception) //================================================================================
/*!
* \brief Return number of tetrahedrons of given order in the mesh
*/
//================================================================================
int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbTetras(order);
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while (itVolumes->more()) {
const SMDS_MeshVolume* curVolume = itVolumes->next();
int nbnod = curVolume->NbNodes();
if ( !curVolume->IsPoly() &&
( order == ORDER_ANY && (nbnod==4 || nbnod==10) ||
order == ORDER_LINEAR && nbnod==4 ||
order == ORDER_QUADRATIC && nbnod==10 ) )
Nb++;
}
return Nb;
} }
int SMESH_Mesh::NbHexas(ElementOrder order) throw(SALOME_Exception) //================================================================================
/*!
* \brief Return number of hexahedrons of given order in the mesh
*/
//================================================================================
int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbHexas(order);
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while (itVolumes->more()) {
const SMDS_MeshVolume* curVolume = itVolumes->next();
int nbnod = curVolume->NbNodes();
if ( !curVolume->IsPoly() &&
( order == ORDER_ANY && (nbnod==8 || nbnod==20) ||
order == ORDER_LINEAR && nbnod==8 ||
order == ORDER_QUADRATIC && nbnod==20 ) )
Nb++;
}
return Nb;
} }
int SMESH_Mesh::NbPyramids(ElementOrder order) throw(SALOME_Exception) //================================================================================
/*!
* \brief Return number of pyramids of given order in the mesh
*/
//================================================================================
int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbPyramids(order);
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while (itVolumes->more()) {
const SMDS_MeshVolume* curVolume = itVolumes->next();
int nbnod = curVolume->NbNodes();
if ( !curVolume->IsPoly() &&
( order == ORDER_ANY && (nbnod==5 || nbnod==13) ||
order == ORDER_LINEAR && nbnod==5 ||
order == ORDER_QUADRATIC && nbnod==13 ) )
Nb++;
}
return Nb;
} }
int SMESH_Mesh::NbPrisms(ElementOrder order) throw(SALOME_Exception) //================================================================================
/*!
* \brief Return number of prisms (penthahedrons) of given order in the mesh
*/
//================================================================================
int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbPrisms(order);
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while (itVolumes->more()) {
const SMDS_MeshVolume* curVolume = itVolumes->next();
int nbnod = curVolume->NbNodes();
if ( !curVolume->IsPoly() &&
( order == ORDER_ANY && (nbnod==6 || nbnod==15) ||
order == ORDER_LINEAR && nbnod==6 ||
order == ORDER_QUADRATIC && nbnod==15 ) )
Nb++;
}
return Nb;
} }
//================================================================================
/*!
* \brief Return number of polyhedrons in the mesh
*/
//================================================================================
int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception) int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; return _myMeshDS->GetMeshInfo().NbPolyhedrons();
SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator();
while (itVolumes->more())
if (itVolumes->next()->IsPoly()) Nb++;
return Nb;
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Return number of submeshes in the mesh
*/ */
//============================================================================= //================================================================================
int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception) int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
@ -1213,7 +1148,7 @@ bool SMESH_Mesh::IsNotConformAllowed() const
{ {
if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed"); if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" )); static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false ); return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
} }
@ -1325,7 +1260,7 @@ ostream& SMESH_Mesh::Dump(ostream& save)
for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic ) for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
{ {
string orderStr = isQuadratic ? "quadratic" : "linear"; string orderStr = isQuadratic ? "quadratic" : "linear";
ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR; SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl; save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl; save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;

View File

@ -191,34 +191,25 @@ public:
int NbNodes() throw(SALOME_Exception); int NbNodes() throw(SALOME_Exception);
/*! int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
* ElementOrder points out entities of what order are requested
*/
enum ElementOrder {
ORDER_ANY, /*! entities of any order */
ORDER_LINEAR, /*! entities of 1st order */
ORDER_QUADRATIC /*! entities of 2nd order */
};
int NbEdges(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbFaces(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbTriangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbTriangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbQuadrangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbPolygons() throw(SALOME_Exception); int NbPolygons() throw(SALOME_Exception);
int NbVolumes(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbVolumes(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbTetras(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbTetras(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbHexas(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbHexas(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbPyramids(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbPrisms(ElementOrder order = ORDER_ANY) throw(SALOME_Exception); int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
int NbPolyhedrons() throw(SALOME_Exception); int NbPolyhedrons() throw(SALOME_Exception);