1 // SMESH SMESHDS : management of mesh data and SMESH document
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_SubMesh.cxx
25 // Author : Yves FRICAUD, OCC
30 #include "SMESHDS_SubMesh.ixx"
31 #include "SMDS_MapIteratorOfExtendedMap.hxx"
33 //=======================================================================
34 //function : SMESHDS_SubMesh
36 //=======================================================================
37 SMESHDS_SubMesh::SMESHDS_SubMesh(const Handle(SMDS_Mesh)& M) : myMesh(M)
39 myListOfEltIDIsUpdate = Standard_False;
40 myListOfNodeIDIsUpdate = Standard_False;
43 //=======================================================================
44 //function : AddElement
46 //=======================================================================
47 void SMESHDS_SubMesh::AddElement (const Handle(SMDS_MeshElement)& ME)
50 myListOfEltIDIsUpdate = Standard_False;
53 //=======================================================================
54 //function : RemoveElement
56 //=======================================================================
57 void SMESHDS_SubMesh::RemoveElement(const Handle(SMDS_MeshElement)& ME)
59 myElements.Remove(ME);
60 myListOfEltIDIsUpdate = Standard_False;
62 //=======================================================================
65 //=======================================================================
66 void SMESHDS_SubMesh::AddNode (const Handle(SMDS_MeshNode)& N)
69 myListOfNodeIDIsUpdate = Standard_False;
72 //=======================================================================
73 //function : RemoveNode
75 //=======================================================================
76 void SMESHDS_SubMesh::RemoveNode (const Handle(SMDS_MeshNode)& N)
79 myListOfNodeIDIsUpdate = Standard_False;
82 //=======================================================================
83 //function : NbElements
85 //=======================================================================
86 Standard_Integer SMESHDS_SubMesh::NbElements()
88 return myElements.Extent();
91 //=======================================================================
92 //function : GetElements
94 //=======================================================================
95 const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetElements()
99 //=======================================================================
102 //=======================================================================
103 Standard_Integer SMESHDS_SubMesh::NbNodes()
105 return myNodes.Extent();
108 //=======================================================================
109 //function : GetNodes
111 //=======================================================================
112 const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetNodes()
117 //=======================================================================
118 //function : GetIDElements
120 //=======================================================================
121 const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDElements()
123 if (!myListOfEltIDIsUpdate) {
124 myListOfEltID.Clear();
125 for (SMDS_MapIteratorOfExtendedMap it(myElements); it.More(); it.Next()) {
126 myListOfEltID.Append(it.Key()->GetID());
128 myListOfEltIDIsUpdate = Standard_True;
130 return myListOfEltID;
133 //=======================================================================
134 //function : GetIDNodes
136 //=======================================================================
137 const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDNodes()
139 if (!myListOfNodeIDIsUpdate) {
140 myListOfNodeID.Clear();
141 for (SMDS_MapIteratorOfExtendedMap it(myNodes); it.More(); it.Next()) {
142 myListOfNodeID.Append(it.Key()->GetID());
144 myListOfNodeIDIsUpdate = Standard_True;
146 return myListOfNodeID;