+
+//=======================================================================
+//function : GetSubMeshIterator
+//purpose :
+//=======================================================================
+
+SMESHDS_SubMeshIteratorPtr SMESHDS_SubMesh::GetSubMeshIterator() const
+{
+ typedef set<const SMESHDS_SubMesh*>::const_iterator TIterator;
+ return SMESHDS_SubMeshIteratorPtr
+ ( new SMDS_SetIterator< const SMESHDS_SubMesh*, TIterator >( mySubMeshes.begin(),
+ mySubMeshes.end()));
+}
+
+//=======================================================================
+//function : Clear
+//purpose : remove the contents
+//=======================================================================
+
+void SMESHDS_SubMesh::Clear()
+{
+ clearVector( myElements );
+ clearVector( myNodes );
+ myUnusedIdNodes = 0;
+ myUnusedIdElements = 0;
+ if ( NbSubMeshes() > 0 )
+ {
+ SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
+ while ( sub->more() ) {
+ if ( SMESHDS_SubMesh* sm = (SMESHDS_SubMesh*) sub->next())
+ sm->Clear();
+ }
+ }
+}
+
+int SMESHDS_SubMesh::getSize()
+{
+ int c = NbNodes();
+ int d = NbElements();
+ return c+d;
+}
+
+void SMESHDS_SubMesh::compactList()
+{
+ if ( myUnusedIdElements > 0 )
+ {
+ std::vector<const SMDS_MeshElement*> newElems;
+ newElems.reserve( myElements.size() - myUnusedIdElements );
+ for (size_t i = 0; i < myElements.size(); i++)
+ if (myElements[i])
+ {
+ SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i];
+ elem->setIdInShape(newElems.size());
+ newElems.push_back(elem);
+ }
+ myElements.swap(newElems);
+ myUnusedIdElements = 0;
+ }
+
+ if ( myUnusedIdNodes > 0 )
+ {
+ std::vector<const SMDS_MeshNode*> newNodes;
+ newNodes.reserve( myNodes.size() - myUnusedIdNodes );
+ for (size_t i = 0; i < myNodes.size(); i++)
+ if (myNodes[i])
+ {
+ SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i];
+ node->setIdInShape(newNodes.size());
+ newNodes.push_back(node);
+ }
+ myNodes.swap(newNodes);
+ myUnusedIdNodes = 0;
+ }
+}