Salome HOME
161d11b1de68c71c2d866b20b60fae6b26a19c51
[tools/medcoupling.git] / src / INTERP_KERNELTest / MeshTestToolkit.hxx
1 // Copyright (C) 2007-2012  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
20 #ifndef __TU_MESH_TEST_TOOLKIT_HXX__
21 #define __TU_MESH_TEST_TOOLKIT_HXX__
22
23 #include "Interpolation3D.hxx"
24 #include "Interpolation3D.txx"
25 #include "InterpolationPlanar.hxx"
26
27 #include <vector>
28 #include <map>
29
30 #define ERR_TOL 1.0e-8
31
32 typedef std::vector<std::map<int,double> > IntersectionMatrix;
33
34 namespace INTERP_KERNEL
35 {
36   class Interpolation3D;
37 }
38
39
40 namespace MEDMEM {
41   class MESH;
42 }
43
44 namespace INTERP_TEST
45 {
46   /**
47    * \brief Class providing services for mesh intersection tests.
48    *
49    */
50   template<int SPACEDIM, int MESHDIM>
51   class MeshTestToolkit
52   {
53
54   public:
55     double _precision;
56     INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections)
57
58     MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation)  {}
59   
60     ~MeshTestToolkit() {}
61
62     void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const;
63
64     // 1.0e-5 here is due to limited precision of "correct" volumes calculated in Salome
65     void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const;
66   
67     void dumpIntersectionMatrix(const IntersectionMatrix& m) const;
68
69     double sumRow(const IntersectionMatrix& m, int i) const;
70
71     double sumCol(const IntersectionMatrix& m, int i) const;
72
73     void getVolumes( MEDMEM::MESH& mesh, double* tab) const;
74
75     bool testVolumes(const IntersectionMatrix& m,  MEDMEM::MESH& sMesh,  MEDMEM::MESH& tMesh) const;
76
77     double sumVolume(const IntersectionMatrix& m) const;
78
79     bool areCompatitable( const IntersectionMatrix& m1,  const IntersectionMatrix& m2) const;
80
81     bool testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const;
82
83     bool testDiagonal(const IntersectionMatrix& m) const;
84   
85     void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const;
86   
87   };
88 }
89 #endif