1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 // File : SMDS_MeshNodeIDFactory.cxx
23 // Author : Jean-Michel BOULCOURT
27 #pragma warning(disable:4786)
30 #include "SMDS_MeshNodeIDFactory.hxx"
31 #include "SMDS_MeshElement.hxx"
32 #include "SMDS_Mesh.hxx"
34 #include <vtkUnstructuredGrid.h>
35 #include <vtkCellType.h>
39 //=======================================================================
40 //function : SMDS_MeshNodeIDFactory
42 //=======================================================================
43 SMDS_MeshNodeIDFactory::SMDS_MeshNodeIDFactory() :
44 SMDS_MeshIDFactory(), myMin(0), myMax(0)
48 //=======================================================================
51 //=======================================================================
52 bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem)
58 //=======================================================================
59 //function : MeshElement
61 //=======================================================================
62 SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
64 // commented since myMax can be 0 after ReleaseID()
65 // if ((ID < 1) || (ID > myMax))
67 const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
68 return (SMDS_MeshElement*) (elem);
71 //=======================================================================
72 //function : GetFreeID
74 //=======================================================================
75 int SMDS_MeshNodeIDFactory::GetFreeID()
79 ID = SMDS_MeshIDFactory::GetFreeID();
80 } while ( MeshElement( ID ));
84 //=======================================================================
85 //function : ReleaseID
87 //=======================================================================
88 void SMDS_MeshNodeIDFactory::ReleaseID(const int ID, int vtkId)
90 SMDS_MeshIDFactory::ReleaseID(ID);
91 myMesh->setMyModified();
93 myMax = 0; // --- force updateMinMax
95 myMax = 0; // --- force updateMinMax
98 //=======================================================================
101 //=======================================================================
103 int SMDS_MeshNodeIDFactory::GetMaxID() const
110 //=======================================================================
111 //function : GetMinID
113 //=======================================================================
115 int SMDS_MeshNodeIDFactory::GetMinID() const
122 //=======================================================================
123 //function : updateMinMax
125 //=======================================================================
127 void SMDS_MeshNodeIDFactory::updateMinMax() const
129 myMesh->updateNodeMinMax();
130 myMin = myMesh->MinNodeID();
131 myMax = myMesh->MaxNodeID();
134 SMDS_ElemIteratorPtr SMDS_MeshNodeIDFactory::elementsIterator() const
136 return myMesh->elementsIterator(SMDSAbs_Node);
139 void SMDS_MeshNodeIDFactory::Clear()
142 SMDS_MeshIDFactory::Clear();
145 void SMDS_MeshNodeIDFactory::emptyPool(int maxId)
147 SMDS_MeshIDFactory::emptyPool(maxId);