]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0022771: [CEA 1311] Creating a smaller wire when using the function "Fuse Colinear...
authorskv <skv@opencascade.com>
Tue, 24 Feb 2015 09:54:42 +0000 (12:54 +0300)
committerskv <skv@opencascade.com>
Tue, 24 Feb 2015 09:54:42 +0000 (12:54 +0300)
src/GEOMImpl/GEOMImpl_Fillet1d.cxx
src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx

index 74675b15996f5c30a2e96f993a30f2b444f09948..b58136b03228defb569bc2ba2e09bbc6672065d7 100644 (file)
 #include <Precision.hxx>
 #include <TColStd_ListIteratorOfListOfReal.hxx>
 #include <IntRes2d_IntersectionSegment.hxx>
+#include <TopExp.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::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)
index 89e8671b30397b4c247e9b033f905be023565cb1..7fa3cbe52f1bd7cc67b8111467ad5c259c2a6857 100644 (file)
@@ -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());