X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_SubMesh.cxx;h=31710630d79ec3e4d2b0fd6a698598e03d43656e;hp=fab9fba9c8233b32d694b05001af1c62dd31ad69;hb=fad0769be87f74668e0a39302912a9118a143a2f;hpb=3a801f21b0ee28fafae89a51de489a08ac5b48f5 diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index fab9fba9c..31710630d 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -1,128 +1,124 @@ -using namespace std; -//============================================================================= -// File : SMESH_SubMesh.cxx -// Created : -// Author : Yves FRICAUD, OCC -// Project : SALOME -// Copyright : OCC 2002 -// $Header: -//============================================================================= - -#include "SMESHDS_SubMesh.ixx" -#include "SMDS_MapIteratorOfExtendedMap.hxx" +// SMESH SMESHDS : management of mesh data and SMESH document +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_SubMesh.cxx +// Author : Yves FRICAUD, OCC +// Module : SMESH +// $Header: -//======================================================================= -//function : SMESHDS_SubMesh -//purpose : -//======================================================================= -SMESHDS_SubMesh::SMESHDS_SubMesh(const Handle(SMDS_Mesh)& M) : myMesh(M) -{ - myListOfEltIDIsUpdate = Standard_False; - myListOfNodeIDIsUpdate = Standard_False; -} +using namespace std; +#include "SMESHDS_SubMesh.hxx" //======================================================================= //function : AddElement //purpose : //======================================================================= -void SMESHDS_SubMesh::AddElement (const Handle(SMDS_MeshElement)& ME) +void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) { - myElements.Add(ME); - myListOfEltIDIsUpdate = Standard_False; + myElements.insert(ME); } //======================================================================= //function : RemoveElement //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveElement(const Handle(SMDS_MeshElement)& ME) +void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) { - myElements.Remove(ME); - myListOfEltIDIsUpdate = Standard_False; + myElements.erase(ME); } + //======================================================================= //function : AddNode //purpose : //======================================================================= -void SMESHDS_SubMesh::AddNode (const Handle(SMDS_MeshNode)& N) +void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N) { - myNodes.Add(N); - myListOfNodeIDIsUpdate = Standard_False; + myNodes.insert(N); } //======================================================================= //function : RemoveNode //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveNode (const Handle(SMDS_MeshNode)& N) +void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) { - myNodes.Remove(N); - myListOfNodeIDIsUpdate = Standard_False; + myNodes.erase(N); } //======================================================================= //function : NbElements //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbElements() +int SMESHDS_SubMesh::NbElements() const { - return myElements.Extent(); + return myElements.size(); } -//======================================================================= -//function : GetElements -//purpose : -//======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetElements() -{ - return myElements; -} //======================================================================= //function : NbNodes //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbNodes() +int SMESHDS_SubMesh::NbNodes() const { - return myNodes.Extent(); + return myNodes.size(); } -//======================================================================= -//function : GetNodes -//purpose : -//======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetNodes() +template class MySetIterator:public SMDS_Iterator { - return myNodes; -} + const set& mySet; + set::const_iterator myIt; -//======================================================================= -//function : GetIDElements -//purpose : -//======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDElements() + public: + MySetIterator(const set& s):mySet(s), myIt(s.begin()) + { + } + + bool more() + { + return myIt!=mySet.end(); + } + const T* next() + { + const T* t=*myIt; + myIt++; + return t; + } +}; +/////////////////////////////////////////////////////////////////////////////// +///Return an iterator on the elements of submesh +///The created iterator must be free by the caller +/////////////////////////////////////////////////////////////////////////////// +SMDS_Iterator * SMESHDS_SubMesh::GetElements() const { - if (!myListOfEltIDIsUpdate) { - myListOfEltID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myElements); it.More(); it.Next()) { - myListOfEltID.Append(it.Key()->GetID()); - } - myListOfEltIDIsUpdate = Standard_True; - } - return myListOfEltID; + return new MySetIterator(myElements); } -//======================================================================= -//function : GetIDNodes -//purpose : -//======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDNodes() +/////////////////////////////////////////////////////////////////////////////// +///Return an iterator on the nodes of submesh +///The created iterator must be free by the caller +/////////////////////////////////////////////////////////////////////////////// +SMDS_Iterator * SMESHDS_SubMesh::GetNodes() const { - if (!myListOfNodeIDIsUpdate) { - myListOfNodeID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myNodes); it.More(); it.Next()) { - myListOfNodeID.Append(it.Key()->GetID()); - } - myListOfNodeIDIsUpdate = Standard_True; - } - return myListOfNodeID; + return new MySetIterator(myNodes); } +