Boolean flag "Scale" has been added for methods "Load" in "Geom2dAPI_Interpolate" class
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 ;
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();
//=======================================================================
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 ;
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()) ;
+ }
}
//=======================================================================
//! 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
//! 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);
+ //! <Scale> - 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,
//! 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);
+ //! <Scale> - 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).
return 0;
}
-
+#include <TColgp_HArray1OfPnt2d.hxx>
+#include <TColgp_Array1OfVec2d.hxx>
+#include <TColStd_HArray1OfBoolean.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2dAPI_Interpolate.hxx>
+#include <GeomAPI.hxx>
+#include <BRepBuilderAPI_MakeEdge2d.hxx>
+
+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";
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;
}
--- /dev/null
+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