Salome HOME
34c1cb01185b62be94ef8ba9d5d80500372ea6cb
[tools/medcoupling.git] / src / INTERP_KERNEL / MeshRegion.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __MESHREGION_HXX__
21 #define __MESHREGION_HXX__
22
23 #include "MeshElement.hxx"
24 #include "BoundingBox.hxx"
25 #include "NormalizedUnstructuredMesh.hxx"
26
27 #include <vector>
28
29 namespace INTERP_KERNEL
30 {
31   /**
32    * \brief Class representing a set of elements in a mesh together with their bounding box.
33    * It permits to split itself in two, which is used in the depth-first search filtering process.
34    *
35    */
36   template<class ConnType>
37   class MeshRegion
38   {
39   public:
40     
41     MeshRegion();
42
43     ~MeshRegion();
44
45     template<class MyMeshType>
46     void addElement(MeshElement<ConnType>* const element, const MyMeshType& mesh);
47
48     template<class MyMeshType>
49     void split(MeshRegion<ConnType>& region1, MeshRegion<ConnType>& region2, BoundingBox::BoxCoord coord, const MyMeshType& mesh);
50
51     bool isDisjointWithElementBoundingBox(const MeshElement<ConnType>& elem) const;
52     /**
53      * Accessor to beginning of elements vector
54      *
55      * @return  constant iterator pointing at the beginning of the vector or elements
56      */
57     typename std::vector< MeshElement<ConnType>* >::const_iterator getBeginElements() const { return _elements.begin(); }
58
59     /**
60      * Accessor to end of elements vector
61      *
62      * @return  constant iterator pointing at the end of the vector or elements
63      */
64     typename std::vector< MeshElement<ConnType>* >::const_iterator getEndElements() const { return _elements.end(); }
65     
66     /**
67      * Gives information on how many elements are contained in the region.
68      *
69      * @return  the number of elements contained in the region
70      */
71     unsigned getNumberOfElements() const { return _elements.size(); }
72
73   private:
74
75     /// disallow copying
76     MeshRegion(const MeshRegion& m);
77
78     /// disallow assignment
79     MeshRegion<ConnType>& operator=(const MeshRegion<ConnType>& m);
80
81     /// Vector of pointers to contained MeshElements. 
82     /// NB : these pointers are not owned by the region object, and are thus
83     /// neither allocated or liberated in this class. The elements must therefore be allocated and liberated outside the class.
84     std::vector< MeshElement<ConnType>* > _elements;
85
86     /// BoundingBox containing all the nodes of all the elements in the region.
87     BoundingBox* _box;
88   
89   };
90
91 }
92
93 #endif