1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMDS : implementaion of Salome mesh data structure
23 // File : SMDS_MeshNodeIDFactory.cxx
24 // Author : Jean-Michel BOULCOURT
28 #pragma warning(disable:4786)
31 #include "SMDS_MeshNodeIDFactory.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_Mesh.hxx"
35 #include <vtkUnstructuredGrid.h>
36 #include <vtkCellType.h>
40 //=======================================================================
41 //function : SMDS_MeshNodeIDFactory
43 //=======================================================================
44 SMDS_MeshNodeIDFactory::SMDS_MeshNodeIDFactory() :
45 SMDS_MeshIDFactory(), myMin(0), myMax(0)
49 //=======================================================================
52 //=======================================================================
53 bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem)
59 //=======================================================================
60 //function : MeshElement
62 //=======================================================================
63 SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
65 // commented since myMax can be 0 after ReleaseID()
66 // if ((ID < 1) || (ID > myMax))
68 const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
69 return (SMDS_MeshElement*) (elem);
72 //=======================================================================
73 //function : GetFreeID
75 //=======================================================================
76 int SMDS_MeshNodeIDFactory::GetFreeID()
80 ID = SMDS_MeshIDFactory::GetFreeID();
81 } while ( MeshElement( ID ));
85 //=======================================================================
86 //function : ReleaseID
88 //=======================================================================
89 void SMDS_MeshNodeIDFactory::ReleaseID(const int ID, int vtkId)
91 SMDS_MeshIDFactory::ReleaseID(ID);
92 myMesh->setMyModified();
94 myMax = 0; // --- force updateMinMax
96 myMax = 0; // --- force updateMinMax
99 //=======================================================================
100 //function : GetMaxID
102 //=======================================================================
104 int SMDS_MeshNodeIDFactory::GetMaxID() const
111 //=======================================================================
112 //function : GetMinID
114 //=======================================================================
116 int SMDS_MeshNodeIDFactory::GetMinID() const
123 //=======================================================================
124 //function : updateMinMax
126 //=======================================================================
128 void SMDS_MeshNodeIDFactory::updateMinMax() const
130 myMesh->updateNodeMinMax();
131 myMin = myMesh->MinNodeID();
132 myMax = myMesh->MaxNodeID();
135 SMDS_ElemIteratorPtr SMDS_MeshNodeIDFactory::elementsIterator() const
137 return myMesh->elementsIterator(SMDSAbs_Node);
140 void SMDS_MeshNodeIDFactory::Clear()
143 SMDS_MeshIDFactory::Clear();
146 void SMDS_MeshNodeIDFactory::emptyPool(int maxId)
148 SMDS_MeshIDFactory::emptyPool(maxId);