From 0e57793fc65aa5013b2f5107764cdf3309f07301 Mon Sep 17 00:00:00 2001 From: mkrylova Date: Thu, 27 Aug 2020 15:12:22 +0300 Subject: [PATCH] 0031688: Visualization - Wrong ISO lines for a face created from BSpline Added a check to see if the ISO line intersects the bounding contour. --- src/StdPrs/StdPrs_Isolines.cxx | 33 +++++++++++++++++++++++++++++++-- src/StdPrs/StdPrs_ToolRFace.cxx | 9 +++++++++ src/StdPrs/StdPrs_ToolRFace.hxx | 4 ++++ tests/bugs/vis/bug31688 | 22 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/vis/bug31688 diff --git a/src/StdPrs/StdPrs_Isolines.cxx b/src/StdPrs/StdPrs_Isolines.cxx index 434490e657..a6da8962a1 100644 --- a/src/StdPrs/StdPrs_Isolines.cxx +++ b/src/StdPrs/StdPrs_Isolines.cxx @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -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. diff --git a/src/StdPrs/StdPrs_ToolRFace.cxx b/src/StdPrs/StdPrs_ToolRFace.cxx index 5450da2f8f..deafc2630e 100644 --- a/src/StdPrs/StdPrs_ToolRFace.cxx +++ b/src/StdPrs/StdPrs_ToolRFace.cxx @@ -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 : diff --git a/src/StdPrs/StdPrs_ToolRFace.hxx b/src/StdPrs/StdPrs_ToolRFace.hxx index 09cfdfd226..b9f72e7364 100644 --- a/src/StdPrs/StdPrs_ToolRFace.hxx +++ b/src/StdPrs/StdPrs_ToolRFace.hxx @@ -26,6 +26,7 @@ #include #include 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 index 0000000000..693bd40076 --- /dev/null +++ b/tests/bugs/vis/bug31688 @@ -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