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