0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TopOpeBRep / TopOpeBRep_EdgesIntersector.cxx
CommitLineData
b311480e 1// Created on: 1994-10-07
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#ifdef DRAW
7868210d 18static void CurveToString(const GeomAbs_CurveType t, TCollection_AsciiString& N)
19{
20 switch(t) {
21 case GeomAbs_Line : N = "LINE"; break;
22 case GeomAbs_Circle : N = "CIRCLE"; break;
23 case GeomAbs_Ellipse : N = "ELLIPSE"; break;
24 case GeomAbs_Hyperbola : N = "HYPERBOLA"; break;
25 case GeomAbs_Parabola : N = "PARABOLA"; break;
26 case GeomAbs_BezierCurve : N = "BEZIER"; break;
27 case GeomAbs_BSplineCurve : N = "BSPLINE"; break;
28 case GeomAbs_OffsetCurve : N = "OFFSET"; break;
29 case GeomAbs_OtherCurve : N = "OTHER"; break;
30 default : N = "UNKNOWN"; break;
31 }
32}
7fd59977 33#endif
34
42cf5bc1 35#include <Bnd_Box.hxx>
7fd59977 36#include <BRep_Tool.hxx>
37#include <BRepAdaptor_HSurface.hxx>
38#include <BRepAdaptor_Surface.hxx>
42cf5bc1 39#include <Geom2dAdaptor_Curve.hxx>
7fd59977 40#include <Geom_Curve.hxx>
41#include <Geom_Surface.hxx>
7fd59977 42#include <GeomTools_Curve2dSet.hxx>
42cf5bc1 43#include <GeomTools_CurveSet.hxx>
7fd59977 44#include <GeomTools_SurfaceSet.hxx>
42cf5bc1 45#include <gp_Circ2d.hxx>
46#include <gp_Pnt.hxx>
47#include <gp_Pnt2d.hxx>
48#include <IntRes2d_IntersectionPoint.hxx>
49#include <IntRes2d_IntersectionSegment.hxx>
42cf5bc1 50#include <Precision.hxx>
51#include <Standard_Failure.hxx>
52#include <TCollection_AsciiString.hxx>
53#include <TopExp.hxx>
54#include <TopExp_Explorer.hxx>
55#include <TopLoc_Location.hxx>
56#include <TopoDS.hxx>
57#include <TopoDS_Shape.hxx>
58#include <TopoDS_Vertex.hxx>
59#include <TopOpeBRep_define.hxx>
60#include <TopOpeBRep_EdgesIntersector.hxx>
61#include <TopOpeBRep_Point2d.hxx>
62#include <TopOpeBRepDS_Transition.hxx>
7fd59977 63#include <TopOpeBRepTool_2d.hxx>
42cf5bc1 64#include <TopOpeBRepTool_CurveTool.hxx>
7fd59977 65#include <TopOpeBRepTool_EXPORT.hxx>
42cf5bc1 66#include <TopOpeBRepTool_ShapeTool.hxx>
7fd59977 67#include <TopOpeBRepTool_tol.hxx>
42cf5bc1 68#include <TopOpeBRepTool_TOOL.hxx>
7fd59977 69
0797d9d3 70#ifdef OCCT_DEBUG
1d0a9d4d 71extern Standard_Boolean TopOpeBRepTool_GettraceNYI();
72extern Standard_Boolean TopOpeBRepTool_GettraceKRO();
1d0a9d4d 73extern Standard_Boolean TopOpeBRep_GettracePROEDG();
74extern Standard_Boolean TopOpeBRep_GetcontextTOL0();
75extern Standard_Boolean TopOpeBRep_GetcontextNOFEI();
76extern Standard_Boolean TopOpeBRep_GettraceFITOL();
77extern Standard_Boolean TopOpeBRep_GettraceEEFF();
78extern void debeeff();
7fd59977 79#include <TopOpeBRepTool_KRO.hxx>
80Standard_EXPORT TOPKRO KRO_DSFILLER_INTEE("intersection edge/edge");
81#endif
82
83// la surface de reference peut etre celle de la 1ere ou la 2eme face
84// de l'appel de SetFaces. Ces deux faces sont "SameDomain".
85// Leurs normales geometriques sont SurfacesSameOriented()
86// Leurs normales topologiques sont FacesSameOriented()
87// cas type 1 :
88// face1 FORWARD, normale geometrique Ng1 en +Z
89// face2 REVERSED, normale geometrique Ng2 en -Z
90// ==> SurfaceSameOriented = 0, FacesSameOriented = 1
91
92//=======================================================================
93//function : TopOpeBRep_EdgesIntersector
94//purpose :
95//=======================================================================
96TopOpeBRep_EdgesIntersector::TopOpeBRep_EdgesIntersector()
97{
98 mySurface1 = new BRepAdaptor_HSurface();
99 mySurface2 = new BRepAdaptor_HSurface();
100 mySurfacesSameOriented = Standard_False;
101 myFacesSameOriented = Standard_False;
102 myTol1 = 0.; // Precision::PConfusion();
103 myTol2 = 0.; // Precision::PIntersection();
104 myDimension = 2;
105 myTolForced = Standard_False;
106 myf1surf1F_sameoriented = Standard_True;
107 myf2surf1F_sameoriented = Standard_True;
108
109 myNbSegments = 0;
110 myHasSegment = Standard_False;
111 SetSameDomain(Standard_False);
112
113 myNbPoints = 0;
114 myTrueNbPoints = 0;
115 myPointIndex = 0;
116 myip2d = mynp2d = 0;
117 myselectkeep = Standard_True;
118}
119
e6f550da 120TopOpeBRep_EdgesIntersector::~TopOpeBRep_EdgesIntersector()
7fd59977 121{}
122
123//=======================================================================
124//function : SetFaces
125//purpose :
126//=======================================================================
127void TopOpeBRep_EdgesIntersector::SetFaces(const TopoDS_Shape& F1,const TopoDS_Shape& F2)
128{
129 Bnd_Box B1,B2;
130 SetFaces(F1,F2,B1,B2);
131}
132
133//=======================================================================
134//function : SetFaces
135//purpose :
136//=======================================================================
137void TopOpeBRep_EdgesIntersector::SetFaces(const TopoDS_Shape& F1,const TopoDS_Shape& F2,const Bnd_Box& B1,const Bnd_Box& B2)
138{
7fd59977 139 Standard_Boolean computerestriction = Standard_False;
140
141 Standard_Boolean so11 = Standard_True;
142 Standard_Boolean so21 = Standard_True;
143 myf1surf1F_sameoriented = so11;
144 myf2surf1F_sameoriented = so21;
145 mySurfacesSameOriented = Standard_True;
146 myFacesSameOriented = Standard_True;
147
148 myFace1 = TopoDS::Face(F1);
149 BRepAdaptor_Surface& S1 = mySurface1->ChangeSurface(); S1.Initialize(myFace1,computerestriction);
150 mySurfaceType1 = S1.GetType();
151
152 myFace2 = TopoDS::Face(F2);
153 BRepAdaptor_Surface& S2 = mySurface2->ChangeSurface(); S2.Initialize(myFace2,computerestriction);
154 mySurfaceType2 = S2.GetType();
155
156 TopoDS_Face face1forward = myFace1;
157 face1forward.Orientation(TopAbs_FORWARD);
158
159 so11 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace1);
160 myf1surf1F_sameoriented = so11;
161
162 so21 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace2);
163 myf2surf1F_sameoriented = so21;
164
165 mySurfacesSameOriented = TopOpeBRepTool_ShapeTool::SurfacesSameOriented(S1,S2);
166 myFacesSameOriented = TopOpeBRepTool_ShapeTool::FacesSameOriented(myFace1,myFace2);
167
168 if ( !myTolForced ) {
169 FTOL_FaceTolerances2d(B1,B2,myFace1,myFace2,S1,S2,myTol1,myTol2);
170 myTol1 = (myTol1 > 1.e-4)? 1.e-4: myTol1;
171 myTol2 = (myTol2 > 1.e-4)? 1.e-4: myTol2;
172 }
173
0797d9d3 174#ifdef OCCT_DEBUG
7fd59977 175 Standard_Integer DEBi = 0;
176 if ( DEBi ) {
04232180 177 std::cout<<"TopOpeBRep_EdgesIntersector::SetFaces : ";
178 std::cout<<"f1 "; TopAbs::Print(myFace1.Orientation(),std::cout);
179 std::cout<< " / f1F : ";
180 if (so11) std::cout<<"sameoriented"; else std::cout<<"difforiented"; std::cout<<std::endl;
181 std::cout <<" ";
182 std::cout<<"f2 "; TopAbs::Print(myFace2.Orientation(),std::cout);
183 std::cout<< " / f1F : ";
184 if (so21) std::cout<<"sameoriented"; else std::cout<<"difforiented"; std::cout<<std::endl;
7fd59977 185 }
186#endif
187}
188
189//=======================================================================
190//function : ForceTolerances
191//purpose :
192//=======================================================================
193void TopOpeBRep_EdgesIntersector::ForceTolerances(const Standard_Real Tol1,const Standard_Real Tol2)
194{
195 myTol1 = Tol1;
196 myTol2 = Tol2;
197 myTolForced = Standard_True;
198}
199
200#include <IntRes2d_Transition.hxx>
201static Standard_Boolean TransitionEqualAndExtremity( const IntRes2d_Transition& T1
202 ,const IntRes2d_Transition& T2) {
203 if( T1.PositionOnCurve() == IntRes2d_Head
204 || T1.PositionOnCurve() == IntRes2d_End) {
205 if(T1.PositionOnCurve() == T2.PositionOnCurve()) {
206 if(T1.TransitionType() == T2.TransitionType()) {
207 if(T1.TransitionType() == IntRes2d_Touch) {
208 if(T1.IsTangent()==T2.IsTangent()) {
209 if(T1.Situation() == T2.Situation()) {
210 if(T1.IsOpposite() == T2.IsOpposite()) {
211 return(Standard_True);
212 }
213 }
214 }
215 }
216 else {
217 return(Standard_True);
218 }
219 }
220 }
221 }
222 return(Standard_False);
223}
224
225// Modified by Sergey KHROMOV - Fri Jan 11 14:49:48 2002 Begin
226static Standard_Boolean IsTangentSegment(const IntRes2d_IntersectionPoint &P1,
227 const IntRes2d_IntersectionPoint &P2,
228 const Geom2dAdaptor_Curve &aC1,
229 const Geom2dAdaptor_Curve &aC2,
230 const Standard_Real aTolConf) {
231 const gp_Pnt2d &aP2d1 = P1.Value();
232 const gp_Pnt2d &aP2d2 = P2.Value();
233 const IntRes2d_Transition &aTrans1 = P1.TransitionOfFirst();
234 const IntRes2d_Transition &aTrans2 = P2.TransitionOfFirst();
235
236 if (aTrans1.TransitionType() == IntRes2d_Touch ||
237 aTrans2.TransitionType() == IntRes2d_Touch) {
238 Standard_Real aSqrDistPP = aP2d1.SquareDistance(aP2d2);
239
240 if (aSqrDistPP <= aTolConf) {
241 Standard_Real aParDist1 = Abs(P1.ParamOnFirst() - P2.ParamOnFirst());
242 Standard_Real aParDist2 = Abs(P1.ParamOnSecond() - P2.ParamOnSecond());
243 Standard_Real aResol1 = aC1.Resolution(aTolConf);
244 Standard_Real aResol2 = aC2.Resolution(aTolConf);
245
246 if (aParDist1*aParDist1 <= aResol1 &&
247 aParDist2*aParDist2 <= aResol2)
248 return Standard_True;
249 }
250 }
251
252 return Standard_False;
253}
254// Modified by Sergey KHROMOV - Fri Jan 11 14:49:49 2002 End
255
256
257//------------------------------------------------------------------------
258Standard_Boolean EdgesIntersector_checkT1D(const TopoDS_Edge& E1,const TopoDS_Edge& E2,const TopoDS_Vertex& vG,
259 TopOpeBRepDS_Transition& newT)
260//------------------------------------------------------------------------
261 // E1 sdm E2, interfers with E2 at vertex vG
262 // vG is vertex of E2, but not vertex of E1
263 // purpose : get newT / attached to E1, I1d=(newT(E2),G,E2)
264{
265#define FIRST (1)
266#define LAST (2)
267#define CLOSING (3)
268
269 newT.Set(TopAbs_UNKNOWN,TopAbs_UNKNOWN);
270 Standard_Integer ovine = FUN_tool_orientVinE(vG,E2);
271 if (ovine == 0) {
272 return Standard_False;
273 }
274 else if (ovine == CLOSING) {
275 newT.Set(TopAbs_INTERNAL);
276 return Standard_True;
277 }
278
279 Standard_Boolean first = (ovine == FIRST);
280 Standard_Boolean last = (ovine == LAST);
281
282 TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED;
283 Standard_Boolean sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(E1,E2);
284 if (!sso) C = TopOpeBRepDS_DIFFORIENTED;
285
286 Standard_Boolean SO = (C == TopOpeBRepDS_SAMEORIENTED);
287 Standard_Boolean DO = (C == TopOpeBRepDS_DIFFORIENTED);
288 TopAbs_Orientation o1 = E1.Orientation();
289 if (o1 == TopAbs_REVERSED) {SO = !SO; DO = !DO;} // relative to E1 FORWARD
290
291 Standard_Boolean reversed = (SO && first) || (DO && last);
292 Standard_Boolean forward = (SO && last) || (DO && first);
293 if (reversed) newT.Set(TopAbs_REVERSED);
294 if (forward) newT.Set(TopAbs_FORWARD);
295 return (reversed || forward);
296} // EdgesIntersector_checkT1D
297
298
299//modified by NIZNHY-PKV Fri Nov 5 12:27:07 1999 from
300#include <BRepAdaptor_Surface.hxx>
301//modified by NIZNHY-PKV Fri Nov 5 12:27:10 1999 to
302//=======================================================================
303//function : Perform
304//purpose :
305//=======================================================================
306 void TopOpeBRep_EdgesIntersector::Perform(const TopoDS_Shape& E1,const TopoDS_Shape& E2,const Standard_Boolean ReduceSegment)
307{
308 mysp2d.Clear();
309 myip2d = 1; mynp2d = 0;
6e6cd5d9 310
7fd59977 311 myEdge1 = TopoDS::Edge(E1);
312 myEdge2 = TopoDS::Edge(E2);
313
314 Standard_Real first,last,tole,tolpc;
315 gp_Pnt2d pfirst,plast;
316 Handle(Geom2d_Curve) PC1;
317 //modified by NIZNHY-PKV Thu Nov 4 16:08:05 1999 f
318
319 BRepAdaptor_Surface aSurface1(myFace1), aSurface2(myFace2);
320 GeomAbs_SurfaceType aSurfaceType1=aSurface1.GetType(),
321 aSurfaceType2=aSurface2.GetType();
322
323 if (aSurfaceType1==GeomAbs_Sphere && aSurfaceType2==GeomAbs_Sphere) {
324 PC1 = FC2D_MakeCurveOnSurface (myEdge1,myFace1,first,last,tolpc, Standard_True);
325 }
326 else {
327 PC1 = FC2D_CurveOnSurface(myEdge1,myFace1,first,last,tolpc);
328 }
329 //modified by NIZNHY-PKV Thu Nov 4 15:44:13 1999 to
330
331 if (PC1.IsNull())
9775fa61 332 throw Standard_Failure("EdgesIntersector::Perform : no 2d curve");
7fd59977 333
334 myCurve1.Load(PC1);
335 BRep_Tool::UVPoints(myEdge1,myFace1,pfirst,plast);
336 tole = BRep_Tool::Tolerance(myEdge1);
337 myDomain1.SetValues(pfirst,first,tole,plast,last,tole);
338
0797d9d3 339#ifdef OCCT_DEBUG
7fd59977 340 Standard_Boolean trc = Standard_False;
341 if (trc) {
04232180 342 std::cout<<"ed1 on fa1 : {pfirst=("<<pfirst.X()<<" "<<pfirst.Y()<<"), first="<<first<<"\n";
343 std::cout<<" plast =("<<plast.X()<<" "<<plast.Y()<<"),last="<<last<<"}"<<std::endl;}
7fd59977 344#endif
345
346 Standard_Boolean memesfaces = myFace1.IsSame(myFace2);
347 Standard_Boolean memesupport = Standard_False;
348 TopLoc_Location L1,L2;
349 const Handle(Geom_Surface) S1 = BRep_Tool::Surface(myFace1,L1);
350 const Handle(Geom_Surface) S2 = BRep_Tool::Surface(myFace2,L2);
351 if (S1 == S2 && L1 == L2) memesupport=Standard_True;
352
353 if ( mySurfaceType1 == GeomAbs_Plane || memesfaces || memesupport) {
354 Handle(Geom2d_Curve) PC2 = FC2D_CurveOnSurface(myEdge2,myFace1,first,last,tolpc);
355 myCurve2.Load(PC2);
356 BRep_Tool::UVPoints(myEdge2,myFace1,pfirst,plast);
357 tole = BRep_Tool::Tolerance(myEdge2);
358 myDomain2.SetValues(pfirst,first,tole,plast,last,tole);
359
0797d9d3 360#ifdef OCCT_DEBUG
7fd59977 361 if (trc) {
04232180 362 std::cout<<"ed2 on fa1 : {pfirst=("<<pfirst.X()<<" "<<pfirst.Y()<<"), first="<<first<<"\n";
363 std::cout<<" plast =("<<plast.X()<<" "<<plast.Y()<<"),last="<<last<<"}"<<std::endl;}
7fd59977 364#endif
365
366 }
367
368 else {
369
370 Handle(Geom2d_Curve) PC2on1; Handle(Geom_Curve) NC;
371 Standard_Boolean dgE2 = BRep_Tool::Degenerated(myEdge2);
372 if (dgE2) { //xpu210998 : cto900Q3
373 TopExp_Explorer exv(myEdge2, TopAbs_VERTEX);
374 const TopoDS_Vertex& v2 = TopoDS::Vertex(exv.Current());
375 gp_Pnt pt2 = BRep_Tool::Pnt(v2);
376 gp_Pnt2d uv2; Standard_Real d; Standard_Boolean ok = FUN_tool_projPonF(pt2,myFace1,uv2,d);
377 if (!ok)
378 return;//nyiRaise
379
51740958 380 Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(myFace1);
381 Standard_Boolean apex = FUN_tool_onapex(uv2, aSurf1);
7fd59977 382 if (apex) {
383 TopoDS_Vertex vf,vl; TopExp::Vertices(myEdge1,vf,vl);
384 gp_Pnt ptf = BRep_Tool::Pnt(vf); Standard_Real df = pt2.Distance(ptf);
302f96fb 385
7fd59977 386 Standard_Real tolf = BRep_Tool::Tolerance(vf);
302f96fb 387
7fd59977 388 Standard_Boolean onf = (df < tolf);
7fd59977 389 TopoDS_Vertex v1 = onf ? vf : vl;
390 TopTools_IndexedDataMapOfShapeListOfShape mapVE; TopExp::MapShapesAndAncestors(myFace1,TopAbs_VERTEX,TopAbs_EDGE,mapVE);
391 const TopTools_ListOfShape& Edsanc = mapVE.FindFromKey(v1);
392 TopTools_ListIteratorOfListOfShape it(Edsanc);
393 for (; it.More(); it.Next()){
394 const TopoDS_Edge& ee = TopoDS::Edge(it.Value());
395 Standard_Boolean dgee = BRep_Tool::Degenerated(ee);
396 if (!dgee) continue;
397// Standard_Real f,l;
398 PC2on1 = BRep_Tool::CurveOnSurface(ee,myFace1,first,last);
399 }
400 }
401 else {} // NYIxpu210998
402 } //dgE2
403 else {
404 // project curve of edge 2 on surface of face 1
405 TopLoc_Location loc ;
406 Handle(Geom_Curve) C = BRep_Tool::Curve(myEdge2,loc,first,last);
407 NC = Handle(Geom_Curve)::DownCast(C->Transformed(loc.Transformation()));
408 Standard_Real tolreached2d;
409
410 //modified by NIZNHY-PKV Fri Nov 5 12:29:13 1999 from
411 if (aSurfaceType1==GeomAbs_Sphere && aSurfaceType2==GeomAbs_Sphere) {
412 PC2on1 = FC2D_MakeCurveOnSurface (myEdge2, myFace1, first, last, tolpc, Standard_True);
413 }
414 else {
415 PC2on1 = TopOpeBRepTool_CurveTool::MakePCurveOnFace(myFace1,NC,tolreached2d);
416 }
417 //modified by NIZNHY-PKV Thu Nov 4 14:52:25 1999 t
418
419 }
420
421 if (!PC2on1.IsNull()) {
422 myCurve2.Load(PC2on1);
423 tole = BRep_Tool::Tolerance(myEdge2);
424 PC2on1->D0(first,pfirst);
425 PC2on1->D0(last,plast);
426 myDomain2.SetValues(pfirst,first,tole,plast,last,tole);
0797d9d3 427#ifdef OCCT_DEBUG
7fd59977 428 if ( TopOpeBRep_GettracePROEDG() ) {
04232180 429 std::cout<<"------------ projection de curve"<<std::endl;
430 std::cout<<"--- Curve : "<<std::endl;
431 GeomTools_CurveSet::PrintCurve(NC,std::cout);
432 std::cout<<"--- nouvelle PCurve : "<<std::endl;
433 GeomTools_Curve2dSet::PrintCurve2d(PC2on1,std::cout);
51740958 434 Handle(Geom_Surface) aS1 = BRep_Tool::Surface(myFace1);
04232180 435 std::cout<<"--- sur surface : "<<std::endl;
436 GeomTools_SurfaceSet::PrintSurface(aS1,std::cout);
437 std::cout<<std::endl;
7fd59977 438 }
439#endif
440 }
441 else return;
442 }
443
444 // compute the intersection
0797d9d3 445#ifdef OCCT_DEBUG
7fd59977 446 if (TopOpeBRepTool_GettraceKRO()) KRO_DSFILLER_INTEE.Start();
447#endif
448
449 Standard_Real tol1 = myTol1, tol2 = myTol2;
450// Wrong !!!
451/* if ( !myTolForced ) {
452 if ( t1 != t2 ) {
0797d9d3 453 //#ifdef OCCT_DEBUG // JYL 28/09/98 : temporaire
7fd59977 454 //if ( TopOpeBRep_GetcontextTOL0() ) { // JYL 28/09/98 : temporaire
455 tol1 = 0.; // JYL 28/09/98 : temporaire
456 tol2 = 0.; // JYL 28/09/98 : temporaire
457 //} // JYL 28/09/98 : temporaire
458 //#endif // JYL 28/09/98 : temporaire
459 }
460 }
461*/
462
0797d9d3 463#ifdef OCCT_DEBUG
7fd59977 464 if (TopOpeBRep_GettraceFITOL()) {
04232180 465 std::cout<<"EdgesIntersector : Perform";
7fd59977 466#ifdef DRAW
467 GeomAbs_CurveType t1 = myCurve1.GetType();
468 GeomAbs_CurveType t2 = myCurve2.GetType();
04232180 469 TCollection_AsciiString s1;CurveToString(t1,s1);std::cout<<" "<<s1;
470 TCollection_AsciiString s2;CurveToString(t2,s2);std::cout<<" "<<s2;
7fd59977 471#endif
04232180 472 std::cout<<std::endl;
473 std::cout<<" tol1 = "<<tol1<<std::endl;
474 std::cout<<" tol2 = "<<tol2<<std::endl;
7fd59977 475 }
476#endif
477
478 myIntersector.Perform(myCurve1,myDomain1,myCurve2,myDomain2,tol1,tol2);
479
480 Standard_Integer nbp = myIntersector.NbPoints();
481 Standard_Integer nbs = myIntersector.NbSegments();
482
483 mylpnt.Clear(); mylseg.Clear();
484// for (Standard_Integer p=1; p<=nbp; p++) mylpnt.Append(myIntersector.Point(p));
485 Standard_Integer p ;
486 for ( p=1; p<=nbp; p++) mylpnt.Append(myIntersector.Point(p));
487 for (Standard_Integer s=1; s<=nbs; s++) mylseg.Append(myIntersector.Segment(s));
488
489 Standard_Boolean filter = Standard_True;
0797d9d3 490#ifdef OCCT_DEBUG
7fd59977 491 Standard_Boolean nofilter = TopOpeBRep_GetcontextNOFEI(); if (nofilter) filter = Standard_False;
492#endif
493
494 //-- Filter :
495 if (filter) {
496 Standard_Boolean fin;
497 do {
498 fin=Standard_True;
499 for(p=1;p<nbp && fin ;p++) {
500 const IntRes2d_IntersectionPoint& P1=mylpnt.Value(p);
501 const IntRes2d_IntersectionPoint& P2=mylpnt.Value(p+1);
502 if( TransitionEqualAndExtremity(P1.TransitionOfFirst(),P2.TransitionOfFirst())
503 || TransitionEqualAndExtremity(P1.TransitionOfSecond(),P2.TransitionOfSecond()) ) {
0797d9d3 504#ifdef OCCT_DEBUG
7fd59977 505 Standard_Boolean TRC = Standard_True;
04232180 506 if (TRC) std::cout<<"\n Egalite de transitions \n"<<std::endl;
7fd59977 507#endif
508 fin = Standard_False;
509 mylpnt.Remove(p);
510 nbp--;
511 }
512// Modified by Sergey KHROMOV - Fri Jan 11 10:31:38 2002 Begin
513 else if (IsTangentSegment(P1, P2, myCurve1, myCurve2, Max(tol1, tol2))) {
514 const IntRes2d_Transition &aTrans = P2.TransitionOfFirst();
515
516 fin = Standard_False;
517 if (aTrans.TransitionType() == IntRes2d_Touch)
518 mylpnt.Remove(p);
519 else
520 mylpnt.Remove(p + 1);
521 nbp--;
522 }
523// Modified by Sergey KHROMOV - Fri Jan 11 10:31:39 2002 End
524 }
525 }
526 while(fin==Standard_False);
527 }
528 //-- End filter
529
530 myNbSegments = mylseg.Length();
531 myHasSegment = (myNbSegments != 0);
532 ComputeSameDomain();
533
534 myNbPoints = mylpnt.Length();
535 myTrueNbPoints = myNbPoints + 2 * myNbSegments;
536 myPointIndex = 0;
537
0797d9d3 538#ifdef OCCT_DEBUG
7fd59977 539 if (TopOpeBRep_GettraceEEFF()) debeeff();
540#endif
541
542 MakePoints2d();
543 if (ReduceSegment) ReduceSegments();
544
545 // xpu010998 : cto900J1, e5 sdm e13, IntPatch (Touch,Inside) ->
546 // faulty INTERNAL transition at G=v9 :
547 // xpu281098 : cto019D2, e3 sdm e9, faulty EXTERNAL transition
548 Standard_Boolean esd = SameDomain();
549 for (InitPoint();MorePoint();NextPoint()) {
550 TopOpeBRep_Point2d& P2D = mysp2d(myip2d);
551 Standard_Boolean isvertex1 = P2D.IsVertex(1);
552 Standard_Boolean isvertex2 = P2D.IsVertex(2);
553 Standard_Boolean isvertex = isvertex1 || isvertex2;
554
555 if (isvertex && esd) {
556 TopOpeBRepDS_Transition& T1 = P2D.ChangeTransition(1);
557 TopOpeBRepDS_Transition& T2 = P2D.ChangeTransition(2);
558
7fd59977 559 Standard_Boolean isvertex12 = isvertex1 && isvertex2;
560 Standard_Boolean isvertex22 = isvertex2 && !isvertex12;
561 Standard_Boolean isvertex11 = isvertex1 && !isvertex12;
562
563 Standard_Boolean T1INT = (T1.Orientation(TopAbs_IN) == TopAbs_INTERNAL);
302f96fb 564
7fd59977 565 if (T1INT && isvertex2 && !isvertex1) {
566 const TopoDS_Vertex& V2 = P2D.Vertex(2);
567 TopOpeBRepDS_Transition newT; Standard_Boolean computed = ::EdgesIntersector_checkT1D(myEdge1,myEdge2,V2,newT);
96a95605 568 if (computed) T1.Set(newT.Orientation(TopAbs_IN));
7fd59977 569 }
570
571 Standard_Boolean T2INT = (T2.Orientation(TopAbs_IN) == TopAbs_INTERNAL);
572 Standard_Boolean T2EXT = (T2.Orientation(TopAbs_IN) == TopAbs_EXTERNAL);
573 Standard_Boolean INTEXT2 = T2INT || T2EXT;
574 if (INTEXT2 && isvertex1 && !isvertex2) {
575 const TopoDS_Vertex& V1 = P2D.Vertex(1);
576 TopOpeBRepDS_Transition newT; Standard_Boolean computed = ::EdgesIntersector_checkT1D(myEdge2,myEdge1,V1,newT);
96a95605 577 if (computed) T2.Set(newT.Orientation(TopAbs_IN));
7fd59977 578 }
579
580 // xpu121098 : cto900I7 (e12on,vG14)
581 TopoDS_Vertex vcl2; Standard_Boolean clE2 = TopOpeBRepTool_TOOL::ClosedE(myEdge2,vcl2);
582 Standard_Boolean nT1 = ( !T1INT && clE2 && isvertex22 && vcl2.IsSame(P2D.Vertex(2)) );
583 if (nT1) T1.Set(TopAbs_INTERNAL);
584 TopoDS_Vertex vcl1; Standard_Boolean clE1 = TopOpeBRepTool_TOOL::ClosedE(myEdge1,vcl1);
585 Standard_Boolean nT2 = ( !T2INT && clE1 && isvertex11 && vcl1.IsSame(P2D.Vertex(1)) );
586 if (nT2) T2.Set(TopAbs_INTERNAL);
587
7fd59977 588 } // (isvertex && esd)
589 } // MorePoint
590
591
0797d9d3 592#ifdef OCCT_DEBUG
7fd59977 593 if (TopOpeBRepTool_GettraceKRO()) KRO_DSFILLER_INTEE.Stop();
594#endif
595} // Perform
596
597//=======================================================================
598//function : Dimension
599//purpose :
600//=======================================================================
601void TopOpeBRep_EdgesIntersector::Dimension(const Standard_Integer Dim)
602{
603 if (Dim == 1 || Dim == 2) {
604 myDimension = Dim;
605 }
606}
607
608//=======================================================================
609//function : Dimension
610//purpose :
611//=======================================================================
612Standard_Integer TopOpeBRep_EdgesIntersector::Dimension() const
613{
614 return myDimension;
615}
616
617//=======================================================================
618//function : ComputeSameDomain
619//purpose :
620//=======================================================================
621Standard_Boolean TopOpeBRep_EdgesIntersector::ComputeSameDomain()
622{
623 const Geom2dAdaptor_Curve& C1 = Curve(1);
624 const Geom2dAdaptor_Curve& C2 = Curve(2);
625 GeomAbs_CurveType t1 = C1.GetType();
626 GeomAbs_CurveType t2 = C2.GetType();
627
628 if (!myHasSegment)
629 return SetSameDomain(Standard_False);
630
631 Standard_Boolean tt = (t1 == t2);
632 if (!tt)
633 return SetSameDomain(Standard_False);
634
635 if (t1 == GeomAbs_Line)
636 return SetSameDomain(Standard_True);
637
638 if (t1 != GeomAbs_Circle) {
0797d9d3 639#ifdef OCCT_DEBUG
7fd59977 640 if (TopOpeBRepTool_GettraceNYI())
04232180 641 std::cout<<"TopOpeBRep_EdgesIntersector : EdgesSameDomain on NYI curve type"<<std::endl;
7fd59977 642#endif
643 return SetSameDomain(Standard_False);
644 }
645
646 gp_Circ2d c1 = C1.Circle();
647 gp_Circ2d c2 = C2.Circle();
648 Standard_Real r1 = c1.Radius();
649 Standard_Real r2 = c2.Radius();
650// Standard_Boolean rr = (r1 == r2);
651 Standard_Boolean rr = (Abs(r1-r2) < Precision::Confusion()); //xpu281098 (cto019D2) tolerance a revoir
652 if (!rr) return SetSameDomain(Standard_False);
653
7fd59977 654 const gp_Pnt2d& p1 = c1.Location();
655 const gp_Pnt2d& p2 = c2.Location();
656
657 const BRepAdaptor_Surface& BAS1 = Surface(1);
658 Standard_Real u1,v1; p1.Coord(u1,v1); gp_Pnt P1 = BAS1.Value(u1,v1);
659 Standard_Real u2,v2; p2.Coord(u2,v2); gp_Pnt P2 = BAS1.Value(u2,v2);// recall myCurve2=C2d(myEdge2,myFace1);
660 Standard_Real dpp = P1.Distance(P2);
661 Standard_Real tol1 = BRep_Tool::Tolerance(TopoDS::Edge(Edge(1)));
662 Standard_Real tol2 = BRep_Tool::Tolerance(TopoDS::Edge(Edge(2)));
663 Standard_Real tol = tol1 + tol2;
664 Standard_Boolean esd = (dpp <= tol);
665 if (esd) return SetSameDomain(Standard_True);
666
667 return SetSameDomain(Standard_False);
668} // ComputeSameDomain
669
670//=======================================================================
671//function : SetSameDomain
672//purpose :
673//=======================================================================
674Standard_Boolean TopOpeBRep_EdgesIntersector::SetSameDomain(const Standard_Boolean B)
675{
676 mySameDomain = B;
677 return B;
678}
679
680//=======================================================================
681//function : MakePoints2d
682//purpose :
683//=======================================================================
684void TopOpeBRep_EdgesIntersector::MakePoints2d()
685{
686 mysp2d.Clear();
687 TopAbs_Orientation E1ori = myEdge1.Orientation();
688 TopAbs_Orientation E2ori = myEdge2.Orientation();
689 for (InitPoint1();MorePoint1();NextPoint1()) {
690 const IntRes2d_IntersectionPoint& IP = Point1();
691 TopOpeBRep_Point2d p2d;
692 p2d.SetPint(IP);
693 p2d.SetTransition(1,Transition1(1,E2ori));
694 p2d.SetTransition(2,Transition1(2,E1ori));
695 p2d.SetParameter(1,Parameter1(1));
696 p2d.SetParameter(2,Parameter1(2));
697 Standard_Boolean isv1 = IsVertex1(1); p2d.SetIsVertex(1,isv1);
698 if (isv1) p2d.SetVertex(1,TopoDS::Vertex(Vertex1(1)));
699 Standard_Boolean isv2 = IsVertex1(2); p2d.SetIsVertex(2,isv2);
700 if (isv2) p2d.SetVertex(2,TopoDS::Vertex(Vertex1(2)));
701 p2d.SetIsPointOfSegment(IsPointOfSegment1());
702 p2d.SetSegmentAncestors(0,0);
703 p2d.SetStatus(Status1());
704 p2d.SetValue(Value1());
705 p2d.SetValue2d(IP.Value());
706 p2d.SetTolerance(ToleranceMax());
707 p2d.SetEdgesConfig(EdgesConfig1());
708 p2d.SetIndex(Index1());
709 mysp2d.Append(p2d);
710 }
711 myip2d = 1; mynp2d = mysp2d.Length();
712}
713
714//=======================================================================
715//function : ReduceSegment
716//purpose :
717//=======================================================================
718Standard_Boolean TopOpeBRep_EdgesIntersector::ReduceSegment(TopOpeBRep_Point2d& psa,
719 TopOpeBRep_Point2d& psb,
720 TopOpeBRep_Point2d& Pn) const
721{
722 Standard_Boolean reduced = Standard_False;
723 Standard_Integer ixpsa = psa.Index();
724 Standard_Integer ixpsb = psb.Index();
725
726 Standard_Boolean pospsa = psa.IsPointOfSegment();
727 TopOpeBRep_P2Dstatus stspsa = psa.Status();
7fd59977 728 Standard_Real tpsa1 = psa.Parameter(1);
729 Standard_Real tpsa2 = psa.Parameter(2);
730 const TopOpeBRepDS_Transition& Tpsa1 = psa.Transition(1);
731 const TopOpeBRepDS_Transition& Tpsa2 = psa.Transition(2);
732
733 Standard_Boolean pospsb = psb.IsPointOfSegment();
734 TopOpeBRep_P2Dstatus stspsb = psb.Status();
7fd59977 735 Standard_Real tpsb1 = psb.Parameter(1);
736 Standard_Real tpsb2 = psb.Parameter(2);
737 const TopOpeBRepDS_Transition& Tpsb1 = psb.Transition(1);
738 const TopOpeBRepDS_Transition& Tpsb2 = psb.Transition(2);
739
740 Standard_Boolean conda = (pospsa && (stspsa == TopOpeBRep_P2DSGF));
741 Standard_Boolean condb = (pospsb && (stspsb == TopOpeBRep_P2DSGL));
742 Standard_Boolean cond = (conda && condb);
743
744 if (cond) {
745 reduced = Standard_True;
746
747 Standard_Real tm1 = (tpsa1 + tpsb1)/2.; Pn.SetParameter(1,tm1);
748 Standard_Real tm2 = (tpsa2 + tpsb2)/2.; Pn.SetParameter(2,tm2);
749
750 TopOpeBRepDS_Transition Tn1;
751 Tn1.Before(Tpsa1.Before(),Tpsa1.ShapeBefore());
752 Tn1.After (Tpsb1.After(),Tpsb1.ShapeAfter());
753 Pn.SetTransition(1,Tn1);
754 TopOpeBRepDS_Transition Tn2;
755 Tn2.Before(Tpsa2.Before(),Tpsa2.ShapeBefore());
756 Tn2.After (Tpsb2.After(),Tpsb2.ShapeAfter());
757 Pn.SetTransition(2,Tn2);
758
759 const gp_Pnt& P3Dpsa = psa.Value();
760 const gp_Pnt& P3Dpsb = psb.Value();
761 gp_Pnt P3Dn((P3Dpsa.X()+P3Dpsb.X())/2,
762 (P3Dpsa.Y()+P3Dpsb.Y())/2,
763 (P3Dpsa.Z()+P3Dpsb.Z())/2);
764 Pn.SetValue(P3Dn);
765 const gp_Pnt2d& P2Dpsa = psa.Value2d();
766 const gp_Pnt2d& P2Dpsb = psb.Value2d();
767 gp_Pnt2d P2Dn((P2Dpsa.X()+P2Dpsb.X())/2,
768 (P2Dpsa.Y()+P2Dpsb.Y())/2);
769 Pn.SetValue2d(P2Dn);
770
771 Standard_Real tolpsa = psa.Tolerance();
772 Standard_Real tolpsb = psb.Tolerance();
773 Standard_Real toln = (tolpsa + tolpsb)*1.5;
774 Pn.SetTolerance(toln);
775
776 Pn.SetIsPointOfSegment(Standard_False);
777 Pn.SetSegmentAncestors(ixpsa,ixpsb);
778 psa.SetKeep(Standard_False);
779 psb.SetKeep(Standard_False);
780
781 TopOpeBRepDS_Config cpsa = psa.EdgesConfig();
6e6cd5d9 782
7fd59977 783 Pn.SetEdgesConfig(cpsa);
784
785 Standard_Boolean isvpsa1 = psa.IsVertex(1);if (isvpsa1) Pn.SetVertex(1,psa.Vertex(1));
786 Standard_Boolean isvpsa2 = psa.IsVertex(2);if (isvpsa2) Pn.SetVertex(2,psa.Vertex(2));
787 Standard_Boolean isvpsb1 = psb.IsVertex(1);if (isvpsb1) Pn.SetVertex(1,psb.Vertex(1));
788 Standard_Boolean isvpsb2 = psb.IsVertex(2);if (isvpsb2) Pn.SetVertex(2,psb.Vertex(2));
789 }
790
791 return reduced;
792} // ReduceSegment
793
794//=======================================================================
795//function : ReduceSegments
796//purpose :
797//=======================================================================
798void TopOpeBRep_EdgesIntersector::ReduceSegments()
799{
800 Standard_Boolean condredu = (myHasSegment && !mySameDomain);
801 if (!condredu) return;
802
7fd59977 803 Standard_Integer ip = 1;Standard_Integer np = mynp2d;
804 while (ip < np) {
805 TopOpeBRep_Point2d& psa = mysp2d(ip);
806 TopOpeBRep_Point2d& psb = mysp2d(ip+1);
807 TopOpeBRep_Point2d pn;
808 Standard_Boolean reduced = ReduceSegment(psa,psb,pn);
809 if (reduced) {
810 pn.SetIndex(++mynp2d);
811 mysp2d.Append(pn);
812 }
813 ip++;
814 }
815
816 mylseg.Clear();
817 myNbSegments = mylseg.Length();
818 myHasSegment = (myNbSegments != 0);
819 myTrueNbPoints = myNbPoints + 2 * myNbSegments;
820
821} // ReduceSegments
822
823
824//=======================================================================
825//function : IsEmpty
826//purpose :
827//=======================================================================
828Standard_Boolean TopOpeBRep_EdgesIntersector::IsEmpty ()
829{
830 return (mynp2d == 0);
831}
832
833//=======================================================================
834//function : HasSegment
835//purpose :
836//=======================================================================
837Standard_Boolean TopOpeBRep_EdgesIntersector::HasSegment () const
838{
839 return myHasSegment;
840}
841
842//=======================================================================
843//function : SameDomain
844//purpose :
845//=======================================================================
846Standard_Boolean TopOpeBRep_EdgesIntersector::SameDomain() const
847{
848 return mySameDomain;
849}
850
851//=======================================================================
852//function : Edge
853//purpose :
854//=======================================================================
855const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Edge(const Standard_Integer Index) const
856{
857 if ( Index == 1 ) return myEdge1;
858 else if ( Index == 2 ) return myEdge2;
9775fa61 859 else throw Standard_Failure("TopOpeBRep_EdgesIntersector::Edge");
7fd59977 860}
861
862//=======================================================================
863//function : Curve
864//purpose :
865//=======================================================================
866const Geom2dAdaptor_Curve& TopOpeBRep_EdgesIntersector::Curve(const Standard_Integer Index) const
867{
868 if ( Index == 1 ) return myCurve1;
869 else if ( Index == 2 ) return myCurve2;
9775fa61 870 else throw Standard_Failure("TopOpeBRep_EdgesIntersector::Curve");
7fd59977 871}
872
873//=======================================================================
874//function : Face
875//purpose :
876//=======================================================================
877const TopoDS_Shape& TopOpeBRep_EdgesIntersector::Face(const Standard_Integer Index) const
878{
879 if ( Index == 1 ) return myFace1;
880 else if ( Index == 2 ) return myFace2;
9775fa61 881 else throw Standard_Failure("TopOpeBRep_EdgesIntersector::Face");
7fd59977 882}
883
884//=======================================================================
885//function : Surface
886//purpose :
887//=======================================================================
888const BRepAdaptor_Surface& TopOpeBRep_EdgesIntersector::Surface(const Standard_Integer Index) const
889{
890 if ( Index == 1 ) return mySurface1->ChangeSurface();
891 else if ( Index == 2 ) return mySurface2->ChangeSurface();
9775fa61 892 else throw Standard_Failure("TopOpeBRep_EdgesIntersector::Surface");
7fd59977 893}
894
895//=======================================================================
896//function : SurfacesSameOriented
897//purpose :
898//=======================================================================
899Standard_Boolean TopOpeBRep_EdgesIntersector::SurfacesSameOriented () const
900{
901 return mySurfacesSameOriented;
902}
903
904//=======================================================================
905//function : FacesSameOriented
906//purpose :
907//=======================================================================
908Standard_Boolean TopOpeBRep_EdgesIntersector::FacesSameOriented () const
909{
910 return myFacesSameOriented;
911}
912
913//=======================================================================
914//function : InitPoint
915//purpose :
916//=======================================================================
917void TopOpeBRep_EdgesIntersector::InitPoint(const Standard_Boolean selectkeep)
918{
919 myselectkeep = selectkeep;
920 myip2d = 1; mynp2d = mysp2d.Length();
921 Find();
922}
923
924//=======================================================================
925//function : MorePoint
926//purpose :
927//=======================================================================
928Standard_Boolean TopOpeBRep_EdgesIntersector::MorePoint() const
929{
930 Standard_Boolean b = (myip2d <= mynp2d);
931 return b;
932}
933
934//=======================================================================
935//function : NextPoint
936//purpose :
937//=======================================================================
938void TopOpeBRep_EdgesIntersector::NextPoint()
939{
940 myip2d++;
941 Find();
942}
943
944//=======================================================================
945//function : Find
946//purpose :
947//=======================================================================
948void TopOpeBRep_EdgesIntersector::Find()
949{
950 while (myip2d <= mynp2d) {
951 if (myselectkeep) {
952 Standard_Boolean kf = mysp2d(myip2d).Keep();
953 if (kf) break;
954 else myip2d++;
955 }
956 else {
957 break;
958 }
959 }
960}
961
962//=======================================================================
963//function : Points
964//purpose :
965//=======================================================================
966const TopOpeBRep_SequenceOfPoint2d& TopOpeBRep_EdgesIntersector::Points() const
967{
968 return mysp2d;
969}
970
971//=======================================================================
972//function : Point
973//purpose :
974//=======================================================================
975const TopOpeBRep_Point2d& TopOpeBRep_EdgesIntersector::Point() const
976{
977 return mysp2d(myip2d);
978}
979
980//=======================================================================
981//function : Point
982//purpose :
983//=======================================================================
984const TopOpeBRep_Point2d& TopOpeBRep_EdgesIntersector::Point(const Standard_Integer I) const
985{
9775fa61 986 if (I<1 || I>mysp2d.Length()) throw Standard_Failure("TopOpeBRep_EdgesIntersector::Point(I)");
7fd59977 987 return mysp2d(I);
988}
989
990//=======================================================================
991//function : ToleranceMax
992//purpose :
993//=======================================================================
994Standard_Real TopOpeBRep_EdgesIntersector::ToleranceMax() const
995{
996 Standard_Real tol = Max(myTol1,myTol2);
997 return tol;
998}
999
1000//=======================================================================
1001//function : Tolerances
1002//purpose :
1003//=======================================================================
1004void TopOpeBRep_EdgesIntersector::Tolerances(Standard_Real& tol1, Standard_Real& tol2) const
1005{
1006 tol1 = myTol1;
1007 tol2 = myTol2;
1008}
1009
1010//=======================================================================
1011//function : NbPoints
1012//purpose : (debug)
1013//=======================================================================
1014Standard_Integer TopOpeBRep_EdgesIntersector::NbPoints() const
1015{
1016 return myNbPoints;
1017}
1018
1019//=======================================================================
1020//function : NbSegments
1021//purpose : (debug)
1022//=======================================================================
1023Standard_Integer TopOpeBRep_EdgesIntersector::NbSegments() const
1024{
1025 return myNbSegments;
1026}
1027
1028//=======================================================================
1029//function : Dump
1030//purpose :
1031//=======================================================================
0797d9d3 1032#ifndef OCCT_DEBUG
7fd59977 1033void TopOpeBRep_EdgesIntersector::Dump(const TCollection_AsciiString& ,const Standard_Integer ,const Standard_Integer )
1034{
1035#else
1036void TopOpeBRep_EdgesIntersector::Dump(const TCollection_AsciiString& str,const Standard_Integer E1index,const Standard_Integer E2index)
1037{
1038 InitPoint();if (!MorePoint()) return;
04232180 1039 std::cout<<std::endl<<"---- "<<str<<" ---- E/E : "<<NbPoints()<<" p , ";
1040 std::cout<<NbSegments()<<" s : "<<myTrueNbPoints<<" true points"<<std::endl;
1041 std::cout<<"E1 = "<<E1index<<" ";TopAbs::Print(Edge(1).Orientation(),std::cout)<<", ";
1042 std::cout<<"E2 = "<<E2index<<" ";TopAbs::Print(Edge(2).Orientation(),std::cout)<<" ";
1043 std::cout<<"hs="<<HasSegment()<<" hsd="<<SameDomain()<<std::endl;
7fd59977 1044
1045 for (InitPoint(); MorePoint(); NextPoint()) {
1046 const TopOpeBRep_Point2d P2d = Point();
1047 P2d.Dump(E1index,E2index);
1048 if (P2d.Status() == TopOpeBRep_P2DNEW) {
1049 Standard_Integer ip1,ip2; P2d.SegmentAncestors(ip1,ip2);
1050 Standard_Real d1 = Point(ip1).Value().Distance(Point(ip2).Value());
1051 Standard_Real d2 = d1 + Point(ip1).Tolerance()/2. + Point(ip2).Tolerance()/2.;
04232180 1052 std::cout<<"ancestor segment : d P"<<ip1<<",P"<<ip2<<" = "<<d1<<std::endl;
1053 std::cout<<" t1/2 + d + t2/2 P"<<ip1<<",P"<<ip2<<" = "<<d2<<std::endl;
7fd59977 1054 }
1055 }
04232180 1056 std::cout<<std::endl;
7fd59977 1057#endif
1058}
1059
1060