1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "QuadraticPlanarInterpTest.hxx"
22 #include "InterpKernelGeo2DQuadraticPolygon.hxx"
23 #include "InterpKernelGeo2DElementaryEdge.hxx"
24 #include "InterpKernelGeo2DEdgeArcCircle.hxx"
25 #include "InterpKernelGeo2DEdgeLin.hxx"
31 using namespace INTERP_KERNEL;
36 void QuadraticPlanarInterpTest::checkInOutDetection()
38 Node *n1=new Node(0.,0.);
39 Node *n2=new Node(1.,0.);
40 Node *n3=new Node(0.5,1.);
41 EdgeLin *e1=new EdgeLin(n1,n2);
42 EdgeLin *e2=new EdgeLin(n2,n3);
43 EdgeLin *e3=new EdgeLin(n3,n1);
44 ComposedEdge *tri=new ComposedEdge;
45 tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3);
47 Node *where=new Node(0.4,0.1);
48 CPPUNIT_ASSERT(tri->isInOrOut(where)); where->decrRef();
49 where=new Node(-0.1,1.);
50 CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef();
51 where=new Node(0.6,-0.1);
52 CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef();
54 n1->decrRef(); n2->decrRef(); n3->decrRef();
55 ComposedEdge::Delete(tri);
59 * Check Iterators mechanism.
61 void QuadraticPlanarInterpTest::checkAssemblingBases1()
63 Node *n1=new Node(0.,0.);
64 Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2);
65 Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3);
66 Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4);
67 Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5);
68 Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6);
69 Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7);
70 Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8);
71 Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9);
72 Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10);
73 Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11);
74 Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12);
75 EdgeLin *e12_1=new EdgeLin(n12,n1);
77 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef();
78 e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef();
79 ComposedEdge *c=new ComposedEdge;
80 c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7);
81 c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1);
82 CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize());
83 IteratorOnComposedEdge it(c);
84 CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
85 it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished());
86 it.next(); it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it.finished());
87 it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it.finished());
88 it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished());
89 it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
90 it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
91 it.next(); CPPUNIT_ASSERT(it.finished());
92 it.first(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
93 it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
94 it.nextLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished());
95 it.last(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished());
97 ComposedEdge::Delete(c);
98 //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) )
99 e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef();
100 e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef();
101 ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9);
102 ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11);
103 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);
104 ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1);
105 c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize());
106 IteratorOnComposedEdge it2(c);
107 CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2);
108 it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
109 it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
110 it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
111 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
112 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
113 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
114 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
115 it2.next(); CPPUNIT_ASSERT(it2.finished());
116 it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
117 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
118 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
119 it2.last(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
120 it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
121 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
122 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
123 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
125 /*it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
126 ElementaryEdge *&tmp=it2.current(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished());
127 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();
128 c1->pushBack(e1_1bis); c1->pushBack(e1bis_2); delete tmp; tmp=(ElementaryEdge *)c1; CPPUNIT_ASSERT_EQUAL(13,c->recursiveSize());
129 CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());// here testing capability of Iterator.'current' method to deal with change of hierarchy.
130 it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
131 it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
132 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
133 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
134 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
135 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished());
136 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished());
137 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished());
138 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished());
139 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished());
140 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished());
141 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished());
142 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
143 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
144 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
145 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
146 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
147 it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
149 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());
150 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished());
151 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished());
152 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished());
153 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished());
154 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished());
155 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished());
156 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished());
157 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished());
158 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished());
159 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished());
160 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished());
161 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished());
162 it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());*/
163 ComposedEdge::SoftDelete(c2_2_4);
164 ComposedEdge::SoftDelete(c2_2_5);
165 ComposedEdge::SoftDelete(c2_2);
166 ComposedEdge::SoftDelete(c2);
167 ComposedEdge::Delete(c);
169 //e1_1bis->decrRef(); e1bis_2->decrRef();
170 e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_7->decrRef();
171 e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef();
173 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
174 n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef();
178 * Check splitting of 2 polygons. After this operation, all ElementaryEdge are either in/out/on.
180 void QuadraticPlanarInterpTest::checkAssemblingBases2()
182 //The "most" basic test1
183 Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3);
184 Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3);
185 Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7);
186 EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5);
187 EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6);
188 EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4);
190 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
191 QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1);
192 QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4);
193 QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0;
194 cpyPol1.SplitPolygonsEachOther(pol1,pol2,nbOfSplits);
195 CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize());
196 CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits);
197 checkBasicsOfPolygons(pol1,pol2,true);
198 CPPUNIT_ASSERT(pol2[1]->getEndNode()==pol1[1]->getEndNode());
199 CPPUNIT_ASSERT(pol2[1]->getEndNode()->getLoc()==ON_1);
200 CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode());
201 CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1);
202 cpyPol1.performLocatingOperation(pol2);
203 ElementaryEdge *tmp=dynamic_cast<ElementaryEdge *>(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5);
204 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
205 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
206 tmp=dynamic_cast<ElementaryEdge *>(pol2[1]); CPPUNIT_ASSERT(tmp);
207 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
208 tmp=dynamic_cast<ElementaryEdge *>(pol2[2]); CPPUNIT_ASSERT(tmp);
209 CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
210 tmp=dynamic_cast<ElementaryEdge *>(pol2[3]); CPPUNIT_ASSERT(tmp);
211 CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
212 tmp=dynamic_cast<ElementaryEdge *>(pol2[4]); CPPUNIT_ASSERT(tmp);
213 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
215 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
216 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
218 //Deeper test some extremities of pol2 are on edges of pol1.
220 n1=new Node(0.,0.); n4=new Node(1.5,-0.5);
221 n2=new Node(1.,0.); n5=new Node(0.5,0.);
222 n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5);
223 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
224 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);
226 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef();
227 QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1);
228 QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5);
229 QuadraticPolygon cpyPol3(pol3); nbOfSplits=0;
230 cpyPol3.SplitPolygonsEachOther(pol3,pol4,nbOfSplits);
231 CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize());
232 CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits);
233 checkBasicsOfPolygons(pol3,pol4,true);
234 CPPUNIT_ASSERT(pol4[0]->getStartNode()==pol3[0]->getEndNode()); CPPUNIT_ASSERT(pol4[0]->getStartNode()==n5);
235 CPPUNIT_ASSERT(n5->getLoc()==ON_LIM_1);
236 CPPUNIT_ASSERT(pol4[2]->getEndNode()==pol3[2]->getEndNode()); CPPUNIT_ASSERT(pol4[2]->getEndNode()==n6);
237 CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1);
238 cpyPol3.performLocatingOperation(pol4);
239 tmp=dynamic_cast<ElementaryEdge *>(pol4[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_7);
240 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
241 tmp=dynamic_cast<ElementaryEdge *>(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5);
242 tmp=dynamic_cast<ElementaryEdge *>(pol4[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_4);
243 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
244 tmp=dynamic_cast<ElementaryEdge *>(pol4[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e7_6);
245 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
246 tmp=dynamic_cast<ElementaryEdge *>(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5);
247 CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1);
249 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef();
250 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef();
252 //Test with one edge of pol2 is included in pol1.
254 n1=new Node(0.,0.); n4=new Node(-0.5,0.);
255 n2=new Node(1.,0.); n5=new Node(0.,-1.);
256 n3=new Node(0.5,1.); n6=new Node(0.5,0.);
257 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
258 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
259 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
260 QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1);
261 QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4);
262 QuadraticPolygon cpyPol5(pol5); nbOfSplits=0;
263 cpyPol5.SplitPolygonsEachOther(pol5,pol6,nbOfSplits);
264 CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize());
265 CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits);
266 checkBasicsOfPolygons(pol5,pol6,false);
267 CPPUNIT_ASSERT(pol6[2]->getStartNode()==pol5[0]->getEndNode()); CPPUNIT_ASSERT(pol6[2]->getStartNode()==n6);
268 CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1);
269 CPPUNIT_ASSERT(pol6[2]->getEndNode()==pol5[0]->getStartNode()); CPPUNIT_ASSERT(pol5[0]->getStartNode()==n1);
270 CPPUNIT_ASSERT(n1->getLoc()==ON_LIM_1);
271 cpyPol5.performLocatingOperation(pol6);
272 tmp=dynamic_cast<ElementaryEdge *>(pol6[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5);
273 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
274 tmp=dynamic_cast<ElementaryEdge *>(pol6[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_6);
275 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
276 tmp=dynamic_cast<ElementaryEdge *>(pol6[2]); CPPUNIT_ASSERT(tmp);
277 CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
278 tmp=dynamic_cast<ElementaryEdge *>(pol6[3]); CPPUNIT_ASSERT(tmp);
279 CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1);
281 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
282 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
284 //Test of full overlapped polygons.
286 n1=new Node(0.,0.); n4=new Node(0.,0.);
287 n2=new Node(1.,0.); n5=new Node(1.,0.);
288 n3=new Node(0.5,1.); n6=new Node(0.5,1.);
289 e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1);
290 e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4);
291 e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef();
292 QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1);
293 QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4);
294 QuadraticPolygon cpyPol7(pol7); nbOfSplits=0;
295 cpyPol7.SplitPolygonsEachOther(pol7,pol8,nbOfSplits);
296 tmp=dynamic_cast<ElementaryEdge *>(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2);
297 CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
298 tmp=dynamic_cast<ElementaryEdge *>(pol8[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e2_3);
299 CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
300 tmp=dynamic_cast<ElementaryEdge *>(pol8[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e3_1);
301 CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1);
303 e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef();
304 n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef();
307 void QuadraticPlanarInterpTest::checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection)
309 IteratorOnComposedEdge it1(&pol1),it2(&pol2); it1.previousLoop(); it2.previousLoop();
310 Node *nIter1=it1.current()->getEndNode(); Node *nIter2=it2.current()->getEndNode();
311 for(it2.first();!it2.finished();it2.next())
313 CPPUNIT_ASSERT(nIter2==it2.current()->getStartNode());
315 CPPUNIT_ASSERT(it2.current()->getDirection());
316 nIter2=it2.current()->getEndNode();
318 for(it1.first();!it1.finished();it1.next())
320 CPPUNIT_ASSERT(nIter1==it1.current()->getStartNode());
322 CPPUNIT_ASSERT(it1.current()->getDirection());
323 nIter1=it1.current()->getEndNode();