-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <Precision.hxx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
+#include <TopExp.hxx>
+
+#include <Standard_NotImplemented.hxx>
+
+
+/**
+ * This function returns Standard_True if it is possible to divide edge, i.e.
+ * if one parameter either start or end one is inside the edge. This function
+ * is used in the method GEOMImpl_Fillet1d::Result.
+ *
+ * \param theEdge the edge
+ * \param theStart the start parameter
+ * \param theEnd the end parameter
+ * \return Standard_True if it is possible to split edge;
+ * Standard_False otherwise.
+ */
+static Standard_Boolean IsDivideEdge(const TopoDS_Edge &theEdge,
+ const Standard_Real theStart,
+ const Standard_Real theEnd)
+{
+ Standard_Real aFirst;
+ Standard_Real aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast);
+ gp_Pnt aPStart = aCurve->Value(theStart);
+ gp_Pnt aPEnd = aCurve->Value(theEnd);
+ TopoDS_Vertex aVFirst = TopExp::FirstVertex(theEdge);
+ TopoDS_Vertex aVLast = TopExp::LastVertex(theEdge);
+ Standard_Real aTolFirst = BRep_Tool::Tolerance(aVFirst);
+ Standard_Real aTolLast = BRep_Tool::Tolerance(aVLast);
+ Standard_Real aTolConf = Precision::Confusion();
+ gp_Pnt aPFirst = BRep_Tool::Pnt(aVFirst);
+ gp_Pnt aPLast = BRep_Tool::Pnt(aVLast);
+ Standard_Real aDistSF = aPStart.Distance(aPFirst);
+ Standard_Real aDistSL = aPStart.Distance(aPLast);
+ Standard_Real aDistEF = aPEnd.Distance(aPFirst);
+ Standard_Real aDistEL = aPEnd.Distance(aPLast);
+ Standard_Boolean isSplit = Standard_True;
+
+ if (aDistSF <= aTolFirst + aTolConf ||
+ aDistSL <= aTolLast + aTolConf) {
+ if (aDistEF <= aTolFirst + aTolConf ||
+ aDistEL <= aTolLast + aTolConf) {
+
+ isSplit = Standard_False;
+ // in this case the original edge is thrown, and distance (gap) from new arc end
+ // to a vertex of original wire can reach (aVertexTolerance + Precision::Confusion()).
+ // Resulting wire is fixed (Mantis issue 0023411) in GEOMImpl_Fillet1dDriver::MakeFillet()
+ }
+ }
+
+ return isSplit;
+}
/**
* class GEOMImpl_Fillet1d
{
const Standard_Real aTol = Precision::Confusion();
const Standard_Real anAngTol = Precision::Angular();
- Geom2dAPI_InterCurveCurve anInter(theCurve, new Geom2d_Line(theStart,
- gp_Dir2d(gp_Vec2d(theStart, theEnd))), aTol);
+ Handle(Geom2d_Line) aRadiusLine = new Geom2d_Line (theStart, gp_Dir2d(gp_Vec2d(theStart, theEnd)));
+ Geom2dAPI_InterCurveCurve anInter (theCurve, aRadiusLine, aTol);
Standard_Integer a;
gp_Pnt2d aPoint;
for(a = anInter.NbPoints(); a > 0; a--)
Handle(Geom2d_Curve) aCurve;
for(a = anInter.NbSegments(); a > 0; a--)
{
- anInter.Segment(a, aCurve);
- aPoint = aCurve->Value(aCurve->FirstParameter());
- if (aPoint.Distance(theStart) < aTol)
- if (!theStartConnected)
- return Standard_True;
- if (aPoint.Distance(theEnd) < aTol)
- return Standard_True;
- if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol))
- return Standard_True;
- aPoint = aCurve->Value(aCurve->LastParameter());
- if (aPoint.Distance(theStart) < aTol)
- if (!theStartConnected)
- return Standard_True;
- if (aPoint.Distance(theEnd) < aTol)
- return Standard_True;
- if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol))
- return Standard_True;
+ // Porting to DEV version of OCCT 10.02.2017 BEGIN
+ Standard_NotImplemented::Raise("The treatment of tangential intersection is not implemented");
+ // Porting to DEV version of OCCT 10.02.2017 END
}
return Standard_False;
}
aParam2 > myStart1 + aTol && aParam2 < myEnd1 - aTol) {
// Add the point in the list in increasing order.
const Standard_Real aParam = 0.5*(aParam1 + aParam2);
-
+
for(anIter.Initialize(aParams); anIter.More(); anIter.Next()) {
if (anIter.Value() > aParam) {
aParams.InsertBefore(aParam, anIter);
aTargetPoint2d.SetCoord(aX, aY);
// choose the nearest circle
- Standard_Real aDistance, aP;
+ Standard_Real aDistance = 0., aP; // todo: aDistance must be explicitly initialized to avoid warning (see below)
GEOMImpl_Fillet1dPoint *aNearest;
Standard_Integer a;
TColStd_ListIteratorOfListOfReal anIter(myResultParams);
if (!aPoint->HasSolution(myRadius))
continue;
aP = fabs(aPoint->GetCenter().Distance(aTargetPoint2d) - myRadius);
- if (!aNearest || aP < aDistance)
+ if (!aNearest || aP < aDistance) // todo: aDistance must be explicitly initialized to avoid warning (see above)
{
aNearest = aPoint;
aDistance = aP;
else
anEnd = aNearest->GetParam();
- if (fabs(aStart - anEnd) > Precision::Confusion())
+ if (IsDivideEdge(myEdge1, aStart, anEnd))
{
//Divide edge
BRepBuilderAPI_MakeEdge aDivider1(aCurve, aStart, anEnd);
else
anEnd = aNearest->GetParam2();
- if (fabs(aStart - anEnd) > Precision::Confusion())
+ if (IsDivideEdge(myEdge2, aStart, anEnd))
{
BRepBuilderAPI_MakeEdge aDivider2(aCurve, aStart, anEnd);
if (myEdgesExchnged)
{
Standard_Integer a;
Standard_Boolean aDiffsSet = (myD.Length() != 0);
- Standard_Real aDX = thePoint->GetParam() - myParam, aDY;
+ Standard_Real aDX = thePoint->GetParam() - myParam, aDY = 0.; // todo: aDY must be explicitly initialized to avoid warning (see below)
if (thePoint->myV.Length() == myV.Length())
{ // absolutely the same points
for(a = 1; a <= myV.Length(); a++)
}
else
{
- myD.Append( fabs(aDX) > gp::Resolution() ? aDY/aDX : 0);
+ myD.Append( fabs(aDX) > gp::Resolution() ? aDY/aDX : 0); // todo: aDY must be explicitly initialized to avoid warning (see above)
}
}