1 // Copyright (C) 2007-2020 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"
36 class SMDS_MeshElement;
38 //------------------------------------------------------------------------------------
40 * \brief Base class of object holding SMDS_MeshElement pointers.
41 * Registering such an object in SMDS_Mesh assures that the
42 * pointers remain valid after compacting the mesh
44 class SMDS_EXPORT SMDS_ElementHolder
48 //! register self in the mesh
49 SMDS_ElementHolder( const SMDS_Mesh* mesh );
51 //! un-register self from the mesh
52 virtual ~SMDS_ElementHolder();
57 //!< the descendant object return its elements just before the mesh compacting
58 virtual SMDS_ElemIteratorPtr getElements() = 0;
60 //!< the descendant object temporary remove its elements
61 virtual void tmpClear() = 0;
63 //!< the descendant object re-add its elements after the mesh compacting
64 virtual void add( const SMDS_MeshElement* element ) = 0;
66 //!< the descendant squeeze its element storage after re-adding elements
67 virtual void compact() = 0;
69 //!< allow the descendant treat its elements before mesh clearing
70 virtual void clear() {}
75 private: // methods called by SMDS_Mesh
77 friend class SMDS_Mesh;
79 //! store vtkIDs of elements
80 void beforeCompacting();
82 //! restore pointers to elements
83 void restoreElements( const std::vector<int>& idNodessOldToNew,
84 const std::vector<int>& idCellsOldToNew );
87 std::vector<const SMDS_MeshElement*> myExternalElems; //!< elements not contained in the mesh
88 std::vector< int > myVtkIDs; //!< vtk IDs of elements
89 std::vector< bool > myIsNode;
90 std::set< SMDS_ElementHolder* >::iterator myPtrInMesh;