23544: SMESH's performance issues

This commit is contained in:
eap 2018-04-10 19:14:21 +03:00
parent dfdbed8fb7
commit 19fe2e412f
4 changed files with 29 additions and 31 deletions

View File

@ -41,6 +41,7 @@ namespace
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
SMDSAbs_GeometryType myGeom; SMDSAbs_GeometryType myGeom;
bool myIsPoly; bool myIsPoly;
bool myIsQuadratic;
int myNbCornerNodes; int myNbCornerNodes;
int myNbNodes; int myNbNodes;
int myNbEdges; int myNbEdges;
@ -65,12 +66,12 @@ namespace
myType = Type; myType = Type;
myGeom = Geom; myGeom = Geom;
myIsPoly = IsPoly; myIsPoly = IsPoly;
myIsQuadratic = ( NbNodes > NbCornerNodes );
myNbCornerNodes = NbCornerNodes; myNbCornerNodes = NbCornerNodes;
myNbNodes = NbNodes; myNbNodes = NbNodes;
myNbEdges = NbEdges; myNbEdges = NbEdges;
myNbFaces = NbFaces; myNbFaces = NbFaces;
} }
bool IsQuadratic() const { return myNbNodes > myNbCornerNodes; }
}; };
//! return vector a CellProps //! return vector a CellProps
@ -259,7 +260,7 @@ bool SMDS_MeshCell::ChangeNodes(const SMDS_MeshNode* nodes[], const int theNbNod
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
int SMDS_MeshCell::NbNodes() const int SMDS_MeshCell::NbNodes() const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbNodes(); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbNodes();
vtkIdType *pts, npts; vtkIdType *pts, npts;
getGrid()->GetCellPoints( GetVtkID(), npts, pts ); getGrid()->GetCellPoints( GetVtkID(), npts, pts );
@ -268,7 +269,7 @@ int SMDS_MeshCell::NbNodes() const
int SMDS_MeshCell::NbFaces() const int SMDS_MeshCell::NbFaces() const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbFaces(); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbFaces();
return getCellProps( GetVtkType() ).myNbFaces; return getCellProps( GetVtkType() ).myNbFaces;
} }
@ -290,13 +291,13 @@ int SMDS_MeshCell::NbEdges() const
int SMDS_MeshCell::NbCornerNodes() const int SMDS_MeshCell::NbCornerNodes() const
{ {
switch ( GetEntityType() ) switch ( GetVtkType() )
{ {
case SMDSEntity_Polyhedra: case VTK_POLYHEDRON:
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbCornerNodes(); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbCornerNodes();
case SMDSEntity_Polygon: case VTK_POLYGON:
return NbNodes(); return NbNodes();
case SMDSEntity_Quad_Polygon: case VTK_QUADRATIC_POLYGON:
return NbNodes() / 2; return NbNodes() / 2;
default:; default:;
} }
@ -308,7 +309,7 @@ int SMDS_MeshCell::NbCornerNodes() const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMDS_ElemIteratorPtr SMDS_MeshCell::nodesIterator() const SMDS_ElemIteratorPtr SMDS_MeshCell::nodesIterator() const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodesIterator(); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodesIterator();
return boost::make_shared< SMDS_VtkCellIterator<> >( GetMesh(), GetVtkID(), GetEntityType()); return boost::make_shared< SMDS_VtkCellIterator<> >( GetMesh(), GetVtkID(), GetEntityType());
@ -319,7 +320,7 @@ SMDS_ElemIteratorPtr SMDS_MeshCell::nodesIterator() const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMDS_NodeIteratorPtr SMDS_MeshCell::nodeIterator() const SMDS_NodeIteratorPtr SMDS_MeshCell::nodeIterator() const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodeIterator(); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::nodeIterator();
return SMDS_NodeIteratorPtr return SMDS_NodeIteratorPtr
@ -340,7 +341,7 @@ SMDS_NodeIteratorPtr SMDS_MeshCell::nodesIteratorToUNV() const
SMDSAbs_ElementType SMDS_MeshCell::GetType() const SMDSAbs_ElementType SMDS_MeshCell::GetType() const
{ {
return ElemType( GetEntityType() ); return getCellProps( GetVtkType() ).myType;
} }
SMDSAbs_EntityType SMDS_MeshCell::GetEntityType() const SMDSAbs_EntityType SMDS_MeshCell::GetEntityType() const
@ -365,12 +366,12 @@ bool SMDS_MeshCell::IsPoly() const
bool SMDS_MeshCell::IsQuadratic() const bool SMDS_MeshCell::IsQuadratic() const
{ {
return getCellProps( GetVtkType() ).IsQuadratic(); return getCellProps( GetVtkType() ).myIsQuadratic;
} }
const SMDS_MeshNode* SMDS_MeshCell::GetNode(const int ind) const const SMDS_MeshNode* SMDS_MeshCell::GetNode(const int ind) const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNode( ind ); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNode( ind );
vtkIdType npts, *pts; vtkIdType npts, *pts;
@ -381,7 +382,7 @@ const SMDS_MeshNode* SMDS_MeshCell::GetNode(const int ind) const
int SMDS_MeshCell::GetNodeIndex( const SMDS_MeshNode* node ) const int SMDS_MeshCell::GetNodeIndex( const SMDS_MeshNode* node ) const
{ {
if ( GetEntityType() == SMDSEntity_Polyhedra ) if ( GetVtkType() == VTK_POLYHEDRON )
return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNodeIndex( node ); return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::GetNodeIndex( node );
vtkIdType npts, *pts; vtkIdType npts, *pts;
@ -767,7 +768,7 @@ bool SMDS_MeshCell::IsPoly( SMDSAbs_EntityType entityType )
bool SMDS_MeshCell::IsQuadratic( SMDSAbs_EntityType entityType ) bool SMDS_MeshCell::IsQuadratic( SMDSAbs_EntityType entityType )
{ {
return getCellProps( entityType ).IsQuadratic(); return getCellProps( entityType ).myIsQuadratic;
} }
int SMDS_MeshCell::NbCornerNodes( SMDSAbs_EntityType entityType ) int SMDS_MeshCell::NbCornerNodes( SMDSAbs_EntityType entityType )

View File

@ -45,7 +45,7 @@
SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh, SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
const SMDSAbs_ElementType theType) const SMDSAbs_ElementType theType)
: SMDS_ElementHolder( theMesh ), myType(theType), myTic(0) : SMDS_ElementHolder( theMesh ), myType( theType ), myTic( 0 )
{ {
} }
@ -69,15 +69,15 @@ void SMDS_MeshGroup::Clear()
bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem) bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
{ {
// the type of the group is determined by the first element added // the type of the group is determined by the first element added
if (myElements.empty()) { if ( myElements.empty() ) {
myType = theElem->GetType(); myType = theElem->GetType();
} }
else if (theElem->GetType() != myType) { else if ( theElem->GetType() != myType ) {
MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType); MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
return false; return false;
} }
myElements.insert(theElem); myElements.insert( theElem );
++myTic; ++myTic;
return true; return true;
@ -88,12 +88,12 @@ bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
//purpose : //purpose :
//======================================================================= //=======================================================================
bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem) bool SMDS_MeshGroup::Remove( const SMDS_MeshElement * theElem )
{ {
TElementSet::iterator found = myElements.find(theElem); TElementSet::iterator found = myElements.find(theElem);
if ( found != myElements.end() ) { if ( found != myElements.end() ) {
myElements.erase(found); myElements.erase( found );
if (myElements.empty()) myType = SMDSAbs_All; if ( myElements.empty() ) myType = SMDSAbs_All;
++myTic; ++myTic;
return true; return true;
} }
@ -107,7 +107,7 @@ bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
{ {
return myElements.find(theElem) != myElements.end(); return myElements.find( theElem ) != myElements.end();
} }
//======================================================================= //=======================================================================
@ -152,6 +152,5 @@ void SMDS_MeshGroup::operator=( SMDS_MeshGroup && other )
void SMDS_MeshGroup::tmpClear() void SMDS_MeshGroup::tmpClear()
{ {
compact();
myElements.clear(); myElements.clear();
} }

View File

@ -33,8 +33,6 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include <set> #include <set>
#include <boost/container/flat_set.hpp>
class SMDS_EXPORT SMDS_MeshGroup: public SMDS_MeshObject, SMDS_ElementHolder class SMDS_EXPORT SMDS_MeshGroup: public SMDS_MeshObject, SMDS_ElementHolder
{ {
public: public:
@ -43,7 +41,7 @@ class SMDS_EXPORT SMDS_MeshGroup: public SMDS_MeshObject, SMDS_ElementHolder
void SetType (const SMDSAbs_ElementType theType); void SetType (const SMDSAbs_ElementType theType);
void Clear(); void Clear();
void Reserve(size_t nbElems) { myElements.reserve( nbElems ); } void Reserve(size_t nbElems) {}
bool Add(const SMDS_MeshElement * theElem); bool Add(const SMDS_MeshElement * theElem);
bool Remove(const SMDS_MeshElement * theElem); bool Remove(const SMDS_MeshElement * theElem);
bool IsEmpty() const { return myElements.empty(); } bool IsEmpty() const { return myElements.empty(); }
@ -62,12 +60,12 @@ class SMDS_EXPORT SMDS_MeshGroup: public SMDS_MeshObject, SMDS_ElementHolder
virtual SMDS_ElemIteratorPtr getElements() { return GetElements(); } virtual SMDS_ElemIteratorPtr getElements() { return GetElements(); }
virtual void tmpClear(); virtual void tmpClear();
virtual void add( const SMDS_MeshElement* element ) { Add( element ); } virtual void add( const SMDS_MeshElement* element ) { Add( element ); }
virtual void compact() { myElements.shrink_to_fit(); } virtual void compact() {}
private: private:
typedef boost::container::flat_set< const SMDS_MeshElement* > TElementSet; typedef std::set< const SMDS_MeshElement* > TElementSet;
typedef TElementSet::const_iterator TIterator; typedef TElementSet::const_iterator TIterator;
const SMDS_Mesh * myMesh; const SMDS_Mesh * myMesh;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;

View File

@ -36,7 +36,7 @@ class SMDS_EXPORT SMDS_SpacePosition : public SMDS_Position
public: public:
virtual SMDS_TypeOfPosition GetTypeOfPosition() const { return SMDS_TOP_3DSPACE; } virtual SMDS_TypeOfPosition GetTypeOfPosition() const { return SMDS_TOP_3DSPACE; }
static SMDS_PositionPtr originSpacePosition(); static SMDS_PositionPtr originSpacePosition();
virtual const double* GetParameters() const { return 0; } virtual const double* GetParameters() const { return 0; }
private: private: