1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "UnitTetra3D2DIntersectionTest.hxx"
22 #include "TetraAffineTransform.hxx"
23 #include "InterpolationUtils.hxx"
24 #include "SplitterTetra.txx"
28 using namespace INTERP_KERNEL;
34 typedef int MyConnType;
35 static const int MY_SPACEDIM=3;
38 static SplitterTetra<__MESH_DUMMY>* buildSplitterTetra()
40 const int conn[4] = { 0,1,2,3 };
42 const double targetCoords[] = { -20., 0.,10.,
47 const double* tetraCoords[]={ targetCoords, targetCoords+3, targetCoords+6, targetCoords+9 };
49 __MESH_DUMMY dummyMesh;
50 SplitterTetra<__MESH_DUMMY>* targetTetra = new SplitterTetra<__MESH_DUMMY>( dummyMesh, tetraCoords, conn );
54 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_1()
56 const int conn[4] = { 0,1,2 };
58 const double sourceCoords[] = { -20., 0., 10.,
62 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
63 const double dimCaracteristic = 1.;
64 const double precision = 1.e-12;
65 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
66 std::set<TriangleFaceKey> listOfTetraFacesColinear;
68 const double* sourceTriCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
69 double surface = targetTetra->intersectSourceFace(NORM_TRI3,
75 listOfTetraFacesTreated,
76 listOfTetraFacesColinear);
78 CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
80 CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
81 std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
82 TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
83 correctListOfTetraFacesTreated.insert(key1);
84 TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
85 correctListOfTetraFacesTreated.insert(key2);
86 TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
87 correctListOfTetraFacesTreated.insert(key3);
88 TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
89 correctListOfTetraFacesTreated.insert(key4);
90 CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
92 CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
93 std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
94 correctListOfTetraFacesColinear.insert(key1);
95 CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
99 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_2()
101 const int conn[4] = { 0,1,2,3 };
103 const double sourceCoords[] = { -20., 0., 10.,
108 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
109 const double dimCaracteristic = 1.;
110 const double precision = 1.e-12;
111 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
112 std::set<TriangleFaceKey> listOfTetraFacesColinear;
114 const double* sourceQuadCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6, sourceCoords+9 };
115 double surface = targetTetra->intersectSourceFace(NORM_QUAD4,
121 listOfTetraFacesTreated,
122 listOfTetraFacesColinear);
124 CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
126 CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
127 std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
128 TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
129 correctListOfTetraFacesTreated.insert(key1);
130 TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
131 correctListOfTetraFacesTreated.insert(key2);
132 TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
133 correctListOfTetraFacesTreated.insert(key3);
134 TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
135 correctListOfTetraFacesTreated.insert(key4);
136 CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
138 CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
139 std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
140 correctListOfTetraFacesColinear.insert(key1);
141 CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
145 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_3()
147 const int conn[4] = { 0,1,2 };
149 const double sourceCoords[] = { -20., 0., 16.,
153 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
154 const double dimCaracteristic = 1.;
155 const double precision = 1.e-12;
156 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
157 std::set<TriangleFaceKey> listOfTetraFacesColinear;
159 const double* sourceTri2Coords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
160 double surface = targetTetra->intersectSourceFace(NORM_TRI3,
166 listOfTetraFacesTreated,
167 listOfTetraFacesColinear);
169 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5,surface,precision);
171 CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesTreated.size());
173 CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesColinear.size());