Salome HOME
a5fb47ba90046dcf67e9d1108ae9a826b1cbaa14
[modules/med.git] / src / INTERP_KERNELTest / MeshTestToolkit.hxx
1 // Copyright (C) 2007-2013  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 ParaMEDMEM
41 {
42   class MEDCouplingUMesh;
43 }
44
45 namespace INTERP_TEST
46 {
47   /**
48    * \brief Class providing services for mesh intersection tests.
49    *
50    */
51   template<int SPACEDIM, int MESHDIM>
52   class MeshTestToolkit
53   {
54
55   public:
56     double _precision;
57     INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections)
58
59     MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation)  {}
60   
61     ~MeshTestToolkit() {}
62
63     void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const;
64
65     // 1.0e-5 here is due to limited precision of "correct" volumes calculated in Salome
66     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;
67   
68     void dumpIntersectionMatrix(const IntersectionMatrix& m) const;
69
70     double sumRow(const IntersectionMatrix& m, int i) const;
71
72     double sumCol(const IntersectionMatrix& m, int i) const;
73
74     void getVolumes(ParaMEDMEM::MEDCouplingUMesh& mesh, double* tab) const;
75
76     bool testVolumes(const IntersectionMatrix& m,  ParaMEDMEM::MEDCouplingUMesh& sMesh,  ParaMEDMEM::MEDCouplingUMesh& tMesh) const;
77
78     double sumVolume(const IntersectionMatrix& m) const;
79
80     bool areCompatitable( const IntersectionMatrix& m1,  const IntersectionMatrix& m2) const;
81
82     bool testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const;
83
84     bool testDiagonal(const IntersectionMatrix& m) const;
85   
86     void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const;
87   
88   };
89 }
90 #endif