]> OCCT Git - occt-copy.git/commitdiff
0030560: Modeling Algorithms - Improvement of the method BRepTools::DetectClosedness CR0-ipdm-jgv
authorjgv <jgv@opencascade.com>
Mon, 3 Sep 2018 09:14:47 +0000 (12:14 +0300)
committerjgv <jgv@opencascade.com>
Tue, 19 Mar 2019 15:45:04 +0000 (18:45 +0300)
1. Rewrite the method BRepTools::DetectClosedness.
2. Correct the method BRepOffset_Tool::EnLargeFace to process properly non-periodic but closed faces.

src/BRepOffset/BRepOffset_Tool.cxx
src/BRepTools/BRepTools.cxx
src/BRepTools/BRepTools.hxx

index 6695653a2073604a7d8f0329b64a7722539f7084..04eab280da71e9d85cad10ee6857580ce55e40d0 100644 (file)
@@ -182,24 +182,6 @@ TopAbs_Orientation BRepOffset_Tool::OriEdgeInFace (const TopoDS_Edge& E,
   return E.Orientation();
 }
 
-//=======================================================================
-//function : IsPCurveUiso
-//purpose  : 
-//=======================================================================
-
-static Standard_Boolean IsPCurveUiso(const Handle(Geom2d_Curve)& thePCurve,
-                                     Standard_Real theFirstPar,
-                                     Standard_Real theLastPar)
-{
-  gp_Pnt2d FirstP2d = thePCurve->Value(theFirstPar);
-  gp_Pnt2d LastP2d  = thePCurve->Value(theLastPar);
-
-  Standard_Real DeltaU = Abs(FirstP2d.X() - LastP2d.X());
-  Standard_Real DeltaV = Abs(FirstP2d.Y() - LastP2d.Y());
-
-  return (DeltaU < DeltaV);
-}
-
 //=======================================================================
 //function : FindPeriod
 //purpose  : 
@@ -3229,40 +3211,6 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F,
     }
 }
 
-//=======================================================================
-//function : DetectClosedness
-//purpose  : 
-//=======================================================================
-
-void BRepOffset_Tool::DetectClosedness(const TopoDS_Face& theFace,
-                                       Standard_Boolean&  theUclosed,
-                                       Standard_Boolean&  theVclosed)
-{
-  theUclosed = theVclosed = Standard_False;
-  
-  BRepAdaptor_Surface BAsurf(theFace, Standard_False);
-  Standard_Boolean IsSurfUclosed = BAsurf.IsUClosed();
-  Standard_Boolean IsSurfVclosed = BAsurf.IsVClosed();
-  if (!IsSurfUclosed && !IsSurfVclosed)
-    return;
-  
-  TopExp_Explorer Explo(theFace, TopAbs_EDGE);
-  for (; Explo.More(); Explo.Next())
-  {
-    const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
-    if (BRepTools::IsReallyClosed(anEdge, theFace))
-    {
-      Standard_Real fpar, lpar;
-      Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
-      Standard_Boolean IsUiso = IsPCurveUiso(aPCurve, fpar, lpar);
-      if (IsSurfUclosed && IsUiso)
-        theUclosed = Standard_True;
-      if (IsSurfVclosed && !IsUiso)
-        theVclosed = Standard_True;
-    }
-  }
-}
-
 //=======================================================================
 //function : EnLargeFace
 //purpose  : 
@@ -3282,16 +3230,13 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
  const Standard_Real      theLenBeforeVfirst,
  const Standard_Real      theLenAfterVlast)
 {
-  //Detect closedness in U and V
-  Standard_Boolean uclosed = Standard_False, vclosed = Standard_False;
-  DetectClosedness(F, uclosed, vclosed);
-  
   //---------------------------
   // extension de la geometrie.
   //---------------------------
   TopLoc_Location       L;
   Handle (Geom_Surface) S = BRep_Tool::Surface(F,L);
   Standard_Real         UU1,VV1,UU2,VV2;
+  Standard_Boolean      uperiodic = Standard_False, vperiodic = Standard_False;
   Standard_Boolean      isVV1degen = Standard_False, isVV2degen = Standard_False;
   Standard_Real         US1,VS1,US2,VS2;
   Standard_Real         UF1,VF1,UF2,VF2;
@@ -3345,6 +3290,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
   }
 
   if (S->IsUPeriodic()) {
+    uperiodic = Standard_True;
     Standard_Real    Period = S->UPeriod(); 
     Standard_Real    Delta  = Period - (UF2 - UF1);
     Standard_Real    alpha  = 0.1;
@@ -3354,6 +3300,7 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
     }
   }
   if (S->IsVPeriodic()) {
+    vperiodic = Standard_True;
     Standard_Real    Period = S->VPeriod(); 
     Standard_Real    Delta  = Period - (VF2 - VF1);
     Standard_Real    alpha  = 0.1;
@@ -3395,6 +3342,16 @@ Standard_Boolean BRepOffset_Tool::EnLargeFace
   if (!theEnlargeVlast)
     VV2 = VF2;
 
+  //Detect closedness in U and V directions
+  Standard_Boolean uclosed = Standard_False, vclosed = Standard_False;
+  BRepTools::DetectClosedness(F, uclosed, vclosed);
+  if (uclosed && !uperiodic &&
+      (theLenBeforeUfirst != 0. || theLenAfterUlast != 0.))
+    uclosed = Standard_False;
+  if (vclosed && !vperiodic &&
+      (theLenBeforeVfirst != 0. && theLenAfterVlast != 0.))
+    vclosed = Standard_False;
+  
   MakeFace(S,UU1,UU2,VV1,VV2,uclosed,vclosed,isVV1degen,isVV2degen,BF);
   BF.Location(L);
 /*
index ae2cb9dce432330961e964590439cc55a6f8e788..dfdb276b09c285a2b18896427a38b6b57e39e28c 100644 (file)
@@ -978,6 +978,39 @@ Standard_Boolean BRepTools::IsReallyClosed(const TopoDS_Edge& E,
   return nbocc == 2;
 }
 
+//=======================================================================
+//function : DetectClosedness
+//purpose  : 
+//=======================================================================
+
+void BRepTools::DetectClosedness(const TopoDS_Face& theFace,
+                                 Standard_Boolean&  theUclosed,
+                                 Standard_Boolean&  theVclosed)
+{
+  theUclosed = theVclosed = Standard_False;
+  
+  TopExp_Explorer Explo(theFace, TopAbs_EDGE);
+  for (; Explo.More(); Explo.Next())
+  {
+    const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
+    if (BRep_Tool::IsClosed(anEdge, theFace) &&
+        BRepTools::IsReallyClosed(anEdge, theFace))
+    {
+      Standard_Real fpar, lpar;
+      Handle(Geom2d_Curve) PCurve1 = BRep_Tool::CurveOnSurface(anEdge, theFace, fpar, lpar);
+      Handle(Geom2d_Curve) PCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(anEdge.Reversed()),
+                                                               theFace, fpar, lpar);
+      gp_Pnt2d Point1 = PCurve1->Value(fpar);
+      gp_Pnt2d Point2 = PCurve2->Value(fpar);
+      Standard_Boolean IsUiso = (Abs(Point1.X() - Point2.X()) > Abs(Point1.Y() - Point2.Y()));
+      if (IsUiso)
+        theUclosed = Standard_True;
+      else
+        theVclosed = Standard_True;
+    }
+  }
+}
+
 //=======================================================================
 //function : EvalAndUpdateTol
 //purpose  : 
index cc49cc1044bcec0d40f62c75ba0ce72c0bcd5c54..fb0ff959a2c722139e6ac81cdff14e5550beb776 100644 (file)
@@ -186,6 +186,11 @@ public:
   //! the face <F> before calling BRep_Tool::IsClosed.
   Standard_EXPORT static Standard_Boolean IsReallyClosed (const TopoDS_Edge& E, const TopoDS_Face& F);
   
+  //! Detect closedness of face in U and V directions
+  Standard_EXPORT static void DetectClosedness (const TopoDS_Face& theFace,
+                                                Standard_Boolean&  theUclosed,
+                                                Standard_Boolean&  theVclosed);
+  
   //! Dumps the topological structure and the geometry
   //! of <Sh> on the stream <S>.
   Standard_EXPORT static void Dump (const TopoDS_Shape& Sh, Standard_OStream& S);