1 // Copyright (C) 2007-2020 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
19 // Author : Anthony Geay (CEA/DEN)
21 #include "QuadraticPlanarInterpTest.hxx"
22 #include "InterpKernelGeo2DQuadraticPolygon.hxx"
23 #include "InterpKernelGeo2DElementaryEdge.hxx"
24 #include "InterpKernelGeo2DEdgeArcCircle.hxx"
25 #include "InterpKernelGeo2DEdgeLin.hxx"
32 using namespace INTERP_KERNEL;
37 void QuadraticPlanarInterpTest::checkPolygonsIntersection1()
39 //The "most" basic test1
40 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3);
41 Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3);
42 Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7);
43 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
44 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
45 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
47 std::vector<QuadraticPolygon *> result;
53 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
54 QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
55 for(int i1=0;i1<i;i1++) pol1.circularPermute(); if(k==1) pol1.reverse();
56 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
57 for(int j1=0;j1<j;j1++) pol2.circularPermute();
58 result=pol1.intersectMySelfWith(pol2);
59 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
60 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
61 double tmp1=0.,tmp2=0.,tmp3=0.;
62 pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3);
63 std::vector<double> v1,v2;
65 pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge
66 pol1.intersectForPoint(pol2,v3);
67 CPPUNIT_ASSERT_EQUAL(3,(int)v1.size());
68 CPPUNIT_ASSERT_EQUAL(3,(int)v2.size());
69 CPPUNIT_ASSERT_EQUAL(3,(int)v3.size());
72 CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]);
73 CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]);
74 CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]);
75 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14);
76 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14);
77 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14);
78 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14);
79 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14);
80 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14);
82 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14);
83 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14);
84 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge
89 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
90 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
92 //Deeper test some extremities of pol2 are on edges of pol1.
94 n1=new Node(0.,0.); n4=new Node(1.5,-0.5);
95 n2=new Node(1.,0.); n5=new Node(0.5,0.);
96 n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5);
97 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
98 EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5);
105 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef();
106 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
107 for(int i1=0;i1<i;i1++) pol3.circularPermute(); if(k==1) pol3.reverse();
108 QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5);
109 for(int j1=0;j1<j;j1++) pol4.circularPermute();
110 result=pol3.intersectMySelfWith(pol4);
111 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
112 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
117 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef();
118 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
120 //Test with one edge of pol2 is included in pol1.
122 n1=new Node(0.,0.); n4=new Node(-0.5,0.);
123 n2=new Node(1.,0.); n5=new Node(0.,-1.);
124 n3=new Node(0.5,1.); n6=new Node(0.5,0.);
125 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
126 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
132 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
133 QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1);
134 for(int i1=0;i1<i;i1++) pol5.circularPermute(); if(k==1) pol5.reverse();
135 QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4);
136 for(int j1=0;j1<j;j1++) pol6.circularPermute();
137 result=pol5.intersectMySelfWith(pol6);
138 CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
142 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
143 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
145 //Test of full overlapped polygons.
147 n1=new Node(0.,0.); n4=new Node(0.,0.);
148 n2=new Node(1.,0.); n5=new Node(1.,0.);
149 n3=new Node(0.5,1.); n6=new Node(0.5,1.);
150 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
151 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
157 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
158 QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1);
159 for(int i1=0;i1<i;i1++) pol7.circularPermute(); if(k==1) pol7.reverse();
160 QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4);
161 for(int j1=0;j1<j;j1++) pol8.circularPermute();
162 result=pol7.intersectMySelfWith(pol8);
163 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
164 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
166 double tmp1=0.,tmp2=0.,tmp3=0.;
167 pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3);
168 std::vector<double> v1,v2;
169 pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges.
170 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14);
171 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14);
172 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14);
173 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14);
174 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14);
178 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
179 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
181 //Test of closing process
183 n1=new Node(0.,0.); n4=new Node(0.539,-0.266);
184 n2=new Node(1.,0.); n5=new Node(1.039,0.6);
185 n3=new Node(0.5,1.); n6=new Node(-0.077,0.667);
186 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
187 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
193 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
194 QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1);
195 for(int i1=0;i1<i;i1++) pol9.circularPermute(); if(k==1) pol9.reverse();
196 QuadraticPolygon pol10; pol10.pushBack(e5_6); pol10.pushBack(e6_4); pol10.pushBack(e4_5);
197 for(int j1=0;j1<j;j1++) pol10.circularPermute();
198 result=pol9.intersectMySelfWith(pol10);
199 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
200 CPPUNIT_ASSERT_EQUAL(6,result[0]->recursiveSize());
205 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
206 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
210 n1=new Node(0.,0.); n4=new Node(0.3,0.1);
211 n2=new Node(1.,0.); n5=new Node(0.7,0.1);
212 n3=new Node(0.5,1.); n6=new Node(0.5,0.7);
213 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
214 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
220 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
221 QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1);
222 for(int i1=0;i1<i;i1++) pol11.circularPermute(); if(k==1) pol11.reverse();
223 QuadraticPolygon pol12; pol12.pushBack(e5_6); pol12.pushBack(e6_4); pol12.pushBack(e4_5);
224 for(int j1=0;j1<j;j1++) pol12.circularPermute();
225 result=pol11.intersectMySelfWith(pol12);
226 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
227 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
232 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
233 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
237 n1=new Node(0.,0.); n4=new Node(-2,0.);
238 n2=new Node(1.,0.); n5=new Node(-1.,0.);
239 n3=new Node(0.5,1.); n6=new Node(-1.5,1.);
240 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
241 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
247 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
248 QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1);
249 for(int i1=0;i1<i;i1++) pol13.circularPermute(); if(k==1) pol13.reverse();
250 QuadraticPolygon pol14; pol14.pushBack(e5_6); pol14.pushBack(e6_4); pol14.pushBack(e4_5);
251 for(int j1=0;j1<j;j1++) pol14.circularPermute();
252 result=pol13.intersectMySelfWith(pol14);
253 CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
257 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
258 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
267 n5=new Node(0.2,0.7);
268 n6=new Node(0.4,0.7);
269 n7=new Node(0.4,1.3);
270 Node *n8=new Node(0.6,1.3);
271 Node *n9=new Node(0.6,0.7);
272 Node *n10=new Node(0.9,0.7);
273 Node *n11=new Node(0.9,2.);
274 Node *n12=new Node(0.2,2.);
276 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); Edge *e3_4=new EdgeLin(n3,n4); Edge *e4_1=new EdgeLin(n4,n1);
277 e5_6=new EdgeLin(n5,n6); Edge *e6_7=new EdgeLin(n6,n7); Edge *e7_8=new EdgeLin(n7,n8); Edge *e8_9=new EdgeLin(n8,n9); Edge *e9_10=new EdgeLin(n9,n10); Edge *e10_11=new EdgeLin(n10,n11);
278 Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5);
285 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef();
286 QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1);
287 for(int i1=0;i1<i;i1++) pol15.circularPermute(); if(k==1) pol15.reverse();
288 QuadraticPolygon pol16; pol16.pushBack(e5_6); pol16.pushBack(e6_7); pol16.pushBack(e7_8); pol16.pushBack(e8_9); pol16.pushBack(e9_10); pol16.pushBack(e10_11); pol16.pushBack(e11_12); pol16.pushBack(e12_1);
289 for(int j1=0;j1<j;j1++) pol16.circularPermute();
290 result=pol15.intersectMySelfWith(pol16);
291 CPPUNIT_ASSERT_EQUAL(2,(int)result.size());
292 checkBasicsOfPolygons(*result[0],*result[1],false);
293 CPPUNIT_ASSERT_EQUAL(4,result[0]->recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize());
294 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10);
295 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10);
296 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10);
297 delete result[0]; delete result[1];
301 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); e5_6->decrRef(); e6_7->decrRef(); e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef();
302 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef();
306 * Testing case where a polygon pol1 is included in an onother polygon pol2.
308 void QuadraticPlanarInterpTest::checkPolygonsIntersection2()
310 Node *n1=new Node(0.,0.); Node *n4=new Node(0.2,0.2);
311 Node *n2=new Node(1.,0.); Node *n5=new Node(0.8,0.2);
312 Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.8);
313 Edge *e1_2=new EdgeLin(n1,n2); Edge *e4_5=new EdgeLin(n4,n5);
314 Edge *e2_3=new EdgeLin(n2,n3); Edge *e5_6=new EdgeLin(n5,n6);
315 Edge *e3_1=new EdgeLin(n3,n1); Edge *e6_4=new EdgeLin(n6,n4);
317 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
318 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
319 std::vector<QuadraticPolygon *> result=pol1.intersectMySelfWith(pol2);
320 CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
321 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
322 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
325 pol1.initLocations();
326 pol2.initLocations();
327 result=pol2.intersectMySelfWith(pol1);
328 CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
329 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
330 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
333 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
336 void QuadraticPlanarInterpTest::checkAreasCalculations()
338 Node *n1=new Node(0.,0.);
339 Node *n2=new Node(1.,0.);
340 Node *n3=new Node(0.5,1.);
341 Edge *e1_2=new EdgeLin(n1,n2);
342 Edge *e2_3=new EdgeLin(n2,n3);
343 Edge *e3_1=new EdgeLin(n3,n1);
345 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
346 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
347 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10);
348 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10);
349 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10);
351 CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5,pol1.getArea(),1e-10);
352 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10);
353 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10);
355 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
356 n1->decrRef(); n2->decrRef(); n3->decrRef();
362 Node *n3m=new Node(1.5,0.5);
364 Node *n4=new Node(0.,1.);
365 e1_2=new EdgeLin(n1,n2);
366 e2_3=new EdgeArcCircle(n2,n3m,n3);
367 Edge *e3_4=new EdgeLin(n3,n4);
368 Edge *e4_1=new EdgeLin(n4,n1);
372 n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4));
373 n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4));
374 n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4));
375 n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2));
376 e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m);
377 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
378 QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1);
379 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6);
380 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
382 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6);
383 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
386 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef();
387 n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
391 const double radius1=0.7;
392 const double radius2=0.9;
393 n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.));
394 n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.));
395 Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.));
396 n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.));
397 n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.));
398 n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.));
399 e1_2=new EdgeArcCircle(n1,n2m,n2);
400 e2_3=new EdgeLin(n2,n3);
401 e3_4=new EdgeArcCircle(n3,n3m,n4);
402 e4_1=new EdgeLin(n4,n1);
404 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
405 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1);
406 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10);
407 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
409 CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10);
410 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
412 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef();
413 n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
416 void QuadraticPlanarInterpTest::checkBarycenterCalculations()
418 Node *n1=new Node(3.,7.);
419 Node *n2=new Node(5.,7.);
420 Node *n3=new Node(4.,8.);
421 Edge *e1_2=new EdgeLin(n1,n2);
422 Edge *e2_3=new EdgeLin(n2,n3);
423 Edge *e3_1=new EdgeLin(n3,n1);
426 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
427 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
428 bary[0]=0.; bary[1]=0.;
429 e1_2->getBarycenterOfZone(bary);
430 CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10);
431 bary[0]=0.; bary[1]=0.;
432 e2_3->getBarycenterOfZone(bary);
433 CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10);
434 CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10);
435 bary[0]=0.; bary[1]=0.;
436 e3_1->getBarycenterOfZone(bary);
437 CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10);
438 CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10);
439 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10);
440 pol1.getBarycenter(bary);
441 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
442 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
444 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
445 QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false);
446 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10);
447 pol4.getBarycenter(bary);
448 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
449 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
451 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
452 n1->decrRef(); n2->decrRef(); n3->decrRef();
457 e1_2=new EdgeLin(n1,n3);
458 e2_3=new EdgeLin(n3,n2);
459 e3_1=new EdgeLin(n2,n1);
460 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
461 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
462 bary[0]=0.; bary[1]=0.;
463 pol3.getBarycenter(bary);
464 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10);
465 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
466 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
468 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
469 n1->decrRef(); n2->decrRef(); n3->decrRef();
471 double center[2]={3.,7.};
472 e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.);
473 bary[0]=0.; bary[1]=0.;
474 e1_2->getBarycenterOfZone(bary);
475 CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10);
476 CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10);
477 n1=new Node(0.99999999999999822,3.5358983848622465);
478 n2=new Node(5.,10.4641016151377544);
479 Edge *e2_1=new EdgeLin(n1,n2);
481 e1_2->incrRef(); e2_1->incrRef();
482 QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1);
483 pol2.getBarycenter(bary);
484 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10);
486 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10);
487 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10);
489 e1_2->decrRef(); e2_1->decrRef();
490 n1->decrRef(); n2->decrRef();
494 * Testing user interface high level function.
496 void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
498 QuadraticPlanarPrecision::setPrecision(1e-10);
500 8.8334591186000004, 5.0999999999999996,
501 7.1014083111000001, 6.0999999999999996,
502 7.8334591186000004, 6.8320508074999999,
503 7.9674337149000003, 5.5999999999999996,
504 7.4192455562999999, 6.5142135623000001,
505 8.3334591186000004, 5.9660254036999998
507 std::vector<Node *> nodes;
508 nodes.push_back(new Node(coords));
509 nodes.push_back(new Node(coords+2));
510 nodes.push_back(new Node(coords+4));
511 nodes.push_back(new Node(coords+6));
512 nodes.push_back(new Node(coords+8));
513 nodes.push_back(new Node(coords+10));
514 QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
515 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5);
516 CPPUNIT_ASSERT_EQUAL(3,pol->size());
517 ElementaryEdge *e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
518 ElementaryEdge *e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
519 ElementaryEdge *e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
520 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
521 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));// <- testing detection of colinearity
522 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
523 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));// <- testing detection of colinearity
526 nodes.push_back(new Node(coords));
527 nodes.push_back(new Node(coords+4));
528 nodes.push_back(new Node(coords+2));
529 nodes.push_back(new Node(coords+10));
530 nodes.push_back(new Node(coords+8));
531 nodes.push_back(new Node(coords+6));
532 pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
533 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5);
534 CPPUNIT_ASSERT_EQUAL(3,pol->size());
535 e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
536 e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
537 e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
538 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
539 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));// <- testing detection of colinearity
540 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
541 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));// <- testing detection of colinearity
543 const double coords2[]={
550 nodes.push_back(new Node(coords2));
551 nodes.push_back(new Node(coords2+2));
552 nodes.push_back(new Node(coords2+4));
553 nodes.push_back(new Node(coords2+6));
554 pol=QuadraticPolygon::BuildLinearPolygon(nodes);
555 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12);
557 pol->getBarycenter(tmp,tmp2);
558 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12);
559 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12);
561 const double coords3[]={
562 1.0999999999000001, -1.9052558882999999,
563 1.9052558881999999, -1.0999999999000001,
564 1.7320508075000001, -0.99999999989999999,
565 0.99999999989999999, -1.7320508075000001,
566 1.5556349186, -1.5556349185,
567 1.8186533478, -1.0499999999,
568 1.4142135623000001, -1.4142135623000001,
569 1.0499999999, -1.8186533479
572 nodes.push_back(new Node(coords3));
573 nodes.push_back(new Node(coords3+2));
574 nodes.push_back(new Node(coords3+4));
575 nodes.push_back(new Node(coords3+6));
576 nodes.push_back(new Node(coords3+8));
577 nodes.push_back(new Node(coords3+10));
578 nodes.push_back(new Node(coords3+12));
579 nodes.push_back(new Node(coords3+14));
580 pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
581 pol->getBarycenter(tmp,tmp2);
583 QuadraticPlanarPrecision::setPrecision(1e-14);
586 void QuadraticPlanarInterpTest::check1DInterpLin()
588 QuadraticPlanarPrecision::setPrecision(1e-9);
589 const int NB_OF_CELL_AXIAL_1=30;
590 static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]=
591 { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500,
592 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500,
593 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356,
595 std::vector<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
597 const int NB_OF_CELL_AXIAL_2=46;
598 static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]=
599 { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356
600 , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15
601 , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700
602 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550
603 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050};
604 std::vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
605 std::map<int,std::map<int,double> > m;
606 Edge::Interpolate1DLin(zLev1,zLev2,m);
607 CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
609 for(int i=0;i<30;i++)
611 CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size());
612 CPPUNIT_ASSERT(m[i][8+i] > 0.15);
615 CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12);
618 const int NB_OF_CELL_AXIAL_3=13;
619 static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={
620 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30,
621 0.35,0.40,0.45,0.50,0.55,0.60 };
622 std::vector<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
623 Edge::Interpolate1DLin(zLev3,zLev1,m);
624 CPPUNIT_ASSERT_EQUAL(13,(int)m.size());
625 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12);
626 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12);
627 for(int i=0;i<11;i++)
629 CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size());
630 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12);
632 QuadraticPlanarPrecision::setPrecision(1e-14);
636 * This test looks if intersectors are in coherency.
638 void QuadraticPlanarInterpTest::checkEpsilonCoherency1()
640 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12);
642 const double pol1[]={
643 -2.1083388455000001, 1.2172499999999999,
644 -1.7320508075000001, 1,
645 -1.9201948265, 1.108625
648 const double pol2[]={
650 -1.9381648534, 1.1189999998,
651 -2.1617419990000002, 0.57923702298000002,
652 -1.9381648534, 1.1189999998,
653 -1.9909924031999999, 1.1494999999,
654 -1.9645786283, 1.1342499998
657 Node *n1=new Node(pol1[0],pol1[1]);
658 Node *n2=new Node(pol1[2],pol1[3]);
661 Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef();
662 n1=new Node(pol2[0],pol2[1]);
663 n2=new Node(pol2[4],pol2[5]);
664 n3=new Node(pol2[2],pol2[3]);
665 Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef();
671 * Tests to avoid regressions : Basic one.
673 void QuadraticPlanarInterpTest::checkNonRegression1()
675 const double coords1[]=
677 16.1732057215, -25.110999999800001,
678 16.02555485246479, -25.340997988918762
680 Node *nS1=new Node(coords1);
681 Node *nE1=new Node(coords1+2);
682 const double radius1=2.902;
683 const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692;
684 const double center1[2]={13.66, -23.66};
685 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
687 const double coords2[]=
689 16.041579804000001, -25.350249998999999,
690 16.367740958999999, -24.132999999999999
692 Node *nS2=new Node(coords2);
693 Node *nE2=new Node(coords2+2);
694 const double radius2=2.4345;
695 const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041;
696 const double center2[]={ 13.933240960547204, -24.132999998525658 };
697 EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2);
699 QuadraticPolygon c1,c2;
700 e1->intersectWith(e2,merge,c1,c2);
701 CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size());
702 CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5);
704 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
707 void QuadraticPlanarInterpTest::checkNonRegression2()
709 QuadraticPlanarPrecision::setPrecision(1e-12);
712 15.141499999899999, -26.226033271399999,
713 16.226033271199999, -25.141499999800001,
714 16.1732057215, -25.110999999800001,
715 15.110999999899999, -26.1732057217,
716 15.755157392699999, -25.755157392499999,
717 16.199619496299999, -25.126249999799999,
718 15.7120238788, -25.712023879099998,
719 15.126249999899999, -26.199619496499999
723 15.933240959000001, -24.132999999999999,
724 15.665291765999999, -25.132999998999999,
725 16.041579804000001, -25.350249998999999,
726 16.367740958999999, -24.132999999999999,
727 15.865092611, -24.650638091000001,
728 15.853435785, -25.241624998999999,
729 16.284787383000001, -24.763094964,
730 16.150490958999999, -24.132999999999999
732 std::vector<Node *> nodes1;
733 nodes1.push_back(new Node(coords1));
734 nodes1.push_back(new Node(coords1+2));
735 nodes1.push_back(new Node(coords1+4));
736 nodes1.push_back(new Node(coords1+6));
737 nodes1.push_back(new Node(coords1+8));
738 nodes1.push_back(new Node(coords1+10));
739 nodes1.push_back(new Node(coords1+12));
740 nodes1.push_back(new Node(coords1+14));
741 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
742 std::vector<Node *> nodes2;
743 nodes2.push_back(new Node(coords2));
744 nodes2.push_back(new Node(coords2+2));
745 nodes2.push_back(new Node(coords2+4));
746 nodes2.push_back(new Node(coords2+6));
747 nodes2.push_back(new Node(coords2+8));
748 nodes2.push_back(new Node(coords2+10));
749 nodes2.push_back(new Node(coords2+12));
750 nodes2.push_back(new Node(coords2+14));
751 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
752 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
753 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
754 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7);
756 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7);
762 * Tests to avoid regressions : Basic one.
764 void QuadraticPlanarInterpTest::checkNonRegression3()
766 const double coords1[]=
768 10.962340811000001, -22.417749999000002,
769 12.217990959, -21.162099852000001
771 Node *nS1=new Node(coords1);
772 Node *nE1=new Node(coords1+2);
773 const double radius1=3.4304999897666599;
774 const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204;
775 const double center1[2]={13.933240950441375, -24.132999992807399};
776 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
778 const double coords2[]=
780 11.1467942784, -22.2090000002,
781 11.0939667286, -22.178500000099998
783 Node *nS2=new Node(coords2);
784 Node *nE2=new Node(coords2+2);
785 EdgeLin *e2=new EdgeLin(nS2,nE2);
787 QuadraticPolygon c1,c2;
788 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2));
789 CPPUNIT_ASSERT_EQUAL(2,c1.size());
790 CPPUNIT_ASSERT_EQUAL(2,c2.size());
791 ElementaryEdge *tmp1=dynamic_cast<ElementaryEdge *>(c1.front()); CPPUNIT_ASSERT(tmp1);
792 EdgeArcCircle *tmp2=dynamic_cast<EdgeArcCircle *>(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2);
793 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14);
795 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
798 void QuadraticPlanarInterpTest::checkNonRegression4()
800 QuadraticPlanarPrecision::setPrecision(1e-12);
803 10.962340811000001, -22.417749999000002,
804 12.217990959, -21.162099852000001,
805 12.051990958999999, -20.874579418,
806 10.674820377, -22.251749999000001,
807 11.507511146000001, -21.707270185999999,
808 12.134990959, -21.018339635,
809 11.272751694, -21.472510735,
810 10.818580594, -22.334749999
815 10.758000000199999, -23.66,
816 11.1467942784, -22.2090000002,
817 11.0939667286, -22.178500000099998,
818 10.696999999999999, -23.66,
819 10.856883252299999, -22.908907131159999,
820 11.1203805035, -22.1937500001,
821 10.797961776699999, -22.893119169449999,
822 10.727500000099999, -23.66
824 std::vector<Node *> nodes1;
825 nodes1.push_back(new Node(coords1));
826 nodes1.push_back(new Node(coords1+2));
827 nodes1.push_back(new Node(coords1+4));
828 nodes1.push_back(new Node(coords1+6));
829 nodes1.push_back(new Node(coords1+8));
830 nodes1.push_back(new Node(coords1+10));
831 nodes1.push_back(new Node(coords1+12));
832 nodes1.push_back(new Node(coords1+14));
833 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
834 std::vector<Node *> nodes2;
835 nodes2.push_back(new Node(coords2));
836 nodes2.push_back(new Node(coords2+2));
837 nodes2.push_back(new Node(coords2+4));
838 nodes2.push_back(new Node(coords2+6));
839 nodes2.push_back(new Node(coords2+8));
840 nodes2.push_back(new Node(coords2+10));
841 nodes2.push_back(new Node(coords2+12));
842 nodes2.push_back(new Node(coords2+14));
843 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
844 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
845 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
846 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
848 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
853 void QuadraticPlanarInterpTest::checkNonRegression5()
855 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12);
858 -1.7320508075000001, 1,
859 -1, 1.7320508075000001 ,
860 -1.2172499999999999, 2.1083388455000001,
861 -2.1083388455000001, 1.2172499999999999,
862 -1.4142135623000001, 1.4142135623000001,
863 -1.108625, 1.9201948265,
864 -1.7214514588000001, 1.7214514588000001,
865 -1.9201948265, 1.108625};
870 -1.9381648534, 1.1189999998,
871 -1.9909924031999999, 1.1494999999,
872 -2.2989999998999999, 0,
873 -2.1617419990000002, 0.57923702298000002,
874 -1.9645786283, 1.1342499998,
875 -2.2206634745999998, 0.59502498461999997,
876 -2.2684999997999999, 0};
877 //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941}
878 //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}}
879 std::vector<Node *> nodes1;
880 nodes1.push_back(new Node(coords1));
881 nodes1.push_back(new Node(coords1+2));
882 nodes1.push_back(new Node(coords1+4));
883 nodes1.push_back(new Node(coords1+6));
884 nodes1.push_back(new Node(coords1+8));
885 nodes1.push_back(new Node(coords1+10));
886 nodes1.push_back(new Node(coords1+12));
887 nodes1.push_back(new Node(coords1+14));
888 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
889 std::vector<Node *> nodes2;
890 nodes2.push_back(new Node(coords2));
891 nodes2.push_back(new Node(coords2+2));
892 nodes2.push_back(new Node(coords2+4));
893 nodes2.push_back(new Node(coords2+6));
894 nodes2.push_back(new Node(coords2+8));
895 nodes2.push_back(new Node(coords2+10));
896 nodes2.push_back(new Node(coords2+12));
897 nodes2.push_back(new Node(coords2+14));
898 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
899 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
900 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
901 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
903 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
908 void QuadraticPlanarInterpTest::checkNonRegression6()
910 QuadraticPlanarPrecision::setPrecision(1e-12);
913 10.962340811000001, -22.417749999000002,
914 12.217990959, -21.162099852000001,
915 12.051990958999999, -20.874579418,
916 10.674820377, -22.251749999000001,
917 11.507511146000001, -21.707270185999999,
918 12.134990959, -21.018339635,
919 11.272751694, -21.472510735,
920 10.818580594, -22.334749999
924 10.859273844199999, -22.043000000100001,
925 10.806446294799999, -22.012500000199999,
926 10.3650000002, -23.66,
927 10.536195877799999, -22.822979208099998,
928 10.832860069499999, -22.027750000200001,
929 10.477274402499999, -22.80719124657,
930 10.3955000001, -23.66};
931 std::vector<Node *> nodes1;
932 nodes1.push_back(new Node(coords1));
933 nodes1.push_back(new Node(coords1+2));
934 nodes1.push_back(new Node(coords1+4));
935 nodes1.push_back(new Node(coords1+6));
936 nodes1.push_back(new Node(coords1+8));
937 nodes1.push_back(new Node(coords1+10));
938 nodes1.push_back(new Node(coords1+12));
939 nodes1.push_back(new Node(coords1+14));
940 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
941 std::vector<Node *> nodes2;
942 nodes2.push_back(new Node(coords2));
943 nodes2.push_back(new Node(coords2+2));
944 nodes2.push_back(new Node(coords2+4));
945 nodes2.push_back(new Node(coords2+6));
946 nodes2.push_back(new Node(coords2+8));
947 nodes2.push_back(new Node(coords2+10));
948 nodes2.push_back(new Node(coords2+12));
949 nodes2.push_back(new Node(coords2+14));
950 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
951 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
952 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
953 CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7);
959 void QuadraticPlanarInterpTest::checkNonRegression7()
961 QuadraticPlanarPrecision::setPrecision(1e-5);
965 -1.7320508075000001, 1,
966 -2.1083388455000001, 1.2172499999999999,
967 -2.4344999999999999, 0,
968 -1.9318516525603098, 0.51763809027157182,
969 -1.9201948265, 1.108625,
970 -2.3515464241024469, 0.63009496529570408,
971 -2.2172499999999999, 0
974 { -2.3369999999000002, 0,
975 -2.0239013684999998, 1.1684999999000001,
976 -2.1927763221999998, 1.2659999998,
978 -2.2573686559260442, 0.60486010843437632,
979 -2.1083388453499996, 1.2172499998499999,
980 -2.445724191994314, 0.65532982205982326,
981 -2.4344999998499999, 0 };
982 std::vector<Node *> nodes1;
983 nodes1.push_back(new Node(coords1));
984 nodes1.push_back(new Node(coords1+2));
985 nodes1.push_back(new Node(coords1+4));
986 nodes1.push_back(new Node(coords1+6));
987 nodes1.push_back(new Node(coords1+8));
988 nodes1.push_back(new Node(coords1+10));
989 nodes1.push_back(new Node(coords1+12));
990 nodes1.push_back(new Node(coords1+14));
991 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
992 std::vector<Node *> nodes2;
993 nodes2.push_back(new Node(coords2));
994 nodes2.push_back(new Node(coords2+2));
995 nodes2.push_back(new Node(coords2+4));
996 nodes2.push_back(new Node(coords2+6));
997 nodes2.push_back(new Node(coords2+8));
998 nodes2.push_back(new Node(coords2+10));
999 nodes2.push_back(new Node(coords2+12));
1000 nodes2.push_back(new Node(coords2+14));
1001 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1002 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1003 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1004 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6);
1010 void QuadraticPlanarInterpTest::checkNonRegression8()
1012 QuadraticPlanarPrecision::setPrecision(1e-3);
1015 -13.933240959000001, -28.559499999,
1016 -16.146490959000001, -27.966461449000001,
1017 -16.383240958999998, -28.376524478,
1018 -13.933240959000001, -29.032999999000001,
1019 -15.078903461873765, -28.408670669106311,
1020 -16.264865958999998, -28.1714929635,
1021 -15.201454280317435, -28.866036547696734,
1022 -13.933240959000001, -28.796249999 };
1024 { -16.382999999950002, -28.376524478457149,
1025 -13.933000000014729, -29.03299999982551,
1026 -13.93300000006697, -28.793999999915993,
1027 -16.263500000000001, -28.169544407039268,
1028 -15.201213320921273, -28.866036548734634,
1029 -13.933000000040851, -28.913499999870751,
1030 -15.139355569325469, -28.635180276305853,
1031 -16.323249999975001, -28.273034442748209 };
1032 std::vector<Node *> nodes1;
1033 nodes1.push_back(new Node(coords1));
1034 nodes1.push_back(new Node(coords1+2));
1035 nodes1.push_back(new Node(coords1+4));
1036 nodes1.push_back(new Node(coords1+6));
1037 nodes1.push_back(new Node(coords1+8));
1038 nodes1.push_back(new Node(coords1+10));
1039 nodes1.push_back(new Node(coords1+12));
1040 nodes1.push_back(new Node(coords1+14));
1041 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1042 std::vector<Node *> nodes2;
1043 nodes2.push_back(new Node(coords2));
1044 nodes2.push_back(new Node(coords2+2));
1045 nodes2.push_back(new Node(coords2+4));
1046 nodes2.push_back(new Node(coords2+6));
1047 nodes2.push_back(new Node(coords2+8));
1048 nodes2.push_back(new Node(coords2+10));
1049 nodes2.push_back(new Node(coords2+12));
1050 nodes2.push_back(new Node(coords2+14));
1051 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1052 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1053 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1054 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6);
1060 void QuadraticPlanarInterpTest::checkNonRegression9()
1062 QuadraticPlanarPrecision::setPrecision(1e-8);
1065 -0.04476229252902969, -0.085118027765365603,
1066 -0.046952683430894329, -0.085704941238358354,
1067 -0.046952683430894329, -0.088063823748058725,
1068 -0.043582851274179504, -0.087160879944491371,
1069 -0.045818853668170414, -0.085555669718918592,
1070 -0.046952683430894329, -0.086884382493208526,
1071 -0.045208329947517549, -0.087834175256748526,
1072 -0.044172571901604597, -0.086139453854928494 };
1075 { -0.05065868681155701, -0.087744551996665671,
1076 -0.046951871439587615, -0.088737790182236015,
1077 -0.046951871439683469, -0.088063823751059062,
1078 -0.050321703596054014, -0.087160879946116557,
1079 -0.0488706602695924, -0.08848517684025306,
1080 -0.046951871439635542, -0.088400806966647538,
1081 -0.048696224921445964, -0.087834175258503858,
1082 -0.050490195203805516, -0.087452715971391121};
1084 std::vector<Node *> nodes1;
1085 nodes1.push_back(new Node(coords1));
1086 nodes1.push_back(new Node(coords1+2));
1087 nodes1.push_back(new Node(coords1+4));
1088 nodes1.push_back(new Node(coords1+6));
1089 nodes1.push_back(new Node(coords1+8));
1090 nodes1.push_back(new Node(coords1+10));
1091 nodes1.push_back(new Node(coords1+12));
1092 nodes1.push_back(new Node(coords1+14));
1093 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1094 std::vector<Node *> nodes2;
1095 nodes2.push_back(new Node(coords2));
1096 nodes2.push_back(new Node(coords2+2));
1097 nodes2.push_back(new Node(coords2+4));
1098 nodes2.push_back(new Node(coords2+6));
1099 nodes2.push_back(new Node(coords2+8));
1100 nodes2.push_back(new Node(coords2+10));
1101 nodes2.push_back(new Node(coords2+12));
1102 nodes2.push_back(new Node(coords2+14));
1103 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1104 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1105 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
1110 void QuadraticPlanarInterpTest::checkNonRegression10()
1112 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1114 { -0.002269581957210453, -0.09851030343724453,
1115 -0.004268022334182935, -0.1059685844580936,
1116 -0.002777851483521377, -0.1023709937816271};
1118 { -0.004114727297178323, -0.1049870239624718,
1119 -0.003544545103522544, -0.1053162188055505};
1120 Node *n1_1=new Node(coords1);
1121 Node *n2_1=new Node(coords1+2);
1122 Node *n3_1=new Node(coords1+4);
1123 Node *n1_2=new Node(coords2);
1124 Node *n2_2=new Node(coords2+2);
1125 EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1);
1126 EdgeLin *e2=new EdgeLin(n1_2,n2_2);
1128 ComposedEdge *c1=new ComposedEdge;
1129 ComposedEdge *c2=new ComposedEdge;
1130 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2));
1131 CPPUNIT_ASSERT_EQUAL(2,c1->size());
1132 CPPUNIT_ASSERT_EQUAL(2,c2->size());
1133 ComposedEdge::Delete(c1); ComposedEdge::Delete(c2);
1134 n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef();
1135 n1_2->decrRef(); n2_2->decrRef();
1136 e1->decrRef(); e2->decrRef();
1139 void QuadraticPlanarInterpTest::checkNonRegression11()
1141 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1143 { -0.002269581957210453, -0.09851030343724453,
1144 -0.004268022334182935, -0.1059685844580936,
1145 -0.002886178753789801, -0.1067663922211958,
1146 -0.0006739664310059821, -0.09851030343724453,
1147 -0.002777851483521377, -0.1023709937816271,
1148 -0.003577100543986368, -0.1063674883396447,
1149 -0.001236605237717319, -0.1027839694676665,
1150 -0.001471774194108217, -0.09851030343724453};
1152 { -0.003544545103522544, -0.1053162188055505,
1153 -0.001941023322604723, -0.09851030343724451,
1154 -0.002598140593501099, -0.09851030343724451,
1155 -0.004114727297178323, -0.1049870239624718,
1156 -0.002347317802266182, -0.1020064358043286,
1157 -0.002269581958052911, -0.09851030343724451,
1158 -0.002982346712452072, -0.1018362598405457,
1159 -0.003829636200350435, -0.1051516213840111};
1161 std::vector<Node *> nodes1;
1162 nodes1.push_back(new Node(coords1));
1163 nodes1.push_back(new Node(coords1+2));
1164 nodes1.push_back(new Node(coords1+4));
1165 nodes1.push_back(new Node(coords1+6));
1166 nodes1.push_back(new Node(coords1+8));
1167 nodes1.push_back(new Node(coords1+10));
1168 nodes1.push_back(new Node(coords1+12));
1169 nodes1.push_back(new Node(coords1+14));
1170 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1171 std::vector<Node *> nodes2;
1172 nodes2.push_back(new Node(coords2));
1173 nodes2.push_back(new Node(coords2+2));
1174 nodes2.push_back(new Node(coords2+4));
1175 nodes2.push_back(new Node(coords2+6));
1176 nodes2.push_back(new Node(coords2+8));
1177 nodes2.push_back(new Node(coords2+10));
1178 nodes2.push_back(new Node(coords2+12));
1179 nodes2.push_back(new Node(coords2+14));
1180 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1181 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1182 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1183 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11);
1189 void QuadraticPlanarInterpTest::checkNonRegression12()
1191 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1193 { -0.5032251558760915, -0.8716087994449138,
1194 -0.4695268343089433, -0.8806382374805872,
1195 -0.4695268343089433, -0.8570494123835835,
1196 -0.4914307433275896, -0.8511802776536561,
1197 -0.4869703691141082, -0.8783417525751493,
1198 -0.4695268343089433, -0.8688438249320853,
1199 -0.480865131947653, -0.8555566971861125,
1200 -0.4973279496018406, -0.8613945385492849};
1203 { -0.5065868681155701, -0.8774455199666568,
1204 -0.4695187143958762, -0.8873779018223601,
1205 -0.4695187143968347, -0.8806382375105907,
1206 -0.5032170359605401, -0.8716087994611657,
1207 -0.488706602695924, -0.8848517684025307,
1208 -0.4695187143963554, -0.8840080696664754,
1209 -0.4869622492144596, -0.8783417525850385,
1210 -0.5049019520380551, -0.8745271597139112};
1212 std::vector<Node *> nodes1;
1213 nodes1.push_back(new Node(coords1));
1214 nodes1.push_back(new Node(coords1+2));
1215 nodes1.push_back(new Node(coords1+4));
1216 nodes1.push_back(new Node(coords1+6));
1217 nodes1.push_back(new Node(coords1+8));
1218 nodes1.push_back(new Node(coords1+10));
1219 nodes1.push_back(new Node(coords1+12));
1220 nodes1.push_back(new Node(coords1+14));
1221 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1222 std::vector<Node *> nodes2;
1223 nodes2.push_back(new Node(coords2));
1224 nodes2.push_back(new Node(coords2+2));
1225 nodes2.push_back(new Node(coords2+4));
1226 nodes2.push_back(new Node(coords2+6));
1227 nodes2.push_back(new Node(coords2+8));
1228 nodes2.push_back(new Node(coords2+10));
1229 nodes2.push_back(new Node(coords2+12));
1230 nodes2.push_back(new Node(coords2+14));
1231 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1232 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1233 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1234 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6);
1240 void QuadraticPlanarInterpTest::checkNonRegression13()
1242 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1244 double coords_1[194]={
1245 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375,
1246 -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1247 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109,
1248 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108,
1249 -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109,
1250 -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108,
1251 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125,
1252 -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125,
1253 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218,
1254 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216,
1255 -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217,
1256 -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216,
1257 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1258 -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1259 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933,
1260 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932,
1261 -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932,
1262 -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932,
1263 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1264 -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1265 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244,
1266 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243,
1267 -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243,
1268 -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243,
1269 2.249646661664983, 0.9318341578089936 };
1272 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15,
1273 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7,
1274 22, 8, 0, 23, 9, 8, 24, 1 };
1277 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15,
1278 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18,
1279 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9,
1280 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36,
1281 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43,
1282 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46,
1283 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61,
1284 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64,
1285 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71,
1286 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 };
1288 double coords_2[20]={
1289 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611,
1290 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611,
1291 0.5922441860137611, 0, -0.5922441860137611, 0 };
1294 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1296 double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2;
1298 const int *work1=tab6_1;
1299 for(int i=0;i<8;i++,work1+=6)
1301 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6);
1302 const int *work2=tab8_2;
1303 for(int j=0;j<2;j++,work2+=8)
1305 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1306 //std::vector<int> tmp;
1307 //pol1->intersectForPoint(*pol2,tmp);
1308 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1309 //pol1->intersectMySelfWith(*pol2);
1315 for(int i=0;i<24;i++,work1+=8)
1317 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8);
1318 const int *work2=tab8_2;
1319 for(int j=0;j<2;j++,work2+=8)
1322 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1323 //std::vector<int> tmp;
1324 //pol1->intersectForPoint(*pol2,tmp);
1325 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1333 Some overlapping cases for intersectForPoint.
1335 void QuadraticPlanarInterpTest::checkNonRegression14()
1337 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1340 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1341 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1342 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1343 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1344 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1345 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1346 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1347 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1352 8,9,10,11,2,14,12,13,
1353 9,15,16,10,5,17,18,14,
1354 9,15,16,10,34,17,35,14,
1355 19,20,21,22,23,24,25,26,
1356 27,28,29,30,31,32,2,33
1358 QuadraticPolygon *pol1,*pol2;
1359 std::vector<int> goalOfTest;
1361 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1363 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1364 pol1->intersectForPoint(*pol2,goalOfTest);
1365 const int res1[4]={0,1,0,0};
1366 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1367 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1));
1370 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1371 pol1->intersectForPoint(*pol2,goalOfTest);
1372 const int res2[4]={0,2,0,0};
1373 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1374 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2));
1377 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8);
1378 pol1->intersectForPoint(*pol2,goalOfTest);
1379 const int res2Bis[4]={0,2,0,0};
1380 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1381 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis));
1384 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8);
1385 pol1->intersectForPoint(*pol2,goalOfTest);
1386 const int res3[4]={0,3,0,0};
1387 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1388 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3));
1391 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8);
1392 pol1->intersectForPoint(*pol2,goalOfTest);
1393 const int res4[4]={0,4,0,0};
1394 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1395 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4));
1402 * This test is one of the most complicated intersection configuration.
1404 void QuadraticPlanarInterpTest::checkNonRegression15()
1406 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1409 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1410 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1411 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1412 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1413 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1414 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1415 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1416 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1422 9,15,16,10,7,17,5,14,
1423 9,10,16,15,14,5,17,7
1426 const double RefLgth=3.88995883524451;
1427 const double RefArea=0.383185168001075;
1429 QuadraticPolygon *pol1,*pol2;
1430 //pol1 and pol2 in same orientation
1431 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1432 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1433 std::vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
1434 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1435 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1436 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1437 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1439 //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2
1440 res=pol2->intersectMySelfWith(*pol1);
1441 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1442 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1443 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1444 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1447 //pol1 and pol2 in opposite orientation
1448 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1449 res=pol1->intersectMySelfWith(*pol2);
1450 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1451 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1452 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1453 CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12);
1455 //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2
1456 res=pol2->intersectMySelfWith(*pol1);
1457 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1458 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1459 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1460 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1470 DoubleEqual(double eps):_eps(eps) { }
1471 bool operator()(double x, double y) { return fabs(x-y)<_eps; }
1477 * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ...
1479 void QuadraticPlanarInterpTest::checkNonRegression16()
1481 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1482 double coords1[194]={
1483 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1484 -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375,
1485 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108,
1486 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109,
1487 -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108,
1488 -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109,
1489 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125,
1490 -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125,
1491 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216,
1492 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217,
1493 -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216,
1494 -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218,
1495 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1496 -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1497 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932,
1498 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932,
1499 -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932,
1500 -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933,
1501 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1502 -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1503 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243,
1504 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243,
1505 -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243,
1506 -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244,
1507 2.249646661664984, -0.9318341578089931, };
1510 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13,
1511 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18,
1512 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23,
1513 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36,
1514 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41,
1515 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46,
1516 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59,
1517 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64,
1518 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69,
1519 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, };
1521 double coords2[20]={
1522 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435,
1523 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925,
1524 2.56375, 0, -2.56375, 0, };
1526 int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1528 QuadraticPolygon *pol1,*pol2;
1529 //pol1 and pol2 in same orientation
1530 std::vector<double> test1,test2;
1531 for(int ii=0;ii<24;ii++)
1533 pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
1534 for(int jj=0;jj<2;jj++)
1536 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
1538 std::vector<double> v1,v2;
1539 pol1->initLocations();
1540 pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
1549 const double test1_res[4]={0.,1.9124445278727873,0.,0.};
1550 CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10)));
1551 const double test2_res[4]={0.,0.,0.,0.};
1552 CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10)));
1556 * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation.
1558 void QuadraticPlanarInterpTest::checkNonRegression17()
1560 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1562 -1., 0., 1., 0. , 1.5, 0., -1.5, 0.,
1563 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.};
1565 double coords2[16]={
1566 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444,
1567 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 };
1569 double coords3[16]={
1570 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0.,
1571 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. };
1574 0, 1, 2, 3, 4, 5, 6, 7 };
1575 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1576 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1577 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1580 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1581 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1582 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1585 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1586 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1587 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1590 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1591 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1592 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1597 void QuadraticPlanarInterpTest::checkNormalize()
1599 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14);
1600 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.);
1601 Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.);
1602 Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.);
1603 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1604 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1605 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
1607 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
1608 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1609 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1610 double area1Start=pol1.getArea();
1612 double fact=pol1.normalize(&pol2,xb,yb);
1613 double area1End=pol1.getArea();
1614 CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14);
1615 CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14);
1616 double area=pol1.intersectWith(pol2);
1617 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14);
1619 n1=new Node(0.,0.); n4=new Node(0.,-3.);
1620 n2=new Node(10.,0.); n5=new Node(10.,-3.);
1621 n3=new Node(5.,10.); n6=new Node(5.,7.);
1622 e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5);
1623 e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6);
1624 e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4);
1625 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
1626 QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4);
1627 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1628 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14);
1629 // Ok testing EdgeArcCircle update.
1630 double center[2]={5.,5.};
1632 EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.);
1633 const Bounds& b=e1->getBounds();
1635 fact2=b.getCaracteristicDim();
1636 b.getBarycenter(x,y);
1637 CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13);
1638 CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10);
1639 e1->getStartNode()->applySimilarity(x,y,fact2);
1640 e1->getEndNode()->applySimilarity(x,y,fact2);
1641 e1->applySimilarity(x,y,fact2);
1642 CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13);
1643 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14);
1644 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13);
1648 void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
1650 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14);
1651 Node *n0=new Node(0.,0.); Node *n4=new Node(0.5,0.25);
1652 Node *n1=new Node(0.,0.5); Node *n5=new Node(0.3,1.2);
1653 Node *n2=new Node(1.,0.5); Node *n6=new Node(1.1,1.3);
1654 Node *n3=new Node(1.,0.); Node *n7=new Node(-0.1,0.9);
1655 EdgeLin *e0_1=new EdgeLin(n0,n1);
1656 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1657 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1658 EdgeLin *e3_0=new EdgeLin(n3,n0); EdgeLin *e6_4=new EdgeLin(n6,n4);
1659 EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_5=new EdgeLin(n7,n5);
1660 QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0);
1661 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1662 pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7);
1663 n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
1664 pol1.dumpInXfigFileWithOther(pol2,"tony.fig");
1668 * Arc/arc intersection was buggy: a point was detected OFF when used in a linear segment, but
1669 * detected ON when used in an (almost flat) arc of circle.
1671 void QuadraticPlanarInterpTest::checkArcArcIntersection1()
1674 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(eps);
1676 Node *n0=new Node(6.37533,38.8928); Node *n3=new Node(6.29194,39.2789);
1677 Node *n1=new Node(6.13158,38.8308); Node *n4=new Node(6.31919,38.7607);
1678 Node *n2=new Node(6.25346,38.8618); Node *n5=new Node(6.38778,39.0241);
1680 Node *n6=new Node(6.2534549999999998, 38.861800000000002); // to have a linear edge e1
1682 //EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n6, true); // to have a linear edge e1
1683 EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n1, true);
1684 EdgeArcCircle *e2=new EdgeArcCircle(n3, n5, n4, true);
1687 QuadraticPolygon c1,c2;
1688 e1->intersectWith(e2,merge,c1,c2);
1689 CPPUNIT_ASSERT_EQUAL(2,c1.size());
1690 CPPUNIT_ASSERT_EQUAL(2,c2.size());
1692 n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1693 e1->decrRef(); e2->decrRef();