1 // Copyright (C) 2007-2008 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.
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 #include "QuadraticPlanarInterpTest.hxx"
20 #include "QuadraticPolygon.hxx"
21 #include "ElementaryEdge.hxx"
22 #include "EdgeArcCircle.hxx"
23 #include "EdgeLin.hxx"
31 using namespace INTERP_KERNEL;
33 void QuadraticPlanarInterpTest::checkPolygonsIntersection1()
35 //The "most" basic test1
36 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3);
37 Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3);
38 Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7);
39 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
40 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
41 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
43 vector<QuadraticPolygon *> result;
49 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
50 QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
51 for(int i1=0;i1<i;i1++) pol1.circularPermute(); if(k==1) pol1.reverse();
52 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
53 for(int j1=0;j1<j;j1++) pol2.circularPermute();
54 result=pol1.intersectMySelfWith(pol2);
55 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
56 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
57 double tmp1=0.,tmp2=0.,tmp3=0.;
58 pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3);
61 pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge
62 pol1.intersectForPoint(pol2,v3);
63 CPPUNIT_ASSERT_EQUAL(3,(int)v1.size());
64 CPPUNIT_ASSERT_EQUAL(3,(int)v2.size());
65 CPPUNIT_ASSERT_EQUAL(3,(int)v3.size());
68 CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]);
69 CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]);
70 CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]);
71 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14);
72 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14);
73 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14);
74 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14);
75 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14);
76 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14);
78 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14);
79 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14);
80 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge
85 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
86 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
88 //Deeper test some extremities of pol2 are on edges of pol1.
90 n1=new Node(0.,0.); n4=new Node(1.5,-0.5);
91 n2=new Node(1.,0.); n5=new Node(0.5,0.);
92 n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5);
93 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
94 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);
101 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef();
102 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
103 for(int i1=0;i1<i;i1++) pol3.circularPermute(); if(k==1) pol3.reverse();
104 QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5);
105 for(int j1=0;j1<j;j1++) pol4.circularPermute();
106 result=pol3.intersectMySelfWith(pol4);
107 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
108 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
113 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef();
114 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
116 //Test with one edge of pol2 is included in pol1.
118 n1=new Node(0.,0.); n4=new Node(-0.5,0.);
119 n2=new Node(1.,0.); n5=new Node(0.,-1.);
120 n3=new Node(0.5,1.); n6=new Node(0.5,0.);
121 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
122 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
128 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
129 QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1);
130 for(int i1=0;i1<i;i1++) pol5.circularPermute(); if(k==1) pol5.reverse();
131 QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4);
132 for(int j1=0;j1<j;j1++) pol6.circularPermute();
133 result=pol5.intersectMySelfWith(pol6);
134 CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
138 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
139 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
141 //Test of full overlapped polygons.
143 n1=new Node(0.,0.); n4=new Node(0.,0.);
144 n2=new Node(1.,0.); n5=new Node(1.,0.);
145 n3=new Node(0.5,1.); n6=new Node(0.5,1.);
146 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
147 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
153 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
154 QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1);
155 for(int i1=0;i1<i;i1++) pol7.circularPermute(); if(k==1) pol7.reverse();
156 QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4);
157 for(int j1=0;j1<j;j1++) pol8.circularPermute();
158 result=pol7.intersectMySelfWith(pol8);
159 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
160 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
162 double tmp1=0.,tmp2=0.,tmp3=0.;
163 pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3);
164 vector<double> v1,v2;
165 pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges.
166 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14);
167 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14);
168 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14);
169 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14);
170 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14);
174 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
175 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
177 //Test of closing process
179 n1=new Node(0.,0.); n4=new Node(0.539,-0.266);
180 n2=new Node(1.,0.); n5=new Node(1.039,0.6);
181 n3=new Node(0.5,1.); n6=new Node(-0.077,0.667);
182 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
183 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
189 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
190 QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1);
191 for(int i1=0;i1<i;i1++) pol9.circularPermute(); if(k==1) pol9.reverse();
192 QuadraticPolygon pol10; pol10.pushBack(e5_6); pol10.pushBack(e6_4); pol10.pushBack(e4_5);
193 for(int j1=0;j1<j;j1++) pol10.circularPermute();
194 result=pol9.intersectMySelfWith(pol10);
195 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
196 CPPUNIT_ASSERT_EQUAL(6,result[0]->recursiveSize());
201 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
202 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
206 n1=new Node(0.,0.); n4=new Node(0.3,0.1);
207 n2=new Node(1.,0.); n5=new Node(0.7,0.1);
208 n3=new Node(0.5,1.); n6=new Node(0.5,0.7);
209 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
210 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
216 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
217 QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1);
218 for(int i1=0;i1<i;i1++) pol11.circularPermute(); if(k==1) pol11.reverse();
219 QuadraticPolygon pol12; pol12.pushBack(e5_6); pol12.pushBack(e6_4); pol12.pushBack(e4_5);
220 for(int j1=0;j1<j;j1++) pol12.circularPermute();
221 result=pol11.intersectMySelfWith(pol12);
222 CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
223 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
228 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
229 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
233 n1=new Node(0.,0.); n4=new Node(-2,0.);
234 n2=new Node(1.,0.); n5=new Node(-1.,0.);
235 n3=new Node(0.5,1.); n6=new Node(-1.5,1.);
236 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
237 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
243 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
244 QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1);
245 for(int i1=0;i1<i;i1++) pol13.circularPermute(); if(k==1) pol13.reverse();
246 QuadraticPolygon pol14; pol14.pushBack(e5_6); pol14.pushBack(e6_4); pol14.pushBack(e4_5);
247 for(int j1=0;j1<j;j1++) pol14.circularPermute();
248 result=pol13.intersectMySelfWith(pol14);
249 CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
253 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
254 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
263 n5=new Node(0.2,0.7);
264 n6=new Node(0.4,0.7);
265 n7=new Node(0.4,1.3);
266 Node *n8=new Node(0.6,1.3);
267 Node *n9=new Node(0.6,0.7);
268 Node *n10=new Node(0.9,0.7);
269 Node *n11=new Node(0.9,2.);
270 Node *n12=new Node(0.2,2.);
272 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);
273 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);
274 Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5);
281 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();
282 QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1);
283 for(int i1=0;i1<i;i1++) pol15.circularPermute(); if(k==1) pol15.reverse();
284 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);
285 for(int j1=0;j1<j;j1++) pol16.circularPermute();
286 result=pol15.intersectMySelfWith(pol16);
287 CPPUNIT_ASSERT_EQUAL(2,(int)result.size());
288 checkBasicsOfPolygons(*result[0],*result[1],false);
289 CPPUNIT_ASSERT_EQUAL(4,result[0]->recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize());
290 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10);
291 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10);
292 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10);
293 delete result[0]; delete result[1];
297 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();
298 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef();
302 * Testing case where a polygon pol1 is included in an onother polygon pol2.
304 void QuadraticPlanarInterpTest::checkPolygonsIntersection2()
306 Node *n1=new Node(0.,0.); Node *n4=new Node(0.2,0.2);
307 Node *n2=new Node(1.,0.); Node *n5=new Node(0.8,0.2);
308 Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.8);
309 Edge *e1_2=new EdgeLin(n1,n2); Edge *e4_5=new EdgeLin(n4,n5);
310 Edge *e2_3=new EdgeLin(n2,n3); Edge *e5_6=new EdgeLin(n5,n6);
311 Edge *e3_1=new EdgeLin(n3,n1); Edge *e6_4=new EdgeLin(n6,n4);
313 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
314 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
315 vector<QuadraticPolygon *> result=pol1.intersectMySelfWith(pol2);
316 CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
317 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
318 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
321 pol1.initLocations();
322 pol2.initLocations();
323 result=pol2.intersectMySelfWith(pol1);
324 CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
325 CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
326 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
329 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
332 void QuadraticPlanarInterpTest::checkAreasCalculations()
334 Node *n1=new Node(0.,0.);
335 Node *n2=new Node(1.,0.);
336 Node *n3=new Node(0.5,1.);
337 Edge *e1_2=new EdgeLin(n1,n2);
338 Edge *e2_3=new EdgeLin(n2,n3);
339 Edge *e3_1=new EdgeLin(n3,n1);
341 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
342 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
343 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10);
344 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10);
345 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10);
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 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
352 n1->decrRef(); n2->decrRef(); n3->decrRef();
358 Node *n3m=new Node(1.5,0.5);
360 Node *n4=new Node(0.,1.);
361 e1_2=new EdgeLin(n1,n2);
362 e2_3=new EdgeArcCircle(n2,n3m,n3);
363 Edge *e3_4=new EdgeLin(n3,n4);
364 Edge *e4_1=new EdgeLin(n4,n1);
368 n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4));
369 n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4));
370 n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4));
371 n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2));
372 e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m);
373 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
374 QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1);
375 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6);
376 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
378 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6);
379 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
382 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef();
383 n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
387 const double radius1=0.7;
388 const double radius2=0.9;
389 n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.));
390 n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.));
391 Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.));
392 n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.));
393 n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.));
394 n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.));
395 e1_2=new EdgeArcCircle(n1,n2m,n2);
396 e2_3=new EdgeLin(n2,n3);
397 e3_4=new EdgeArcCircle(n3,n3m,n4);
398 e4_1=new EdgeLin(n4,n1);
400 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
401 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1);
402 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10);
403 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
405 CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10);
406 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
408 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef();
409 n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
412 void QuadraticPlanarInterpTest::checkBarycenterCalculations()
414 Node *n1=new Node(3.,7.);
415 Node *n2=new Node(5.,7.);
416 Node *n3=new Node(4.,8.);
417 Edge *e1_2=new EdgeLin(n1,n2);
418 Edge *e2_3=new EdgeLin(n2,n3);
419 Edge *e3_1=new EdgeLin(n3,n1);
422 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
423 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
424 bary[0]=0.; bary[1]=0.;
425 e1_2->getBarycenterOfZone(bary);
426 CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10);
427 bary[0]=0.; bary[1]=0.;
428 e2_3->getBarycenterOfZone(bary);
429 CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10);
430 CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10);
431 bary[0]=0.; bary[1]=0.;
432 e3_1->getBarycenterOfZone(bary);
433 CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10);
434 CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10);
435 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10);
436 pol1.getBarycenter(bary);
437 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
438 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
440 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
441 QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false);
442 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10);
443 pol4.getBarycenter(bary);
444 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
445 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
447 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
448 n1->decrRef(); n2->decrRef(); n3->decrRef();
453 e1_2=new EdgeLin(n1,n3);
454 e2_3=new EdgeLin(n3,n2);
455 e3_1=new EdgeLin(n2,n1);
456 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
457 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
458 bary[0]=0.; bary[1]=0.;
459 pol3.getBarycenter(bary);
460 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10);
461 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
462 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
464 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
465 n1->decrRef(); n2->decrRef(); n3->decrRef();
467 double center[2]={3.,7.};
468 e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.);
469 bary[0]=0.; bary[1]=0.;
470 e1_2->getBarycenterOfZone(bary);
471 CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10);
472 CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10);
473 n1=new Node(0.99999999999999822,3.5358983848622465);
474 n2=new Node(5.,10.4641016151377544);
475 Edge *e2_1=new EdgeLin(n1,n2);
477 e1_2->incrRef(); e2_1->incrRef();
478 QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1);
479 pol2.getBarycenter(bary);
480 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10);
482 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10);
483 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10);
485 e1_2->decrRef(); e2_1->decrRef();
486 n1->decrRef(); n2->decrRef();
490 * Testing user interface high level function.
492 void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
494 QUADRATIC_PLANAR::setPrecision(1e-12);
495 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
497 8.8334591186000004, 5.0999999999999996,
498 7.1014083111000001, 6.0999999999999996,
499 7.8334591186000004, 6.8320508074999999,
500 7.9674337149000003, 5.5999999999999996,
501 7.4192455562999999, 6.5142135623000001,
502 8.3334591186000004, 5.9660254036999998
504 vector<Node *> nodes;
505 nodes.push_back(new Node(coords));
506 nodes.push_back(new Node(coords+2));
507 nodes.push_back(new Node(coords+4));
508 nodes.push_back(new Node(coords+6));
509 nodes.push_back(new Node(coords+8));
510 nodes.push_back(new Node(coords+10));
511 QuadraticPolygon *pol=QuadraticPolygon::buildArcCirclePolygon(nodes);
512 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5);
513 CPPUNIT_ASSERT_EQUAL(3,pol->size());
514 ElementaryEdge *e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
515 ElementaryEdge *e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
516 ElementaryEdge *e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
517 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
518 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
519 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
520 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
523 nodes.push_back(new Node(coords));
524 nodes.push_back(new Node(coords+4));
525 nodes.push_back(new Node(coords+2));
526 nodes.push_back(new Node(coords+10));
527 nodes.push_back(new Node(coords+8));
528 nodes.push_back(new Node(coords+6));
529 pol=QuadraticPolygon::buildArcCirclePolygon(nodes);
530 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5);
531 CPPUNIT_ASSERT_EQUAL(3,pol->size());
532 e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
533 e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
534 e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
535 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
536 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
537 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
538 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
540 const double coords2[]={
547 nodes.push_back(new Node(coords2));
548 nodes.push_back(new Node(coords2+2));
549 nodes.push_back(new Node(coords2+4));
550 nodes.push_back(new Node(coords2+6));
551 pol=QuadraticPolygon::buildLinearPolygon(nodes);
552 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12);
554 pol->getBarycenter(tmp,tmp2);
555 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12);
556 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12);
558 const double coords3[]={
559 1.0999999999000001, -1.9052558882999999,
560 1.9052558881999999, -1.0999999999000001,
561 1.7320508075000001, -0.99999999989999999,
562 0.99999999989999999, -1.7320508075000001,
563 1.5556349186, -1.5556349185,
564 1.8186533478, -1.0499999999,
565 1.4142135623000001, -1.4142135623000001,
566 1.0499999999, -1.8186533479
569 nodes.push_back(new Node(coords3));
570 nodes.push_back(new Node(coords3+2));
571 nodes.push_back(new Node(coords3+4));
572 nodes.push_back(new Node(coords3+6));
573 nodes.push_back(new Node(coords3+8));
574 nodes.push_back(new Node(coords3+10));
575 nodes.push_back(new Node(coords3+12));
576 nodes.push_back(new Node(coords3+14));
577 pol=QuadraticPolygon::buildArcCirclePolygon(nodes);
578 pol->getBarycenter(tmp,tmp2);
580 QUADRATIC_PLANAR::setPrecision(1e-14);
583 void QuadraticPlanarInterpTest::check1DInterpLin()
585 QUADRATIC_PLANAR::setPrecision(1e-7);
586 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
587 const int NB_OF_CELL_AXIAL_1=30;
588 static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]=
589 { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500,
590 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500,
591 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356,
593 vector<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
595 const int NB_OF_CELL_AXIAL_2=46;
596 static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]=
597 { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356
598 , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15
599 , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700
600 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550
601 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050};
602 vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
603 map<int,map<int,double> > m;
604 Edge::interpolate1DLin(zLev1,zLev2,m);
605 CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
607 for(int i=0;i<30;i++)
609 CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size());
610 CPPUNIT_ASSERT(m[i][8+i] > 0.15);
613 CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12);
616 const int NB_OF_CELL_AXIAL_3=13;
617 static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={
618 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30,
619 0.35,0.40,0.45,0.50,0.55,0.60 };
620 vector<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
621 Edge::interpolate1DLin(zLev3,zLev1,m);
622 CPPUNIT_ASSERT_EQUAL(13,(int)m.size());
623 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12);
624 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12);
625 for(int i=0;i<11;i++)
627 CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size());
628 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12);
630 QUADRATIC_PLANAR::setPrecision(1e-14);
634 * This test looks if intersectors are in coherency.
636 void QuadraticPlanarInterpTest::checkEpsilonCoherency1()
638 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
639 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
641 const double pol1[]={
642 -2.1083388455000001, 1.2172499999999999,
643 -1.7320508075000001, 1,
644 -1.9201948265, 1.108625
647 const double pol2[]={
649 -1.9381648534, 1.1189999998,
650 -2.1617419990000002, 0.57923702298000002,
651 -1.9381648534, 1.1189999998,
652 -1.9909924031999999, 1.1494999999,
653 -1.9645786283, 1.1342499998
656 Node *n1=new Node(pol1[0],pol1[1]);
657 Node *n2=new Node(pol1[2],pol1[3]);
660 Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef();
661 n1=new Node(pol2[0],pol2[1]);
662 n2=new Node(pol2[4],pol2[5]);
663 n3=new Node(pol2[2],pol2[3]);
664 Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef();
670 * Tests to avoid regressions : Basic one.
672 void QuadraticPlanarInterpTest::checkNonRegression1()
674 const double coords1[]=
676 16.1732057215, -25.110999999800001,
677 16.02555485246479, -25.340997988918762
679 Node *nS1=new Node(coords1);
680 Node *nE1=new Node(coords1+2);
681 const double radius1=2.902;
682 const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692;
683 const double center1[2]={13.66, -23.66};
684 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
686 const double coords2[]=
688 16.041579804000001, -25.350249998999999,
689 16.367740958999999, -24.132999999999999
691 Node *nS2=new Node(coords2);
692 Node *nE2=new Node(coords2+2);
693 const double radius2=2.4345;
694 const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041;
695 const double center2[]={ 13.933240960547204, -24.132999998525658 };
696 EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2);
698 QuadraticPolygon c1,c2;
699 e1->intersectWith(e2,merge,c1,c2);
700 CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size());
701 CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5);
703 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
706 void QuadraticPlanarInterpTest::checkNonRegression2()
708 QUADRATIC_PLANAR::setPrecision(1e-12);
709 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
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 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 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 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 QUADRATIC_PLANAR::setPrecision(1e-12);
801 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
804 10.962340811000001, -22.417749999000002,
805 12.217990959, -21.162099852000001,
806 12.051990958999999, -20.874579418,
807 10.674820377, -22.251749999000001,
808 11.507511146000001, -21.707270185999999,
809 12.134990959, -21.018339635,
810 11.272751694, -21.472510735,
811 10.818580594, -22.334749999
816 10.758000000199999, -23.66,
817 11.1467942784, -22.2090000002,
818 11.0939667286, -22.178500000099998,
819 10.696999999999999, -23.66,
820 10.856883252299999, -22.908907131159999,
821 11.1203805035, -22.1937500001,
822 10.797961776699999, -22.893119169449999,
823 10.727500000099999, -23.66
825 vector<Node *> nodes1;
826 nodes1.push_back(new Node(coords1));
827 nodes1.push_back(new Node(coords1+2));
828 nodes1.push_back(new Node(coords1+4));
829 nodes1.push_back(new Node(coords1+6));
830 nodes1.push_back(new Node(coords1+8));
831 nodes1.push_back(new Node(coords1+10));
832 nodes1.push_back(new Node(coords1+12));
833 nodes1.push_back(new Node(coords1+14));
834 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
835 vector<Node *> nodes2;
836 nodes2.push_back(new Node(coords2));
837 nodes2.push_back(new Node(coords2+2));
838 nodes2.push_back(new Node(coords2+4));
839 nodes2.push_back(new Node(coords2+6));
840 nodes2.push_back(new Node(coords2+8));
841 nodes2.push_back(new Node(coords2+10));
842 nodes2.push_back(new Node(coords2+12));
843 nodes2.push_back(new Node(coords2+14));
844 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
845 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
846 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
847 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
849 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
854 void QuadraticPlanarInterpTest::checkNonRegression5()
856 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
857 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
860 -1.7320508075000001, 1,
861 -1, 1.7320508075000001 ,
862 -1.2172499999999999, 2.1083388455000001,
863 -2.1083388455000001, 1.2172499999999999,
864 -1.4142135623000001, 1.4142135623000001,
865 -1.108625, 1.9201948265,
866 -1.7214514588000001, 1.7214514588000001,
867 -1.9201948265, 1.108625};
872 -1.9381648534, 1.1189999998,
873 -1.9909924031999999, 1.1494999999,
874 -2.2989999998999999, 0,
875 -2.1617419990000002, 0.57923702298000002,
876 -1.9645786283, 1.1342499998,
877 -2.2206634745999998, 0.59502498461999997,
878 -2.2684999997999999, 0};
879 //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941}
880 //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}}
881 vector<Node *> nodes1;
882 nodes1.push_back(new Node(coords1));
883 nodes1.push_back(new Node(coords1+2));
884 nodes1.push_back(new Node(coords1+4));
885 nodes1.push_back(new Node(coords1+6));
886 nodes1.push_back(new Node(coords1+8));
887 nodes1.push_back(new Node(coords1+10));
888 nodes1.push_back(new Node(coords1+12));
889 nodes1.push_back(new Node(coords1+14));
890 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
891 vector<Node *> nodes2;
892 nodes2.push_back(new Node(coords2));
893 nodes2.push_back(new Node(coords2+2));
894 nodes2.push_back(new Node(coords2+4));
895 nodes2.push_back(new Node(coords2+6));
896 nodes2.push_back(new Node(coords2+8));
897 nodes2.push_back(new Node(coords2+10));
898 nodes2.push_back(new Node(coords2+12));
899 nodes2.push_back(new Node(coords2+14));
900 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
901 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
902 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
903 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
905 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
910 void QuadraticPlanarInterpTest::checkNonRegression6()
912 QUADRATIC_PLANAR::setPrecision(1e-12);
913 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
916 10.962340811000001, -22.417749999000002,
917 12.217990959, -21.162099852000001,
918 12.051990958999999, -20.874579418,
919 10.674820377, -22.251749999000001,
920 11.507511146000001, -21.707270185999999,
921 12.134990959, -21.018339635,
922 11.272751694, -21.472510735,
923 10.818580594, -22.334749999
927 10.859273844199999, -22.043000000100001,
928 10.806446294799999, -22.012500000199999,
929 10.3650000002, -23.66,
930 10.536195877799999, -22.822979208099998,
931 10.832860069499999, -22.027750000200001,
932 10.477274402499999, -22.80719124657,
933 10.3955000001, -23.66};
934 vector<Node *> nodes1;
935 nodes1.push_back(new Node(coords1));
936 nodes1.push_back(new Node(coords1+2));
937 nodes1.push_back(new Node(coords1+4));
938 nodes1.push_back(new Node(coords1+6));
939 nodes1.push_back(new Node(coords1+8));
940 nodes1.push_back(new Node(coords1+10));
941 nodes1.push_back(new Node(coords1+12));
942 nodes1.push_back(new Node(coords1+14));
943 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
944 vector<Node *> nodes2;
945 nodes2.push_back(new Node(coords2));
946 nodes2.push_back(new Node(coords2+2));
947 nodes2.push_back(new Node(coords2+4));
948 nodes2.push_back(new Node(coords2+6));
949 nodes2.push_back(new Node(coords2+8));
950 nodes2.push_back(new Node(coords2+10));
951 nodes2.push_back(new Node(coords2+12));
952 nodes2.push_back(new Node(coords2+14));
953 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
954 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
955 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
956 CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7);
962 void QuadraticPlanarInterpTest::checkNonRegression7()
964 QUADRATIC_PLANAR::setPrecision(1e-5);
965 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
969 -1.7320508075000001, 1,
970 -2.1083388455000001, 1.2172499999999999,
971 -2.4344999999999999, 0,
972 -1.9318516525603098, 0.51763809027157182,
973 -1.9201948265, 1.108625,
974 -2.3515464241024469, 0.63009496529570408,
975 -2.2172499999999999, 0
978 { -2.3369999999000002, 0,
979 -2.0239013684999998, 1.1684999999000001,
980 -2.1927763221999998, 1.2659999998,
982 -2.2573686559260442, 0.60486010843437632,
983 -2.1083388453499996, 1.2172499998499999,
984 -2.445724191994314, 0.65532982205982326,
985 -2.4344999998499999, 0 };
986 vector<Node *> nodes1;
987 nodes1.push_back(new Node(coords1));
988 nodes1.push_back(new Node(coords1+2));
989 nodes1.push_back(new Node(coords1+4));
990 nodes1.push_back(new Node(coords1+6));
991 nodes1.push_back(new Node(coords1+8));
992 nodes1.push_back(new Node(coords1+10));
993 nodes1.push_back(new Node(coords1+12));
994 nodes1.push_back(new Node(coords1+14));
995 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
996 vector<Node *> nodes2;
997 nodes2.push_back(new Node(coords2));
998 nodes2.push_back(new Node(coords2+2));
999 nodes2.push_back(new Node(coords2+4));
1000 nodes2.push_back(new Node(coords2+6));
1001 nodes2.push_back(new Node(coords2+8));
1002 nodes2.push_back(new Node(coords2+10));
1003 nodes2.push_back(new Node(coords2+12));
1004 nodes2.push_back(new Node(coords2+14));
1005 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
1006 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1007 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1008 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6);
1014 void QuadraticPlanarInterpTest::checkNonRegression8()
1016 QUADRATIC_PLANAR::setPrecision(1e-3);
1017 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
1020 -13.933240959000001, -28.559499999,
1021 -16.146490959000001, -27.966461449000001,
1022 -16.383240958999998, -28.376524478,
1023 -13.933240959000001, -29.032999999000001,
1024 -15.078903461873765, -28.408670669106311,
1025 -16.264865958999998, -28.1714929635,
1026 -15.201454280317435, -28.866036547696734,
1027 -13.933240959000001, -28.796249999 };
1029 { -16.382999999950002, -28.376524478457149,
1030 -13.933000000014729, -29.03299999982551,
1031 -13.93300000006697, -28.793999999915993,
1032 -16.263500000000001, -28.169544407039268,
1033 -15.201213320921273, -28.866036548734634,
1034 -13.933000000040851, -28.913499999870751,
1035 -15.139355569325469, -28.635180276305853,
1036 -16.323249999975001, -28.273034442748209 };
1037 vector<Node *> nodes1;
1038 nodes1.push_back(new Node(coords1));
1039 nodes1.push_back(new Node(coords1+2));
1040 nodes1.push_back(new Node(coords1+4));
1041 nodes1.push_back(new Node(coords1+6));
1042 nodes1.push_back(new Node(coords1+8));
1043 nodes1.push_back(new Node(coords1+10));
1044 nodes1.push_back(new Node(coords1+12));
1045 nodes1.push_back(new Node(coords1+14));
1046 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
1047 vector<Node *> nodes2;
1048 nodes2.push_back(new Node(coords2));
1049 nodes2.push_back(new Node(coords2+2));
1050 nodes2.push_back(new Node(coords2+4));
1051 nodes2.push_back(new Node(coords2+6));
1052 nodes2.push_back(new Node(coords2+8));
1053 nodes2.push_back(new Node(coords2+10));
1054 nodes2.push_back(new Node(coords2+12));
1055 nodes2.push_back(new Node(coords2+14));
1056 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
1057 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1058 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1059 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6);
1065 void QuadraticPlanarInterpTest::checkNonRegression9()
1067 QUADRATIC_PLANAR::setPrecision(1e-7);
1068 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8);
1071 -0.04476229252902969, -0.085118027765365603,
1072 -0.046952683430894329, -0.085704941238358354,
1073 -0.046952683430894329, -0.088063823748058725,
1074 -0.043582851274179504, -0.087160879944491371,
1075 -0.045818853668170414, -0.085555669718918592,
1076 -0.046952683430894329, -0.086884382493208526,
1077 -0.045208329947517549, -0.087834175256748526,
1078 -0.044172571901604597, -0.086139453854928494 };
1081 { -0.05065868681155701, -0.087744551996665671,
1082 -0.046951871439587615, -0.088737790182236015,
1083 -0.046951871439683469, -0.088063823751059062,
1084 -0.050321703596054014, -0.087160879946116557,
1085 -0.0488706602695924, -0.08848517684025306,
1086 -0.046951871439635542, -0.088400806966647538,
1087 -0.048696224921445964, -0.087834175258503858,
1088 -0.050490195203805516, -0.087452715971391121};
1090 vector<Node *> nodes1;
1091 nodes1.push_back(new Node(coords1));
1092 nodes1.push_back(new Node(coords1+2));
1093 nodes1.push_back(new Node(coords1+4));
1094 nodes1.push_back(new Node(coords1+6));
1095 nodes1.push_back(new Node(coords1+8));
1096 nodes1.push_back(new Node(coords1+10));
1097 nodes1.push_back(new Node(coords1+12));
1098 nodes1.push_back(new Node(coords1+14));
1099 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
1100 vector<Node *> nodes2;
1101 nodes2.push_back(new Node(coords2));
1102 nodes2.push_back(new Node(coords2+2));
1103 nodes2.push_back(new Node(coords2+4));
1104 nodes2.push_back(new Node(coords2+6));
1105 nodes2.push_back(new Node(coords2+8));
1106 nodes2.push_back(new Node(coords2+10));
1107 nodes2.push_back(new Node(coords2+12));
1108 nodes2.push_back(new Node(coords2+14));
1109 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
1110 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1111 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
1116 void QuadraticPlanarInterpTest::checkNonRegression10()
1118 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1119 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1121 { -0.002269581957210453, -0.09851030343724453,
1122 -0.004268022334182935, -0.1059685844580936,
1123 -0.002777851483521377, -0.1023709937816271};
1125 { -0.004114727297178323, -0.1049870239624718,
1126 -0.003544545103522544, -0.1053162188055505};
1127 Node *n1_1=new Node(coords1);
1128 Node *n2_1=new Node(coords1+2);
1129 Node *n3_1=new Node(coords1+4);
1130 Node *n1_2=new Node(coords2);
1131 Node *n2_2=new Node(coords2+2);
1132 EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1);
1133 EdgeLin *e2=new EdgeLin(n1_2,n2_2);
1135 ComposedEdge *c1=new ComposedEdge;
1136 ComposedEdge *c2=new ComposedEdge;
1137 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2));
1138 CPPUNIT_ASSERT_EQUAL(2,c1->size());
1139 CPPUNIT_ASSERT_EQUAL(2,c2->size());
1140 ComposedEdge::Delete(c1); ComposedEdge::Delete(c2);
1141 n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef();
1142 n1_2->decrRef(); n2_2->decrRef();
1143 e1->decrRef(); e2->decrRef();
1146 void QuadraticPlanarInterpTest::checkNonRegression11()
1148 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1149 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1151 { -0.002269581957210453, -0.09851030343724453,
1152 -0.004268022334182935, -0.1059685844580936,
1153 -0.002886178753789801, -0.1067663922211958,
1154 -0.0006739664310059821, -0.09851030343724453,
1155 -0.002777851483521377, -0.1023709937816271,
1156 -0.003577100543986368, -0.1063674883396447,
1157 -0.001236605237717319, -0.1027839694676665,
1158 -0.001471774194108217, -0.09851030343724453};
1160 { -0.003544545103522544, -0.1053162188055505,
1161 -0.001941023322604723, -0.09851030343724451,
1162 -0.002598140593501099, -0.09851030343724451,
1163 -0.004114727297178323, -0.1049870239624718,
1164 -0.002347317802266182, -0.1020064358043286,
1165 -0.002269581958052911, -0.09851030343724451,
1166 -0.002982346712452072, -0.1018362598405457,
1167 -0.003829636200350435, -0.1051516213840111};
1169 vector<Node *> nodes1;
1170 nodes1.push_back(new Node(coords1));
1171 nodes1.push_back(new Node(coords1+2));
1172 nodes1.push_back(new Node(coords1+4));
1173 nodes1.push_back(new Node(coords1+6));
1174 nodes1.push_back(new Node(coords1+8));
1175 nodes1.push_back(new Node(coords1+10));
1176 nodes1.push_back(new Node(coords1+12));
1177 nodes1.push_back(new Node(coords1+14));
1178 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
1179 vector<Node *> nodes2;
1180 nodes2.push_back(new Node(coords2));
1181 nodes2.push_back(new Node(coords2+2));
1182 nodes2.push_back(new Node(coords2+4));
1183 nodes2.push_back(new Node(coords2+6));
1184 nodes2.push_back(new Node(coords2+8));
1185 nodes2.push_back(new Node(coords2+10));
1186 nodes2.push_back(new Node(coords2+12));
1187 nodes2.push_back(new Node(coords2+14));
1188 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
1189 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1190 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1191 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11);
1197 void QuadraticPlanarInterpTest::checkNonRegression12()
1199 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6);
1200 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1202 { -0.5032251558760915, -0.8716087994449138,
1203 -0.4695268343089433, -0.8806382374805872,
1204 -0.4695268343089433, -0.8570494123835835,
1205 -0.4914307433275896, -0.8511802776536561,
1206 -0.4869703691141082, -0.8783417525751493,
1207 -0.4695268343089433, -0.8688438249320853,
1208 -0.480865131947653, -0.8555566971861125,
1209 -0.4973279496018406, -0.8613945385492849};
1212 { -0.5065868681155701, -0.8774455199666568,
1213 -0.4695187143958762, -0.8873779018223601,
1214 -0.4695187143968347, -0.8806382375105907,
1215 -0.5032170359605401, -0.8716087994611657,
1216 -0.488706602695924, -0.8848517684025307,
1217 -0.4695187143963554, -0.8840080696664754,
1218 -0.4869622492144596, -0.8783417525850385,
1219 -0.5049019520380551, -0.8745271597139112};
1221 vector<Node *> nodes1;
1222 nodes1.push_back(new Node(coords1));
1223 nodes1.push_back(new Node(coords1+2));
1224 nodes1.push_back(new Node(coords1+4));
1225 nodes1.push_back(new Node(coords1+6));
1226 nodes1.push_back(new Node(coords1+8));
1227 nodes1.push_back(new Node(coords1+10));
1228 nodes1.push_back(new Node(coords1+12));
1229 nodes1.push_back(new Node(coords1+14));
1230 QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1);
1231 vector<Node *> nodes2;
1232 nodes2.push_back(new Node(coords2));
1233 nodes2.push_back(new Node(coords2+2));
1234 nodes2.push_back(new Node(coords2+4));
1235 nodes2.push_back(new Node(coords2+6));
1236 nodes2.push_back(new Node(coords2+8));
1237 nodes2.push_back(new Node(coords2+10));
1238 nodes2.push_back(new Node(coords2+12));
1239 nodes2.push_back(new Node(coords2+14));
1240 QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
1241 vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1242 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1243 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6);
1249 void QuadraticPlanarInterpTest::checkNonRegression13()
1251 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1252 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1254 double coords_1[194]={
1255 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375,
1256 -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1257 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109,
1258 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108,
1259 -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109,
1260 -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108,
1261 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125,
1262 -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125,
1263 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218,
1264 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216,
1265 -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217,
1266 -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216,
1267 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1268 -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1269 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933,
1270 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932,
1271 -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932,
1272 -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932,
1273 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1274 -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1275 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244,
1276 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243,
1277 -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243,
1278 -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243,
1279 2.249646661664983, 0.9318341578089936 };
1282 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15,
1283 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7,
1284 22, 8, 0, 23, 9, 8, 24, 1 };
1287 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15,
1288 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18,
1289 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9,
1290 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36,
1291 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43,
1292 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46,
1293 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61,
1294 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64,
1295 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71,
1296 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 };
1298 double coords_2[20]={
1299 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611,
1300 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611,
1301 0.5922441860137611, 0, -0.5922441860137611, 0 };
1304 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1306 double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2;
1308 const int *work1=tab6_1;
1309 for(int i=0;i<8;i++,work1+=6)
1311 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6);
1312 const int *work2=tab8_2;
1313 for(int j=0;j<2;j++,work2+=8)
1315 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1317 //pol1->intersectForPoint(*pol2,tmp);
1318 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1319 //pol1->intersectMySelfWith(*pol2);
1325 for(int i=0;i<24;i++,work1+=8)
1327 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8);
1328 const int *work2=tab8_2;
1329 for(int j=0;j<2;j++,work2+=8)
1332 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1334 //pol1->intersectForPoint(*pol2,tmp);
1335 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1343 Some overlapping cases for intersectForPoint.
1345 void QuadraticPlanarInterpTest::checkNonRegression14()
1347 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1348 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1351 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1352 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1353 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1354 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1355 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1356 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1357 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1358 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1363 8,9,10,11,2,14,12,13,
1364 9,15,16,10,5,17,18,14,
1365 9,15,16,10,34,17,35,14,
1366 19,20,21,22,23,24,25,26,
1367 27,28,29,30,31,32,2,33
1369 QuadraticPolygon *pol1,*pol2;
1370 vector<int> goalOfTest;
1372 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1374 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1375 pol1->intersectForPoint(*pol2,goalOfTest);
1376 const int res1[4]={0,1,0,0};
1377 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1378 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1));
1381 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1382 pol1->intersectForPoint(*pol2,goalOfTest);
1383 const int res2[4]={0,2,0,0};
1384 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1385 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2));
1388 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8);
1389 pol1->intersectForPoint(*pol2,goalOfTest);
1390 const int res2Bis[4]={0,2,0,0};
1391 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1392 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis));
1395 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8);
1396 pol1->intersectForPoint(*pol2,goalOfTest);
1397 const int res3[4]={0,3,0,0};
1398 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1399 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3));
1402 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8);
1403 pol1->intersectForPoint(*pol2,goalOfTest);
1404 const int res4[4]={0,4,0,0};
1405 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1406 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4));
1413 * This test is one of the most complicated intersection configuration.
1415 void QuadraticPlanarInterpTest::checkNonRegression15()
1417 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1418 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1421 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1422 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1423 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1424 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1425 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1426 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1427 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1428 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1434 9,15,16,10,7,17,5,14,
1435 9,10,16,15,14,5,17,7
1438 const double RefLgth=3.88995883524451;
1439 const double RefArea=0.383185168001075;
1441 QuadraticPolygon *pol1,*pol2;
1442 //pol1 and pol2 in same orientation
1443 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1444 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1445 vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
1446 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1447 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1448 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1449 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1451 //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2
1452 res=pol2->intersectMySelfWith(*pol1);
1453 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1454 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1455 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1456 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1459 //pol1 and pol2 in opposite orientation
1460 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1461 res=pol1->intersectMySelfWith(*pol2);
1462 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1463 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1464 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1465 CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12);
1467 //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2
1468 res=pol2->intersectMySelfWith(*pol1);
1469 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1470 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1471 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1472 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1482 DoubleEqual(double eps):_eps(eps) { }
1483 bool operator()(double x, double y) { return fabs(x-y)<_eps; }
1489 * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ...
1491 void QuadraticPlanarInterpTest::checkNonRegression16()
1493 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1494 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1495 double coords1[194]={
1496 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1497 -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375,
1498 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108,
1499 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109,
1500 -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108,
1501 -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109,
1502 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125,
1503 -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125,
1504 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216,
1505 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217,
1506 -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216,
1507 -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218,
1508 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1509 -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1510 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932,
1511 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932,
1512 -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932,
1513 -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933,
1514 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1515 -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1516 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243,
1517 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243,
1518 -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243,
1519 -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244,
1520 2.249646661664984, -0.9318341578089931, };
1523 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13,
1524 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18,
1525 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23,
1526 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36,
1527 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41,
1528 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46,
1529 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59,
1530 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64,
1531 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69,
1532 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, };
1534 double coords2[20]={
1535 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435,
1536 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925,
1537 2.56375, 0, -2.56375, 0, };
1539 int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1541 QuadraticPolygon *pol1,*pol2;
1542 //pol1 and pol2 in same orientation
1543 vector<double> test1,test2;
1544 for(int ii=0;ii<24;ii++)
1546 pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
1547 for(int jj=0;jj<2;jj++)
1549 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
1551 vector<double> v1,v2;
1552 pol1->initLocations();
1553 pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
1562 const double test1_res[4]={0.,1.9124445278727873,0.,0.};
1563 CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10)));
1564 const double test2_res[4]={0.,0.,0.,0.};
1565 CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10)));
1569 * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation.
1571 void QuadraticPlanarInterpTest::checkNonRegression17()
1573 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1574 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1576 -1., 0., 1., 0. , 1.5, 0., -1.5, 0.,
1577 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.};
1579 double coords2[16]={
1580 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444,
1581 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 };
1583 double coords3[16]={
1584 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0.,
1585 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. };
1588 0, 1, 2, 3, 4, 5, 6, 7 };
1589 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1590 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1591 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1594 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1595 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1596 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1599 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1600 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1601 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1604 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1605 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1606 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1611 void QuadraticPlanarInterpTest::checkNormalize()
1613 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
1614 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.);
1615 Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.);
1616 Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.);
1617 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1618 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1619 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
1621 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
1622 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1623 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1624 double area1Start=pol1.getArea();
1625 double fact=pol1.normalize(&pol2);
1626 double area1End=pol1.getArea();
1627 CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14);
1628 CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14);
1629 double area=pol1.intersectWith(pol2);
1630 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14);
1632 n1=new Node(0.,0.); n4=new Node(0.,-3.);
1633 n2=new Node(10.,0.); n5=new Node(10.,-3.);
1634 n3=new Node(5.,10.); n6=new Node(5.,7.);
1635 e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5);
1636 e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6);
1637 e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4);
1638 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
1639 QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4);
1640 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1641 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14);
1642 // Ok testing EdgeArcCircle update.
1643 double center[2]={5.,5.};
1645 EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.);
1646 const Bounds& b=e1->getBounds();
1648 fact2=b.getCaracteristicDim();
1649 b.getBarycenter(x,y);
1650 CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13);
1651 CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10);
1652 e1->getStartNode()->applySimilarity(x,y,fact2);
1653 e1->getEndNode()->applySimilarity(x,y,fact2);
1654 e1->applySimilarity(x,y,fact2);
1655 CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13);
1656 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14);
1657 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13);