Salome HOME
Doc: indicating how to pass MPI_Comm from mpi4py
[tools/medcoupling.git] / src / INTERP_KERNEL / MeshElement.hxx
1 // Copyright (C) 2007-2022  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 __MESHELEMENT_HXX__
21 #define __MESHELEMENT_HXX__
22
23 #include "BoundingBox.hxx"
24
25 #include <cstdint>
26
27 namespace INTERP_KERNEL
28 {
29
30   /**
31    * \brief Class representing a single element of a mesh together with its bounding box.
32    * It gives access to the element's global number, type and bounding box and allows
33    * easy bounding box intersection tests between MeshElements and collections of MeshElement (MeshRegions)
34    */
35   template<class ConnType>
36   class MeshElement
37   {
38
39   public:
40     using nbnodesincelltype = std::uint32_t;
41     template<class MyMeshType>
42     MeshElement(const ConnType index, const MyMeshType& mesh);
43     
44     MeshElement() = default;
45
46     template<class MyMeshType>
47     void assign(const ConnType index, const MyMeshType& mesh);
48
49     ~MeshElement() { }
50     
51     nbnodesincelltype getNumberOfNodes() const { return _number; }
52     
53     const BoundingBox *getBoundingBox() const { return &_box; }
54
55     MeshElement& operator=(const MeshElement& elem) = delete;
56
57   private:
58     /// disallow copying
59     MeshElement(const MeshElement& elem);
60
61     nbnodesincelltype _number;
62     
63     /// bounding box of the element - does not change after having been initialised
64     BoundingBox _box;
65   };
66
67   /**
68    * \brief Class defining an order for MeshElements based on their bounding boxes.
69    * The order defined between two elements is that between a given coordinate of 
70    * their bounding boxes. For instance, if the order is based on YMIN, an element whose boxes
71    * has a smaller YMIN is sorted before one with a larger YMIN.
72    *
73    */
74   class ElementBBoxOrder
75   {
76   public : 
77     
78     ElementBBoxOrder(BoundingBox::BoxCoord coord);
79     template<class ConnType>
80     bool operator()(MeshElement<ConnType>* elem1, MeshElement<ConnType>* elem2);
81     
82   private :
83     /// BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering
84     BoundingBox::BoxCoord _coord;  
85   };
86
87 }
88
89 #endif