From: skv Date: Tue, 24 Feb 2015 09:54:42 +0000 (+0300) Subject: 0022771: [CEA 1311] Creating a smaller wire when using the function "Fuse Colinear... X-Git-Tag: V7_6_0a1~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2c5180adf1f0161d4526b942dddd37688e0cdb20;p=modules%2Fgeom.git 0022771: [CEA 1311] Creating a smaller wire when using the function "Fuse Colinear Edges Within A Wire" --- diff --git a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx index 74675b159..b58136b03 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx @@ -37,6 +37,52 @@ #include #include #include +#include + + +/** + * 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::FirstVertex(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; + } + } + + return isSplit; +} /** * class GEOMImpl_Fillet1d @@ -617,7 +663,7 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint, else anEnd = aNearest->GetParam(); - if (fabs(aStart - anEnd) > Precision::Confusion()) + if (IsDivideEdge(myEdge1, aStart, anEnd)) { //Divide edge BRepBuilderAPI_MakeEdge aDivider1(aCurve, aStart, anEnd); @@ -636,7 +682,7 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint, else anEnd = aNearest->GetParam2(); - if (fabs(aStart - anEnd) > Precision::Confusion()) + if (IsDivideEdge(myEdge2, aStart, anEnd)) { BRepBuilderAPI_MakeEdge aDivider2(aCurve, aStart, anEnd); if (myEdgesExchnged) diff --git a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx index 89e8671b3..7fa3cbe52 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx @@ -251,6 +251,11 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const MakeFillet(aWireNew, aVertexListNew, rad, isFinalPass, aResult); } + if (!GEOMUtils::CheckShape(aResult, true) && + !GEOMUtils::FixShapeTolerance(aResult)) { + Standard_ConstructionError::Raise("Non valid shape result"); + } + aFunction->SetValue(aResult); log.SetTouched(Label());