1 // Created on: 1992-11-19
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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.
17 // Modified by skv - Thu Jul 13 17:42:58 2006 OCC12627
18 // Total rewriting of the method Segment; add the method OtherSegment.
20 #include <BRepClass_FaceExplorer.ixx>
21 #include <Precision.hxx>
22 #include <Geom2d_Curve.hxx>
24 #include <BRep_Tool.hxx>
26 //=======================================================================
27 //function : BRepClass_FaceExplorer
29 //=======================================================================
31 BRepClass_FaceExplorer::BRepClass_FaceExplorer(const TopoDS_Face& F) :
36 myFace.Orientation(TopAbs_FORWARD);
39 //=======================================================================
42 //=======================================================================
44 Standard_Boolean BRepClass_FaceExplorer::Reject(const gp_Pnt2d&)const
46 return Standard_False;
49 //=======================================================================
52 //=======================================================================
54 Standard_Boolean BRepClass_FaceExplorer::Segment(const gp_Pnt2d& P,
61 return OtherSegment(P, L, Par);
64 //=======================================================================
65 //function : OtherSegment
67 //=======================================================================
69 Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
73 TopExp_Explorer anExpF(myFace,TopAbs_EDGE);
77 Handle(Geom2d_Curve) aC2d;
78 Standard_Real aTolParConf = Precision::PConfusion();
80 Standard_Real aParamIn;
82 for (i = 1; anExpF.More(); anExpF.Next(), i++) {
83 if (i != myCurEdgeInd)
86 const TopoDS_Shape &aLocalShape = anExpF.Current();
87 const TopAbs_Orientation anOrientation = aLocalShape.Orientation();
89 if (anOrientation == TopAbs_FORWARD || anOrientation == TopAbs_REVERSED) {
90 const TopoDS_Edge &anEdge = TopoDS::Edge(aLocalShape);
92 aC2d = BRep_Tool::CurveOnSurface(anEdge, myFace, aFPar, aLPar);
95 // Treatment of infinite cases.
96 if (Precision::IsNegativeInfinite(aFPar)) {
97 if (Precision::IsPositiveInfinite(aLPar)) {
103 } else if (Precision::IsPositiveInfinite(aLPar))
106 for (; myCurEdgePar < 0.7 ;myCurEdgePar += 0.2111) {
107 aParamIn = myCurEdgePar*aFPar + (1. - myCurEdgePar)*aLPar;
109 aC2d->D0(aParamIn, aPOnC);
110 Par = aPOnC.Distance(P);
112 if (Par > aTolParConf) {
113 gp_Vec2d aLinVec(P, aPOnC);
114 gp_Dir2d aLinDir(aLinVec);
116 L = gp_Lin2d(P, aLinDir);
118 // Check if ends of a curve lie on a line.
119 aC2d->D0(aFPar, aPOnC);
121 if (L.Distance(aPOnC) > aTolParConf) {
122 aC2d->D0(aLPar, aPOnC);
124 if (L.Distance(aPOnC) > aTolParConf) {
125 myCurEdgePar += 0.2111;
127 if (myCurEdgePar >= 0.7) {
129 myCurEdgePar = 0.123;
132 return Standard_True;
137 } // if (!aC2d.IsNull()) {
138 } // if (anOrientation == TopAbs_FORWARD ...
140 // This curve is not valid for line construction. Go to another edge.
142 myCurEdgePar = 0.123;
145 // nothing found, return an horizontal line
147 L = gp_Lin2d(P,gp_Dir2d(1,0));
149 return Standard_False;
152 //=======================================================================
153 //function : InitWires
155 //=======================================================================
157 void BRepClass_FaceExplorer::InitWires()
159 myWExplorer.Init(myFace,TopAbs_WIRE);
162 //=======================================================================
163 //function : RejectWire NYI
165 //=======================================================================
167 Standard_Boolean BRepClass_FaceExplorer::RejectWire
169 const Standard_Real)const
171 return Standard_False;
174 //=======================================================================
175 //function : InitEdges
177 //=======================================================================
179 void BRepClass_FaceExplorer::InitEdges()
181 myEExplorer.Init(myWExplorer.Current(),TopAbs_EDGE);
184 //=======================================================================
185 //function : RejectEdge NYI
187 //=======================================================================
189 Standard_Boolean BRepClass_FaceExplorer::RejectEdge
191 const Standard_Real )const
193 return Standard_False;
197 //=======================================================================
198 //function : CurrentEdge
200 //=======================================================================
202 void BRepClass_FaceExplorer::CurrentEdge(BRepClass_Edge& E,
203 TopAbs_Orientation& Or) const
205 E.Edge() = TopoDS::Edge(myEExplorer.Current());
207 Or = E.Edge().Orientation();