]> OCCT Git - occt.git/commitdiff
0031688: Visualization - Wrong ISO lines for a face created from BSpline
authormkrylova <mkrylova@opencascade.com>
Thu, 27 Aug 2020 12:12:22 +0000 (15:12 +0300)
committerbugmaster <bugmaster@opencascade.com>
Sun, 27 Sep 2020 09:00:08 +0000 (12:00 +0300)
Added a check to see if the ISO line intersects the bounding contour.

src/StdPrs/StdPrs_Isolines.cxx
src/StdPrs/StdPrs_ToolRFace.cxx
src/StdPrs/StdPrs_ToolRFace.hxx
tests/bugs/vis/bug31688 [new file with mode: 0644]

index 434490e657f6525af0420a6c0699e137367aeb88..a6da8962a1b2af8128b742cda8bef6d988aca987 100644 (file)
@@ -16,6 +16,7 @@
 #include <StdPrs_Isolines.hxx>
 
 #include <Adaptor3d_IsoCurve.hxx>
+#include <Bnd_Range.hxx>
 #include <BRepTools.hxx>
 #include <BRep_Tool.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
@@ -479,6 +480,24 @@ void StdPrs_Isolines::addOnSurface (const Handle(BRepAdaptor_HSurface)& theSurfa
       }
     }
 
+    // re-calculate UV-range basing on p-curves tessellation
+    Bnd_Range aTrimU, aTrimV;
+    for (Standard_Integer anI = 1; anI <= aTrimPoints.Length(); ++anI)
+    {
+      const gp_Pnt2d& aTrimPnt = aTrimPoints.Value (anI);
+      aTrimU.Add (aTrimPnt.X());
+      aTrimV.Add (aTrimPnt.Y());
+    }
+    // ignore p-curves tessellation under sampler deflection - it might clamp range
+    if (!aTrimU.IsVoid() && aTrimU.Delta() <= aSamplerDeflection)
+    {
+      aTrimU.SetVoid();
+    }
+    if (!aTrimV.IsVoid() && aTrimV.Delta() <= aSamplerDeflection)
+    {
+      aTrimV.SetVoid();
+    }
+
     // Compute a hatching tolerance.
     aHatchingTolerance *= 0.1;
     aHatchingTolerance = Max (Precision::Confusion(), aHatchingTolerance);
@@ -489,11 +508,21 @@ void StdPrs_Isolines::addOnSurface (const Handle(BRepAdaptor_HSurface)& theSurfa
 
     for (Standard_Integer anIso = 1; anIso <= theUIsoParams.Length(); ++anIso)
     {
-      aHatcher.AddXLine (theUIsoParams.Value (anIso));
+      const Standard_Real anIsoParamU = theUIsoParams.Value (anIso);
+      if (aTrimU.IsVoid()
+      || !aTrimU.IsOut (anIsoParamU))
+      {
+        aHatcher.AddXLine (anIsoParamU);
+      }
     }
     for (Standard_Integer anIso = 1; anIso <= theVIsoParams.Length(); ++anIso)
     {
-      aHatcher.AddYLine (theVIsoParams.Value (anIso));
+      const Standard_Real anIsoParamV = theVIsoParams.Value (anIso);
+      if (aTrimV.IsVoid()
+      || !aTrimV.IsOut (anIsoParamV))
+      {
+        aHatcher.AddYLine (anIsoParamV);
+      }
     }
 
     // Trim hatching region.
index 5450da2f8f43086185a34818bccb0dc28d66ba1e..deafc2630ebe37369808fe9f4c338883e7b0f3c5 100644 (file)
@@ -39,6 +39,15 @@ StdPrs_ToolRFace::StdPrs_ToolRFace (const Handle(BRepAdaptor_HSurface)& theSurfa
   myFace.Orientation(TopAbs_FORWARD);
 }
 
+//=======================================================================
+//function : Edge
+//purpose  :
+//=======================================================================
+const TopoDS_Edge& StdPrs_ToolRFace::Edge() const
+{
+  return TopoDS::Edge (myExplorer.Current());
+}
+
 //=======================================================================
 //function : next
 //purpose  :
index 09cfdfd2268d8d3c8ed46ce80d2d148f59c9caac..b9f72e7364d608d3100979ebd396875bef426444 100644 (file)
@@ -26,6 +26,7 @@
 #include <Geom2dAdaptor_Curve.hxx>
 #include <TopAbs_Orientation.hxx>
 class BRepAdaptor_HSurface;
+class TopoDS_Edge;
 
 //! Iterator over 2D curves restricting a face (skipping internal/external edges).
 //! In addition, the algorithm skips NULL curves - IsInvalidGeometry() can be checked if this should be handled within algorithm.
@@ -64,6 +65,9 @@ public:
   //! Return current curve.
   const Adaptor2d_Curve2d& Value() const { return myCurve; }
 
+  //! Return current edge.
+  Standard_EXPORT const TopoDS_Edge& Edge() const;
+
   //! Return current edge orientation.
   TopAbs_Orientation Orientation() const { return myExplorer.Current().Orientation(); }
 
diff --git a/tests/bugs/vis/bug31688 b/tests/bugs/vis/bug31688
new file mode 100644 (file)
index 0000000..693bd40
--- /dev/null
@@ -0,0 +1,22 @@
+puts "============"
+puts "0031688: Visualization - Wrong ISO lines for a face created from BSpline"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+pbsplinecurve aa 2 4 0 1 1 1 2 1 3 1  0 0 0 1  1 2 0 1  2 0 0 1
+mkedge ee aa
+wire ww ee
+mkplane ff ww
+vinit
+vdisplay ff
+visos ff 50 50 1
+vfit
+
+if { [vreadpixel 365 200 -rgb -name] != "BLACK" ||
+     [vreadpixel 366 200 -rgb -name] != "BLACK" ||
+     [vreadpixel 367 200 -rgb -name] != "BLACK" } {
+  puts "Error: isolines are not expected here"
+}
+
+vdump ${imagedir}/${casename}.png