CHANGE_ELEMENT_NODES,
CHANGE_POLYHEDRON_NODES,
RENUMBER,
+ CLEAR_MESH,
ADD_QUADEDGE,
ADD_QUADTRIANGLE,
ADD_QUADQUADRANGLE,
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();
for (; ite.More(); ite.Next())
{
SMDS_MeshElement* elem = ite.Value();
- if(myParent!=NULL)
- myElementIDFactory->ReleaseID(elem->GetID());
delete elem;
}
for (; itf.More(); itf.Next())
{
SMDS_MeshElement* elem = itf.Value();
- if(myParent!=NULL)
- myElementIDFactory->ReleaseID(elem->GetID());
delete elem;
}
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();
}
///////////////////////////////////////////////////////////////////////////////
* Implemented for fast cleaning of meshes.
*/
virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
+
+ virtual void Clear();
virtual bool RemoveFromParent();
virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
return SMDS_ElemIteratorPtr
(new SMDS_Fact_MyElemIterator(myIDElements));
}
+
+void SMDS_MeshElementIDFactory::Clear()
+{
+ myIDElements.Clear();
+ myMin = myMax = 0;
+ SMDS_MeshIDFactory::Clear();
+}
int GetMaxID() const;
int GetMinID() const;
SMDS_ElemIteratorPtr elementsIterator() const;
+ virtual void Clear();
private:
void updateMinMax() const;
void updateMinMax(int id) const
}
}
}
+
+void SMDS_MeshIDFactory::Clear()
+{
+ myMaxID = 0;
+ myPoolOfID.clear();
+}
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();
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
-
- SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
- while ( vIt->more() )
- _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
-
- 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);
- }
+// // clear sub-meshes; get ready to re-compute as a side-effect
+
+// 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 );
+// }
+// }
+
+// // clear entities not on sub-meshes
+
+// SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
+// while ( vIt->more() )
+// _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
+
+// 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);
+// }
}
//=======================================================================
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;
}
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 )
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] ) );
SMESHDS_ChangeElementNodes,
SMESHDS_ChangePolyhedronNodes,
SMESHDS_Renumber,
+ SMESHDS_ClearAll,
// special types for quadratic elements
SMESHDS_AddQuadEdge,
SMESHDS_AddQuadTriangle,
// 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
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
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);
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);
}
//=======================================================================
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();
( 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();
+ }
+}
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;