Back to index

salome-med  6.5.0
QuadraticPlanarInterpTest4.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "QuadraticPlanarInterpTest.hxx"
00021 #include "InterpKernelGeo2DQuadraticPolygon.hxx"
00022 #include "InterpKernelGeo2DElementaryEdge.hxx"
00023 #include "InterpKernelGeo2DEdgeArcCircle.hxx"
00024 #include "InterpKernelGeo2DEdgeLin.hxx"
00025 
00026 #include <cmath>
00027 #include <sstream>
00028 #include <iostream>
00029 #include <iterator>
00030 
00031 using namespace INTERP_KERNEL;
00032 
00033 namespace INTERP_TEST
00034 {
00035 
00036 void QuadraticPlanarInterpTest::checkPolygonsIntersection1()
00037 {
00038   //The "most" basic test1
00039   Node *n1=new Node(0.,0.);                Node *n4=new Node(0.,-0.3);   
00040   Node *n2=new Node(1.,0.);                Node *n5=new Node(1.,-0.3);
00041   Node *n3=new Node(0.5,1.);               Node *n6=new Node(0.5,0.7);
00042   EdgeLin *e1_2=new EdgeLin(n1,n2);        EdgeLin *e4_5=new EdgeLin(n4,n5);
00043   EdgeLin *e2_3=new EdgeLin(n2,n3);        EdgeLin *e5_6=new EdgeLin(n5,n6);
00044   EdgeLin *e3_1=new EdgeLin(n3,n1);        EdgeLin *e6_4=new EdgeLin(n6,n4);
00045   //
00046   std::vector<QuadraticPolygon *> result;
00047   for(int k=0;k<2;k++)
00048     for(int i=0;i<3;i++)
00049       {
00050         for(int j=0;j<1;j++)
00051           {
00052             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); 
00053             QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
00054             for(int i1=0;i1<i;i1++) pol1.circularPermute(); if(k==1) pol1.reverse();
00055             QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
00056             for(int j1=0;j1<j;j1++) pol2.circularPermute();
00057             result=pol1.intersectMySelfWith(pol2);
00058             CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
00059             CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00060             double tmp1=0.,tmp2=0.,tmp3=0.;
00061             pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3);
00062             std::vector<double> v1,v2;
00063             std::vector<int> v3;
00064             pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge
00065             pol1.intersectForPoint(pol2,v3);
00066             CPPUNIT_ASSERT_EQUAL(3,(int)v1.size());
00067             CPPUNIT_ASSERT_EQUAL(3,(int)v2.size());
00068             CPPUNIT_ASSERT_EQUAL(3,(int)v3.size());
00069             if(k==0)
00070               {
00071                 CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]);
00072                 CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]);
00073                 CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]);
00074                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14);
00075                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14);
00076                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14);
00077                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14);
00078                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14);
00079                 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14);
00080               }
00081             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14);
00082             CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14);
00083             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge
00084             delete result[0];
00085           }
00086       }
00087   //clean-up for test1
00088   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00089   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00090 
00091   //Deeper test some extremities of pol2 are on edges of pol1.
00092 
00093   n1=new Node(0.,0.);                n4=new Node(1.5,-0.5);   
00094   n2=new Node(1.,0.);                n5=new Node(0.5,0.);
00095   n3=new Node(0.5,1.);               n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5);
00096   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00097   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);
00098   //
00099   for(int k=0;k<2;k++)
00100     for(int i=0;i<3;i++)
00101       {
00102         for(int j=0;j<4;j++)
00103           {
00104             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef();
00105             QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
00106             for(int i1=0;i1<i;i1++) pol3.circularPermute(); if(k==1) pol3.reverse();
00107             QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5);
00108             for(int j1=0;j1<j;j1++) pol4.circularPermute();
00109             result=pol3.intersectMySelfWith(pol4);
00110             CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
00111             CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00112             delete result[0];          
00113           }
00114       }
00115   //clean-up for test2
00116   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef();
00117   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
00118 
00119   //Test with one edge of pol2 is included in pol1.
00120 
00121   n1=new Node(0.,0.);                n4=new Node(-0.5,0.);   
00122   n2=new Node(1.,0.);                n5=new Node(0.,-1.);
00123   n3=new Node(0.5,1.);               n6=new Node(0.5,0.);
00124   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00125   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00126   for(int k=0;k<2;k++)
00127     for(int i=0;i<3;i++)
00128       {
00129         for(int j=0;j<3;j++)
00130           {
00131             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00132             QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1);
00133             for(int i1=0;i1<i;i1++) pol5.circularPermute(); if(k==1) pol5.reverse();
00134             QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4);
00135             for(int j1=0;j1<j;j1++) pol6.circularPermute();
00136             result=pol5.intersectMySelfWith(pol6);
00137             CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
00138           }
00139       }
00140   //clean-up test3
00141   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00142   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00143 
00144   //Test of full overlapped polygons.
00145 
00146   n1=new Node(0.,0.);                n4=new Node(0.,0.);   
00147   n2=new Node(1.,0.);                n5=new Node(1.,0.);
00148   n3=new Node(0.5,1.);               n6=new Node(0.5,1.);
00149   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00150   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00151   for(int k=0;k<2;k++)
00152     for(int i=0;i<3;i++)
00153       {
00154         for(int j=0;j<3;j++)
00155           {
00156             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00157             QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1);
00158             for(int i1=0;i1<i;i1++) pol7.circularPermute(); if(k==1) pol7.reverse();
00159             QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4);
00160             for(int j1=0;j1<j;j1++) pol8.circularPermute();
00161             result=pol7.intersectMySelfWith(pol8);
00162             CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
00163             CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00164             delete result[0];
00165             double tmp1=0.,tmp2=0.,tmp3=0.;
00166             pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3);
00167             std::vector<double> v1,v2;
00168             pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges.
00169             CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14);
00170             CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14);
00171             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14);
00172             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14);
00173             CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14);
00174           }
00175       }
00176   //clean-up test4
00177   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00178   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00179 
00180   //Test of closing process
00181   
00182   n1=new Node(0.,0.);                n4=new Node(0.539,-0.266);   
00183   n2=new Node(1.,0.);                n5=new Node(1.039,0.6);
00184   n3=new Node(0.5,1.);               n6=new Node(-0.077,0.667);
00185   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00186   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00187   for(int k=0;k<2;k++)
00188     for(int i=0;i<3;i++)
00189       {
00190         for(int j=0;j<3;j++)
00191           {
00192             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00193             QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1);
00194             for(int i1=0;i1<i;i1++) pol9.circularPermute(); if(k==1) pol9.reverse();
00195             QuadraticPolygon pol10; pol10.pushBack(e5_6); pol10.pushBack(e6_4); pol10.pushBack(e4_5);
00196             for(int j1=0;j1<j;j1++) pol10.circularPermute();
00197             result=pol9.intersectMySelfWith(pol10);
00198             CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
00199             CPPUNIT_ASSERT_EQUAL(6,result[0]->recursiveSize());
00200             delete result[0];
00201           }
00202       }
00203   //clean-up test5
00204   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00205   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00206 
00207   // Full in case
00208 
00209   n1=new Node(0.,0.);                n4=new Node(0.3,0.1);   
00210   n2=new Node(1.,0.);                n5=new Node(0.7,0.1);
00211   n3=new Node(0.5,1.);               n6=new Node(0.5,0.7);
00212   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00213   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00214   for(int k=0;k<2;k++)
00215     for(int i=0;i<3;i++)
00216       {
00217         for(int j=0;j<3;j++)
00218           {
00219             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00220             QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1);
00221             for(int i1=0;i1<i;i1++) pol11.circularPermute(); if(k==1) pol11.reverse();
00222             QuadraticPolygon pol12; pol12.pushBack(e5_6); pol12.pushBack(e6_4); pol12.pushBack(e4_5);
00223             for(int j1=0;j1<j;j1++) pol12.circularPermute();
00224             result=pol11.intersectMySelfWith(pol12);
00225             CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); checkBasicsOfPolygons(*result[0],*result[0],false);
00226             CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00227             delete result[0];
00228           }
00229       }
00230   //clean-up test6
00231   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00232   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00233 
00234   // Full out case
00235 
00236   n1=new Node(0.,0.);                n4=new Node(-2,0.);   
00237   n2=new Node(1.,0.);                n5=new Node(-1.,0.);
00238   n3=new Node(0.5,1.);               n6=new Node(-1.5,1.);
00239   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00240   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00241   for(int k=0;k<2;k++)
00242     for(int i=0;i<3;i++)
00243       {
00244         for(int j=0;j<3;j++)
00245           {
00246             e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00247             QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1);
00248             for(int i1=0;i1<i;i1++) pol13.circularPermute(); if(k==1) pol13.reverse();
00249             QuadraticPolygon pol14; pol14.pushBack(e5_6); pol14.pushBack(e6_4); pol14.pushBack(e4_5);
00250             for(int j1=0;j1<j;j1++) pol14.circularPermute();
00251             result=pol13.intersectMySelfWith(pol14);
00252             CPPUNIT_ASSERT_EQUAL(0,(int)result.size());
00253           }
00254       }
00255   //clean-up test7
00256   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00257   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00258 
00259   //Multi polygons
00260   
00261   n1=new Node(0.,0.);
00262   n2=new Node(1.,0.);
00263   n3=new Node(1.,1.);
00264   n4=new Node(0.,1.);
00265   //
00266   n5=new Node(0.2,0.7);
00267   n6=new Node(0.4,0.7);
00268   n7=new Node(0.4,1.3);
00269   Node *n8=new Node(0.6,1.3);
00270   Node *n9=new Node(0.6,0.7);
00271   Node *n10=new Node(0.9,0.7);
00272   Node *n11=new Node(0.9,2.);
00273   Node *n12=new Node(0.2,2.);
00274   //
00275   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);
00276   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);
00277   Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5);
00278   //
00279   for(int k=0;k<2;k++)
00280     for(int i=0;i<4;i++)
00281       {
00282         for(int j=0;j<8;j++)
00283           {
00284             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();
00285             QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1);
00286             for(int i1=0;i1<i;i1++) pol15.circularPermute(); if(k==1) pol15.reverse();
00287             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);
00288             for(int j1=0;j1<j;j1++) pol16.circularPermute();
00289             result=pol15.intersectMySelfWith(pol16);
00290             CPPUNIT_ASSERT_EQUAL(2,(int)result.size());
00291             checkBasicsOfPolygons(*result[0],*result[1],false);
00292             CPPUNIT_ASSERT_EQUAL(4,result[0]->recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize());
00293             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10);
00294             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10);
00295             CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10);
00296             delete result[0]; delete result[1];
00297           }
00298       }
00299   //clean-up test8
00300   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();
00301   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef();
00302 }
00303 
00307 void QuadraticPlanarInterpTest::checkPolygonsIntersection2()
00308 {
00309   Node *n1=new Node(0.,0.);          Node *n4=new Node(0.2,0.2);
00310   Node *n2=new Node(1.,0.);          Node *n5=new Node(0.8,0.2);
00311   Node *n3=new Node(0.5,1.);         Node *n6=new Node(0.5,0.8);
00312   Edge *e1_2=new EdgeLin(n1,n2);     Edge *e4_5=new EdgeLin(n4,n5);
00313   Edge *e2_3=new EdgeLin(n2,n3);     Edge *e5_6=new EdgeLin(n5,n6);
00314   Edge *e3_1=new EdgeLin(n3,n1);     Edge *e6_4=new EdgeLin(n6,n4);
00315   //
00316   QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
00317   QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
00318   std::vector<QuadraticPolygon *> result=pol1.intersectMySelfWith(pol2);
00319   CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
00320   CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00321   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
00322   delete result[0];
00323   result.clear();
00324   pol1.initLocations();
00325   pol2.initLocations();
00326   result=pol2.intersectMySelfWith(pol1);
00327   CPPUNIT_ASSERT_EQUAL(1,(int)result.size());
00328   CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
00329   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10);
00330   delete result[0];
00331   //clean-up
00332   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00333 }
00334 
00335 void QuadraticPlanarInterpTest::checkAreasCalculations()
00336 {
00337   Node *n1=new Node(0.,0.);
00338   Node *n2=new Node(1.,0.);
00339   Node *n3=new Node(0.5,1.);
00340   Edge *e1_2=new EdgeLin(n1,n2);
00341   Edge *e2_3=new EdgeLin(n2,n3);
00342   Edge *e3_1=new EdgeLin(n3,n1);
00343   //
00344   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
00345   QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
00346   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10);
00347   CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10);
00348   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10);
00349   pol1.reverse();
00350   CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5,pol1.getArea(),1e-10);
00351   CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10);
00352   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10);
00353   //clean-up
00354   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
00355   n1->decrRef(); n2->decrRef(); n3->decrRef();
00356 
00357   //case 2
00358 
00359   n1=new Node(0.,0.);
00360   n2=new Node(1.,0.);
00361   Node *n3m=new Node(1.5,0.5);
00362   n3=new Node(1.,1.);
00363   Node *n4=new Node(0.,1.);
00364   e1_2=new EdgeLin(n1,n2);
00365   e2_3=new EdgeArcCircle(n2,n3m,n3);
00366   Edge *e3_4=new EdgeLin(n3,n4);
00367   Edge *e4_1=new EdgeLin(n4,n1);
00368   //
00369   for(int k=0;k<8;k++)
00370     {
00371       n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4));
00372       n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4));
00373       n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4));
00374       n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2));
00375       e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m);
00376       e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
00377       QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1);
00378       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6);
00379       CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
00380       pol2.reverse();
00381       CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6);
00382       CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6);
00383     }
00384   //clean-up case2
00385   e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); 
00386   n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
00387   
00388   //case 3
00389 
00390   const double radius1=0.7;
00391   const double radius2=0.9;
00392   n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.));
00393   n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.));
00394   Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.));
00395   n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.));
00396   n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.));
00397   n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.));
00398   e1_2=new EdgeArcCircle(n1,n2m,n2);
00399   e2_3=new EdgeLin(n2,n3);
00400   e3_4=new EdgeArcCircle(n3,n3m,n4);
00401   e4_1=new EdgeLin(n4,n1);
00402   //
00403   e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef();
00404   QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1);
00405   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10);
00406   CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
00407   pol3.reverse();
00408   CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10);
00409   CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10);
00410   //clean-up case3
00411   e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); 
00412   n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef();
00413 }
00414 
00415 void QuadraticPlanarInterpTest::checkBarycenterCalculations()
00416 {
00417   Node *n1=new Node(3.,7.);
00418   Node *n2=new Node(5.,7.);
00419   Node *n3=new Node(4.,8.);
00420   Edge *e1_2=new EdgeLin(n1,n2);
00421   Edge *e2_3=new EdgeLin(n2,n3);
00422   Edge *e3_1=new EdgeLin(n3,n1);
00423   //
00424   double bary[2];
00425   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
00426   QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
00427   bary[0]=0.; bary[1]=0.;
00428   e1_2->getBarycenterOfZone(bary);
00429   CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10);
00430   bary[0]=0.; bary[1]=0.;
00431   e2_3->getBarycenterOfZone(bary);
00432   CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10);
00433   CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10);
00434   bary[0]=0.; bary[1]=0.;
00435   e3_1->getBarycenterOfZone(bary);
00436   CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10);
00437   CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10);
00438   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10);
00439   pol1.getBarycenter(bary);
00440   CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
00441   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
00442   //
00443   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
00444   QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false);
00445   CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10);
00446   pol4.getBarycenter(bary);
00447   CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
00448   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
00449   //clean-up
00450   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
00451   n1->decrRef(); n2->decrRef(); n3->decrRef();
00452   //Inverting polygon
00453   n1=new Node(3.,7.);
00454   n2=new Node(5.,7.);
00455   n3=new Node(4.,8.);
00456   e1_2=new EdgeLin(n1,n3);
00457   e2_3=new EdgeLin(n3,n2);
00458   e3_1=new EdgeLin(n2,n1);
00459   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef();
00460   QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
00461   bary[0]=0.; bary[1]=0.;
00462   pol3.getBarycenter(bary);
00463   CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10);
00464   CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10);
00465   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10);
00466   //clean-up
00467   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef();
00468   n1->decrRef(); n2->decrRef(); n3->decrRef();
00469   //
00470   double center[2]={3.,7.};
00471   e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.);
00472   bary[0]=0.; bary[1]=0.;
00473   e1_2->getBarycenterOfZone(bary);
00474   CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10);
00475   CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10);
00476   n1=new Node(0.99999999999999822,3.5358983848622465);
00477   n2=new Node(5.,10.4641016151377544);
00478   Edge *e2_1=new EdgeLin(n1,n2);
00479   //
00480   e1_2->incrRef(); e2_1->incrRef();
00481   QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1);
00482   pol2.getBarycenter(bary);
00483   CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10);
00484   //4*radius/(3.*pi)
00485   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10);
00486   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10);
00487   //clean-up
00488   e1_2->decrRef(); e2_1->decrRef();
00489   n1->decrRef(); n2->decrRef();
00490 }
00491 
00495 void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
00496 {
00497   QUADRATIC_PLANAR::setPrecision(1e-12);
00498   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
00499   double coords[]={
00500     8.8334591186000004, 5.0999999999999996,
00501     7.1014083111000001, 6.0999999999999996,
00502     7.8334591186000004, 6.8320508074999999,
00503     7.9674337149000003, 5.5999999999999996,
00504     7.4192455562999999, 6.5142135623000001,
00505     8.3334591186000004, 5.9660254036999998
00506   };
00507   std::vector<Node *> nodes;
00508   nodes.push_back(new Node(coords));
00509   nodes.push_back(new Node(coords+2));
00510   nodes.push_back(new Node(coords+4));
00511   nodes.push_back(new Node(coords+6));
00512   nodes.push_back(new Node(coords+8));
00513   nodes.push_back(new Node(coords+10));
00514   QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
00515   CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5);
00516   CPPUNIT_ASSERT_EQUAL(3,pol->size());
00517   ElementaryEdge *e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
00518   ElementaryEdge *e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
00519   ElementaryEdge *e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
00520   CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
00521   CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
00522   CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
00523   CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
00524   nodes.clear();
00525   delete pol;
00526   nodes.push_back(new Node(coords));
00527   nodes.push_back(new Node(coords+4));
00528   nodes.push_back(new Node(coords+2));
00529   nodes.push_back(new Node(coords+10));
00530   nodes.push_back(new Node(coords+8));
00531   nodes.push_back(new Node(coords+6));
00532   pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
00533   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5);
00534   CPPUNIT_ASSERT_EQUAL(3,pol->size());
00535   e0=dynamic_cast<ElementaryEdge *>((*pol)[0]);
00536   e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
00537   e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
00538   CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
00539   CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
00540   CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
00541   CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
00542   delete pol;
00543   const double coords2[]={
00544     0.,0.,
00545     1.5,0.,
00546     1.5,1.,
00547     0.,1.
00548   };
00549   nodes.clear();
00550   nodes.push_back(new Node(coords2));
00551   nodes.push_back(new Node(coords2+2));
00552   nodes.push_back(new Node(coords2+4));
00553   nodes.push_back(new Node(coords2+6));
00554   pol=QuadraticPolygon::BuildLinearPolygon(nodes);
00555   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12);
00556   double tmp[2],tmp2;
00557   pol->getBarycenter(tmp,tmp2);
00558   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12);
00559   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12);
00560   delete pol;
00561   const double coords3[]={
00562     1.0999999999000001, -1.9052558882999999,
00563     1.9052558881999999, -1.0999999999000001,
00564     1.7320508075000001, -0.99999999989999999,
00565     0.99999999989999999, -1.7320508075000001,
00566     1.5556349186, -1.5556349185,
00567     1.8186533478, -1.0499999999,
00568     1.4142135623000001, -1.4142135623000001,
00569     1.0499999999, -1.8186533479
00570   };
00571   nodes.clear();
00572   nodes.push_back(new Node(coords3));
00573   nodes.push_back(new Node(coords3+2));
00574   nodes.push_back(new Node(coords3+4));
00575   nodes.push_back(new Node(coords3+6));
00576   nodes.push_back(new Node(coords3+8));
00577   nodes.push_back(new Node(coords3+10));
00578   nodes.push_back(new Node(coords3+12));
00579   nodes.push_back(new Node(coords3+14));
00580   pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
00581   pol->getBarycenter(tmp,tmp2);
00582   delete pol;
00583   QUADRATIC_PLANAR::setPrecision(1e-14);
00584 }
00585 
00586 void QuadraticPlanarInterpTest::check1DInterpLin()
00587 {
00588   QUADRATIC_PLANAR::setPrecision(1e-7);
00589   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
00590   const int NB_OF_CELL_AXIAL_1=30;
00591   static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]=
00592     { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194,  0.0000 , 0.0500, 
00593       0.1000 , 0.1500 , 0.2000 , 0.2500,  0.3000,  0.3500,  0.4000,  0.4500,  0.5000,  0.5500, 
00594       0.6000,  0.6500,  0.7000,  0.7194,  0.7388,  0.7581,  0.7775,  0.7969,  0.8163,  0.8356, 
00595       0.8550};
00596   std::vector<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
00597 
00598   const int NB_OF_CELL_AXIAL_2=46;
00599   static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]=
00600     { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356  
00601       , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15 
00602       ,  0.20,  0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700
00603       , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550
00604       ,  0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050};
00605   std::vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
00606   std::map<int,std::map<int,double> > m;
00607   Edge::Interpolate1DLin(zLev1,zLev2,m);
00608   CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
00609   double ret=0;
00610   for(int i=0;i<30;i++)
00611     {
00612       CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size());
00613       CPPUNIT_ASSERT(m[i][8+i] > 0.15);
00614       ret+=m[i][8+i];
00615     }
00616   CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12);
00617   //
00618   m.clear();
00619   const int NB_OF_CELL_AXIAL_3=13;
00620   static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={
00621     0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30,
00622     0.35,0.40,0.45,0.50,0.55,0.60 };
00623   std::vector<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
00624   Edge::Interpolate1DLin(zLev3,zLev1,m);
00625   CPPUNIT_ASSERT_EQUAL(13,(int)m.size());
00626   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12);
00627   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12);
00628   for(int i=0;i<11;i++)
00629     {
00630       CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size());
00631       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12);
00632     }
00633   QUADRATIC_PLANAR::setPrecision(1e-14);
00634 }
00635 
00639 void QuadraticPlanarInterpTest::checkEpsilonCoherency1()
00640 {
00641   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
00642   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
00643 
00644   const double pol1[]={
00645     -2.1083388455000001, 1.2172499999999999,
00646     -1.7320508075000001, 1,
00647     -1.9201948265, 1.108625
00648   };
00649 
00650   const double pol2[]={
00651     -2.2379999998, 0,
00652     -1.9381648534, 1.1189999998,
00653     -2.1617419990000002, 0.57923702298000002,
00654     -1.9381648534, 1.1189999998,
00655     -1.9909924031999999, 1.1494999999,
00656     -1.9645786283, 1.1342499998
00657   };
00658   //
00659   Node *n1=new Node(pol1[0],pol1[1]);
00660   Node *n2=new Node(pol1[2],pol1[3]);
00661   Node *n3;
00662   //
00663   Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef();
00664   n1=new Node(pol2[0],pol2[1]);
00665   n2=new Node(pol2[4],pol2[5]);
00666   n3=new Node(pol2[2],pol2[3]);
00667   Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef();
00668   e2->decrRef();
00669   e1->decrRef();
00670 }
00671 
00675 void QuadraticPlanarInterpTest::checkNonRegression1()
00676 {
00677   const double coords1[]=
00678     {
00679       16.1732057215, -25.110999999800001,
00680       16.02555485246479, -25.340997988918762
00681     };
00682   Node *nS1=new Node(coords1);
00683   Node *nE1=new Node(coords1+2);
00684   const double radius1=2.902;
00685   const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692;
00686   const double center1[2]={13.66, -23.66};
00687   EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
00688   //
00689   const double coords2[]=
00690     {
00691       16.041579804000001, -25.350249998999999,
00692       16.367740958999999, -24.132999999999999
00693     };
00694   Node *nS2=new Node(coords2);
00695   Node *nE2=new Node(coords2+2);
00696   const double radius2=2.4345;
00697   const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041;
00698   const double center2[]={ 13.933240960547204, -24.132999998525658 };
00699   EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2);
00700   MergePoints merge;
00701   QuadraticPolygon c1,c2;
00702   e1->intersectWith(e2,merge,c1,c2);
00703   CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size());
00704   CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5);
00705   //clean-up
00706   nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
00707 }
00708 
00709 void QuadraticPlanarInterpTest::checkNonRegression2()
00710 {
00711   QUADRATIC_PLANAR::setPrecision(1e-12);
00712   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
00713   double coords1[]=
00714     {
00715       15.141499999899999, -26.226033271399999,
00716       16.226033271199999, -25.141499999800001,
00717       16.1732057215, -25.110999999800001,
00718       15.110999999899999, -26.1732057217,
00719       15.755157392699999, -25.755157392499999,
00720       16.199619496299999, -25.126249999799999,
00721       15.7120238788, -25.712023879099998,
00722       15.126249999899999, -26.199619496499999
00723     };
00724   double coords2[]=
00725     {
00726       15.933240959000001, -24.132999999999999,
00727       15.665291765999999, -25.132999998999999,
00728       16.041579804000001, -25.350249998999999,
00729       16.367740958999999, -24.132999999999999,
00730       15.865092611, -24.650638091000001,
00731       15.853435785, -25.241624998999999,
00732       16.284787383000001, -24.763094964,
00733       16.150490958999999, -24.132999999999999
00734     };
00735   std::vector<Node *> nodes1;
00736   nodes1.push_back(new Node(coords1));
00737   nodes1.push_back(new Node(coords1+2));
00738   nodes1.push_back(new Node(coords1+4));
00739   nodes1.push_back(new Node(coords1+6));
00740   nodes1.push_back(new Node(coords1+8));
00741   nodes1.push_back(new Node(coords1+10));
00742   nodes1.push_back(new Node(coords1+12));
00743   nodes1.push_back(new Node(coords1+14));
00744   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
00745   std::vector<Node *> nodes2;
00746   nodes2.push_back(new Node(coords2));
00747   nodes2.push_back(new Node(coords2+2));
00748   nodes2.push_back(new Node(coords2+4));
00749   nodes2.push_back(new Node(coords2+6));
00750   nodes2.push_back(new Node(coords2+8));
00751   nodes2.push_back(new Node(coords2+10));
00752   nodes2.push_back(new Node(coords2+12));
00753   nodes2.push_back(new Node(coords2+14));
00754   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
00755   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
00756   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
00757   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7);
00758   delete v[0];
00759   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7);
00760   delete pol1;
00761   delete pol2;
00762 }
00763 
00767 void QuadraticPlanarInterpTest::checkNonRegression3()
00768 {
00769   const double coords1[]=
00770     {
00771       10.962340811000001, -22.417749999000002,
00772       12.217990959, -21.162099852000001
00773     };
00774   Node *nS1=new Node(coords1);
00775   Node *nE1=new Node(coords1+2);
00776   const double radius1=3.4304999897666599;
00777   const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204;
00778   const double center1[2]={13.933240950441375, -24.132999992807399};
00779   EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1);
00780   //
00781   const double coords2[]=
00782     {
00783       11.1467942784, -22.2090000002,
00784       11.0939667286, -22.178500000099998
00785     };
00786   Node *nS2=new Node(coords2);
00787   Node *nE2=new Node(coords2+2);
00788   EdgeLin *e2=new EdgeLin(nS2,nE2);
00789   MergePoints merge;
00790   QuadraticPolygon c1,c2;
00791   CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2));
00792   CPPUNIT_ASSERT_EQUAL(2,c1.size());
00793   CPPUNIT_ASSERT_EQUAL(2,c2.size());
00794   ElementaryEdge *tmp1=dynamic_cast<ElementaryEdge *>(c1.front()); CPPUNIT_ASSERT(tmp1);
00795   EdgeArcCircle *tmp2=dynamic_cast<EdgeArcCircle *>(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2);
00796   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14);
00797   //clean-up
00798   nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef();
00799 }
00800 
00801 void QuadraticPlanarInterpTest::checkNonRegression4()
00802 {
00803   QUADRATIC_PLANAR::setPrecision(1e-12);
00804   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
00805   double coords1[]=
00806     {
00807       10.962340811000001, -22.417749999000002,
00808       12.217990959, -21.162099852000001,
00809       12.051990958999999, -20.874579418,
00810       10.674820377, -22.251749999000001,
00811       11.507511146000001, -21.707270185999999,
00812       12.134990959, -21.018339635,
00813       11.272751694, -21.472510735,
00814       10.818580594, -22.334749999
00815     };
00816 
00817   double coords2[]=
00818     {
00819       10.758000000199999, -23.66,
00820       11.1467942784, -22.2090000002,
00821       11.0939667286, -22.178500000099998,
00822       10.696999999999999, -23.66,
00823       10.856883252299999, -22.908907131159999,
00824       11.1203805035, -22.1937500001,
00825       10.797961776699999, -22.893119169449999,
00826       10.727500000099999, -23.66
00827     };
00828   std::vector<Node *> nodes1;
00829   nodes1.push_back(new Node(coords1));
00830   nodes1.push_back(new Node(coords1+2));
00831   nodes1.push_back(new Node(coords1+4));
00832   nodes1.push_back(new Node(coords1+6));
00833   nodes1.push_back(new Node(coords1+8));
00834   nodes1.push_back(new Node(coords1+10));
00835   nodes1.push_back(new Node(coords1+12));
00836   nodes1.push_back(new Node(coords1+14));
00837   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
00838   std::vector<Node *> nodes2;
00839   nodes2.push_back(new Node(coords2));
00840   nodes2.push_back(new Node(coords2+2));
00841   nodes2.push_back(new Node(coords2+4));
00842   nodes2.push_back(new Node(coords2+6));
00843   nodes2.push_back(new Node(coords2+8));
00844   nodes2.push_back(new Node(coords2+10));
00845   nodes2.push_back(new Node(coords2+12));
00846   nodes2.push_back(new Node(coords2+14));
00847   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
00848   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
00849   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
00850   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
00851   delete v[0];
00852   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
00853   delete pol1;
00854   delete pol2;
00855 }
00856 
00857 void QuadraticPlanarInterpTest::checkNonRegression5()
00858 {
00859   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12);
00860   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
00861   double coords1[]=
00862     {
00863       -1.7320508075000001, 1,
00864       -1, 1.7320508075000001 ,
00865       -1.2172499999999999, 2.1083388455000001,
00866       -2.1083388455000001, 1.2172499999999999,
00867       -1.4142135623000001, 1.4142135623000001,
00868       -1.108625, 1.9201948265,
00869       -1.7214514588000001, 1.7214514588000001,
00870       -1.9201948265, 1.108625};
00871 
00872   double coords2[]=
00873     {
00874       -2.2379999998, 0,
00875       -1.9381648534, 1.1189999998,
00876       -1.9909924031999999, 1.1494999999,
00877       -2.2989999998999999, 0,
00878       -2.1617419990000002, 0.57923702298000002,
00879       -1.9645786283, 1.1342499998,
00880       -2.2206634745999998, 0.59502498461999997,
00881       -2.2684999997999999, 0};
00882   //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941}
00883   //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}}
00884   std::vector<Node *> nodes1;
00885   nodes1.push_back(new Node(coords1));
00886   nodes1.push_back(new Node(coords1+2));
00887   nodes1.push_back(new Node(coords1+4));
00888   nodes1.push_back(new Node(coords1+6));
00889   nodes1.push_back(new Node(coords1+8));
00890   nodes1.push_back(new Node(coords1+10));
00891   nodes1.push_back(new Node(coords1+12));
00892   nodes1.push_back(new Node(coords1+14));
00893   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
00894   std::vector<Node *> nodes2;
00895   nodes2.push_back(new Node(coords2));
00896   nodes2.push_back(new Node(coords2+2));
00897   nodes2.push_back(new Node(coords2+4));
00898   nodes2.push_back(new Node(coords2+6));
00899   nodes2.push_back(new Node(coords2+8));
00900   nodes2.push_back(new Node(coords2+10));
00901   nodes2.push_back(new Node(coords2+12));
00902   nodes2.push_back(new Node(coords2+14));
00903   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
00904   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
00905   CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
00906   //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7);
00907   //delete v[0];
00908   //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7);
00909   delete pol1;
00910   delete pol2;
00911 }
00912 
00913 void QuadraticPlanarInterpTest::checkNonRegression6()
00914 {
00915   QUADRATIC_PLANAR::setPrecision(1e-12);
00916   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
00917   double coords1[]=
00918     {
00919       10.962340811000001, -22.417749999000002,
00920       12.217990959, -21.162099852000001,
00921       12.051990958999999, -20.874579418,
00922       10.674820377, -22.251749999000001,
00923       11.507511146000001, -21.707270185999999,
00924       12.134990959, -21.018339635,
00925       11.272751694, -21.472510735,
00926       10.818580594, -22.334749999
00927     };
00928   double coords2[]=
00929     { 10.426, -23.66,
00930       10.859273844199999, -22.043000000100001,
00931       10.806446294799999, -22.012500000199999,
00932       10.3650000002, -23.66,
00933       10.536195877799999, -22.822979208099998,
00934       10.832860069499999, -22.027750000200001,
00935       10.477274402499999, -22.80719124657,
00936       10.3955000001, -23.66};
00937   std::vector<Node *> nodes1;
00938   nodes1.push_back(new Node(coords1));
00939   nodes1.push_back(new Node(coords1+2));
00940   nodes1.push_back(new Node(coords1+4));
00941   nodes1.push_back(new Node(coords1+6));
00942   nodes1.push_back(new Node(coords1+8));
00943   nodes1.push_back(new Node(coords1+10));
00944   nodes1.push_back(new Node(coords1+12));
00945   nodes1.push_back(new Node(coords1+14));
00946   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
00947   std::vector<Node *> nodes2;
00948   nodes2.push_back(new Node(coords2));
00949   nodes2.push_back(new Node(coords2+2));
00950   nodes2.push_back(new Node(coords2+4));
00951   nodes2.push_back(new Node(coords2+6));
00952   nodes2.push_back(new Node(coords2+8));
00953   nodes2.push_back(new Node(coords2+10));
00954   nodes2.push_back(new Node(coords2+12));
00955   nodes2.push_back(new Node(coords2+14));
00956   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
00957   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
00958   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
00959   CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7);
00960   delete v[0];
00961   delete pol1;
00962   delete pol2;
00963 }
00964 
00965 void QuadraticPlanarInterpTest::checkNonRegression7()
00966 {
00967   QUADRATIC_PLANAR::setPrecision(1e-5);
00968   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
00969   double coords1[]=
00970     {
00971       -2., 0,
00972       -1.7320508075000001, 1,
00973       -2.1083388455000001, 1.2172499999999999,
00974       -2.4344999999999999, 0,
00975       -1.9318516525603098, 0.51763809027157182,
00976       -1.9201948265, 1.108625,
00977       -2.3515464241024469, 0.63009496529570408,
00978       -2.2172499999999999, 0
00979     };
00980   double coords2[]=
00981     { -2.3369999999000002, 0,
00982       -2.0239013684999998, 1.1684999999000001,
00983       -2.1927763221999998, 1.2659999998,
00984       -2.5319999998, 0,
00985       -2.2573686559260442, 0.60486010843437632,
00986       -2.1083388453499996, 1.2172499998499999,
00987       -2.445724191994314, 0.65532982205982326,
00988       -2.4344999998499999, 0 };
00989   std::vector<Node *> nodes1;
00990   nodes1.push_back(new Node(coords1));
00991   nodes1.push_back(new Node(coords1+2));
00992   nodes1.push_back(new Node(coords1+4));
00993   nodes1.push_back(new Node(coords1+6));
00994   nodes1.push_back(new Node(coords1+8));
00995   nodes1.push_back(new Node(coords1+10));
00996   nodes1.push_back(new Node(coords1+12));
00997   nodes1.push_back(new Node(coords1+14));
00998   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
00999   std::vector<Node *> nodes2;
01000   nodes2.push_back(new Node(coords2));
01001   nodes2.push_back(new Node(coords2+2));
01002   nodes2.push_back(new Node(coords2+4));
01003   nodes2.push_back(new Node(coords2+6));
01004   nodes2.push_back(new Node(coords2+8));
01005   nodes2.push_back(new Node(coords2+10));
01006   nodes2.push_back(new Node(coords2+12));
01007   nodes2.push_back(new Node(coords2+14));
01008   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
01009   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
01010   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
01011   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6);
01012   delete v[0];
01013   delete pol1;
01014   delete pol2;
01015 }
01016 
01017 void QuadraticPlanarInterpTest::checkNonRegression8()
01018 {
01019   QUADRATIC_PLANAR::setPrecision(1e-3);
01020   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
01021   double coords1[]=
01022     {
01023       -13.933240959000001, -28.559499999,
01024       -16.146490959000001, -27.966461449000001,
01025       -16.383240958999998, -28.376524478,
01026       -13.933240959000001, -29.032999999000001,
01027       -15.078903461873765, -28.408670669106311,
01028       -16.264865958999998, -28.1714929635,
01029       -15.201454280317435, -28.866036547696734,
01030       -13.933240959000001, -28.796249999 };
01031   double coords2[]=
01032     { -16.382999999950002, -28.376524478457149,
01033       -13.933000000014729, -29.03299999982551,
01034       -13.93300000006697, -28.793999999915993,
01035       -16.263500000000001, -28.169544407039268,
01036       -15.201213320921273, -28.866036548734634,
01037       -13.933000000040851, -28.913499999870751,
01038       -15.139355569325469, -28.635180276305853,
01039       -16.323249999975001, -28.273034442748209 };
01040   std::vector<Node *> nodes1;
01041   nodes1.push_back(new Node(coords1));
01042   nodes1.push_back(new Node(coords1+2));
01043   nodes1.push_back(new Node(coords1+4));
01044   nodes1.push_back(new Node(coords1+6));
01045   nodes1.push_back(new Node(coords1+8));
01046   nodes1.push_back(new Node(coords1+10));
01047   nodes1.push_back(new Node(coords1+12));
01048   nodes1.push_back(new Node(coords1+14));
01049   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
01050   std::vector<Node *> nodes2;
01051   nodes2.push_back(new Node(coords2));
01052   nodes2.push_back(new Node(coords2+2));
01053   nodes2.push_back(new Node(coords2+4));
01054   nodes2.push_back(new Node(coords2+6));
01055   nodes2.push_back(new Node(coords2+8));
01056   nodes2.push_back(new Node(coords2+10));
01057   nodes2.push_back(new Node(coords2+12));
01058   nodes2.push_back(new Node(coords2+14));
01059   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
01060   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
01061   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
01062   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6);
01063   delete v[0];
01064   delete pol1;
01065   delete pol2;
01066 }
01067 
01068 void QuadraticPlanarInterpTest::checkNonRegression9()
01069 {
01070   QUADRATIC_PLANAR::setPrecision(1e-7);
01071   QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8);
01072   double coords1[]=
01073     {
01074       -0.04476229252902969, -0.085118027765365603,
01075       -0.046952683430894329, -0.085704941238358354,
01076       -0.046952683430894329, -0.088063823748058725,
01077       -0.043582851274179504, -0.087160879944491371,
01078       -0.045818853668170414, -0.085555669718918592,
01079       -0.046952683430894329, -0.086884382493208526,
01080       -0.045208329947517549, -0.087834175256748526,
01081       -0.044172571901604597, -0.086139453854928494 };
01082 
01083   double coords2[]=
01084     { -0.05065868681155701, -0.087744551996665671,
01085       -0.046951871439587615, -0.088737790182236015,
01086       -0.046951871439683469, -0.088063823751059062,
01087       -0.050321703596054014, -0.087160879946116557,
01088       -0.0488706602695924, -0.08848517684025306,
01089       -0.046951871439635542, -0.088400806966647538,
01090       -0.048696224921445964, -0.087834175258503858,
01091       -0.050490195203805516, -0.087452715971391121};
01092 
01093   std::vector<Node *> nodes1;
01094   nodes1.push_back(new Node(coords1));
01095   nodes1.push_back(new Node(coords1+2));
01096   nodes1.push_back(new Node(coords1+4));
01097   nodes1.push_back(new Node(coords1+6));
01098   nodes1.push_back(new Node(coords1+8));
01099   nodes1.push_back(new Node(coords1+10));
01100   nodes1.push_back(new Node(coords1+12));
01101   nodes1.push_back(new Node(coords1+14));
01102   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
01103   std::vector<Node *> nodes2;
01104   nodes2.push_back(new Node(coords2));
01105   nodes2.push_back(new Node(coords2+2));
01106   nodes2.push_back(new Node(coords2+4));
01107   nodes2.push_back(new Node(coords2+6));
01108   nodes2.push_back(new Node(coords2+8));
01109   nodes2.push_back(new Node(coords2+10));
01110   nodes2.push_back(new Node(coords2+12));
01111   nodes2.push_back(new Node(coords2+14));
01112   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
01113   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
01114   CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
01115   delete pol1;
01116   delete pol2;
01117 }
01118 
01119 void QuadraticPlanarInterpTest::checkNonRegression10()
01120 {
01121   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01122   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
01123   double coords1[]=
01124     { -0.002269581957210453, -0.09851030343724453,
01125       -0.004268022334182935, -0.1059685844580936,
01126       -0.002777851483521377, -0.1023709937816271};
01127   double coords2[]=
01128     { -0.004114727297178323, -0.1049870239624718,
01129       -0.003544545103522544, -0.1053162188055505};
01130   Node *n1_1=new Node(coords1);
01131   Node *n2_1=new Node(coords1+2);
01132   Node *n3_1=new Node(coords1+4);
01133   Node *n1_2=new Node(coords2);
01134   Node *n2_2=new Node(coords2+2);
01135   EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1);
01136   EdgeLin *e2=new EdgeLin(n1_2,n2_2);
01137   MergePoints merge;
01138   ComposedEdge *c1=new ComposedEdge;
01139   ComposedEdge *c2=new ComposedEdge;
01140   CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2));
01141   CPPUNIT_ASSERT_EQUAL(2,c1->size());
01142   CPPUNIT_ASSERT_EQUAL(2,c2->size());
01143   ComposedEdge::Delete(c1); ComposedEdge::Delete(c2);
01144   n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef();
01145   n1_2->decrRef(); n2_2->decrRef();
01146   e1->decrRef(); e2->decrRef();
01147 }
01148 
01149 void QuadraticPlanarInterpTest::checkNonRegression11()
01150 {
01151   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01152   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
01153   double coords1[]=
01154     { -0.002269581957210453, -0.09851030343724453,
01155       -0.004268022334182935, -0.1059685844580936,
01156       -0.002886178753789801, -0.1067663922211958,
01157       -0.0006739664310059821, -0.09851030343724453,
01158       -0.002777851483521377, -0.1023709937816271,
01159       -0.003577100543986368, -0.1063674883396447,
01160       -0.001236605237717319, -0.1027839694676665,
01161       -0.001471774194108217, -0.09851030343724453};
01162   double coords2[]=
01163     { -0.003544545103522544, -0.1053162188055505,
01164       -0.001941023322604723, -0.09851030343724451,
01165       -0.002598140593501099, -0.09851030343724451,
01166       -0.004114727297178323, -0.1049870239624718,
01167       -0.002347317802266182, -0.1020064358043286,
01168       -0.002269581958052911, -0.09851030343724451,
01169       -0.002982346712452072, -0.1018362598405457,
01170       -0.003829636200350435, -0.1051516213840111};
01171   
01172   std::vector<Node *> nodes1;
01173   nodes1.push_back(new Node(coords1));
01174   nodes1.push_back(new Node(coords1+2));
01175   nodes1.push_back(new Node(coords1+4));
01176   nodes1.push_back(new Node(coords1+6));
01177   nodes1.push_back(new Node(coords1+8));
01178   nodes1.push_back(new Node(coords1+10));
01179   nodes1.push_back(new Node(coords1+12));
01180   nodes1.push_back(new Node(coords1+14));
01181   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
01182   std::vector<Node *> nodes2;
01183   nodes2.push_back(new Node(coords2));
01184   nodes2.push_back(new Node(coords2+2));
01185   nodes2.push_back(new Node(coords2+4));
01186   nodes2.push_back(new Node(coords2+6));
01187   nodes2.push_back(new Node(coords2+8));
01188   nodes2.push_back(new Node(coords2+10));
01189   nodes2.push_back(new Node(coords2+12));
01190   nodes2.push_back(new Node(coords2+14));
01191   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
01192   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
01193   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
01194   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11);
01195   delete v[0];
01196   delete pol1;
01197   delete pol2;
01198 }
01199 
01200 void QuadraticPlanarInterpTest::checkNonRegression12()
01201 {
01202   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6);
01203   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
01204   double coords1[]=
01205     { -0.5032251558760915, -0.8716087994449138,
01206       -0.4695268343089433, -0.8806382374805872,
01207       -0.4695268343089433, -0.8570494123835835,
01208       -0.4914307433275896, -0.8511802776536561,
01209       -0.4869703691141082, -0.8783417525751493,
01210       -0.4695268343089433, -0.8688438249320853,
01211       -0.480865131947653, -0.8555566971861125,
01212       -0.4973279496018406, -0.8613945385492849};
01213 
01214   double coords2[]=
01215     { -0.5065868681155701, -0.8774455199666568,
01216       -0.4695187143958762, -0.8873779018223601,
01217       -0.4695187143968347, -0.8806382375105907,
01218       -0.5032170359605401, -0.8716087994611657,
01219       -0.488706602695924, -0.8848517684025307,
01220       -0.4695187143963554, -0.8840080696664754,
01221       -0.4869622492144596, -0.8783417525850385,
01222       -0.5049019520380551, -0.8745271597139112};
01223 
01224   std::vector<Node *> nodes1;
01225   nodes1.push_back(new Node(coords1));
01226   nodes1.push_back(new Node(coords1+2));
01227   nodes1.push_back(new Node(coords1+4));
01228   nodes1.push_back(new Node(coords1+6));
01229   nodes1.push_back(new Node(coords1+8));
01230   nodes1.push_back(new Node(coords1+10));
01231   nodes1.push_back(new Node(coords1+12));
01232   nodes1.push_back(new Node(coords1+14));
01233   QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
01234   std::vector<Node *> nodes2;
01235   nodes2.push_back(new Node(coords2));
01236   nodes2.push_back(new Node(coords2+2));
01237   nodes2.push_back(new Node(coords2+4));
01238   nodes2.push_back(new Node(coords2+6));
01239   nodes2.push_back(new Node(coords2+8));
01240   nodes2.push_back(new Node(coords2+10));
01241   nodes2.push_back(new Node(coords2+12));
01242   nodes2.push_back(new Node(coords2+14));
01243   QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
01244   std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
01245   CPPUNIT_ASSERT_EQUAL(1,(int)v.size());
01246   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6);
01247   delete v[0];
01248   delete pol1;
01249   delete pol2;
01250 }
01251 
01252 void QuadraticPlanarInterpTest::checkNonRegression13()
01253 {
01254   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01255   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
01256 
01257   double coords_1[194]={ 
01258     0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375, 
01259     -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, 
01260     0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109, 
01261     0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108, 
01262     -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109, 
01263     -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108, 
01264     0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125, 
01265     -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125, 
01266     0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218, 
01267     0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216, 
01268     -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217, 
01269     -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216, 
01270     1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, 
01271     -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, 
01272     1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933, 
01273     0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932, 
01274     -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932, 
01275     -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932, 
01276     1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, 
01277     -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, 
01278     1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244, 
01279     0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243, 
01280     -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243, 
01281     -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243, 
01282     2.249646661664983, 0.9318341578089936 };
01283 
01284   int tab6_1[48]={ 
01285     0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15, 
01286     17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7, 
01287     22, 8, 0, 23, 9, 8, 24, 1 };
01288 
01289   int tab8_1[192]={ 
01290     9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15, 
01291     27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18, 
01292     19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9, 
01293     32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36, 
01294     37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43, 
01295     53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46, 
01296     47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61, 
01297     74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64, 
01298     65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71, 
01299     79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 };
01300 
01301   double coords_2[20]={ 
01302     0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611, 
01303     0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611, 
01304     0.5922441860137611, 0, -0.5922441860137611, 0 };
01305   
01306   int tab8_2[16]={ 
01307     0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
01308   
01309   double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2;
01310 
01311   const int *work1=tab6_1;
01312   for(int i=0;i<8;i++,work1+=6)
01313     {
01314       QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6);
01315       const int *work2=tab8_2;
01316       for(int j=0;j<2;j++,work2+=8)
01317         {
01318           QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
01319           //std::vector<int> tmp;
01320           //pol1->intersectForPoint(*pol2,tmp);
01321           pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
01322           //pol1->intersectMySelfWith(*pol2);
01323           delete pol2;
01324         }
01325       delete pol1;
01326     }
01327   work1=tab8_1;
01328   for(int i=0;i<24;i++,work1+=8)
01329     {
01330       QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8);
01331       const int *work2=tab8_2;
01332       for(int j=0;j<2;j++,work2+=8)
01333         {
01334           
01335           QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
01336           //std::vector<int> tmp;
01337           //pol1->intersectForPoint(*pol2,tmp);
01338           pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
01339           delete pol2;
01340         }
01341       delete pol1;
01342     }
01343 }
01344 
01348 void QuadraticPlanarInterpTest::checkNonRegression14()
01349 {
01350   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01351   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
01352 
01353   double coords[72]={
01354     1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
01355     -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
01356     -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
01357     0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
01358     -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
01359     -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
01360     -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
01361     -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
01362     0.,-1.3,0.,-1.5
01363   };
01364   int tab[48]={
01365     0,1,2,3,4,5,6,7,
01366     8,9,10,11,2,14,12,13,
01367     9,15,16,10,5,17,18,14,
01368     9,15,16,10,34,17,35,14,
01369     19,20,21,22,23,24,25,26,
01370     27,28,29,30,31,32,2,33
01371   };
01372   QuadraticPolygon *pol1,*pol2;
01373   std::vector<int> goalOfTest;
01374   //
01375   pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
01376   // Level 1
01377   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
01378   pol1->intersectForPoint(*pol2,goalOfTest);
01379   const int res1[4]={0,1,0,0};
01380   CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
01381   CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1));
01382   delete pol2;
01383   // Level 2
01384   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
01385   pol1->intersectForPoint(*pol2,goalOfTest);
01386   const int res2[4]={0,2,0,0};
01387   CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
01388   CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2));
01389   delete pol2;
01390   //Level 2 bis
01391   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8);
01392   pol1->intersectForPoint(*pol2,goalOfTest);
01393   const int res2Bis[4]={0,2,0,0};
01394   CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
01395   CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis));
01396   delete pol2;
01397   // Level 3
01398   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8);
01399   pol1->intersectForPoint(*pol2,goalOfTest);
01400   const int res3[4]={0,3,0,0};
01401   CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
01402   CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3));
01403   delete pol2;
01404   // Level 4
01405   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8);
01406   pol1->intersectForPoint(*pol2,goalOfTest);
01407   const int res4[4]={0,4,0,0};
01408   CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size());
01409   CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4));
01410   delete pol2;
01411   //
01412   delete pol1;
01413 }
01414 
01418 void QuadraticPlanarInterpTest::checkNonRegression15()
01419 {
01420   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01421   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6);
01422 
01423   double coords[72]={
01424     1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1.,
01425     -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0.,
01426     -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658,
01427     0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5,
01428     -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65,
01429     -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877,
01430     -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565,
01431     -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169,
01432     0.,-1.3,0.,-1.5
01433   };
01434 
01435   int tab[24]={
01436     0,1,2,3,4,5,6,7,
01437     9,15,16,10,7,17,5,14,
01438     9,10,16,15,14,5,17,7
01439   };
01440 
01441   const double RefLgth=3.88995883524451;
01442   const double RefArea=0.383185168001075;
01443   //
01444   QuadraticPolygon *pol1,*pol2;
01445   //pol1 and pol2 in same orientation
01446   pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
01447   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
01448   std::vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
01449   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01450   CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
01451   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
01452   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
01453   delete res[0];
01454   //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2
01455   res=pol2->intersectMySelfWith(*pol1);
01456   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01457   CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
01458   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
01459   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
01460   delete res[0];
01461   delete pol2;
01462   //pol1 and pol2 in opposite orientation
01463   pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8);
01464   res=pol1->intersectMySelfWith(*pol2);
01465   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01466   CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
01467   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
01468   CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12);
01469   delete res[0];
01470   //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2
01471   res=pol2->intersectMySelfWith(*pol1);
01472   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01473   CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize());
01474   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12);
01475   CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12);
01476   delete res[0];
01477   delete pol2;
01478   //
01479   delete pol1;
01480 }
01481 
01482 class DoubleEqual
01483 {
01484 public:
01485   DoubleEqual(double eps):_eps(eps) { }
01486   bool operator()(double x, double y) { return fabs(x-y)<_eps; }
01487 private:
01488   double _eps;
01489 };
01490 
01494 void QuadraticPlanarInterpTest::checkNonRegression16()
01495 {
01496   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01497   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
01498   double coords1[194]={ 
01499     0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, 
01500     -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375, 
01501     0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108, 
01502     0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109, 
01503     -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108, 
01504     -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109, 
01505     0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125, 
01506     -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125, 
01507     0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216, 
01508     0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217, 
01509     -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216, 
01510     -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218, 
01511     1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, 
01512     -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, 
01513     1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932, 
01514     0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932, 
01515     -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932, 
01516     -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933, 
01517     1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, 
01518     -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, 
01519     1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243, 
01520     0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243, 
01521     -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243, 
01522     -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244, 
01523     2.249646661664984, -0.9318341578089931, };
01524 
01525   int tab1_8[192]={ 
01526     11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13, 
01527     28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18, 
01528     21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23, 
01529     25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36, 
01530     39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41, 
01531     54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46, 
01532     33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59, 
01533     75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64, 
01534     67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69, 
01535     80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, };
01536 
01537   double coords2[20]={ 
01538     2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435, 
01539     2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925, 
01540     2.56375, 0, -2.56375, 0, };
01541 
01542   int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 };
01543 
01544   QuadraticPolygon *pol1,*pol2;
01545   //pol1 and pol2 in same orientation
01546   std::vector<double> test1,test2;
01547   for(int ii=0;ii<24;ii++)
01548     {
01549       pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
01550       for(int jj=0;jj<2;jj++)
01551         {
01552           pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
01553           //
01554           std::vector<double> v1,v2;
01555           pol1->initLocations();
01556           pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
01557           if(ii==16 && jj==1)
01558             test1=v1;
01559           if(ii==20 && jj==1)
01560             test2=v1;
01561           delete pol2;
01562         }
01563       delete pol1;
01564     }
01565   const double test1_res[4]={0.,1.9124445278727873,0.,0.};
01566   CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10)));
01567   const double test2_res[4]={0.,0.,0.,0.};
01568   CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10)));
01569 }
01570 
01574 void QuadraticPlanarInterpTest::checkNonRegression17()
01575 {
01576   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7);
01577   INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7);
01578   double coords[16]={
01579     -1., 0., 1., 0. , 1.5, 0., -1.5, 0., 
01580     0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.};
01581   
01582   double coords2[16]={
01583     0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0.,  0.88388347648318444, 0.88388347648318444,
01584     0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 };
01585 
01586   double coords3[16]={
01587     0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0.,
01588     0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. };
01589 
01590   int tab8[8]={
01591     0, 1, 2, 3, 4, 5, 6, 7 };
01592   QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
01593   QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
01594   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
01595   delete pol1;
01596   delete pol2;
01597   pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
01598   pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8);
01599   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
01600   delete pol1;
01601   delete pol2;
01602   pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
01603   pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
01604   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13);
01605   delete pol1;
01606   delete pol2;
01607   pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8);
01608   pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8);
01609   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13);
01610   delete pol1;
01611   delete pol2;
01612 }
01613 
01614 void QuadraticPlanarInterpTest::checkNormalize()
01615 {
01616   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
01617   Node *n1=new Node(0.,0.);                Node *n4=new Node(0.,-3.);
01618   Node *n2=new Node(10.,0.);               Node *n5=new Node(10.,-3.);
01619   Node *n3=new Node(5.,10.);               Node *n6=new Node(5.,7.);
01620   EdgeLin *e1_2=new EdgeLin(n1,n2);        EdgeLin *e4_5=new EdgeLin(n4,n5);
01621   EdgeLin *e2_3=new EdgeLin(n2,n3);        EdgeLin *e5_6=new EdgeLin(n5,n6);
01622   EdgeLin *e3_1=new EdgeLin(n3,n1);        EdgeLin *e6_4=new EdgeLin(n6,n4);
01623   //
01624   QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
01625   QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
01626   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
01627   double area1Start=pol1.getArea();
01628   double xb,yb;
01629   double fact=pol1.normalize(&pol2,xb,yb);
01630   double area1End=pol1.getArea();
01631   CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14);
01632   CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14);
01633   double area=pol1.intersectWith(pol2);
01634   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14);
01635   //
01636   n1=new Node(0.,0.);  n4=new Node(0.,-3.);
01637   n2=new Node(10.,0.); n5=new Node(10.,-3.);
01638   n3=new Node(5.,10.); n6=new Node(5.,7.);
01639   e1_2=new EdgeLin(n1,n2);        e4_5=new EdgeLin(n4,n5);
01640   e2_3=new EdgeLin(n2,n3);        e5_6=new EdgeLin(n5,n6);
01641   e3_1=new EdgeLin(n3,n1);        e6_4=new EdgeLin(n6,n4);
01642   QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
01643   QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4);
01644   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
01645   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14);
01646   // Ok testing EdgeArcCircle update.
01647   double center[2]={5.,5.};
01648   double radius=300.;
01649   EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.);
01650   const Bounds& b=e1->getBounds();
01651   double x,y,fact2;
01652   fact2=b.getCaracteristicDim();
01653   b.getBarycenter(x,y);
01654   CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13);
01655   CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10);
01656   e1->getStartNode()->applySimilarity(x,y,fact2);
01657   e1->getEndNode()->applySimilarity(x,y,fact2);
01658   e1->applySimilarity(x,y,fact2);
01659   CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13);
01660   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14);
01661   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13);
01662   e1->decrRef();
01663 }
01664 
01665 void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
01666 {
01667   INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
01668   Node *n0=new Node(0.,0.);                Node *n4=new Node(0.5,0.25);
01669   Node *n1=new Node(0.,0.5);               Node *n5=new Node(0.3,1.2);
01670   Node *n2=new Node(1.,0.5);               Node *n6=new Node(1.1,1.3);
01671   Node *n3=new Node(1.,0.);                Node *n7=new Node(-0.1,0.9);
01672   EdgeLin *e0_1=new EdgeLin(n0,n1);
01673   EdgeLin *e1_2=new EdgeLin(n1,n2);        EdgeLin *e4_5=new EdgeLin(n4,n5);
01674   EdgeLin *e2_3=new EdgeLin(n2,n3);        EdgeLin *e5_6=new EdgeLin(n5,n6);
01675   EdgeLin *e3_0=new EdgeLin(n3,n0);        EdgeLin *e6_4=new EdgeLin(n6,n4);
01676   EdgeLin *e4_7=new EdgeLin(n4,n7);        EdgeLin *e7_5=new EdgeLin(n7,n5);
01677   QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0);
01678   QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
01679   pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7);
01680   n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
01681   pol1.dumpInXfigFileWithOther(pol2,"tony.fig");
01682 }
01683 
01684 }