Salome HOME
Copyright update 2021
[tools/medcoupling.git] / src / INTERP_KERNEL / UnitTetraIntersectionBary.hxx
1 // Copyright (C) 2007-2021  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 // File      : UnitTetraIntersectionBary.hxx
21 // Created   : Tue Dec  9 16:06:33 2008
22 // Author    : Edward AGAPOV (eap)
23 //
24 #ifndef __UNITTETRAINTERSECTIONBARY_HXX__
25 #define __UNITTETRAINTERSECTIONBARY_HXX__
26
27 #include "TransformedTriangle.hxx"
28 #include "INTERPKERNELDefines.hxx"
29
30 #include <vector>
31 #include <list>
32
33 namespace INTERP_KERNEL
34 {
35   class UnitTetraIntersectionBary : protected TransformedTriangle
36   {
37   public:
38     INTERPKERNEL_EXPORT UnitTetraIntersectionBary(bool isTetraInversed=false);
39
40     INTERPKERNEL_EXPORT void init(bool isTetraInversed=false);
41     /*!
42      * \brief Stores a part of triangle common with the unit tetrahedron
43      *  \param triangle - triangle side of other cell, whose calculateIntersectionVolume()
44      *                    must have already been called
45      */
46     INTERPKERNEL_EXPORT void addSide(const TransformedTriangle& triangle);
47
48     /*!
49      * \brief Computes and return coordinates of barycentre
50      */
51     INTERPKERNEL_EXPORT bool getBary(double* baryCenter);
52
53     /*!
54      * \brief Returns volume of intersection
55      *  \retval double - 
56      */
57     INTERPKERNEL_EXPORT inline double getVolume() const { return _int_volume; }
58
59     INTERPKERNEL_EXPORT virtual ~UnitTetraIntersectionBary();
60
61   private:
62
63     int addSideFaces();
64
65     void setTriangleOnSide(int i);
66
67     void clearPolygons(bool andFaces=false);
68
69     /// volume of intersection
70     double  _int_volume;
71
72     /// faces of intersection polyhedron
73     std::list< std::vector< double* > >   _faces;
74     std::vector< std::vector< double > >  _polyNormals;
75
76     bool _isTetraInversed;
77   };
78
79 }
80
81 #endif