Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / INTERP_KERNELTest / InterpolationPlanarTestSuite.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_INTERPOLATION_PLANAR_TEST_SUITE_HXX__
20 #define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__
21
22 #include <cppunit/extensions/HelperMacros.h>
23 #include <deque>
24 #include <cmath>
25 #include <iostream>
26
27 using namespace std;
28
29 namespace INTERP_TEST
30 {
31
32   /**
33    * \brief Base class for planar mesh intersection test suites.
34    * 
35    */
36   class InterpolationPlanarTestSuite : public CppUnit::TestFixture
37   {
38
39   public:
40     double _Epsilon;
41     double _Precision;
42
43     /**
44      * Sets up the test suite.
45      *
46      */
47     void setUp()
48     {
49       _Epsilon = 1.e-6;
50       _Precision = 1.e-6;
51     }
52     void tearDown()  {}
53
54     //     bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon);
55     //     bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon);
56     //     void dequePrintOut(std::deque< double > deque1);
57     //     void vectPrintOut(std::vector< double > vect);
58     //     void tabPrintOut( const double * tab, int size);
59
60     bool checkDequesEqual(std::deque< double > deque1,  
61                           std::deque< double > deque2, double epsilon)
62     {
63       int size1 = deque1.size();
64       int size2 = deque2.size();
65       bool are_equal = size1 == size2;
66     
67       if(are_equal)
68         for(int i = 0; i < size1 && are_equal; i++)
69           are_equal = fabs(deque1[i] - deque2[i]) < epsilon;
70       
71       return are_equal; 
72     }
73     bool checkVectorsEqual(std::vector< double > vect1,  
74                            std::vector< double > vect2, double epsilon)
75     {
76       int size1 = vect1.size();
77       int size2 = vect2.size();
78       bool are_equal = size1 == size2;
79       
80       if(are_equal)
81         for(int i = 0; i < size1 && are_equal; i++)
82           are_equal = fabs(vect1[i] - vect2[i]) < epsilon;
83       
84       return are_equal; 
85     }
86     void dequePrintOut(std::deque< double > deque1)
87     {
88       for(int i = 0; i< (int)deque1.size(); i++)
89         {
90           std::cerr << deque1[i] << " ";
91         }
92       std::cerr<< endl;
93     }
94     void vectPrintOut(std::vector< double > vect)
95     {
96       for(int i = 0; i< (int)vect.size(); i++)
97         {
98           std::cerr << vect[i] << " ";
99         }
100       std::cerr<< endl;
101     }  
102     void tabPrintOut( const double * tab,int size)
103     {
104       for(int i = 0; i< size; i++)
105         {
106           std::cerr << tab[i] << " ";
107         }
108       std::cerr<< endl;
109     }  
110
111     /**
112      * Cleans up after the test suite.
113      * Liberates the MeshTestToolkit object used by the tests.
114      */
115     //     void tearDown()
116     //     {
117     //       delete _testTools;
118     //     }
119
120     
121
122     //   protected:
123     //     /// MeshTestToolkit object to which the tests are delegated
124     //     MeshTestToolkit* _testTools; 
125
126   };
127 }
128 #endif