]> OCCT Git - occt.git/commitdiff
0032877: Modeling algorithms - Sweeping issue
authormgerus <mgerus@opencascade.com>
Thu, 23 Jun 2022 05:35:33 +0000 (08:35 +0300)
committerafokin <afokin@opencascade.com>
Thu, 23 Jun 2022 17:37:37 +0000 (20:37 +0300)
Add fix at sweeping algorithm: sweeping happens in the opposite direction as expected
Add test case tests/bugs/modalg_7/bug32877

src/GeomFill/GeomFill_SectionPlacement.cxx
tests/bugs/modalg_7/bug32877 [new file with mode: 0644]

index 163429828c555e77561b2f624b7de263ea321eb1..a2616b4b1d12ae54b79f1888c152d8e6ce586999 100644 (file)
@@ -102,41 +102,6 @@ static Standard_Real EvalAngle(const gp_Vec& V1,
  return angle;
 }
 
-static Standard_Integer NbSamples(const Handle(Geom_Curve)& aCurve)
-{
-  Standard_Real nbs = 100.; //on default
-
-  Handle(Geom_Curve) theCurve = aCurve;
-  if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
-    theCurve = (Handle(Geom_TrimmedCurve)::DownCast(aCurve))->BasisCurve();
-
-  if (theCurve->IsInstance(STANDARD_TYPE(Geom_Line)))
-    nbs = 1;
-  else if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic)))
-    nbs = 4;
-  else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BezierCurve)))
-    {
-      Handle(Geom_BezierCurve) BC = Handle(Geom_BezierCurve)::DownCast(theCurve);
-      nbs = 3 + BC->NbPoles();
-    }
-  else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BSplineCurve)))
-    {
-      Handle(Geom_BSplineCurve) BC = Handle(Geom_BSplineCurve)::DownCast(theCurve);
-      nbs  = BC->NbKnots();
-      nbs *= BC->Degree();
-      Standard_Real ratio =
-       (aCurve->LastParameter() - aCurve->FirstParameter())/(BC->LastParameter() - BC->FirstParameter());
-      nbs *= ratio;
-      if(nbs < 4.0)
-       nbs = 4;
-    }
-
-  if (nbs > 300.)
-    nbs = 300;
-
-  return ((Standard_Integer)nbs);
-}
-
 //===============================================================
 // Function :DistMini
 // Purpose : Examine un extrema pour updater <Dist> & <Param>
@@ -495,24 +460,22 @@ void GeomFill_SectionPlacement::Perform(const Handle(Adaptor3d_Curve)& Path,
                  }
              }
          }
-       if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
-         {
-           Standard_Integer NbPnts = NbSamples( mySection );
-           TColgp_Array1OfPnt Pnts( 1, NbPnts+1 );
-           Standard_Real delta = (mySection->LastParameter()-mySection->FirstParameter())/NbPnts;
-           for (ii = 0; ii <= NbPnts; ii++)
-             Pnts(ii+1) = mySection->Value( mySection->FirstParameter() + ii*delta );
-           
-           gp_Pnt BaryCenter;
-           gp_Dir Xdir, Ydir;
-           Standard_Real Xgap, Ygap, Zgap;
-           GeomLib::Inertia( Pnts, BaryCenter, Xdir, Ydir, Xgap, Ygap, Zgap );
-           
-           gp_Pnt Pfirst = Path->Value( Path->FirstParameter() );
-           if (Pfirst.Distance(BaryCenter) < Plast.Distance(BaryCenter))
-             PathParam = Path->FirstParameter();
-           else
-             {
+  if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
+  {
+    // Comparing the distances from the path's endpoints to the best matching plane of the profile.
+    const gp_Pnt firstPoint = Path->Value(Path->FirstParameter());
+    const gp_Pnt lastPoint = Path->Value(Path->LastParameter());
+    const gp_Pln plane = plan->Pln();
+    Standard_Real firstDistance = plane.SquareDistance(firstPoint);
+    Standard_Real lastDistance = plane.SquareDistance(lastPoint);
+
+    if (((Abs(firstDistance) < Precision::SquareConfusion()) && Abs(lastDistance) < Precision::SquareConfusion()) ||
+       firstDistance < lastDistance)
+    {
+      PathParam = Path->FirstParameter(); 
+    }
+    else 
+    {
                PathParam = Path->LastParameter();
                Tangente (*Path, PathParam, PonPath, dp1);
                PonSec = myAdpSection.Value(SecParam);
diff --git a/tests/bugs/modalg_7/bug32877 b/tests/bugs/modalg_7/bug32877
new file mode 100644 (file)
index 0000000..f17498a
--- /dev/null
@@ -0,0 +1,16 @@
+puts "================================================="
+puts "0032877: Modeling algorithms - Sweeping issue"
+puts "================================================="
+puts ""
+
+polyline f 0 0 0 10 0 0 10 5 0 0 5 0 0 0 0
+mkplane f f
+polyline path 9 1 0.01 5 2.5 4
+pipe result path f
+
+checkshape result
+checknbshapes result -shell 1 -face 6 -wire 6 -edge 12
+
+smallview
+fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file