1 // Copyright (C) 2007-2022 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_ElementHolder.hxx
25 #ifndef _SMDS_ElementHolder_HeaderFile
26 #define _SMDS_ElementHolder_HeaderFile
28 #include "SMESH_SMDS.hxx"
30 #include "SMDS_ElemIterator.hxx"
32 #include <smIdType.hxx>
39 class SMDS_MeshElement;
41 //------------------------------------------------------------------------------------
43 * \brief Base class of object holding SMDS_MeshElement pointers.
44 * Registering such an object in SMDS_Mesh assures that the
45 * pointers remain valid after compacting the mesh
47 class SMDS_EXPORT SMDS_ElementHolder
51 //! register self in the mesh
52 SMDS_ElementHolder( const SMDS_Mesh* mesh );
54 //! un-register self from the mesh
55 virtual ~SMDS_ElementHolder();
60 //!< the descendant object return its elements just before the mesh compacting
61 virtual SMDS_ElemIteratorPtr getElements() = 0;
63 //!< the descendant object temporary remove its elements
64 virtual void tmpClear() = 0;
66 //!< the descendant object re-add its elements after the mesh compacting
67 virtual void add( const SMDS_MeshElement* element ) = 0;
69 //!< the descendant squeeze its element storage after re-adding elements
70 virtual void compact() = 0;
72 //!< allow the descendant treat its elements before mesh clearing
73 virtual void clear() {}
78 private: // methods called by SMDS_Mesh
80 friend class SMDS_Mesh;
82 //! store vtkIDs of elements
83 void beforeCompacting();
85 //! restore pointers to elements
86 void restoreElements( const std::vector<smIdType>& idNodessOldToNew,
87 const std::vector<smIdType>& idCellsOldToNew );
90 std::vector<const SMDS_MeshElement*> myExternalElems; //!< elements not contained in the mesh
91 std::vector< vtkIdType > myVtkIDs; //!< vtk IDs of elements
92 std::vector< bool > myIsNode;
93 std::set< SMDS_ElementHolder* >::iterator myPtrInMesh;