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