1 // Created on: 1995-12-15
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Bnd_Box2d.hxx>
19 #include <BndLib_Add2dCurve.hxx>
20 #include <BRep_Builder.hxx>
21 #include <BRep_TFace.hxx>
22 #include <BRep_Tool.hxx>
23 #include <BRepAdaptor_HSurface.hxx>
24 #include <BRepCheck.hxx>
25 #include <BRepCheck_Face.hxx>
26 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
27 #include <BRepCheck_ListOfStatus.hxx>
28 #include <BRepClass_FaceClassifier.hxx>
29 #include <BRepTopAdaptor_FClass2d.hxx>
30 #include <Geom2d_Curve.hxx>
31 #include <Geom2dAdaptor_Curve.hxx>
32 #include <Geom2dInt_GInter.hxx>
33 #include <Geom_Curve.hxx>
34 #include <gp_Pnt2d.hxx>
35 #include <GProp_GProps.hxx>
36 #include <IntRes2d_Domain.hxx>
37 #include <IntRes2d_IntersectionPoint.hxx>
38 #include <IntRes2d_IntersectionSegment.hxx>
39 #include <NCollection_DataMap.hxx>
40 #include <Precision.hxx>
41 #include <Standard_Type.hxx>
42 #include <TColgp_SequenceOfPnt.hxx>
43 #include <TopAbs_State.hxx>
45 #include <TopExp_Explorer.hxx>
47 #include <TopoDS_Face.hxx>
48 #include <TopoDS_Shape.hxx>
49 #include <TopoDS_Vertex.hxx>
50 #include <TopoDS_Wire.hxx>
51 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
52 #include <TopTools_DataMapOfShapeListOfShape.hxx>
53 #include <TopTools_ListIteratorOfListOfShape.hxx>
54 #include <TopTools_ListOfShape.hxx>
55 #include <TopTools_MapOfShape.hxx>
56 #include <TopTools_OrientedShapeMapHasher.hxx>
57 #include <TopTools_SequenceOfShape.hxx>
59 IMPLEMENT_STANDARD_RTTIEXT(BRepCheck_Face,BRepCheck_Result)
61 //#include <BRepAdaptor_Curve2d.hxx>
62 //#include <Geom2dInt_GInter.hxx>
63 typedef NCollection_DataMap<TopoDS_Shape, Bnd_Box2d, TopTools_OrientedShapeMapHasher> DataMapOfShapeBox2d;
65 static Standard_Boolean Intersect(const TopoDS_Wire&,
68 const DataMapOfShapeBox2d&);
71 static Standard_Boolean IsInside(const TopoDS_Wire& wir,
72 const Standard_Boolean Inside,
73 const BRepTopAdaptor_FClass2d& FClass2d,
74 const TopoDS_Face& F);
76 static Standard_Boolean CheckThin(const TopoDS_Shape& w,
77 const TopoDS_Shape& f);
79 //=======================================================================
80 //function : BRepCheck_Face
82 //=======================================================================
84 BRepCheck_Face::BRepCheck_Face (const TopoDS_Face& F)
87 myIntdone = Standard_False;
88 myImbdone = Standard_False;
89 myOridone = Standard_False;
90 myGctrl = Standard_True;
93 //=======================================================================
96 //=======================================================================
98 void BRepCheck_Face::Minimum()
101 BRepCheck_ListOfStatus thelist;
102 myMap.Bind(myShape, thelist);
103 BRepCheck_ListOfStatus& lst = myMap(myShape);
105 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &myShape.TShape());
106 if (TF->Surface().IsNull()) {
107 BRepCheck::Add(lst,BRepCheck_NoSurface);
110 // Flag natural restriction???
113 lst.Append(BRepCheck_NoError);
115 myMin = Standard_True;
120 //=======================================================================
121 //function : InContext
123 //=======================================================================
125 void BRepCheck_Face::InContext(const TopoDS_Shape& S)
127 if (myMap.IsBound(S)) {
130 BRepCheck_ListOfStatus thelist;
131 myMap.Bind(S, thelist);
133 BRepCheck_ListOfStatus& lst = myMap(S);
135 TopExp_Explorer exp(S,TopAbs_FACE);
136 for (; exp.More(); exp.Next()) {
137 if (exp.Current().IsSame(myShape)) {
142 BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
147 lst.Append(BRepCheck_NoError);
152 //=======================================================================
155 //=======================================================================
157 void BRepCheck_Face::Blind()
160 // nothing more than in the minimum
161 myBlind = Standard_True;
166 //=======================================================================
167 //function : IntersectWires
169 //=======================================================================
171 BRepCheck_Status BRepCheck_Face::IntersectWires(const Standard_Boolean Update)
175 BRepCheck::Add(myMap(myShape),myIntres);
180 myIntdone = Standard_True;
181 myIntres = BRepCheck_NoError;
182 // This method has to be called by an analyzer. It is assumed that
183 // each edge has a correct 2d representation on the face.
185 TopExp_Explorer exp1,exp2;
187 // the wires are mapped
188 exp1.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
189 TopTools_ListOfShape theListOfShape;
190 while (exp1.More()) {
191 if (!myMapImb.IsBound(exp1.Current())) {
192 myMapImb.Bind(exp1.Current(), theListOfShape);
194 else { // the same wire is met twice...
195 myIntres = BRepCheck_RedundantWire;
197 BRepCheck::Add(myMap(myShape),myIntres);
204 Geom2dAdaptor_Curve aC;
205 Standard_Real aFirst, aLast;
206 DataMapOfShapeBox2d aMapShapeBox2d;
207 for (exp1.Init (myShape, TopAbs_WIRE); exp1.More(); exp1.Next())
209 const TopoDS_Wire& aWire = TopoDS::Wire (exp1.Current());
210 // create 2d boxes for all edges from wire
212 for (exp2.Init (aWire, TopAbs_EDGE); exp2.More(); exp2.Next())
214 const TopoDS_Edge& anEdge = TopoDS::Edge (exp2.Current());
215 aC.Load (BRep_Tool::CurveOnSurface (anEdge, TopoDS::Face (myShape), aFirst, aLast));
216 // To avoid exeption in Segment if C1 is BSpline
217 if (aC.FirstParameter() > aFirst)
219 aFirst = aC.FirstParameter();
221 if (aC.LastParameter() < aLast)
223 aLast = aC.LastParameter();
226 BndLib_Add2dCurve::Add (aC, aFirst, aLast, 0., aBoxE);
227 aMapShapeBox2d.Bind (anEdge, aBoxE);
230 aMapShapeBox2d.Bind (aWire, aBoxW);
233 Standard_Integer Nbwire, Index,Indexbis;
234 Nbwire = myMapImb.Extent();
237 while (Index < Nbwire) {
238 for (exp1.Init(myShape,TopAbs_WIRE),Indexbis = 0;
239 exp1.More();exp1.Next()) {
241 if (Indexbis == Index) {
245 TopoDS_Wire wir1 = TopoDS::Wire(exp1.Current());
246 // to reduce the number of calls Intersect(wir1,wir2)
247 Bnd_Box2d aBox1, aBox2;
248 if (aMapShapeBox2d.IsBound (wir1))
250 aBox1 = aMapShapeBox2d (wir1);
253 for (; exp1.More(); exp1.Next()) {
254 const TopoDS_Wire& wir2 = TopoDS::Wire(exp1.Current());
255 if (aMapShapeBox2d.IsBound (wir2))
257 aBox2 = aMapShapeBox2d (wir2);
259 if (!aBox1.IsVoid() && !aBox2.IsVoid() && aBox1.IsOut (aBox2))
263 if (Intersect(wir1,wir2,TopoDS::Face(myShape), aMapShapeBox2d)) {
264 myIntres = BRepCheck_IntersectingWires;
266 BRepCheck::Add(myMap(myShape),myIntres);
274 BRepCheck::Add(myMap(myShape),myIntres);
280 //=======================================================================
281 //function : ClassifyWires
283 //=======================================================================
285 BRepCheck_Status BRepCheck_Face::ClassifyWires(const Standard_Boolean Update)
287 // It is assumed that each wire does not intersect any other one.
290 BRepCheck::Add(myMap(myShape),myImbres);
295 myImbdone = Standard_True;
296 myImbres = IntersectWires();
297 if (myImbres != BRepCheck_NoError) {
299 BRepCheck::Add(myMap(myShape),myImbres);
304 Standard_Integer Nbwire = myMapImb.Extent();
307 BRepCheck::Add(myMap(myShape),myImbres);
313 TopExp_Explorer exp1,exp2;
314 TopTools_ListOfShape theListOfShape;
315 for (exp1.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
316 exp1.More();exp1.Next()) {
318 const TopoDS_Wire& wir1 = TopoDS::Wire(exp1.Current());
319 TopoDS_Shape aLocalShape = myShape.EmptyCopied();
320 TopoDS_Face newFace = TopoDS::Face(aLocalShape);
321 // TopoDS_Face newFace = TopoDS::Face(myShape.EmptyCopied());
323 newFace.Orientation(TopAbs_FORWARD);
326 BRepTopAdaptor_FClass2d FClass2d(newFace,Precision::PConfusion());
327 Standard_Boolean WireBienOriente = Standard_False;
328 if(FClass2d.PerformInfinitePoint() != TopAbs_OUT) {
329 WireBienOriente=Standard_True;
330 // the given wire defines a hole
331 myMapImb.UnBind(wir1);
332 myMapImb.Bind(wir1.Reversed(), theListOfShape);
335 for (exp2.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
336 exp2.More();exp2.Next()) {
337 const TopoDS_Wire& wir2 = TopoDS::Wire(exp2.Current());
338 if (!wir2.IsSame(wir1)) {
340 if (IsInside(wir2,WireBienOriente,FClass2d,newFace)) {
341 myMapImb(wir1).Append(wir2);
346 // It is required to have 1 wire that contains all others, and the others should not
347 // contain anything (case solid ended) or
348 // the wires do not contain anything : in this case the wires should be
349 // holes in an infinite face.
351 for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(myMapImb);
354 if (!itm.Value().IsEmpty()) {
356 Wext = TopoDS::Wire(itm.Key());
359 myImbres = BRepCheck_InvalidImbricationOfWires;
361 BRepCheck::Add(myMap(myShape),myImbres);
368 if (!Wext.IsNull()) {
369 // verifies that the list contains nbwire-1 elements
370 if (myMapImb(Wext).Extent() != Nbwire-1) {
371 myImbres = BRepCheck_InvalidImbricationOfWires;
373 BRepCheck::Add(myMap(myShape),myImbres);
378 // quit without errors
380 BRepCheck::Add(myMap(myShape),myImbres);
387 //=======================================================================
388 //function : OrientationOfWires
390 //=======================================================================
392 BRepCheck_Status BRepCheck_Face::OrientationOfWires
393 (const Standard_Boolean Update)
395 // WARNING : it is assumed that the edges of a wire are correctly oriented
398 Standard_Boolean Infinite = myShape.Infinite();
402 BRepCheck::Add(myMap(myShape),myOrires);
407 myOridone = Standard_True;
408 myOrires = ClassifyWires();
409 if (myOrires != BRepCheck_NoError) {
411 BRepCheck::Add(myMap(myShape),myOrires);
416 Standard_Integer Nbwire = myMapImb.Extent();
418 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(myMapImb);
421 Wext = TopoDS::Wire(itm.Key());
425 for (;itm.More();itm.Next()) {
426 if (!itm.Value().IsEmpty()) {
427 Wext = TopoDS::Wire(itm.Key());
432 if (Wext.IsNull() && !Infinite) {
433 if (Nbwire>0) myOrires = BRepCheck_InvalidImbricationOfWires;
435 BRepCheck::Add(myMap(myShape),myOrires);
441 TopExp_Explorer exp(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
442 for (; exp.More(); exp.Next()) {
443 const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
444 if (!Wext.IsNull() && wir.IsSame(Wext)) {
445 if (wir.Orientation() != Wext.Orientation()) {
446 //the exterior wire defines a hole
447 if( CheckThin(wir,myShape.Oriented(TopAbs_FORWARD)) )
449 myOrires = BRepCheck_BadOrientationOfSubshape;
451 BRepCheck::Add(myMap(myShape),myOrires);
457 for (itm.Reset(); itm.More(); itm.Next()) {
458 if (itm.Key().IsSame(wir)) {
462 // No control on More()
463 if (itm.Key().Orientation() == wir.Orientation()) {
464 // the given wire does not define a hole
465 myOrires = BRepCheck_BadOrientationOfSubshape;
467 BRepCheck::Add(myMap(myShape),myOrires);
473 // quit withour error
475 BRepCheck::Add(myMap(myShape),myOrires);
481 //=======================================================================
482 //function : SetUnorientable
484 //=======================================================================
486 void BRepCheck_Face::SetUnorientable()
488 BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape);
491 //=======================================================================
492 //function : SetStatus
494 //=======================================================================
496 void BRepCheck_Face::SetStatus(const BRepCheck_Status theStatus)
498 BRepCheck::Add(myMap(myShape),theStatus);
501 //=======================================================================
502 //function : IsUnorientable
504 //=======================================================================
506 Standard_Boolean BRepCheck_Face::IsUnorientable() const
509 return (myOrires != BRepCheck_NoError);
511 for (BRepCheck_ListIteratorOfListOfStatus itl(myMap(myShape));
514 if (itl.Value() == BRepCheck_UnorientableShape) {
515 return Standard_True;
518 return Standard_False;
521 //=======================================================================
522 //function : GeometricControls
524 //=======================================================================
526 void BRepCheck_Face::GeometricControls(const Standard_Boolean B)
530 myIntdone = Standard_False;
531 myImbdone = Standard_False;
532 myOridone = Standard_False;
539 //=======================================================================
540 //function : GeometricControls
542 //=======================================================================
544 Standard_Boolean BRepCheck_Face::GeometricControls() const
550 //=======================================================================
551 //function : Intersect
553 //=======================================================================
555 static Standard_Boolean Intersect(const TopoDS_Wire& wir1,
556 const TopoDS_Wire& wir2,
557 const TopoDS_Face& F,
558 const DataMapOfShapeBox2d& theMapEdgeBox)
560 Standard_Real Inter2dTol = 1.e-10;
561 TopExp_Explorer exp1,exp2;
562 // BRepAdaptor_Curve2d cur1,cur2;
564 //Find common vertices of two wires - non-manifold case
565 TopTools_MapOfShape MapW1;
566 TopTools_SequenceOfShape CommonVertices;
567 for (exp1.Init( wir1, TopAbs_VERTEX ); exp1.More(); exp1.Next())
568 MapW1.Add( exp1.Current() );
569 for (exp2.Init( wir2, TopAbs_VERTEX ); exp2.More(); exp2.Next())
571 TopoDS_Shape V = exp2.Current();
572 if (MapW1.Contains( V ))
573 CommonVertices.Append( V );
576 // MSV 03.04.2002: create pure surface adaptor to avoid UVBounds computation
577 // due to performance problem
578 BRepAdaptor_Surface Surf(F,Standard_False);
580 TColgp_SequenceOfPnt PntSeq;
582 for (i = 1; i <= CommonVertices.Length(); i++)
584 TopoDS_Vertex V = TopoDS::Vertex( CommonVertices(i) );
585 gp_Pnt2d P2d = BRep_Tool::Parameters( V, F );
586 gp_Pnt P = Surf.Value( P2d.X(), P2d.Y() );
590 Geom2dAdaptor_Curve C1,C2;
591 gp_Pnt2d pfirst1,plast1,pfirst2,plast2;
592 Standard_Real first1,last1,first2,last2;
593 Geom2dInt_GInter Inter;
594 IntRes2d_Domain myDomain1,myDomain2;
595 Bnd_Box2d Box1, Box2;
597 for (exp1.Init(wir1,TopAbs_EDGE); exp1.More(); exp1.Next())
599 const TopoDS_Edge& edg1 = TopoDS::Edge(exp1.Current());
600 // cur1.Initialize(edg1,F);
601 C1.Load( BRep_Tool::CurveOnSurface(edg1,F,first1,last1) );
602 // To avoid exeption in Segment if C1 is BSpline - IFV
603 if(C1.FirstParameter() > first1) first1 = C1.FirstParameter();
604 if(C1.LastParameter() < last1 ) last1 = C1.LastParameter();
607 if (theMapEdgeBox.IsBound (edg1))
609 Box1 = theMapEdgeBox (edg1);
613 BndLib_Add2dCurve::Add( C1, first1, last1, 0., Box1 );
615 for (exp2.Init(wir2,TopAbs_EDGE); exp2.More(); exp2.Next())
617 const TopoDS_Edge& edg2 = TopoDS::Edge(exp2.Current());
618 if (!edg1.IsSame(edg2))
620 //cur2.Initialize(edg2,F);
621 C2.Load( BRep_Tool::CurveOnSurface(edg2,F,first2,last2) );
622 // To avoid exeption in Segment if C2 is BSpline - IFV
623 if(C2.FirstParameter() > first2) first2 = C2.FirstParameter();
624 if(C2.LastParameter() < last2 ) last2 = C2.LastParameter();
627 if (theMapEdgeBox.IsBound (edg2))
629 Box2 = theMapEdgeBox (edg2);
633 BndLib_Add2dCurve::Add( C2, first2, last2, 0., Box2 );
635 if (! Box1.IsOut( Box2 ))
637 BRep_Tool::UVPoints(edg1,F,pfirst1,plast1);
638 myDomain1.SetValues( pfirst1, first1, Inter2dTol, plast1, last1, Inter2dTol );
639 BRep_Tool::UVPoints(edg2,F,pfirst2,plast2);
640 myDomain2.SetValues( pfirst2, first2, Inter2dTol, plast2, last2, Inter2dTol );
641 Inter.Perform( C1, myDomain1, C2, myDomain2, Inter2dTol, Inter2dTol );
643 return Standard_True;
644 if (Inter.NbSegments() > 0)
646 if (PntSeq.IsEmpty())
647 return Standard_True;
650 Standard_Integer NbCoinc = 0;
651 for (i = 1; i <= Inter.NbSegments(); i++)
653 if (!Inter.Segment(i).HasFirstPoint() || !Inter.Segment(i).HasLastPoint())
654 return Standard_True;
655 gp_Pnt2d FirstP2d = Inter.Segment(i).FirstPoint().Value();
656 gp_Pnt2d LastP2d = Inter.Segment(i).LastPoint().Value();
657 gp_Pnt FirstP = Surf.Value( FirstP2d.X(), FirstP2d.Y() );
658 gp_Pnt LastP = Surf.Value( LastP2d.X(), LastP2d.Y() );
659 for (Standard_Integer j = 1; j <= PntSeq.Length(); j++)
661 Standard_Real tolv = BRep_Tool::Tolerance( TopoDS::Vertex(CommonVertices(j)) );
662 if (FirstP.IsEqual( PntSeq(j), tolv ) || LastP.IsEqual( PntSeq(j), tolv ))
669 if (NbCoinc == Inter.NbSegments())
670 return Standard_False;
671 return Standard_True;
674 if (Inter.NbPoints() > 0)
676 if (PntSeq.IsEmpty())
677 return Standard_True;
680 Standard_Integer NbCoinc = 0;
681 for (i = 1; i <= Inter.NbPoints(); i++)
683 gp_Pnt2d P2d = Inter.Point(i).Value();
684 gp_Pnt P = Surf.Value( P2d.X(), P2d.Y() );
685 for (Standard_Integer j = 1; j <= PntSeq.Length(); j++)
687 Standard_Real tolv = BRep_Tool::Tolerance( TopoDS::Vertex(CommonVertices(j)) );
688 if (P.IsEqual( PntSeq(j), tolv ))
695 if (NbCoinc == Inter.NbPoints())
696 return Standard_False;
697 return Standard_True;
704 return Standard_False;
708 //=======================================================================
709 //function : IsInside
711 //=======================================================================
713 static Standard_Boolean IsInside(const TopoDS_Wire& theWire,
714 const Standard_Boolean WireBienOriente,
715 const BRepTopAdaptor_FClass2d& FClass2d,
716 const TopoDS_Face& theFace)
718 Standard_Real aParameter, aFirst, aLast;
720 TopExp_Explorer anExplorer(theWire, TopAbs_EDGE);
721 for( ; anExplorer.More(); anExplorer.Next() )
723 const TopoDS_Edge& anEdge = TopoDS::Edge( anExplorer.Current() );
724 Handle(Geom2d_Curve) aCurve2D =
725 BRep_Tool::CurveOnSurface( anEdge, theFace, aFirst, aLast );
727 // Selects the parameter of point on the curve
728 if( !Precision::IsNegativeInfinite(aFirst) &&
729 !Precision::IsPositiveInfinite(aLast) )
731 aParameter = (aFirst + aLast) * 0.5;
733 // Edge is skipped if its parametric range is too small
734 if( Abs(aParameter - aFirst) < Precision::PConfusion() )
739 //Edge is skipped if its length is too small
740 Standard_Real aFirst3D, aLast3D;
741 Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aFirst3D, aLast3D );
742 if ( aCurve.IsNull() )
748 // Compute start point of edge
749 aCurve->D0( aFirst, aPoints[0] );
750 // Compute middle point of edge
751 aCurve->D0( (aFirst3D+aLast3D)/2., aPoints[1] );
752 if( aPoints[0].Distance(aPoints[1]) < Precision::Confusion() )
759 if( Precision::IsNegativeInfinite(aFirst) &&
760 Precision::IsPositiveInfinite(aLast) )
764 else if( Precision::IsNegativeInfinite(aFirst) )
766 aParameter = aLast - 1.;
770 aParameter = aFirst + 1.;
774 // Find point on curve (edge)
775 gp_Pnt2d aPoint2D(aCurve2D->Value(aParameter));
776 // Compute the topological position of a point relative to face
777 TopAbs_State aState = FClass2d.Perform(aPoint2D, Standard_False);
779 if( WireBienOriente )
781 return aState == TopAbs_OUT;
785 return aState == TopAbs_IN;
788 return Standard_False;
790 Standard_Boolean CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f)
792 TopoDS_Face aF = TopoDS::Face(f);
793 TopoDS_Wire aW = TopoDS::Wire(w);
795 Standard_Integer nbE = 0;
796 TopTools_ListOfShape lE;
797 TopExp_Explorer exp(aW,TopAbs_EDGE);
798 for(; exp.More(); exp.Next()) {
799 const TopoDS_Shape& s = exp.Current();
804 if( nbE != 2 ) return Standard_False;
805 TopoDS_Edge e1 = TopoDS::Edge(lE.First());
806 TopoDS_Edge e2 = TopoDS::Edge(lE.Last());
808 TopoDS_Vertex v1, v2, v3, v4;
809 TopExp::Vertices(e1,v1,v2);
810 TopExp::Vertices(e2,v3,v4);
812 if( v1.IsNull() || v2.IsNull() ||
813 v3.IsNull() || v4.IsNull() ) return Standard_False;
815 if( v1.IsSame(v2) || v3.IsSame(v4) )
816 return Standard_False;
818 Standard_Boolean sF = Standard_False, sL = Standard_False;
819 if( v1.IsSame(v3) || v1.IsSame(v4) ) sF = Standard_True;
820 if( v2.IsSame(v3) || v2.IsSame(v4) ) sL = Standard_True;
822 if( !sF || !sL ) return Standard_False;
824 TopAbs_Orientation e1or = e1.Orientation();
825 TopAbs_Orientation e2or = e2.Orientation();
827 Standard_Real f1 = 0., l1 = 0., f2 = 0., l2 = 0.;
828 Handle(Geom2d_Curve) pc1 = BRep_Tool::CurveOnSurface(e1,aF,f1,l1);
829 Handle(Geom2d_Curve) pc2 = BRep_Tool::CurveOnSurface(e2,aF,f2,l2);
831 if( pc1.IsNull() || pc2.IsNull() ) return Standard_False;
833 Standard_Real d1 = Abs(l1-f1)/100.;
834 Standard_Real d2 = Abs(l2-f2)/100.;
835 Standard_Real m1 = (l1+f1)*0.5;
836 Standard_Real m2 = (l2+f2)*0.5;
838 gp_Pnt2d p1f(pc1->Value(m1-d1));
839 gp_Pnt2d p1l(pc1->Value(m1+d1));
840 gp_Pnt2d p2f(pc2->Value(m2-d2));
841 gp_Pnt2d p2l(pc2->Value(m2+d2));
843 gp_Vec2d vc1(p1f,p1l);
844 gp_Vec2d vc2(p2f,p2l);
846 if( (vc1*vc2) >= 0. && e1or == e2or ) return Standard_False;
848 return Standard_True;