Back to index

salome-med  6.5.0
QuadraticPlanarInterpTest3.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 
00030 using namespace INTERP_KERNEL;
00031 
00032 namespace INTERP_TEST
00033 {
00034 
00035 void QuadraticPlanarInterpTest::checkInOutDetection()
00036 {
00037   Node *n1=new Node(0.,0.);
00038   Node *n2=new Node(1.,0.);
00039   Node *n3=new Node(0.5,1.);
00040   EdgeLin *e1=new EdgeLin(n1,n2);
00041   EdgeLin *e2=new EdgeLin(n2,n3);
00042   EdgeLin *e3=new EdgeLin(n3,n1);
00043   ComposedEdge *tri=new ComposedEdge;
00044   tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3);
00045   //
00046   Node *where=new Node(0.4,0.1);
00047   CPPUNIT_ASSERT(tri->isInOrOut(where)); where->decrRef();
00048   where=new Node(-0.1,1.);
00049   CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef();
00050   where=new Node(0.6,-0.1);
00051   CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef();
00052   //Clean-up
00053   n1->decrRef(); n2->decrRef(); n3->decrRef();
00054   ComposedEdge::Delete(tri);
00055 }
00056 
00060 void QuadraticPlanarInterpTest::checkAssemblingBases1()
00061 {
00062   Node *n1=new Node(0.,0.);
00063   Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2);
00064   Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3);
00065   Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4);
00066   Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5);
00067   Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6);
00068   Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7);
00069   Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8);
00070   Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9);
00071   Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10);
00072   Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11);
00073   Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12);
00074   EdgeLin *e12_1=new EdgeLin(n12,n1);
00075   //Only one level
00076   e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); 
00077   e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef();
00078   ComposedEdge *c=new ComposedEdge;
00079   c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7);
00080   c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1);
00081   CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize());
00082   IteratorOnComposedEdge it(c);
00083   CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
00084   it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished());
00085   it.next(); it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it.finished());
00086   it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it.finished());
00087   it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished());
00088   it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
00089   it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
00090   it.next(); CPPUNIT_ASSERT(it.finished());
00091   it.first(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
00092   it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
00093   it.nextLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
00094   it.last(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
00095   //Multi-Level
00096   ComposedEdge::Delete(c);
00097   //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) )
00098   e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); 
00099   e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef();
00100   ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9);
00101   ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11);
00102   ComposedEdge *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6);  c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12);
00103   ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1);
00104   c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize());
00105   IteratorOnComposedEdge it2(c);
00106   CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2);
00107   it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00108   it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
00109   it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
00110   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
00111   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00112   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00113   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00114   it2.next(); CPPUNIT_ASSERT(it2.finished());
00115   it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00116   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00117   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00118   it2.last(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00119   it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00120   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00121   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
00122   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
00123   //  substitutions.
00124   /*it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00125   ElementaryEdge *&tmp=it2.current(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
00126   ComposedEdge *c1=new ComposedEdge;  Node *n1_bis=new Node(0.,0.05); EdgeLin *e1_1bis=new EdgeLin(n1,n1_bis); EdgeLin *e1bis_2=new EdgeLin(n1_bis,n2); e1_1bis->incrRef(); e1bis_2->incrRef();
00127   c1->pushBack(e1_1bis); c1->pushBack(e1bis_2); delete tmp; tmp=(ElementaryEdge *)c1; CPPUNIT_ASSERT_EQUAL(13,c->recursiveSize());
00128   CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());// here testing capability of Iterator.'current' method to deal with change of hierarchy.
00129   it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
00130   it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00131   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
00132   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
00133   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00134   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished());
00135   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished());
00136   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished());
00137   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished());
00138   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished());
00139   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished());
00140   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished());
00141   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
00142   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
00143   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00144   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
00145   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
00146   it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00147   //go forward
00148   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
00149   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
00150   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
00151   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
00152   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
00153   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished());
00154   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished());
00155   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished());
00156   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished());
00157   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished());
00158   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished());
00159   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished());
00160   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
00161   it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());*/
00162   ComposedEdge::SoftDelete(c2_2_4);
00163   ComposedEdge::SoftDelete(c2_2_5);
00164   ComposedEdge::SoftDelete(c2_2);
00165   ComposedEdge::SoftDelete(c2);
00166   ComposedEdge::Delete(c);
00167   //clean-up
00168   //e1_1bis->decrRef(); e1bis_2->decrRef();
00169   e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_7->decrRef(); 
00170   e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); 
00171   //n1_bis->decrRef();
00172   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00173   n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef();
00174 }
00175 
00179 void QuadraticPlanarInterpTest::checkAssemblingBases2()
00180 {
00181   //The "most" basic test1
00182   Node *n1=new Node(0.,0.);                Node *n4=new Node(0.,-0.3);   
00183   Node *n2=new Node(1.,0.);                Node *n5=new Node(1.,-0.3);
00184   Node *n3=new Node(0.5,1.);               Node *n6=new Node(0.5,0.7);
00185   EdgeLin *e1_2=new EdgeLin(n1,n2);        EdgeLin *e4_5=new EdgeLin(n4,n5);
00186   EdgeLin *e2_3=new EdgeLin(n2,n3);        EdgeLin *e5_6=new EdgeLin(n5,n6);
00187   EdgeLin *e3_1=new EdgeLin(n3,n1);        EdgeLin *e6_4=new EdgeLin(n6,n4);
00188   //
00189   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); 
00190   QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
00191   QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
00192   QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0;
00193   cpyPol1.SplitPolygonsEachOther(pol1,pol2,nbOfSplits);
00194   CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize());
00195   CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits);
00196   checkBasicsOfPolygons(pol1,pol2,true);
00197   CPPUNIT_ASSERT(pol2[1]->getEndNode()==pol1[1]->getEndNode());
00198   CPPUNIT_ASSERT(pol2[1]->getEndNode()->getLoc()==ON_1);
00199   CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode());
00200   CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1);
00201   cpyPol1.performLocatingOperation(pol2);
00202   ElementaryEdge *tmp=dynamic_cast<ElementaryEdge *>(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5);
00203   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00204   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00205   tmp=dynamic_cast<ElementaryEdge *>(pol2[1]); CPPUNIT_ASSERT(tmp);
00206   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00207   tmp=dynamic_cast<ElementaryEdge *>(pol2[2]); CPPUNIT_ASSERT(tmp);
00208   CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
00209   tmp=dynamic_cast<ElementaryEdge *>(pol2[3]); CPPUNIT_ASSERT(tmp);
00210   CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
00211   tmp=dynamic_cast<ElementaryEdge *>(pol2[4]); CPPUNIT_ASSERT(tmp);
00212   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00213   //clean-up for test1
00214   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00215   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00216 
00217   //Deeper test some extremities of pol2 are on edges of pol1.
00218 
00219   n1=new Node(0.,0.);                n4=new Node(1.5,-0.5);   
00220   n2=new Node(1.,0.);                n5=new Node(0.5,0.);
00221   n3=new Node(0.5,1.);               n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5);
00222   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00223   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);
00224   //
00225   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef();
00226   QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
00227   QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5);
00228   QuadraticPolygon cpyPol3(pol3); nbOfSplits=0;
00229   cpyPol3.SplitPolygonsEachOther(pol3,pol4,nbOfSplits);
00230   CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize());
00231   CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits);
00232   checkBasicsOfPolygons(pol3,pol4,true);
00233   CPPUNIT_ASSERT(pol4[0]->getStartNode()==pol3[0]->getEndNode()); CPPUNIT_ASSERT(pol4[0]->getStartNode()==n5);
00234   CPPUNIT_ASSERT(n5->getLoc()==ON_LIM_1);
00235   CPPUNIT_ASSERT(pol4[2]->getEndNode()==pol3[2]->getEndNode()); CPPUNIT_ASSERT(pol4[2]->getEndNode()==n6);
00236   CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1);
00237   cpyPol3.performLocatingOperation(pol4);
00238   tmp=dynamic_cast<ElementaryEdge *>(pol4[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_7);
00239   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00240   tmp=dynamic_cast<ElementaryEdge *>(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5);
00241   tmp=dynamic_cast<ElementaryEdge *>(pol4[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_4);
00242   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00243   tmp=dynamic_cast<ElementaryEdge *>(pol4[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e7_6);
00244   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00245   tmp=dynamic_cast<ElementaryEdge *>(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5);
00246   CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
00247   //clean-up for test2
00248   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef();
00249   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
00250 
00251   //Test with one edge of pol2 is included in pol1.
00252 
00253   n1=new Node(0.,0.);                n4=new Node(-0.5,0.);   
00254   n2=new Node(1.,0.);                n5=new Node(0.,-1.);
00255   n3=new Node(0.5,1.);               n6=new Node(0.5,0.);
00256   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00257   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00258   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00259   QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1);
00260   QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4);
00261   QuadraticPolygon cpyPol5(pol5); nbOfSplits=0;
00262   cpyPol5.SplitPolygonsEachOther(pol5,pol6,nbOfSplits);
00263   CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize());
00264   CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits);
00265   checkBasicsOfPolygons(pol5,pol6,false);
00266   CPPUNIT_ASSERT(pol6[2]->getStartNode()==pol5[0]->getEndNode()); CPPUNIT_ASSERT(pol6[2]->getStartNode()==n6);
00267   CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1);
00268   CPPUNIT_ASSERT(pol6[2]->getEndNode()==pol5[0]->getStartNode()); CPPUNIT_ASSERT(pol5[0]->getStartNode()==n1);
00269   CPPUNIT_ASSERT(n1->getLoc()==ON_LIM_1);
00270   cpyPol5.performLocatingOperation(pol6);
00271   tmp=dynamic_cast<ElementaryEdge *>(pol6[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5);
00272   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00273   tmp=dynamic_cast<ElementaryEdge *>(pol6[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_6);
00274   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00275   tmp=dynamic_cast<ElementaryEdge *>(pol6[2]); CPPUNIT_ASSERT(tmp);
00276   CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
00277   tmp=dynamic_cast<ElementaryEdge *>(pol6[3]); CPPUNIT_ASSERT(tmp);
00278   CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
00279   //clean-up test3
00280   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00281   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00282 
00283   //Test of full overlapped polygons.
00284 
00285   n1=new Node(0.,0.);                n4=new Node(0.,0.);   
00286   n2=new Node(1.,0.);                n5=new Node(1.,0.);
00287   n3=new Node(0.5,1.);               n6=new Node(0.5,1.);
00288   e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
00289   e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
00290   e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
00291   QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1);
00292   QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4);
00293   QuadraticPolygon cpyPol7(pol7); nbOfSplits=0;
00294   cpyPol7.SplitPolygonsEachOther(pol7,pol8,nbOfSplits);
00295   tmp=dynamic_cast<ElementaryEdge *>(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2);
00296   CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
00297   tmp=dynamic_cast<ElementaryEdge *>(pol8[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e2_3);
00298   CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
00299   tmp=dynamic_cast<ElementaryEdge *>(pol8[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e3_1);
00300   CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
00301   //clean-up test4
00302   e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
00303   n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
00304 }
00305 
00306 void QuadraticPlanarInterpTest::checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection)
00307 {
00308   IteratorOnComposedEdge it1(&pol1),it2(&pol2); it1.previousLoop(); it2.previousLoop();
00309   Node *nIter1=it1.current()->getEndNode(); Node *nIter2=it2.current()->getEndNode();
00310   for(it2.first();!it2.finished();it2.next())
00311     {
00312       CPPUNIT_ASSERT(nIter2==it2.current()->getStartNode());
00313       if(checkDirection)
00314         CPPUNIT_ASSERT(it2.current()->getDirection());
00315       nIter2=it2.current()->getEndNode();
00316     }
00317   for(it1.first();!it1.finished();it1.next())
00318     {
00319       CPPUNIT_ASSERT(nIter1==it1.current()->getStartNode());
00320       if(checkDirection)
00321         CPPUNIT_ASSERT(it1.current()->getDirection());
00322       nIter1=it1.current()->getEndNode();
00323     }
00324 }
00325 
00326 }