1 // Copyright (C) 2007-2023 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"
25 #include "MCIdType.hxx"
29 using namespace INTERP_KERNEL;
35 typedef mcIdType MyConnType;
36 static const int MY_SPACEDIM=3;
39 static SplitterTetra<__MESH_DUMMY>* buildSplitterTetra()
41 const mcIdType conn[4] = { 0,1,2,3 };
43 const double targetCoords[] = { -20., 0.,10.,
48 const double* tetraCoords[]={ targetCoords, targetCoords+3, targetCoords+6, targetCoords+9 };
50 __MESH_DUMMY dummyMesh;
51 SplitterTetra<__MESH_DUMMY>* targetTetra = new SplitterTetra<__MESH_DUMMY>( dummyMesh, tetraCoords, conn );
55 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_1()
57 const mcIdType conn[4] = { 0,1,2 };
59 const double sourceCoords[] = { -20., 0., 10.,
63 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
64 const double dimCaracteristic = 1.;
65 const double precision = 1.e-12;
66 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
67 std::set<TriangleFaceKey> listOfTetraFacesColinear;
69 const double* sourceTriCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
70 double surface = targetTetra->intersectSourceFace(NORM_TRI3,
76 listOfTetraFacesTreated,
77 listOfTetraFacesColinear);
79 CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
81 CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
82 std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
83 TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
84 correctListOfTetraFacesTreated.insert(key1);
85 TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
86 correctListOfTetraFacesTreated.insert(key2);
87 TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
88 correctListOfTetraFacesTreated.insert(key3);
89 TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
90 correctListOfTetraFacesTreated.insert(key4);
91 CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
93 CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
94 std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
95 correctListOfTetraFacesColinear.insert(key1);
96 CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
100 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_2()
102 const mcIdType conn[4] = { 0,1,2,3 };
104 const double sourceCoords[] = { -20., 0., 10.,
109 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
110 const double dimCaracteristic = 1.;
111 const double precision = 1.e-12;
112 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
113 std::set<TriangleFaceKey> listOfTetraFacesColinear;
115 const double* sourceQuadCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6, sourceCoords+9 };
116 double surface = targetTetra->intersectSourceFace(NORM_QUAD4,
122 listOfTetraFacesTreated,
123 listOfTetraFacesColinear);
125 CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
127 CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
128 std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
129 TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
130 correctListOfTetraFacesTreated.insert(key1);
131 TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
132 correctListOfTetraFacesTreated.insert(key2);
133 TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
134 correctListOfTetraFacesTreated.insert(key3);
135 TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
136 correctListOfTetraFacesTreated.insert(key4);
137 CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
139 CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
140 std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
141 correctListOfTetraFacesColinear.insert(key1);
142 CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
146 void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_3()
148 const mcIdType conn[4] = { 0,1,2 };
150 const double sourceCoords[] = { -20., 0., 16.,
154 SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
155 const double dimCaracteristic = 1.;
156 const double precision = 1.e-12;
157 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
158 std::set<TriangleFaceKey> listOfTetraFacesColinear;
160 const double* sourceTri2Coords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
161 double surface = targetTetra->intersectSourceFace(NORM_TRI3,
167 listOfTetraFacesTreated,
168 listOfTetraFacesColinear);
170 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5,surface,precision);
172 CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesTreated.size());
174 CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesColinear.size());