mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 02:10:35 +05:00
Speed up "Clear mesh data"
This commit is contained in:
parent
f705b9c354
commit
be3fad7494
@ -61,6 +61,7 @@ module SMESH
|
||||
CHANGE_ELEMENT_NODES,
|
||||
CHANGE_POLYHEDRON_NODES,
|
||||
RENUMBER,
|
||||
CLEAR_MESH,
|
||||
ADD_QUADEDGE,
|
||||
ADD_QUADTRIANGLE,
|
||||
ADD_QUADQUADRANGLE,
|
||||
|
@ -1843,6 +1843,20 @@ SMDS_Mesh::~SMDS_Mesh()
|
||||
itc++;
|
||||
}
|
||||
|
||||
if(myParent==NULL)
|
||||
{
|
||||
delete myNodeIDFactory;
|
||||
delete myElementIDFactory;
|
||||
}
|
||||
else
|
||||
{
|
||||
SMDS_ElemIteratorPtr eIt = elementsIterator();
|
||||
while ( eIt->more() )
|
||||
myElementIDFactory->ReleaseID(eIt->next()->GetID());
|
||||
SMDS_NodeIteratorPtr itn = nodesIterator();
|
||||
while (itn->more())
|
||||
myNodeIDFactory->ReleaseID(itn->next()->GetID());
|
||||
}
|
||||
SetOfNodes::Iterator itn(myNodes);
|
||||
for (; itn.More(); itn.Next())
|
||||
delete itn.Value();
|
||||
@ -1851,8 +1865,6 @@ SMDS_Mesh::~SMDS_Mesh()
|
||||
for (; ite.More(); ite.Next())
|
||||
{
|
||||
SMDS_MeshElement* elem = ite.Value();
|
||||
if(myParent!=NULL)
|
||||
myElementIDFactory->ReleaseID(elem->GetID());
|
||||
delete elem;
|
||||
}
|
||||
|
||||
@ -1860,8 +1872,6 @@ SMDS_Mesh::~SMDS_Mesh()
|
||||
for (; itf.More(); itf.Next())
|
||||
{
|
||||
SMDS_MeshElement* elem = itf.Value();
|
||||
if(myParent!=NULL)
|
||||
myElementIDFactory->ReleaseID(elem->GetID());
|
||||
delete elem;
|
||||
}
|
||||
|
||||
@ -1869,16 +1879,56 @@ SMDS_Mesh::~SMDS_Mesh()
|
||||
for (; itv.More(); itv.Next())
|
||||
{
|
||||
SMDS_MeshElement* elem = itv.Value();
|
||||
if(myParent!=NULL)
|
||||
myElementIDFactory->ReleaseID(elem->GetID());
|
||||
delete elem;
|
||||
}
|
||||
|
||||
if(myParent==NULL)
|
||||
{
|
||||
delete myNodeIDFactory;
|
||||
delete myElementIDFactory;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Clear all data
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMDS_Mesh::Clear()
|
||||
{
|
||||
if (myParent!=NULL) {
|
||||
SMDS_ElemIteratorPtr eIt = elementsIterator();
|
||||
while ( eIt->more() )
|
||||
myElementIDFactory->ReleaseID(eIt->next()->GetID());
|
||||
SMDS_NodeIteratorPtr itn = nodesIterator();
|
||||
while (itn->more())
|
||||
myNodeIDFactory->ReleaseID(itn->next()->GetID());
|
||||
}
|
||||
else {
|
||||
myNodeIDFactory->Clear();
|
||||
myElementIDFactory->Clear();
|
||||
}
|
||||
SMDS_VolumeIteratorPtr itv = volumesIterator();
|
||||
while (itv->more())
|
||||
delete itv->next();
|
||||
myVolumes.Clear();
|
||||
|
||||
SMDS_FaceIteratorPtr itf = facesIterator();
|
||||
while (itf->more())
|
||||
delete itf->next();
|
||||
myFaces.Clear();
|
||||
|
||||
SMDS_EdgeIteratorPtr ite = edgesIterator();
|
||||
while (ite->more())
|
||||
delete ite->next();
|
||||
myEdges.Clear();
|
||||
|
||||
SMDS_NodeIteratorPtr itn = nodesIterator();
|
||||
while (itn->more())
|
||||
delete itn->next();
|
||||
myNodes.Clear();
|
||||
|
||||
list<SMDS_Mesh*>::iterator itc=myChildren.begin();
|
||||
while(itc!=myChildren.end())
|
||||
(*itc)->Clear();
|
||||
|
||||
myInfo = SMDS_MeshInfo();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -430,6 +430,8 @@ public:
|
||||
*/
|
||||
virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
|
||||
|
||||
virtual void Clear();
|
||||
|
||||
virtual bool RemoveFromParent();
|
||||
virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
|
||||
|
||||
|
@ -167,3 +167,10 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
|
||||
return SMDS_ElemIteratorPtr
|
||||
(new SMDS_Fact_MyElemIterator(myIDElements));
|
||||
}
|
||||
|
||||
void SMDS_MeshElementIDFactory::Clear()
|
||||
{
|
||||
myIDElements.Clear();
|
||||
myMin = myMax = 0;
|
||||
SMDS_MeshIDFactory::Clear();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
int GetMaxID() const;
|
||||
int GetMinID() const;
|
||||
SMDS_ElemIteratorPtr elementsIterator() const;
|
||||
virtual void Clear();
|
||||
private:
|
||||
void updateMinMax() const;
|
||||
void updateMinMax(int id) const
|
||||
|
@ -81,3 +81,9 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SMDS_MeshIDFactory::Clear()
|
||||
{
|
||||
myMaxID = 0;
|
||||
myPoolOfID.clear();
|
||||
}
|
||||
|
@ -35,9 +35,10 @@
|
||||
|
||||
class SMDS_EXPORT SMDS_MeshIDFactory:public SMDS_MeshObject
|
||||
{
|
||||
public:
|
||||
virtual int GetFreeID();
|
||||
virtual void ReleaseID(int ID);
|
||||
public:
|
||||
virtual int GetFreeID();
|
||||
virtual void ReleaseID(int ID);
|
||||
virtual void Clear();
|
||||
|
||||
protected:
|
||||
SMDS_MeshIDFactory();
|
||||
|
@ -212,46 +212,59 @@ const TopoDS_Solid& SMESH_Mesh::PseudoShape()
|
||||
|
||||
void SMESH_Mesh::Clear()
|
||||
{
|
||||
// clear sub-meshes; get ready to re-compute as a side-effect
|
||||
// clear mesh data
|
||||
_myMeshDS->ClearMesh();
|
||||
|
||||
if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
|
||||
{
|
||||
// update compute state of submeshes
|
||||
if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) ) {
|
||||
SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
|
||||
/*complexShapeFirst=*/false);
|
||||
while ( smIt->more() )
|
||||
{
|
||||
while ( smIt->more() ) {
|
||||
sm = smIt->next();
|
||||
TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
|
||||
if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
|
||||
// all other shapes depends on vertices so they are already cleaned
|
||||
sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
|
||||
// to recompute even if failed
|
||||
sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
|
||||
}
|
||||
}
|
||||
|
||||
// clear entities not on sub-meshes
|
||||
// // clear sub-meshes; get ready to re-compute as a side-effect
|
||||
|
||||
SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
|
||||
while ( vIt->more() )
|
||||
_myMeshDS->RemoveFreeElement( vIt->next(), 0 );
|
||||
// if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
|
||||
// {
|
||||
// SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
|
||||
// /*complexShapeFirst=*/false);
|
||||
// while ( smIt->more() )
|
||||
// {
|
||||
// sm = smIt->next();
|
||||
// TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
|
||||
// if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
|
||||
// // all other shapes depends on vertices so they are already cleaned
|
||||
// sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
|
||||
// // to recompute even if failed
|
||||
// sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
|
||||
// }
|
||||
// }
|
||||
|
||||
SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
|
||||
while ( fIt->more() )
|
||||
_myMeshDS->RemoveFreeElement( fIt->next(), 0 );
|
||||
// // clear entities not on sub-meshes
|
||||
|
||||
SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
|
||||
while ( eIt->more() )
|
||||
_myMeshDS->RemoveFreeElement( eIt->next(), 0 );
|
||||
// SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
|
||||
// while ( vIt->more() )
|
||||
// _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
|
||||
|
||||
SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
|
||||
while ( nIt->more() ) {
|
||||
const SMDS_MeshNode * node = nIt->next();
|
||||
if ( node->NbInverseElements() == 0 )
|
||||
_myMeshDS->RemoveFreeNode( node, 0 );
|
||||
else
|
||||
_myMeshDS->RemoveNode(node);
|
||||
}
|
||||
// SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
|
||||
// while ( fIt->more() )
|
||||
// _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
|
||||
|
||||
// SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
|
||||
// while ( eIt->more() )
|
||||
// _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
|
||||
|
||||
// SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
|
||||
// while ( nIt->more() ) {
|
||||
// const SMDS_MeshNode * node = nIt->next();
|
||||
// if ( node->NbInverseElements() == 0 )
|
||||
// _myMeshDS->RemoveFreeNode( node, 0 );
|
||||
// else
|
||||
// _myMeshDS->RemoveNode(node);
|
||||
// }
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -195,7 +195,7 @@ void SMESH_subMesh::SetIsAlwaysComputed(bool isAlCo)
|
||||
bool SMESH_subMesh::IsEmpty() const
|
||||
{
|
||||
if (SMESHDS_SubMesh * subMeshDS = ((SMESH_subMesh*)this)->GetSubMeshDS())
|
||||
return (!subMeshDS->GetNodes()->more() && !subMeshDS->GetElements()->more());
|
||||
return (!subMeshDS->NbElements() && !subMeshDS->NbNodes());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -513,7 +513,8 @@ bool SMESH_subMesh::CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) cons
|
||||
int aShapeDim = SMESH_Gen::GetShapeDim(_subShape);
|
||||
if (aHypDim == 3 && aShapeDim == 3) {
|
||||
// check case of open shell
|
||||
if (_subShape.ShapeType() == TopAbs_SHELL && !_subShape.Closed())
|
||||
//if (_subShape.ShapeType() == TopAbs_SHELL && !_subShape.Closed())
|
||||
if (_subShape.ShapeType() == TopAbs_SHELL && !BRep_Tool::IsClosed(_subShape))
|
||||
return false;
|
||||
}
|
||||
if ( aHypDim <= aShapeDim )
|
||||
|
@ -729,6 +729,10 @@ SMESH_Client::Update(bool theIsClear)
|
||||
case SMESH::ADD_QUADPENTAHEDRON: AddQuadPentasWithID ( mySMDSMesh, aSeq, anId ); break;
|
||||
case SMESH::ADD_QUADHEXAHEDRON : AddQuadHexasWithID ( mySMDSMesh, aSeq, anId ); break;
|
||||
|
||||
case SMESH::CLEAR_MESH:
|
||||
mySMDSMesh->Clear();
|
||||
break;
|
||||
|
||||
case SMESH::REMOVE_NODE:
|
||||
for( ; anElemId < aNbElems; anElemId++ )
|
||||
mySMDSMesh->RemoveNode( FindNode( mySMDSMesh, anIndexes[anElemId] ) );
|
||||
|
@ -46,6 +46,7 @@ enum SMESHDS_CommandType {
|
||||
SMESHDS_ChangeElementNodes,
|
||||
SMESHDS_ChangePolyhedronNodes,
|
||||
SMESHDS_Renumber,
|
||||
SMESHDS_ClearAll,
|
||||
// special types for quadratic elements
|
||||
SMESHDS_AddQuadEdge,
|
||||
SMESHDS_AddQuadTriangle,
|
||||
|
@ -769,13 +769,11 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMe
|
||||
|
||||
// Rm from group
|
||||
// Node can belong to several groups
|
||||
if (!myGroups.empty()) {
|
||||
set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
|
||||
for (; GrIt != myGroups.end(); GrIt++) {
|
||||
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
|
||||
if (!group || group->IsEmpty()) continue;
|
||||
set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
|
||||
for (; GrIt != myGroups.end(); GrIt++) {
|
||||
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
|
||||
if (group && !group->IsEmpty())
|
||||
group->SMDSGroup().Remove(elt);
|
||||
}
|
||||
}
|
||||
|
||||
// Rm from sub-mesh
|
||||
@ -786,6 +784,33 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMe
|
||||
SMDS_Mesh::RemoveFreeElement(elt);
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Remove all data from the mesh
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMESHDS_Mesh::ClearMesh()
|
||||
{
|
||||
myScript->ClearMesh();
|
||||
SMDS_Mesh::Clear();
|
||||
|
||||
// clear submeshes
|
||||
map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
|
||||
for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
|
||||
sub->second->Clear();
|
||||
|
||||
// clear groups
|
||||
TGroups::iterator group, groupEnd = myGroups.end();
|
||||
for ( group = myGroups.begin(); group != groupEnd; ++group ) {
|
||||
if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
|
||||
SMDSAbs_ElementType groupType = g->GetType();
|
||||
g->Clear();
|
||||
g->SetType( groupType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief return submesh by shape
|
||||
|
@ -382,6 +382,8 @@ public:
|
||||
void RemoveFreeNode(const SMDS_MeshNode *, SMESHDS_SubMesh *);
|
||||
void RemoveFreeElement(const SMDS_MeshElement *, SMESHDS_SubMesh *);
|
||||
|
||||
void ClearMesh();
|
||||
|
||||
bool ChangeElementNodes(const SMDS_MeshElement * elem,
|
||||
const SMDS_MeshNode * nodes[],
|
||||
const int nbnodes);
|
||||
|
@ -317,7 +317,21 @@ void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int
|
||||
myIsModified = true;
|
||||
return;
|
||||
}
|
||||
getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
|
||||
getCommand(SMESHDS_Renumber);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearMesh
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMESHDS_Script::ClearMesh ()
|
||||
{
|
||||
if(myIsEmbeddedMode){
|
||||
myIsModified = true;
|
||||
return;
|
||||
}
|
||||
Clear();// previous commands become useless to reproduce on client side
|
||||
getCommand(SMESHDS_ClearAll);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -93,6 +93,7 @@ class SMESHDS_EXPORT SMESHDS_Script
|
||||
std::vector<int> nodes_ids,
|
||||
std::vector<int> quantities);
|
||||
void Renumber (const bool isNodes, const int startID, const int deltaID);
|
||||
void ClearMesh();
|
||||
void Clear();
|
||||
const std::list<SMESHDS_Command*> & GetCommands();
|
||||
|
||||
|
@ -311,3 +311,19 @@ SMESHDS_SubMeshIteratorPtr SMESHDS_SubMesh::GetSubMeshIterator() const
|
||||
( new SMDS_SetIterator< const SMESHDS_SubMesh*, TIterator >( mySubMeshes.begin(),
|
||||
mySubMeshes.end()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose : remove the contents
|
||||
//=======================================================================
|
||||
|
||||
void SMESHDS_SubMesh::Clear()
|
||||
{
|
||||
myElements.clear();
|
||||
myNodes.clear();
|
||||
SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
|
||||
while ( sub->more() ) {
|
||||
if ( SMESHDS_SubMesh* sm = (SMESHDS_SubMesh*) sub->next())
|
||||
sm->Clear();
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
|
||||
SMDS_NodeIteratorPtr GetNodes() const;
|
||||
bool Contains(const SMDS_MeshElement * ME) const; // check if elem or node is in
|
||||
|
||||
// clear the contents
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
//const SMDS_Mesh * myMesh;
|
||||
std::set<const SMDS_MeshElement*> myElements;
|
||||
|
Loading…
Reference in New Issue
Block a user