1 // Copyright (C) 2007-2016 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-7);
589 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-9);
590 const int NB_OF_CELL_AXIAL_1=30;
591 static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]=
592 { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500,
593 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500,
594 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356,
596 std::vector<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
598 const int NB_OF_CELL_AXIAL_2=46;
599 static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]=
600 { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356
601 , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15
602 , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700
603 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550
604 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050};
605 std::vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
606 std::map<int,std::map<int,double> > m;
607 Edge::Interpolate1DLin(zLev1,zLev2,m);
608 CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
610 for(int i=0;i<30;i++)
612 CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size());
613 CPPUNIT_ASSERT(m[i][8+i] > 0.15);
616 CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12);
619 const int NB_OF_CELL_AXIAL_3=13;
620 static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={
621 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30,
622 0.35,0.40,0.45,0.50,0.55,0.60 };
623 std::vector<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
624 Edge::Interpolate1DLin(zLev3,zLev1,m);
625 CPPUNIT_ASSERT_EQUAL(13,(int)m.size());
626 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12);
627 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12);
628 for(int i=0;i<11;i++)
630 CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size());
631 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12);
633 QuadraticPlanarPrecision::setPrecision(1e-14);
637 * This test looks if intersectors are in coherency.
639 void QuadraticPlanarInterpTest::checkEpsilonCoherency1()
641 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12);
642 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-5);
644 const double pol1[]={
645 -2.1083388455000001, 1.2172499999999999,
646 -1.7320508075000001, 1,
647 -1.9201948265, 1.108625
650 const double pol2[]={
652 -1.9381648534, 1.1189999998,
653 -2.1617419990000002, 0.57923702298000002,
654 -1.9381648534, 1.1189999998,
655 -1.9909924031999999, 1.1494999999,
656 -1.9645786283, 1.1342499998
659 Node *n1=new Node(pol1[0],pol1[1]);
660 Node *n2=new Node(pol1[2],pol1[3]);
663 Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef();
664 n1=new Node(pol2[0],pol2[1]);
665 n2=new Node(pol2[4],pol2[5]);
666 n3=new Node(pol2[2],pol2[3]);
667 Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef();
673 * Tests to avoid regressions : Basic one.
675 void QuadraticPlanarInterpTest::checkNonRegression1()
677 const double coords1[]=
679 16.1732057215, -25.110999999800001,
680 16.02555485246479, -25.340997988918762
682 Node *nS1=new Node(coords1);
683 Node *nE1=new Node(coords1+2);
684 const double radius1=2.902;
685 const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692;
686 const double center1[2]={13.66, -23.66};
687 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
689 const double coords2[]=
691 16.041579804000001, -25.350249998999999,
692 16.367740958999999, -24.132999999999999
694 Node *nS2=new Node(coords2);
695 Node *nE2=new Node(coords2+2);
696 const double radius2=2.4345;
697 const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041;
698 const double center2[]={ 13.933240960547204, -24.132999998525658 };
699 EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2);
701 QuadraticPolygon c1,c2;
702 e1->intersectWith(e2,merge,c1,c2);
703 CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size());
704 CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5);
706 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
709 void QuadraticPlanarInterpTest::checkNonRegression2()
711 QuadraticPlanarPrecision::setPrecision(1e-12);
712 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-9);
715 15.141499999899999, -26.226033271399999,
716 16.226033271199999, -25.141499999800001,
717 16.1732057215, -25.110999999800001,
718 15.110999999899999, -26.1732057217,
719 15.755157392699999, -25.755157392499999,
720 16.199619496299999, -25.126249999799999,
721 15.7120238788, -25.712023879099998,
722 15.126249999899999, -26.199619496499999
726 15.933240959000001, -24.132999999999999,
727 15.665291765999999, -25.132999998999999,
728 16.041579804000001, -25.350249998999999,
729 16.367740958999999, -24.132999999999999,
730 15.865092611, -24.650638091000001,
731 15.853435785, -25.241624998999999,
732 16.284787383000001, -24.763094964,
733 16.150490958999999, -24.132999999999999
735 std::vector<Node *> nodes1;
736 nodes1.push_back(new Node(coords1));
737 nodes1.push_back(new Node(coords1+2));
738 nodes1.push_back(new Node(coords1+4));
739 nodes1.push_back(new Node(coords1+6));
740 nodes1.push_back(new Node(coords1+8));
741 nodes1.push_back(new Node(coords1+10));
742 nodes1.push_back(new Node(coords1+12));
743 nodes1.push_back(new Node(coords1+14));
744 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
745 std::vector<Node *> nodes2;
746 nodes2.push_back(new Node(coords2));
747 nodes2.push_back(new Node(coords2+2));
748 nodes2.push_back(new Node(coords2+4));
749 nodes2.push_back(new Node(coords2+6));
750 nodes2.push_back(new Node(coords2+8));
751 nodes2.push_back(new Node(coords2+10));
752 nodes2.push_back(new Node(coords2+12));
753 nodes2.push_back(new Node(coords2+14));
754 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
755 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
756 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
757 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7);
759 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7);
765 * Tests to avoid regressions : Basic one.
767 void QuadraticPlanarInterpTest::checkNonRegression3()
769 const double coords1[]=
771 10.962340811000001, -22.417749999000002,
772 12.217990959, -21.162099852000001
774 Node *nS1=new Node(coords1);
775 Node *nE1=new Node(coords1+2);
776 const double radius1=3.4304999897666599;
777 const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204;
778 const double center1[2]={13.933240950441375, -24.132999992807399};
779 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
781 const double coords2[]=
783 11.1467942784, -22.2090000002,
784 11.0939667286, -22.178500000099998
786 Node *nS2=new Node(coords2);
787 Node *nE2=new Node(coords2+2);
788 EdgeLin *e2=new EdgeLin(nS2,nE2);
790 QuadraticPolygon c1,c2;
791 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2));
792 CPPUNIT_ASSERT_EQUAL(2,c1.size());
793 CPPUNIT_ASSERT_EQUAL(2,c2.size());
794 ElementaryEdge *tmp1=dynamic_cast<ElementaryEdge *>(c1.front()); CPPUNIT_ASSERT(tmp1);
795 EdgeArcCircle *tmp2=dynamic_cast<EdgeArcCircle *>(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2);
796 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14);
798 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
801 void QuadraticPlanarInterpTest::checkNonRegression4()
803 QuadraticPlanarPrecision::setPrecision(1e-12);
804 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-9);
807 10.962340811000001, -22.417749999000002,
808 12.217990959, -21.162099852000001,
809 12.051990958999999, -20.874579418,
810 10.674820377, -22.251749999000001,
811 11.507511146000001, -21.707270185999999,
812 12.134990959, -21.018339635,
813 11.272751694, -21.472510735,
814 10.818580594, -22.334749999
819 10.758000000199999, -23.66,
820 11.1467942784, -22.2090000002,
821 11.0939667286, -22.178500000099998,
822 10.696999999999999, -23.66,
823 10.856883252299999, -22.908907131159999,
824 11.1203805035, -22.1937500001,
825 10.797961776699999, -22.893119169449999,
826 10.727500000099999, -23.66
828 std::vector<Node *> nodes1;
829 nodes1.push_back(new Node(coords1));
830 nodes1.push_back(new Node(coords1+2));
831 nodes1.push_back(new Node(coords1+4));
832 nodes1.push_back(new Node(coords1+6));
833 nodes1.push_back(new Node(coords1+8));
834 nodes1.push_back(new Node(coords1+10));
835 nodes1.push_back(new Node(coords1+12));
836 nodes1.push_back(new Node(coords1+14));
837 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
838 std::vector<Node *> nodes2;
839 nodes2.push_back(new Node(coords2));
840 nodes2.push_back(new Node(coords2+2));
841 nodes2.push_back(new Node(coords2+4));
842 nodes2.push_back(new Node(coords2+6));
843 nodes2.push_back(new Node(coords2+8));
844 nodes2.push_back(new Node(coords2+10));
845 nodes2.push_back(new Node(coords2+12));
846 nodes2.push_back(new Node(coords2+14));
847 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
848 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
849 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
850 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
852 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
857 void QuadraticPlanarInterpTest::checkNonRegression5()
859 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12);
860 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-5);
863 -1.7320508075000001, 1,
864 -1, 1.7320508075000001 ,
865 -1.2172499999999999, 2.1083388455000001,
866 -2.1083388455000001, 1.2172499999999999,
867 -1.4142135623000001, 1.4142135623000001,
868 -1.108625, 1.9201948265,
869 -1.7214514588000001, 1.7214514588000001,
870 -1.9201948265, 1.108625};
875 -1.9381648534, 1.1189999998,
876 -1.9909924031999999, 1.1494999999,
877 -2.2989999998999999, 0,
878 -2.1617419990000002, 0.57923702298000002,
879 -1.9645786283, 1.1342499998,
880 -2.2206634745999998, 0.59502498461999997,
881 -2.2684999997999999, 0};
882 //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941}
883 //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}}
884 std::vector<Node *> nodes1;
885 nodes1.push_back(new Node(coords1));
886 nodes1.push_back(new Node(coords1+2));
887 nodes1.push_back(new Node(coords1+4));
888 nodes1.push_back(new Node(coords1+6));
889 nodes1.push_back(new Node(coords1+8));
890 nodes1.push_back(new Node(coords1+10));
891 nodes1.push_back(new Node(coords1+12));
892 nodes1.push_back(new Node(coords1+14));
893 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
894 std::vector<Node *> nodes2;
895 nodes2.push_back(new Node(coords2));
896 nodes2.push_back(new Node(coords2+2));
897 nodes2.push_back(new Node(coords2+4));
898 nodes2.push_back(new Node(coords2+6));
899 nodes2.push_back(new Node(coords2+8));
900 nodes2.push_back(new Node(coords2+10));
901 nodes2.push_back(new Node(coords2+12));
902 nodes2.push_back(new Node(coords2+14));
903 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
904 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
905 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
906 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
908 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
913 void QuadraticPlanarInterpTest::checkNonRegression6()
915 QuadraticPlanarPrecision::setPrecision(1e-12);
916 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-5);
919 10.962340811000001, -22.417749999000002,
920 12.217990959, -21.162099852000001,
921 12.051990958999999, -20.874579418,
922 10.674820377, -22.251749999000001,
923 11.507511146000001, -21.707270185999999,
924 12.134990959, -21.018339635,
925 11.272751694, -21.472510735,
926 10.818580594, -22.334749999
930 10.859273844199999, -22.043000000100001,
931 10.806446294799999, -22.012500000199999,
932 10.3650000002, -23.66,
933 10.536195877799999, -22.822979208099998,
934 10.832860069499999, -22.027750000200001,
935 10.477274402499999, -22.80719124657,
936 10.3955000001, -23.66};
937 std::vector<Node *> nodes1;
938 nodes1.push_back(new Node(coords1));
939 nodes1.push_back(new Node(coords1+2));
940 nodes1.push_back(new Node(coords1+4));
941 nodes1.push_back(new Node(coords1+6));
942 nodes1.push_back(new Node(coords1+8));
943 nodes1.push_back(new Node(coords1+10));
944 nodes1.push_back(new Node(coords1+12));
945 nodes1.push_back(new Node(coords1+14));
946 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
947 std::vector<Node *> nodes2;
948 nodes2.push_back(new Node(coords2));
949 nodes2.push_back(new Node(coords2+2));
950 nodes2.push_back(new Node(coords2+4));
951 nodes2.push_back(new Node(coords2+6));
952 nodes2.push_back(new Node(coords2+8));
953 nodes2.push_back(new Node(coords2+10));
954 nodes2.push_back(new Node(coords2+12));
955 nodes2.push_back(new Node(coords2+14));
956 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
957 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
958 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
959 CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7);
965 void QuadraticPlanarInterpTest::checkNonRegression7()
967 QuadraticPlanarPrecision::setPrecision(1e-5);
968 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-5);
972 -1.7320508075000001, 1,
973 -2.1083388455000001, 1.2172499999999999,
974 -2.4344999999999999, 0,
975 -1.9318516525603098, 0.51763809027157182,
976 -1.9201948265, 1.108625,
977 -2.3515464241024469, 0.63009496529570408,
978 -2.2172499999999999, 0
981 { -2.3369999999000002, 0,
982 -2.0239013684999998, 1.1684999999000001,
983 -2.1927763221999998, 1.2659999998,
985 -2.2573686559260442, 0.60486010843437632,
986 -2.1083388453499996, 1.2172499998499999,
987 -2.445724191994314, 0.65532982205982326,
988 -2.4344999998499999, 0 };
989 std::vector<Node *> nodes1;
990 nodes1.push_back(new Node(coords1));
991 nodes1.push_back(new Node(coords1+2));
992 nodes1.push_back(new Node(coords1+4));
993 nodes1.push_back(new Node(coords1+6));
994 nodes1.push_back(new Node(coords1+8));
995 nodes1.push_back(new Node(coords1+10));
996 nodes1.push_back(new Node(coords1+12));
997 nodes1.push_back(new Node(coords1+14));
998 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
999 std::vector<Node *> nodes2;
1000 nodes2.push_back(new Node(coords2));
1001 nodes2.push_back(new Node(coords2+2));
1002 nodes2.push_back(new Node(coords2+4));
1003 nodes2.push_back(new Node(coords2+6));
1004 nodes2.push_back(new Node(coords2+8));
1005 nodes2.push_back(new Node(coords2+10));
1006 nodes2.push_back(new Node(coords2+12));
1007 nodes2.push_back(new Node(coords2+14));
1008 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1009 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1010 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1011 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6);
1017 void QuadraticPlanarInterpTest::checkNonRegression8()
1019 QuadraticPlanarPrecision::setPrecision(1e-3);
1020 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-5);
1023 -13.933240959000001, -28.559499999,
1024 -16.146490959000001, -27.966461449000001,
1025 -16.383240958999998, -28.376524478,
1026 -13.933240959000001, -29.032999999000001,
1027 -15.078903461873765, -28.408670669106311,
1028 -16.264865958999998, -28.1714929635,
1029 -15.201454280317435, -28.866036547696734,
1030 -13.933240959000001, -28.796249999 };
1032 { -16.382999999950002, -28.376524478457149,
1033 -13.933000000014729, -29.03299999982551,
1034 -13.93300000006697, -28.793999999915993,
1035 -16.263500000000001, -28.169544407039268,
1036 -15.201213320921273, -28.866036548734634,
1037 -13.933000000040851, -28.913499999870751,
1038 -15.139355569325469, -28.635180276305853,
1039 -16.323249999975001, -28.273034442748209 };
1040 std::vector<Node *> nodes1;
1041 nodes1.push_back(new Node(coords1));
1042 nodes1.push_back(new Node(coords1+2));
1043 nodes1.push_back(new Node(coords1+4));
1044 nodes1.push_back(new Node(coords1+6));
1045 nodes1.push_back(new Node(coords1+8));
1046 nodes1.push_back(new Node(coords1+10));
1047 nodes1.push_back(new Node(coords1+12));
1048 nodes1.push_back(new Node(coords1+14));
1049 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1050 std::vector<Node *> nodes2;
1051 nodes2.push_back(new Node(coords2));
1052 nodes2.push_back(new Node(coords2+2));
1053 nodes2.push_back(new Node(coords2+4));
1054 nodes2.push_back(new Node(coords2+6));
1055 nodes2.push_back(new Node(coords2+8));
1056 nodes2.push_back(new Node(coords2+10));
1057 nodes2.push_back(new Node(coords2+12));
1058 nodes2.push_back(new Node(coords2+14));
1059 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1060 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1061 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1062 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6);
1068 void QuadraticPlanarInterpTest::checkNonRegression9()
1070 QuadraticPlanarPrecision::setPrecision(1e-7);
1071 QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-8);
1074 -0.04476229252902969, -0.085118027765365603,
1075 -0.046952683430894329, -0.085704941238358354,
1076 -0.046952683430894329, -0.088063823748058725,
1077 -0.043582851274179504, -0.087160879944491371,
1078 -0.045818853668170414, -0.085555669718918592,
1079 -0.046952683430894329, -0.086884382493208526,
1080 -0.045208329947517549, -0.087834175256748526,
1081 -0.044172571901604597, -0.086139453854928494 };
1084 { -0.05065868681155701, -0.087744551996665671,
1085 -0.046951871439587615, -0.088737790182236015,
1086 -0.046951871439683469, -0.088063823751059062,
1087 -0.050321703596054014, -0.087160879946116557,
1088 -0.0488706602695924, -0.08848517684025306,
1089 -0.046951871439635542, -0.088400806966647538,
1090 -0.048696224921445964, -0.087834175258503858,
1091 -0.050490195203805516, -0.087452715971391121};
1093 std::vector<Node *> nodes1;
1094 nodes1.push_back(new Node(coords1));
1095 nodes1.push_back(new Node(coords1+2));
1096 nodes1.push_back(new Node(coords1+4));
1097 nodes1.push_back(new Node(coords1+6));
1098 nodes1.push_back(new Node(coords1+8));
1099 nodes1.push_back(new Node(coords1+10));
1100 nodes1.push_back(new Node(coords1+12));
1101 nodes1.push_back(new Node(coords1+14));
1102 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1103 std::vector<Node *> nodes2;
1104 nodes2.push_back(new Node(coords2));
1105 nodes2.push_back(new Node(coords2+2));
1106 nodes2.push_back(new Node(coords2+4));
1107 nodes2.push_back(new Node(coords2+6));
1108 nodes2.push_back(new Node(coords2+8));
1109 nodes2.push_back(new Node(coords2+10));
1110 nodes2.push_back(new Node(coords2+12));
1111 nodes2.push_back(new Node(coords2+14));
1112 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1113 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1114 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
1119 void QuadraticPlanarInterpTest::checkNonRegression10()
1121 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1122 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-7);
1124 { -0.002269581957210453, -0.09851030343724453,
1125 -0.004268022334182935, -0.1059685844580936,
1126 -0.002777851483521377, -0.1023709937816271};
1128 { -0.004114727297178323, -0.1049870239624718,
1129 -0.003544545103522544, -0.1053162188055505};
1130 Node *n1_1=new Node(coords1);
1131 Node *n2_1=new Node(coords1+2);
1132 Node *n3_1=new Node(coords1+4);
1133 Node *n1_2=new Node(coords2);
1134 Node *n2_2=new Node(coords2+2);
1135 EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1);
1136 EdgeLin *e2=new EdgeLin(n1_2,n2_2);
1138 ComposedEdge *c1=new ComposedEdge;
1139 ComposedEdge *c2=new ComposedEdge;
1140 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2));
1141 CPPUNIT_ASSERT_EQUAL(2,c1->size());
1142 CPPUNIT_ASSERT_EQUAL(2,c2->size());
1143 ComposedEdge::Delete(c1); ComposedEdge::Delete(c2);
1144 n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef();
1145 n1_2->decrRef(); n2_2->decrRef();
1146 e1->decrRef(); e2->decrRef();
1149 void QuadraticPlanarInterpTest::checkNonRegression11()
1151 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1152 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-7);
1154 { -0.002269581957210453, -0.09851030343724453,
1155 -0.004268022334182935, -0.1059685844580936,
1156 -0.002886178753789801, -0.1067663922211958,
1157 -0.0006739664310059821, -0.09851030343724453,
1158 -0.002777851483521377, -0.1023709937816271,
1159 -0.003577100543986368, -0.1063674883396447,
1160 -0.001236605237717319, -0.1027839694676665,
1161 -0.001471774194108217, -0.09851030343724453};
1163 { -0.003544545103522544, -0.1053162188055505,
1164 -0.001941023322604723, -0.09851030343724451,
1165 -0.002598140593501099, -0.09851030343724451,
1166 -0.004114727297178323, -0.1049870239624718,
1167 -0.002347317802266182, -0.1020064358043286,
1168 -0.002269581958052911, -0.09851030343724451,
1169 -0.002982346712452072, -0.1018362598405457,
1170 -0.003829636200350435, -0.1051516213840111};
1172 std::vector<Node *> nodes1;
1173 nodes1.push_back(new Node(coords1));
1174 nodes1.push_back(new Node(coords1+2));
1175 nodes1.push_back(new Node(coords1+4));
1176 nodes1.push_back(new Node(coords1+6));
1177 nodes1.push_back(new Node(coords1+8));
1178 nodes1.push_back(new Node(coords1+10));
1179 nodes1.push_back(new Node(coords1+12));
1180 nodes1.push_back(new Node(coords1+14));
1181 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1182 std::vector<Node *> nodes2;
1183 nodes2.push_back(new Node(coords2));
1184 nodes2.push_back(new Node(coords2+2));
1185 nodes2.push_back(new Node(coords2+4));
1186 nodes2.push_back(new Node(coords2+6));
1187 nodes2.push_back(new Node(coords2+8));
1188 nodes2.push_back(new Node(coords2+10));
1189 nodes2.push_back(new Node(coords2+12));
1190 nodes2.push_back(new Node(coords2+14));
1191 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1192 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1193 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1194 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11);
1200 void QuadraticPlanarInterpTest::checkNonRegression12()
1202 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-6);
1203 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-7);
1205 { -0.5032251558760915, -0.8716087994449138,
1206 -0.4695268343089433, -0.8806382374805872,
1207 -0.4695268343089433, -0.8570494123835835,
1208 -0.4914307433275896, -0.8511802776536561,
1209 -0.4869703691141082, -0.8783417525751493,
1210 -0.4695268343089433, -0.8688438249320853,
1211 -0.480865131947653, -0.8555566971861125,
1212 -0.4973279496018406, -0.8613945385492849};
1215 { -0.5065868681155701, -0.8774455199666568,
1216 -0.4695187143958762, -0.8873779018223601,
1217 -0.4695187143968347, -0.8806382375105907,
1218 -0.5032170359605401, -0.8716087994611657,
1219 -0.488706602695924, -0.8848517684025307,
1220 -0.4695187143963554, -0.8840080696664754,
1221 -0.4869622492144596, -0.8783417525850385,
1222 -0.5049019520380551, -0.8745271597139112};
1224 std::vector<Node *> nodes1;
1225 nodes1.push_back(new Node(coords1));
1226 nodes1.push_back(new Node(coords1+2));
1227 nodes1.push_back(new Node(coords1+4));
1228 nodes1.push_back(new Node(coords1+6));
1229 nodes1.push_back(new Node(coords1+8));
1230 nodes1.push_back(new Node(coords1+10));
1231 nodes1.push_back(new Node(coords1+12));
1232 nodes1.push_back(new Node(coords1+14));
1233 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1234 std::vector<Node *> nodes2;
1235 nodes2.push_back(new Node(coords2));
1236 nodes2.push_back(new Node(coords2+2));
1237 nodes2.push_back(new Node(coords2+4));
1238 nodes2.push_back(new Node(coords2+6));
1239 nodes2.push_back(new Node(coords2+8));
1240 nodes2.push_back(new Node(coords2+10));
1241 nodes2.push_back(new Node(coords2+12));
1242 nodes2.push_back(new Node(coords2+14));
1243 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1244 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1245 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1246 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6);
1252 void QuadraticPlanarInterpTest::checkNonRegression13()
1254 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1255 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-6);
1257 double coords_1[194]={
1258 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375,
1259 -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1260 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109,
1261 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108,
1262 -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109,
1263 -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108,
1264 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125,
1265 -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125,
1266 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218,
1267 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216,
1268 -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217,
1269 -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216,
1270 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1271 -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1272 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933,
1273 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932,
1274 -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932,
1275 -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932,
1276 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1277 -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1278 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244,
1279 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243,
1280 -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243,
1281 -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243,
1282 2.249646661664983, 0.9318341578089936 };
1285 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15,
1286 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7,
1287 22, 8, 0, 23, 9, 8, 24, 1 };
1290 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15,
1291 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18,
1292 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9,
1293 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36,
1294 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43,
1295 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46,
1296 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61,
1297 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64,
1298 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71,
1299 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 };
1301 double coords_2[20]={
1302 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611,
1303 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611,
1304 0.5922441860137611, 0, -0.5922441860137611, 0 };
1307 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1309 double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2;
1311 const int *work1=tab6_1;
1312 for(int i=0;i<8;i++,work1+=6)
1314 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6);
1315 const int *work2=tab8_2;
1316 for(int j=0;j<2;j++,work2+=8)
1318 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1319 //std::vector<int> tmp;
1320 //pol1->intersectForPoint(*pol2,tmp);
1321 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1322 //pol1->intersectMySelfWith(*pol2);
1328 for(int i=0;i<24;i++,work1+=8)
1330 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8);
1331 const int *work2=tab8_2;
1332 for(int j=0;j<2;j++,work2+=8)
1335 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1336 //std::vector<int> tmp;
1337 //pol1->intersectForPoint(*pol2,tmp);
1338 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1346 Some overlapping cases for intersectForPoint.
1348 void QuadraticPlanarInterpTest::checkNonRegression14()
1350 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1351 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-6);
1354 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1355 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1356 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1357 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1358 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1359 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1360 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1361 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1366 8,9,10,11,2,14,12,13,
1367 9,15,16,10,5,17,18,14,
1368 9,15,16,10,34,17,35,14,
1369 19,20,21,22,23,24,25,26,
1370 27,28,29,30,31,32,2,33
1372 QuadraticPolygon *pol1,*pol2;
1373 std::vector<int> goalOfTest;
1375 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1377 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1378 pol1->intersectForPoint(*pol2,goalOfTest);
1379 const int res1[4]={0,1,0,0};
1380 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1381 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1));
1384 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1385 pol1->intersectForPoint(*pol2,goalOfTest);
1386 const int res2[4]={0,2,0,0};
1387 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1388 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2));
1391 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8);
1392 pol1->intersectForPoint(*pol2,goalOfTest);
1393 const int res2Bis[4]={0,2,0,0};
1394 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1395 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis));
1398 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8);
1399 pol1->intersectForPoint(*pol2,goalOfTest);
1400 const int res3[4]={0,3,0,0};
1401 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1402 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3));
1405 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8);
1406 pol1->intersectForPoint(*pol2,goalOfTest);
1407 const int res4[4]={0,4,0,0};
1408 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1409 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4));
1416 * This test is one of the most complicated intersection configuration.
1418 void QuadraticPlanarInterpTest::checkNonRegression15()
1420 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1421 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-6);
1424 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1425 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1426 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1427 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1428 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1429 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1430 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1431 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1437 9,15,16,10,7,17,5,14,
1438 9,10,16,15,14,5,17,7
1441 const double RefLgth=3.88995883524451;
1442 const double RefArea=0.383185168001075;
1444 QuadraticPolygon *pol1,*pol2;
1445 //pol1 and pol2 in same orientation
1446 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1447 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1448 std::vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
1449 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1450 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1451 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1452 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1454 //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2
1455 res=pol2->intersectMySelfWith(*pol1);
1456 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1457 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1458 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1459 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1462 //pol1 and pol2 in opposite orientation
1463 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1464 res=pol1->intersectMySelfWith(*pol2);
1465 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1466 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1467 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1468 CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12);
1470 //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2
1471 res=pol2->intersectMySelfWith(*pol1);
1472 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1473 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1474 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1475 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1485 DoubleEqual(double eps):_eps(eps) { }
1486 bool operator()(double x, double y) { return fabs(x-y)<_eps; }
1492 * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ...
1494 void QuadraticPlanarInterpTest::checkNonRegression16()
1496 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1497 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-7);
1498 double coords1[194]={
1499 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1500 -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375,
1501 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108,
1502 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109,
1503 -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108,
1504 -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109,
1505 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125,
1506 -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125,
1507 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216,
1508 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217,
1509 -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216,
1510 -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218,
1511 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1512 -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1513 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932,
1514 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932,
1515 -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932,
1516 -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933,
1517 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1518 -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1519 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243,
1520 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243,
1521 -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243,
1522 -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244,
1523 2.249646661664984, -0.9318341578089931, };
1526 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13,
1527 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18,
1528 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23,
1529 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36,
1530 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41,
1531 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46,
1532 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59,
1533 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64,
1534 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69,
1535 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, };
1537 double coords2[20]={
1538 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435,
1539 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925,
1540 2.56375, 0, -2.56375, 0, };
1542 int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1544 QuadraticPolygon *pol1,*pol2;
1545 //pol1 and pol2 in same orientation
1546 std::vector<double> test1,test2;
1547 for(int ii=0;ii<24;ii++)
1549 pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
1550 for(int jj=0;jj<2;jj++)
1552 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
1554 std::vector<double> v1,v2;
1555 pol1->initLocations();
1556 pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
1565 const double test1_res[4]={0.,1.9124445278727873,0.,0.};
1566 CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10)));
1567 const double test2_res[4]={0.,0.,0.,0.};
1568 CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10)));
1572 * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation.
1574 void QuadraticPlanarInterpTest::checkNonRegression17()
1576 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7);
1577 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(1e-7);
1579 -1., 0., 1., 0. , 1.5, 0., -1.5, 0.,
1580 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.};
1582 double coords2[16]={
1583 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444,
1584 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 };
1586 double coords3[16]={
1587 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0.,
1588 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. };
1591 0, 1, 2, 3, 4, 5, 6, 7 };
1592 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1593 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1594 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1597 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1598 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1599 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1602 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1603 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1604 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1607 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1608 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1609 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1614 void QuadraticPlanarInterpTest::checkNormalize()
1616 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14);
1617 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.);
1618 Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.);
1619 Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.);
1620 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1621 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1622 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
1624 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
1625 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1626 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1627 double area1Start=pol1.getArea();
1629 double fact=pol1.normalize(&pol2,xb,yb);
1630 double area1End=pol1.getArea();
1631 CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14);
1632 CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14);
1633 double area=pol1.intersectWith(pol2);
1634 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14);
1636 n1=new Node(0.,0.); n4=new Node(0.,-3.);
1637 n2=new Node(10.,0.); n5=new Node(10.,-3.);
1638 n3=new Node(5.,10.); n6=new Node(5.,7.);
1639 e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5);
1640 e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6);
1641 e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4);
1642 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
1643 QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4);
1644 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1645 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14);
1646 // Ok testing EdgeArcCircle update.
1647 double center[2]={5.,5.};
1649 EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.);
1650 const Bounds& b=e1->getBounds();
1652 fact2=b.getCaracteristicDim();
1653 b.getBarycenter(x,y);
1654 CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13);
1655 CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10);
1656 e1->getStartNode()->applySimilarity(x,y,fact2);
1657 e1->getEndNode()->applySimilarity(x,y,fact2);
1658 e1->applySimilarity(x,y,fact2);
1659 CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13);
1660 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14);
1661 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13);
1665 void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
1667 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14);
1668 Node *n0=new Node(0.,0.); Node *n4=new Node(0.5,0.25);
1669 Node *n1=new Node(0.,0.5); Node *n5=new Node(0.3,1.2);
1670 Node *n2=new Node(1.,0.5); Node *n6=new Node(1.1,1.3);
1671 Node *n3=new Node(1.,0.); Node *n7=new Node(-0.1,0.9);
1672 EdgeLin *e0_1=new EdgeLin(n0,n1);
1673 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1674 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1675 EdgeLin *e3_0=new EdgeLin(n3,n0); EdgeLin *e6_4=new EdgeLin(n6,n4);
1676 EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_5=new EdgeLin(n7,n5);
1677 QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0);
1678 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1679 pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7);
1680 n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
1681 pol1.dumpInXfigFileWithOther(pol2,"tony.fig");
1685 * Arc/arc intersection was buggy: a point was detected OFF when used in a linear segment, but
1686 * detected ON when used in an (almost flat) arc of circle.
1688 void QuadraticPlanarInterpTest::checkArcArcIntersection1()
1691 INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(eps);
1692 INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision::setArcDetectionPrecision(eps);
1694 Node *n0=new Node(6.37533,38.8928); Node *n3=new Node(6.29194,39.2789);
1695 Node *n1=new Node(6.13158,38.8308); Node *n4=new Node(6.31919,38.7607);
1696 Node *n2=new Node(6.25346,38.8618); Node *n5=new Node(6.38778,39.0241);
1698 Node *n6=new Node(6.2534549999999998, 38.861800000000002); // to have a linear edge e1
1700 //EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n6, true); // to have a linear edge e1
1701 EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n1, true);
1702 EdgeArcCircle *e2=new EdgeArcCircle(n3, n5, n4, true);
1705 QuadraticPolygon c1,c2;
1706 e1->intersectWith(e2,merge,c1,c2);
1707 CPPUNIT_ASSERT_EQUAL(2,c1.size());
1708 CPPUNIT_ASSERT_EQUAL(2,c2.size());
1710 n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1711 e1->decrRef(); e2->decrRef();