-// File: BRepClass_FaceExplorer.cxx
-// Created: Thu Nov 19 15:54:56 1992
-// Author: Remi LEQUETTE
-// <rle@phylox>
-
+// Created on: 1992-11-19
+// Created by: Remi LEQUETTE
+// Copyright (c) 1992-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
// Modified by skv - Thu Jul 13 17:42:58 2006 OCC12627
// Total rewriting of the method Segment; add the method OtherSegment.
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
+static const Standard_Real Probing_Start = 0.123;
+static const Standard_Real Probing_End = 0.7;
+static const Standard_Real Probing_Step = 0.2111;
+
//=======================================================================
//function : BRepClass_FaceExplorer
//purpose :
BRepClass_FaceExplorer::BRepClass_FaceExplorer(const TopoDS_Face& F) :
myFace(F),
myCurEdgeInd(1),
- myCurEdgePar(0.123)
+ myCurEdgePar(Probing_Start)
{
myFace.Orientation(TopAbs_FORWARD);
}
Standard_Real& Par)
{
myCurEdgeInd = 1;
- myCurEdgePar = 0.123;
+ myCurEdgePar = Probing_Start;
return OtherSegment(P, L, Par);
}
Standard_Real aFPar;
Standard_Real aLPar;
Handle(Geom2d_Curve) aC2d;
- Standard_Real aTolParConf = Precision::PConfusion();
+ Standard_Real aTolParConf2 = Precision::PConfusion() * Precision::PConfusion();
gp_Pnt2d aPOnC;
Standard_Real aParamIn;
} else if (Precision::IsPositiveInfinite(aLPar))
aLPar = aFPar + 1.;
- for (; myCurEdgePar < 0.7 ;myCurEdgePar += 0.2111) {
+ for (; myCurEdgePar < Probing_End ;myCurEdgePar += Probing_Step) {
aParamIn = myCurEdgePar*aFPar + (1. - myCurEdgePar)*aLPar;
- aC2d->D0(aParamIn, aPOnC);
- Par = aPOnC.Distance(P);
+ gp_Vec2d aTanVec;
+ aC2d->D1(aParamIn, aPOnC, aTanVec);
+ Par = aPOnC.SquareDistance(P);
- if (Par > aTolParConf) {
+ if (Par > aTolParConf2) {
gp_Vec2d aLinVec(P, aPOnC);
gp_Dir2d aLinDir(aLinVec);
+ Standard_Real aTanMod = aTanVec.SquareMagnitude();
+ if (aTanMod < aTolParConf2)
+ continue;
+ aTanVec /= Sqrt(aTanMod);
+ Standard_Real aSinA = aTanVec.Crossed(aLinDir.XY());
+ const Standard_Real SmallAngle = 0.001;
+ if (Abs(aSinA) < SmallAngle)
+ {
+ // The line from the input point P to the current point on edge
+ // is tangent to the edge curve. This condition is bad for classification.
+ // Therefore try to go to another point in the hope that there will be
+ // no tangent. If there tangent is preserved then leave the last point in
+ // order to get this edge chanse to participate in classification.
+ if (myCurEdgePar + Probing_Step < Probing_End)
+ continue;
+ }
+
L = gp_Lin2d(P, aLinDir);
// Check if ends of a curve lie on a line.
aC2d->D0(aFPar, aPOnC);
- if (L.Distance(aPOnC) > aTolParConf) {
+ if (L.SquareDistance(aPOnC) > aTolParConf2) {
aC2d->D0(aLPar, aPOnC);
- if (L.Distance(aPOnC) > aTolParConf) {
- myCurEdgePar += 0.2111;
+ if (L.SquareDistance(aPOnC) > aTolParConf2) {
+ myCurEdgePar += Probing_Step;
- if (myCurEdgePar >= 0.7) {
+ if (myCurEdgePar >= Probing_End) {
myCurEdgeInd++;
- myCurEdgePar = 0.123;
+ myCurEdgePar = Probing_Start;
}
+ Par = Sqrt(Par);
return Standard_True;
}
}
// This curve is not valid for line construction. Go to another edge.
myCurEdgeInd++;
- myCurEdgePar = 0.123;
+ myCurEdgePar = Probing_Start;
}
// nothing found, return an horizontal line