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 QUADRATIC_PLANAR::setPrecision(1e-12);
499 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
501 8.8334591186000004, 5.0999999999999996,
502 7.1014083111000001, 6.0999999999999996,
503 7.8334591186000004, 6.8320508074999999,
504 7.9674337149000003, 5.5999999999999996,
505 7.4192455562999999, 6.5142135623000001,
506 8.3334591186000004, 5.9660254036999998
508 std::vector<Node *> nodes;
509 nodes.push_back(new Node(coords));
510 nodes.push_back(new Node(coords+2));
511 nodes.push_back(new Node(coords+4));
512 nodes.push_back(new Node(coords+6));
513 nodes.push_back(new Node(coords+8));
514 nodes.push_back(new Node(coords+10));
515 QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
516 CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5);
517 CPPUNIT_ASSERT_EQUAL(3,pol->size());
518 ElementaryEdge *e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
519 ElementaryEdge *e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
520 ElementaryEdge *e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
521 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
522 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
523 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
524 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
527 nodes.push_back(new Node(coords));
528 nodes.push_back(new Node(coords+4));
529 nodes.push_back(new Node(coords+2));
530 nodes.push_back(new Node(coords+10));
531 nodes.push_back(new Node(coords+8));
532 nodes.push_back(new Node(coords+6));
533 pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
534 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5);
535 CPPUNIT_ASSERT_EQUAL(3,pol->size());
536 e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
537 e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
538 e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
539 CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
540 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
541 CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
542 CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
544 const double coords2[]={
551 nodes.push_back(new Node(coords2));
552 nodes.push_back(new Node(coords2+2));
553 nodes.push_back(new Node(coords2+4));
554 nodes.push_back(new Node(coords2+6));
555 pol=QuadraticPolygon::BuildLinearPolygon(nodes);
556 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12);
558 pol->getBarycenter(tmp,tmp2);
559 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12);
560 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12);
562 const double coords3[]={
563 1.0999999999000001, -1.9052558882999999,
564 1.9052558881999999, -1.0999999999000001,
565 1.7320508075000001, -0.99999999989999999,
566 0.99999999989999999, -1.7320508075000001,
567 1.5556349186, -1.5556349185,
568 1.8186533478, -1.0499999999,
569 1.4142135623000001, -1.4142135623000001,
570 1.0499999999, -1.8186533479
573 nodes.push_back(new Node(coords3));
574 nodes.push_back(new Node(coords3+2));
575 nodes.push_back(new Node(coords3+4));
576 nodes.push_back(new Node(coords3+6));
577 nodes.push_back(new Node(coords3+8));
578 nodes.push_back(new Node(coords3+10));
579 nodes.push_back(new Node(coords3+12));
580 nodes.push_back(new Node(coords3+14));
581 pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
582 pol->getBarycenter(tmp,tmp2);
584 QUADRATIC_PLANAR::setPrecision(1e-14);
587 void QuadraticPlanarInterpTest::check1DInterpLin()
589 QUADRATIC_PLANAR::setPrecision(1e-7);
590 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
591 const int NB_OF_CELL_AXIAL_1=30;
592 static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]=
593 { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500,
594 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500,
595 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356,
597 std::vector<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
599 const int NB_OF_CELL_AXIAL_2=46;
600 static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]=
601 { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356
602 , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15
603 , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700
604 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550
605 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050};
606 std::vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
607 std::map<int,std::map<int,double> > m;
608 Edge::Interpolate1DLin(zLev1,zLev2,m);
609 CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
611 for(int i=0;i<30;i++)
613 CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size());
614 CPPUNIT_ASSERT(m[i][8+i] > 0.15);
617 CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12);
620 const int NB_OF_CELL_AXIAL_3=13;
621 static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={
622 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30,
623 0.35,0.40,0.45,0.50,0.55,0.60 };
624 std::vector<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
625 Edge::Interpolate1DLin(zLev3,zLev1,m);
626 CPPUNIT_ASSERT_EQUAL(13,(int)m.size());
627 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12);
628 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12);
629 for(int i=0;i<11;i++)
631 CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size());
632 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12);
634 QUADRATIC_PLANAR::setPrecision(1e-14);
638 * This test looks if intersectors are in coherency.
640 void QuadraticPlanarInterpTest::checkEpsilonCoherency1()
642 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
643 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
645 const double pol1[]={
646 -2.1083388455000001, 1.2172499999999999,
647 -1.7320508075000001, 1,
648 -1.9201948265, 1.108625
651 const double pol2[]={
653 -1.9381648534, 1.1189999998,
654 -2.1617419990000002, 0.57923702298000002,
655 -1.9381648534, 1.1189999998,
656 -1.9909924031999999, 1.1494999999,
657 -1.9645786283, 1.1342499998
660 Node *n1=new Node(pol1[0],pol1[1]);
661 Node *n2=new Node(pol1[2],pol1[3]);
664 Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef();
665 n1=new Node(pol2[0],pol2[1]);
666 n2=new Node(pol2[4],pol2[5]);
667 n3=new Node(pol2[2],pol2[3]);
668 Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef();
674 * Tests to avoid regressions : Basic one.
676 void QuadraticPlanarInterpTest::checkNonRegression1()
678 const double coords1[]=
680 16.1732057215, -25.110999999800001,
681 16.02555485246479, -25.340997988918762
683 Node *nS1=new Node(coords1);
684 Node *nE1=new Node(coords1+2);
685 const double radius1=2.902;
686 const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692;
687 const double center1[2]={13.66, -23.66};
688 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
690 const double coords2[]=
692 16.041579804000001, -25.350249998999999,
693 16.367740958999999, -24.132999999999999
695 Node *nS2=new Node(coords2);
696 Node *nE2=new Node(coords2+2);
697 const double radius2=2.4345;
698 const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041;
699 const double center2[]={ 13.933240960547204, -24.132999998525658 };
700 EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2);
702 QuadraticPolygon c1,c2;
703 e1->intersectWith(e2,merge,c1,c2);
704 CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size());
705 CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5);
707 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
710 void QuadraticPlanarInterpTest::checkNonRegression2()
712 QUADRATIC_PLANAR::setPrecision(1e-12);
713 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
716 15.141499999899999, -26.226033271399999,
717 16.226033271199999, -25.141499999800001,
718 16.1732057215, -25.110999999800001,
719 15.110999999899999, -26.1732057217,
720 15.755157392699999, -25.755157392499999,
721 16.199619496299999, -25.126249999799999,
722 15.7120238788, -25.712023879099998,
723 15.126249999899999, -26.199619496499999
727 15.933240959000001, -24.132999999999999,
728 15.665291765999999, -25.132999998999999,
729 16.041579804000001, -25.350249998999999,
730 16.367740958999999, -24.132999999999999,
731 15.865092611, -24.650638091000001,
732 15.853435785, -25.241624998999999,
733 16.284787383000001, -24.763094964,
734 16.150490958999999, -24.132999999999999
736 std::vector<Node *> nodes1;
737 nodes1.push_back(new Node(coords1));
738 nodes1.push_back(new Node(coords1+2));
739 nodes1.push_back(new Node(coords1+4));
740 nodes1.push_back(new Node(coords1+6));
741 nodes1.push_back(new Node(coords1+8));
742 nodes1.push_back(new Node(coords1+10));
743 nodes1.push_back(new Node(coords1+12));
744 nodes1.push_back(new Node(coords1+14));
745 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
746 std::vector<Node *> nodes2;
747 nodes2.push_back(new Node(coords2));
748 nodes2.push_back(new Node(coords2+2));
749 nodes2.push_back(new Node(coords2+4));
750 nodes2.push_back(new Node(coords2+6));
751 nodes2.push_back(new Node(coords2+8));
752 nodes2.push_back(new Node(coords2+10));
753 nodes2.push_back(new Node(coords2+12));
754 nodes2.push_back(new Node(coords2+14));
755 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
756 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
757 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
758 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7);
760 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7);
766 * Tests to avoid regressions : Basic one.
768 void QuadraticPlanarInterpTest::checkNonRegression3()
770 const double coords1[]=
772 10.962340811000001, -22.417749999000002,
773 12.217990959, -21.162099852000001
775 Node *nS1=new Node(coords1);
776 Node *nE1=new Node(coords1+2);
777 const double radius1=3.4304999897666599;
778 const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204;
779 const double center1[2]={13.933240950441375, -24.132999992807399};
780 EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
782 const double coords2[]=
784 11.1467942784, -22.2090000002,
785 11.0939667286, -22.178500000099998
787 Node *nS2=new Node(coords2);
788 Node *nE2=new Node(coords2+2);
789 EdgeLin *e2=new EdgeLin(nS2,nE2);
791 QuadraticPolygon c1,c2;
792 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2));
793 CPPUNIT_ASSERT_EQUAL(2,c1.size());
794 CPPUNIT_ASSERT_EQUAL(2,c2.size());
795 ElementaryEdge *tmp1=dynamic_cast<ElementaryEdge *>(c1.front()); CPPUNIT_ASSERT(tmp1);
796 EdgeArcCircle *tmp2=dynamic_cast<EdgeArcCircle *>(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2);
797 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14);
799 nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
802 void QuadraticPlanarInterpTest::checkNonRegression4()
804 QUADRATIC_PLANAR::setPrecision(1e-12);
805 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
808 10.962340811000001, -22.417749999000002,
809 12.217990959, -21.162099852000001,
810 12.051990958999999, -20.874579418,
811 10.674820377, -22.251749999000001,
812 11.507511146000001, -21.707270185999999,
813 12.134990959, -21.018339635,
814 11.272751694, -21.472510735,
815 10.818580594, -22.334749999
820 10.758000000199999, -23.66,
821 11.1467942784, -22.2090000002,
822 11.0939667286, -22.178500000099998,
823 10.696999999999999, -23.66,
824 10.856883252299999, -22.908907131159999,
825 11.1203805035, -22.1937500001,
826 10.797961776699999, -22.893119169449999,
827 10.727500000099999, -23.66
829 std::vector<Node *> nodes1;
830 nodes1.push_back(new Node(coords1));
831 nodes1.push_back(new Node(coords1+2));
832 nodes1.push_back(new Node(coords1+4));
833 nodes1.push_back(new Node(coords1+6));
834 nodes1.push_back(new Node(coords1+8));
835 nodes1.push_back(new Node(coords1+10));
836 nodes1.push_back(new Node(coords1+12));
837 nodes1.push_back(new Node(coords1+14));
838 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
839 std::vector<Node *> nodes2;
840 nodes2.push_back(new Node(coords2));
841 nodes2.push_back(new Node(coords2+2));
842 nodes2.push_back(new Node(coords2+4));
843 nodes2.push_back(new Node(coords2+6));
844 nodes2.push_back(new Node(coords2+8));
845 nodes2.push_back(new Node(coords2+10));
846 nodes2.push_back(new Node(coords2+12));
847 nodes2.push_back(new Node(coords2+14));
848 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
849 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
850 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
851 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
853 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
858 void QuadraticPlanarInterpTest::checkNonRegression5()
860 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
861 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
864 -1.7320508075000001, 1,
865 -1, 1.7320508075000001 ,
866 -1.2172499999999999, 2.1083388455000001,
867 -2.1083388455000001, 1.2172499999999999,
868 -1.4142135623000001, 1.4142135623000001,
869 -1.108625, 1.9201948265,
870 -1.7214514588000001, 1.7214514588000001,
871 -1.9201948265, 1.108625};
876 -1.9381648534, 1.1189999998,
877 -1.9909924031999999, 1.1494999999,
878 -2.2989999998999999, 0,
879 -2.1617419990000002, 0.57923702298000002,
880 -1.9645786283, 1.1342499998,
881 -2.2206634745999998, 0.59502498461999997,
882 -2.2684999997999999, 0};
883 //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941}
884 //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}}
885 std::vector<Node *> nodes1;
886 nodes1.push_back(new Node(coords1));
887 nodes1.push_back(new Node(coords1+2));
888 nodes1.push_back(new Node(coords1+4));
889 nodes1.push_back(new Node(coords1+6));
890 nodes1.push_back(new Node(coords1+8));
891 nodes1.push_back(new Node(coords1+10));
892 nodes1.push_back(new Node(coords1+12));
893 nodes1.push_back(new Node(coords1+14));
894 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
895 std::vector<Node *> nodes2;
896 nodes2.push_back(new Node(coords2));
897 nodes2.push_back(new Node(coords2+2));
898 nodes2.push_back(new Node(coords2+4));
899 nodes2.push_back(new Node(coords2+6));
900 nodes2.push_back(new Node(coords2+8));
901 nodes2.push_back(new Node(coords2+10));
902 nodes2.push_back(new Node(coords2+12));
903 nodes2.push_back(new Node(coords2+14));
904 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
905 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
906 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
907 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
909 //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
914 void QuadraticPlanarInterpTest::checkNonRegression6()
916 QUADRATIC_PLANAR::setPrecision(1e-12);
917 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
920 10.962340811000001, -22.417749999000002,
921 12.217990959, -21.162099852000001,
922 12.051990958999999, -20.874579418,
923 10.674820377, -22.251749999000001,
924 11.507511146000001, -21.707270185999999,
925 12.134990959, -21.018339635,
926 11.272751694, -21.472510735,
927 10.818580594, -22.334749999
931 10.859273844199999, -22.043000000100001,
932 10.806446294799999, -22.012500000199999,
933 10.3650000002, -23.66,
934 10.536195877799999, -22.822979208099998,
935 10.832860069499999, -22.027750000200001,
936 10.477274402499999, -22.80719124657,
937 10.3955000001, -23.66};
938 std::vector<Node *> nodes1;
939 nodes1.push_back(new Node(coords1));
940 nodes1.push_back(new Node(coords1+2));
941 nodes1.push_back(new Node(coords1+4));
942 nodes1.push_back(new Node(coords1+6));
943 nodes1.push_back(new Node(coords1+8));
944 nodes1.push_back(new Node(coords1+10));
945 nodes1.push_back(new Node(coords1+12));
946 nodes1.push_back(new Node(coords1+14));
947 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
948 std::vector<Node *> nodes2;
949 nodes2.push_back(new Node(coords2));
950 nodes2.push_back(new Node(coords2+2));
951 nodes2.push_back(new Node(coords2+4));
952 nodes2.push_back(new Node(coords2+6));
953 nodes2.push_back(new Node(coords2+8));
954 nodes2.push_back(new Node(coords2+10));
955 nodes2.push_back(new Node(coords2+12));
956 nodes2.push_back(new Node(coords2+14));
957 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
958 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
959 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
960 CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7);
966 void QuadraticPlanarInterpTest::checkNonRegression7()
968 QUADRATIC_PLANAR::setPrecision(1e-5);
969 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
973 -1.7320508075000001, 1,
974 -2.1083388455000001, 1.2172499999999999,
975 -2.4344999999999999, 0,
976 -1.9318516525603098, 0.51763809027157182,
977 -1.9201948265, 1.108625,
978 -2.3515464241024469, 0.63009496529570408,
979 -2.2172499999999999, 0
982 { -2.3369999999000002, 0,
983 -2.0239013684999998, 1.1684999999000001,
984 -2.1927763221999998, 1.2659999998,
986 -2.2573686559260442, 0.60486010843437632,
987 -2.1083388453499996, 1.2172499998499999,
988 -2.445724191994314, 0.65532982205982326,
989 -2.4344999998499999, 0 };
990 std::vector<Node *> nodes1;
991 nodes1.push_back(new Node(coords1));
992 nodes1.push_back(new Node(coords1+2));
993 nodes1.push_back(new Node(coords1+4));
994 nodes1.push_back(new Node(coords1+6));
995 nodes1.push_back(new Node(coords1+8));
996 nodes1.push_back(new Node(coords1+10));
997 nodes1.push_back(new Node(coords1+12));
998 nodes1.push_back(new Node(coords1+14));
999 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1000 std::vector<Node *> nodes2;
1001 nodes2.push_back(new Node(coords2));
1002 nodes2.push_back(new Node(coords2+2));
1003 nodes2.push_back(new Node(coords2+4));
1004 nodes2.push_back(new Node(coords2+6));
1005 nodes2.push_back(new Node(coords2+8));
1006 nodes2.push_back(new Node(coords2+10));
1007 nodes2.push_back(new Node(coords2+12));
1008 nodes2.push_back(new Node(coords2+14));
1009 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1010 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1011 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1012 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6);
1018 void QuadraticPlanarInterpTest::checkNonRegression8()
1020 QUADRATIC_PLANAR::setPrecision(1e-3);
1021 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
1024 -13.933240959000001, -28.559499999,
1025 -16.146490959000001, -27.966461449000001,
1026 -16.383240958999998, -28.376524478,
1027 -13.933240959000001, -29.032999999000001,
1028 -15.078903461873765, -28.408670669106311,
1029 -16.264865958999998, -28.1714929635,
1030 -15.201454280317435, -28.866036547696734,
1031 -13.933240959000001, -28.796249999 };
1033 { -16.382999999950002, -28.376524478457149,
1034 -13.933000000014729, -29.03299999982551,
1035 -13.93300000006697, -28.793999999915993,
1036 -16.263500000000001, -28.169544407039268,
1037 -15.201213320921273, -28.866036548734634,
1038 -13.933000000040851, -28.913499999870751,
1039 -15.139355569325469, -28.635180276305853,
1040 -16.323249999975001, -28.273034442748209 };
1041 std::vector<Node *> nodes1;
1042 nodes1.push_back(new Node(coords1));
1043 nodes1.push_back(new Node(coords1+2));
1044 nodes1.push_back(new Node(coords1+4));
1045 nodes1.push_back(new Node(coords1+6));
1046 nodes1.push_back(new Node(coords1+8));
1047 nodes1.push_back(new Node(coords1+10));
1048 nodes1.push_back(new Node(coords1+12));
1049 nodes1.push_back(new Node(coords1+14));
1050 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1051 std::vector<Node *> nodes2;
1052 nodes2.push_back(new Node(coords2));
1053 nodes2.push_back(new Node(coords2+2));
1054 nodes2.push_back(new Node(coords2+4));
1055 nodes2.push_back(new Node(coords2+6));
1056 nodes2.push_back(new Node(coords2+8));
1057 nodes2.push_back(new Node(coords2+10));
1058 nodes2.push_back(new Node(coords2+12));
1059 nodes2.push_back(new Node(coords2+14));
1060 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1061 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1062 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1063 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6);
1069 void QuadraticPlanarInterpTest::checkNonRegression9()
1071 QUADRATIC_PLANAR::setPrecision(1e-7);
1072 QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8);
1075 -0.04476229252902969, -0.085118027765365603,
1076 -0.046952683430894329, -0.085704941238358354,
1077 -0.046952683430894329, -0.088063823748058725,
1078 -0.043582851274179504, -0.087160879944491371,
1079 -0.045818853668170414, -0.085555669718918592,
1080 -0.046952683430894329, -0.086884382493208526,
1081 -0.045208329947517549, -0.087834175256748526,
1082 -0.044172571901604597, -0.086139453854928494 };
1085 { -0.05065868681155701, -0.087744551996665671,
1086 -0.046951871439587615, -0.088737790182236015,
1087 -0.046951871439683469, -0.088063823751059062,
1088 -0.050321703596054014, -0.087160879946116557,
1089 -0.0488706602695924, -0.08848517684025306,
1090 -0.046951871439635542, -0.088400806966647538,
1091 -0.048696224921445964, -0.087834175258503858,
1092 -0.050490195203805516, -0.087452715971391121};
1094 std::vector<Node *> nodes1;
1095 nodes1.push_back(new Node(coords1));
1096 nodes1.push_back(new Node(coords1+2));
1097 nodes1.push_back(new Node(coords1+4));
1098 nodes1.push_back(new Node(coords1+6));
1099 nodes1.push_back(new Node(coords1+8));
1100 nodes1.push_back(new Node(coords1+10));
1101 nodes1.push_back(new Node(coords1+12));
1102 nodes1.push_back(new Node(coords1+14));
1103 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1104 std::vector<Node *> nodes2;
1105 nodes2.push_back(new Node(coords2));
1106 nodes2.push_back(new Node(coords2+2));
1107 nodes2.push_back(new Node(coords2+4));
1108 nodes2.push_back(new Node(coords2+6));
1109 nodes2.push_back(new Node(coords2+8));
1110 nodes2.push_back(new Node(coords2+10));
1111 nodes2.push_back(new Node(coords2+12));
1112 nodes2.push_back(new Node(coords2+14));
1113 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1114 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1115 CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
1120 void QuadraticPlanarInterpTest::checkNonRegression10()
1122 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1123 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1125 { -0.002269581957210453, -0.09851030343724453,
1126 -0.004268022334182935, -0.1059685844580936,
1127 -0.002777851483521377, -0.1023709937816271};
1129 { -0.004114727297178323, -0.1049870239624718,
1130 -0.003544545103522544, -0.1053162188055505};
1131 Node *n1_1=new Node(coords1);
1132 Node *n2_1=new Node(coords1+2);
1133 Node *n3_1=new Node(coords1+4);
1134 Node *n1_2=new Node(coords2);
1135 Node *n2_2=new Node(coords2+2);
1136 EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1);
1137 EdgeLin *e2=new EdgeLin(n1_2,n2_2);
1139 ComposedEdge *c1=new ComposedEdge;
1140 ComposedEdge *c2=new ComposedEdge;
1141 CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2));
1142 CPPUNIT_ASSERT_EQUAL(2,c1->size());
1143 CPPUNIT_ASSERT_EQUAL(2,c2->size());
1144 ComposedEdge::Delete(c1); ComposedEdge::Delete(c2);
1145 n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef();
1146 n1_2->decrRef(); n2_2->decrRef();
1147 e1->decrRef(); e2->decrRef();
1150 void QuadraticPlanarInterpTest::checkNonRegression11()
1152 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1153 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1155 { -0.002269581957210453, -0.09851030343724453,
1156 -0.004268022334182935, -0.1059685844580936,
1157 -0.002886178753789801, -0.1067663922211958,
1158 -0.0006739664310059821, -0.09851030343724453,
1159 -0.002777851483521377, -0.1023709937816271,
1160 -0.003577100543986368, -0.1063674883396447,
1161 -0.001236605237717319, -0.1027839694676665,
1162 -0.001471774194108217, -0.09851030343724453};
1164 { -0.003544545103522544, -0.1053162188055505,
1165 -0.001941023322604723, -0.09851030343724451,
1166 -0.002598140593501099, -0.09851030343724451,
1167 -0.004114727297178323, -0.1049870239624718,
1168 -0.002347317802266182, -0.1020064358043286,
1169 -0.002269581958052911, -0.09851030343724451,
1170 -0.002982346712452072, -0.1018362598405457,
1171 -0.003829636200350435, -0.1051516213840111};
1173 std::vector<Node *> nodes1;
1174 nodes1.push_back(new Node(coords1));
1175 nodes1.push_back(new Node(coords1+2));
1176 nodes1.push_back(new Node(coords1+4));
1177 nodes1.push_back(new Node(coords1+6));
1178 nodes1.push_back(new Node(coords1+8));
1179 nodes1.push_back(new Node(coords1+10));
1180 nodes1.push_back(new Node(coords1+12));
1181 nodes1.push_back(new Node(coords1+14));
1182 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1183 std::vector<Node *> nodes2;
1184 nodes2.push_back(new Node(coords2));
1185 nodes2.push_back(new Node(coords2+2));
1186 nodes2.push_back(new Node(coords2+4));
1187 nodes2.push_back(new Node(coords2+6));
1188 nodes2.push_back(new Node(coords2+8));
1189 nodes2.push_back(new Node(coords2+10));
1190 nodes2.push_back(new Node(coords2+12));
1191 nodes2.push_back(new Node(coords2+14));
1192 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1193 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1194 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1195 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11);
1201 void QuadraticPlanarInterpTest::checkNonRegression12()
1203 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6);
1204 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1206 { -0.5032251558760915, -0.8716087994449138,
1207 -0.4695268343089433, -0.8806382374805872,
1208 -0.4695268343089433, -0.8570494123835835,
1209 -0.4914307433275896, -0.8511802776536561,
1210 -0.4869703691141082, -0.8783417525751493,
1211 -0.4695268343089433, -0.8688438249320853,
1212 -0.480865131947653, -0.8555566971861125,
1213 -0.4973279496018406, -0.8613945385492849};
1216 { -0.5065868681155701, -0.8774455199666568,
1217 -0.4695187143958762, -0.8873779018223601,
1218 -0.4695187143968347, -0.8806382375105907,
1219 -0.5032170359605401, -0.8716087994611657,
1220 -0.488706602695924, -0.8848517684025307,
1221 -0.4695187143963554, -0.8840080696664754,
1222 -0.4869622492144596, -0.8783417525850385,
1223 -0.5049019520380551, -0.8745271597139112};
1225 std::vector<Node *> nodes1;
1226 nodes1.push_back(new Node(coords1));
1227 nodes1.push_back(new Node(coords1+2));
1228 nodes1.push_back(new Node(coords1+4));
1229 nodes1.push_back(new Node(coords1+6));
1230 nodes1.push_back(new Node(coords1+8));
1231 nodes1.push_back(new Node(coords1+10));
1232 nodes1.push_back(new Node(coords1+12));
1233 nodes1.push_back(new Node(coords1+14));
1234 QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
1235 std::vector<Node *> nodes2;
1236 nodes2.push_back(new Node(coords2));
1237 nodes2.push_back(new Node(coords2+2));
1238 nodes2.push_back(new Node(coords2+4));
1239 nodes2.push_back(new Node(coords2+6));
1240 nodes2.push_back(new Node(coords2+8));
1241 nodes2.push_back(new Node(coords2+10));
1242 nodes2.push_back(new Node(coords2+12));
1243 nodes2.push_back(new Node(coords2+14));
1244 QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
1245 std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
1246 CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
1247 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6);
1253 void QuadraticPlanarInterpTest::checkNonRegression13()
1255 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1256 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1258 double coords_1[194]={
1259 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375,
1260 -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1261 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109,
1262 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108,
1263 -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109,
1264 -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108,
1265 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125,
1266 -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125,
1267 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218,
1268 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216,
1269 -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217,
1270 -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216,
1271 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1272 -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1273 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933,
1274 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932,
1275 -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932,
1276 -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932,
1277 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1278 -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1279 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244,
1280 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243,
1281 -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243,
1282 -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243,
1283 2.249646661664983, 0.9318341578089936 };
1286 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15,
1287 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7,
1288 22, 8, 0, 23, 9, 8, 24, 1 };
1291 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15,
1292 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18,
1293 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9,
1294 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36,
1295 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43,
1296 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46,
1297 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61,
1298 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64,
1299 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71,
1300 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 };
1302 double coords_2[20]={
1303 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611,
1304 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611,
1305 0.5922441860137611, 0, -0.5922441860137611, 0 };
1308 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1310 double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2;
1312 const int *work1=tab6_1;
1313 for(int i=0;i<8;i++,work1+=6)
1315 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6);
1316 const int *work2=tab8_2;
1317 for(int j=0;j<2;j++,work2+=8)
1319 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1320 //std::vector<int> tmp;
1321 //pol1->intersectForPoint(*pol2,tmp);
1322 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1323 //pol1->intersectMySelfWith(*pol2);
1329 for(int i=0;i<24;i++,work1+=8)
1331 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8);
1332 const int *work2=tab8_2;
1333 for(int j=0;j<2;j++,work2+=8)
1336 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
1337 //std::vector<int> tmp;
1338 //pol1->intersectForPoint(*pol2,tmp);
1339 pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
1347 Some overlapping cases for intersectForPoint.
1349 void QuadraticPlanarInterpTest::checkNonRegression14()
1351 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1352 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1355 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1356 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1357 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1358 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1359 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1360 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1361 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1362 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1367 8,9,10,11,2,14,12,13,
1368 9,15,16,10,5,17,18,14,
1369 9,15,16,10,34,17,35,14,
1370 19,20,21,22,23,24,25,26,
1371 27,28,29,30,31,32,2,33
1373 QuadraticPolygon *pol1,*pol2;
1374 std::vector<int> goalOfTest;
1376 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1378 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1379 pol1->intersectForPoint(*pol2,goalOfTest);
1380 const int res1[4]={0,1,0,0};
1381 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1382 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1));
1385 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1386 pol1->intersectForPoint(*pol2,goalOfTest);
1387 const int res2[4]={0,2,0,0};
1388 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1389 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2));
1392 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8);
1393 pol1->intersectForPoint(*pol2,goalOfTest);
1394 const int res2Bis[4]={0,2,0,0};
1395 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1396 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis));
1399 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8);
1400 pol1->intersectForPoint(*pol2,goalOfTest);
1401 const int res3[4]={0,3,0,0};
1402 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1403 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3));
1406 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8);
1407 pol1->intersectForPoint(*pol2,goalOfTest);
1408 const int res4[4]={0,4,0,0};
1409 CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
1410 CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4));
1417 * This test is one of the most complicated intersection configuration.
1419 void QuadraticPlanarInterpTest::checkNonRegression15()
1421 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1422 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
1425 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
1426 -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
1427 -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
1428 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
1429 -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
1430 -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
1431 -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
1432 -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
1438 9,15,16,10,7,17,5,14,
1439 9,10,16,15,14,5,17,7
1442 const double RefLgth=3.88995883524451;
1443 const double RefArea=0.383185168001075;
1445 QuadraticPolygon *pol1,*pol2;
1446 //pol1 and pol2 in same orientation
1447 pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
1448 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
1449 std::vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
1450 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1451 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1452 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1453 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1455 //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2
1456 res=pol2->intersectMySelfWith(*pol1);
1457 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1458 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1459 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1460 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1463 //pol1 and pol2 in opposite orientation
1464 pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
1465 res=pol1->intersectMySelfWith(*pol2);
1466 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1467 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1468 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1469 CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12);
1471 //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2
1472 res=pol2->intersectMySelfWith(*pol1);
1473 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1474 CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
1475 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
1476 CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
1486 DoubleEqual(double eps):_eps(eps) { }
1487 bool operator()(double x, double y) { return fabs(x-y)<_eps; }
1493 * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ...
1495 void QuadraticPlanarInterpTest::checkNonRegression16()
1497 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1498 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1499 double coords1[194]={
1500 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375,
1501 -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375,
1502 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108,
1503 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109,
1504 -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108,
1505 -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109,
1506 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125,
1507 -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125,
1508 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216,
1509 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217,
1510 -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216,
1511 -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218,
1512 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875,
1513 -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875,
1514 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932,
1515 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932,
1516 -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932,
1517 -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933,
1518 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625,
1519 -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625,
1520 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243,
1521 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243,
1522 -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243,
1523 -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244,
1524 2.249646661664984, -0.9318341578089931, };
1527 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13,
1528 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18,
1529 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23,
1530 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36,
1531 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41,
1532 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46,
1533 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59,
1534 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64,
1535 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69,
1536 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, };
1538 double coords2[20]={
1539 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435,
1540 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925,
1541 2.56375, 0, -2.56375, 0, };
1543 int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
1545 QuadraticPolygon *pol1,*pol2;
1546 //pol1 and pol2 in same orientation
1547 std::vector<double> test1,test2;
1548 for(int ii=0;ii<24;ii++)
1550 pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
1551 for(int jj=0;jj<2;jj++)
1553 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
1555 std::vector<double> v1,v2;
1556 pol1->initLocations();
1557 pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
1566 const double test1_res[4]={0.,1.9124445278727873,0.,0.};
1567 CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10)));
1568 const double test2_res[4]={0.,0.,0.,0.};
1569 CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10)));
1573 * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation.
1575 void QuadraticPlanarInterpTest::checkNonRegression17()
1577 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
1578 INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
1580 -1., 0., 1., 0. , 1.5, 0., -1.5, 0.,
1581 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.};
1583 double coords2[16]={
1584 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444,
1585 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 };
1587 double coords3[16]={
1588 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0.,
1589 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. };
1592 0, 1, 2, 3, 4, 5, 6, 7 };
1593 QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1594 QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1595 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1598 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1599 pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
1600 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1603 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1604 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1605 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
1608 pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
1609 pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
1610 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
1615 void QuadraticPlanarInterpTest::checkNormalize()
1617 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
1618 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.);
1619 Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.);
1620 Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.);
1621 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1622 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1623 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
1625 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
1626 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1627 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1628 double area1Start=pol1.getArea();
1630 double fact=pol1.normalize(&pol2,xb,yb);
1631 double area1End=pol1.getArea();
1632 CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14);
1633 CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14);
1634 double area=pol1.intersectWith(pol2);
1635 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14);
1637 n1=new Node(0.,0.); n4=new Node(0.,-3.);
1638 n2=new Node(10.,0.); n5=new Node(10.,-3.);
1639 n3=new Node(5.,10.); n6=new Node(5.,7.);
1640 e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5);
1641 e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6);
1642 e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4);
1643 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
1644 QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4);
1645 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
1646 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14);
1647 // Ok testing EdgeArcCircle update.
1648 double center[2]={5.,5.};
1650 EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.);
1651 const Bounds& b=e1->getBounds();
1653 fact2=b.getCaracteristicDim();
1654 b.getBarycenter(x,y);
1655 CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13);
1656 CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10);
1657 e1->getStartNode()->applySimilarity(x,y,fact2);
1658 e1->getEndNode()->applySimilarity(x,y,fact2);
1659 e1->applySimilarity(x,y,fact2);
1660 CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13);
1661 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14);
1662 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13);
1666 void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
1668 INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
1669 Node *n0=new Node(0.,0.); Node *n4=new Node(0.5,0.25);
1670 Node *n1=new Node(0.,0.5); Node *n5=new Node(0.3,1.2);
1671 Node *n2=new Node(1.,0.5); Node *n6=new Node(1.1,1.3);
1672 Node *n3=new Node(1.,0.); Node *n7=new Node(-0.1,0.9);
1673 EdgeLin *e0_1=new EdgeLin(n0,n1);
1674 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
1675 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
1676 EdgeLin *e3_0=new EdgeLin(n3,n0); EdgeLin *e6_4=new EdgeLin(n6,n4);
1677 EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_5=new EdgeLin(n7,n5);
1678 QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0);
1679 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
1680 pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7);
1681 n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
1682 pol1.dumpInXfigFileWithOther(pol2,"tony.fig");