From 353e6fa0cf037e1031f436922f186195620db324 Mon Sep 17 00:00:00 2001 From: imn Date: Wed, 29 Mar 2017 18:28:33 +0300 Subject: [PATCH] 0028594: Geom2dAPI_Interpolate generated curve is not the same as proe Boolean flag "Scale" has been added for methods "Load" in "Geom2dAPI_Interpolate" class --- src/Geom2dAPI/Geom2dAPI_Interpolate.cxx | 26 +++++++----- src/Geom2dAPI/Geom2dAPI_Interpolate.hxx | 21 ++++++++-- src/QABugs/QABugs_20.cxx | 55 ++++++++++++++++++++++++- tests/bugs/modalg_6/bug28594 | 25 +++++++++++ 4 files changed, 112 insertions(+), 15 deletions(-) create mode 100644 tests/bugs/modalg_6/bug28594 diff --git a/src/Geom2dAPI/Geom2dAPI_Interpolate.cxx b/src/Geom2dAPI/Geom2dAPI_Interpolate.cxx index 919e4d23e1..106600b900 100644 --- a/src/Geom2dAPI/Geom2dAPI_Interpolate.cxx +++ b/src/Geom2dAPI/Geom2dAPI_Interpolate.cxx @@ -405,7 +405,8 @@ myTangentRequest(Standard_False) void Geom2dAPI_Interpolate::Load( const TColgp_Array1OfVec2d& Tangents, - const Handle(TColStd_HArray1OfBoolean)& TangentFlagsPtr) + const Handle(TColStd_HArray1OfBoolean)& TangentFlagsPtr, + const Standard_Boolean Scale) { Standard_Boolean result ; @@ -426,10 +427,12 @@ void Geom2dAPI_Interpolate::Load( for (ii = Tangents.Lower() ; ii <= Tangents.Upper() ; ii++ ) { myTangents->SetValue(ii,Tangents.Value(ii)) ; } - ScaleTangents(myPoints->Array1(), - myTangents->ChangeArray1(), - TangentFlagsPtr->Array1(), - myParameters->Array1()) ; + if (Scale) { + ScaleTangents(myPoints->Array1(), + myTangents->ChangeArray1(), + TangentFlagsPtr->Array1(), + myParameters->Array1()) ; + } } else { throw Standard_ConstructionError(); @@ -444,7 +447,8 @@ void Geom2dAPI_Interpolate::Load( //======================================================================= void Geom2dAPI_Interpolate::Load(const gp_Vec2d& InitialTangent, - const gp_Vec2d& FinalTangent) + const gp_Vec2d& FinalTangent, + const Standard_Boolean Scale) { Standard_Boolean result ; myTangentRequest = Standard_True ; @@ -459,10 +463,12 @@ void Geom2dAPI_Interpolate::Load(const gp_Vec2d& InitialTangent, if (!result) { throw Standard_ConstructionError(); } - ScaleTangents(myPoints->Array1(), - myTangents->ChangeArray1(), - myTangentFlags->Array1(), - myParameters->Array1()) ; + if (Scale) { + ScaleTangents(myPoints->Array1(), + myTangents->ChangeArray1(), + myTangentFlags->Array1(), + myParameters->Array1()) ; + } } //======================================================================= diff --git a/src/Geom2dAPI/Geom2dAPI_Interpolate.hxx b/src/Geom2dAPI/Geom2dAPI_Interpolate.hxx index 2cf1df71e8..c98ecf167c 100644 --- a/src/Geom2dAPI/Geom2dAPI_Interpolate.hxx +++ b/src/Geom2dAPI/Geom2dAPI_Interpolate.hxx @@ -56,14 +56,19 @@ public: //! It is also used to check if the tangent vector is not too small. //! There should be at least 2 points //! if PeriodicFlag is True then the curve will be periodic. - Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance); + Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, + const Standard_Boolean PeriodicFlag, + const Standard_Real Tolerance); //! if PeriodicFlag is True then the curve will be periodic //! Warning: //! There should be as many parameters as there are points //! except if PeriodicFlag is True : then there should be one more //! parameter to close the curve - Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, const Handle(TColStd_HArray1OfReal)& Parameters, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance); + Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, + const Handle(TColStd_HArray1OfReal)& Parameters, + const Standard_Boolean PeriodicFlag, + const Standard_Real Tolerance); //! Assigns this constrained BSpline curve to be //! tangential to vectors InitialTangent and FinalTangent @@ -71,7 +76,11 @@ public: //! the first and last points of the table of //! points through which the curve passes, as //! defined at the time of initialization). - Standard_EXPORT void Load (const gp_Vec2d& InitialTangent, const gp_Vec2d& FinalTangent); + //! - boolean flag defining whether tangent vectors are to + //! be scaled according to derivatives of lagrange interpolation. + Standard_EXPORT void Load(const gp_Vec2d& InitialTangent, + const gp_Vec2d& FinalTangent, + const Standard_Boolean Scale = Standard_True); //! Assigns this constrained BSpline curve to be //! tangential to vectors defined in the table Tangents, @@ -82,7 +91,11 @@ public: //! the flag given in the parallel table //! TangentFlags is true: only these vectors //! are set as tangency constraints. - Standard_EXPORT void Load (const TColgp_Array1OfVec2d& Tangents, const Handle(TColStd_HArray1OfBoolean)& TangentFlags); + //! - boolean flag defining whether tangent vectors are to + //! be scaled according to derivatives of lagrange interpolation. + Standard_EXPORT void Load(const TColgp_Array1OfVec2d& Tangents, + const Handle(TColStd_HArray1OfBoolean)& TangentFlags, + const Standard_Boolean Scale = Standard_True); //! Clears all tangency constraints on this //! constrained BSpline curve (as initialized by the function Load). diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 5be38190b9..6bb12714ef 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2251,7 +2251,59 @@ static Standard_Integer OCC28389(Draw_Interpretor& di, Standard_Integer argc, co return 0; } - +#include +#include +#include +#include +#include +#include +#include + +static Standard_Integer OCC28594(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc != 3) + { + di << "Usage :" << argv[0] << " curve_with_scale curve_without_scale\n"; + return 0; + } + Handle(TColgp_HArray1OfPnt2d) points_2d = new TColgp_HArray1OfPnt2d(1, 6); + (*points_2d)(1) = gp_Pnt2d(-30.4, 8); + (*points_2d)(2) = gp_Pnt2d(-16.689912, 17.498217); + (*points_2d)(3) = gp_Pnt2d(-23.803064, 24.748543); + (*points_2d)(4) = gp_Pnt2d(-16.907466, 32.919615); + (*points_2d)(5) = gp_Pnt2d(-8.543829, 26.549421); + (*points_2d)(6) = gp_Pnt2d(0, 39.200000); + + TColgp_Array1OfVec2d tangent_2d(1, 6); + (tangent_2d)(1) = gp_Vec2d(0.3, 0.4); + (tangent_2d)(2) = gp_Vec2d(0, 0); + (tangent_2d)(3) = gp_Vec2d(0, 0); + (tangent_2d)(4) = gp_Vec2d(0, 0); + (tangent_2d)(5) = gp_Vec2d(0, 0); + (tangent_2d)(6) = gp_Vec2d(1, 0); + + Handle(TColStd_HArray1OfBoolean) tangent_flags = new TColStd_HArray1OfBoolean(1, 6); + (*tangent_flags)(1) = true; + (*tangent_flags)(2) = false; + (*tangent_flags)(3) = false; + (*tangent_flags)(4) = false; + (*tangent_flags)(5) = false; + (*tangent_flags)(6) = true; + + Geom2dAPI_Interpolate interp_2d_with_scale(points_2d, Standard_False, Precision::Confusion()); + interp_2d_with_scale.Load(tangent_2d, tangent_flags); + interp_2d_with_scale.Perform(); + Handle(Geom2d_BSplineCurve) curve_2d_with_scale = interp_2d_with_scale.Curve(); + + Geom2dAPI_Interpolate interp_2d_without_scale(points_2d, Standard_False, Precision::Confusion()); + interp_2d_without_scale.Load(tangent_2d, tangent_flags, Standard_False); + interp_2d_without_scale.Perform(); + Handle(Geom2d_BSplineCurve) curve_2d_without_scale = interp_2d_without_scale.Curve(); + + DrawTrSurf::Set(argv[1], curve_2d_with_scale); + DrawTrSurf::Set(argv[2], curve_2d_without_scale); + return 0; +} void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2273,6 +2325,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add ("OCC27552", "OCC27552", __FILE__, OCC27552, group); theCommands.Add("OCC27875", "OCC27875 curve", __FILE__, OCC27875, group); theCommands.Add("OCC28389", "OCC28389", __FILE__, OCC28389, group); + theCommands.Add("OCC28594", "OCC28594", __FILE__, OCC28594, group); return; } diff --git a/tests/bugs/modalg_6/bug28594 b/tests/bugs/modalg_6/bug28594 new file mode 100644 index 0000000000..1d5ca206dc --- /dev/null +++ b/tests/bugs/modalg_6/bug28594 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC28594" +puts "========" +puts "" +#################################################################### +# Geom2dAPI_Interpolate generated curve is not the same as proe +#################################################################### + +pload QAcommands + +set anImageWithScale ${imagedir}/${test_image}_c1.png +set anImageWithoutScale ${imagedir}/${test_image}_c2.png + +OCC28594 c1 c2 +smallview -2D- +donly c1 +2dfit +checkview -screenshot -2d -path ${anImageWithScale} +donly c2 +checkview -screenshot -2d -path ${anImageWithoutScale} + +set aDiffImageResult [diffimage $anImageWithScale $anImageWithoutScale 0.1 0 0] +if {$aDiffImageResult == 0} { + puts "Error: curves are equal" +} \ No newline at end of file -- 2.20.1