//
// check if the degree did not change
//
- if (cachepoles->Upper() < deg + 1) {
+ if (cachepoles->Upper() < deg + 1)
cachepoles = new TColgp_HArray1OfPnt(1,deg + 1);
- if (rational) {
- cacheweights = new TColStd_HArray1OfReal(1,deg + 1);
- }
+ if (rational)
+ {
+ if (cacheweights.IsNull() || cacheweights->Upper() < deg + 1)
+ cacheweights = new TColStd_HArray1OfReal(1,deg + 1);
}
+ else if (!cacheweights.IsNull())
+ cacheweights.Nullify();
+
BSplCLib::LocateParameter(deg,
(flatknots->Array1()),
(BSplCLib::NoMults()),
}
}
}
+ else if (!cacheweights.IsNull())
+ cacheweights.Nullify();
BSplCLib::LocateParameter(udeg,
(ufknots->Array1()),
//
// check if the degree did not change
//
- if (cachepoles->Upper() < deg + 1) {
+ if (cachepoles->Upper() < deg + 1)
cachepoles = new TColgp_HArray1OfPnt2d(1,deg + 1);
- if (rational) {
- cacheweights = new TColStd_HArray1OfReal(1,deg + 1);
- }
+ if (rational)
+ {
+ if (cacheweights.IsNull() || cacheweights->Upper() < deg + 1)
+ cacheweights = new TColStd_HArray1OfReal(1,deg + 1);
}
+ else if (!cacheweights.IsNull())
+ cacheweights.Nullify();
BSplCLib::LocateParameter(deg,
(flatknots->Array1()),
#include <Precision.hxx>
#include <GeomLib.hxx>
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom_BezierCurve.hxx>
+#include <Geom_BezierSurface.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_BSplineSurface.hxx>
+
#ifdef WNT
#include <stdio.h>
//#define strcasecmp strcmp Already defined
}
+//=======================================================================
+//function : setweight
+//purpose : Changes a weight of a pole on B-spline curve/surface
+//=======================================================================
+
+static Standard_Integer setweight(Draw_Interpretor& di, Standard_Integer n, const char** a)
+{
+ if (n < 4 || n > 5)
+ {
+ std::cout << "Wrong parameters" << std::endl;
+ return 1;
+ }
+
+ Standard_Integer anIndex1 = Draw::Atoi(a[2]);
+ Standard_Integer anIndex2 = n == 5 ? Draw::Atoi(a[3]) : 0;
+ Standard_Real aWeight = Draw::Atof(a[n-1]);
+
+ Handle(Geom_BSplineCurve) aBSplCurve = DrawTrSurf::GetBSplineCurve(a[1]);
+ if (!aBSplCurve.IsNull())
+ {
+ aBSplCurve->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom_BezierCurve) aBezCurve = DrawTrSurf::GetBezierCurve(a[1]);
+ if (!aBezCurve.IsNull())
+ {
+ aBezCurve->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom2d_BSplineCurve) aBSplCurve2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
+ if (!aBSplCurve2d.IsNull())
+ {
+ aBSplCurve2d->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom2d_BezierCurve) aBezCurve2d = DrawTrSurf::GetBezierCurve2d(a[1]);
+ if (!aBezCurve2d.IsNull())
+ {
+ aBezCurve2d->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom_BSplineSurface) aBSplSurf = DrawTrSurf::GetBSplineSurface(a[1]);
+ Handle(Geom_BezierSurface) aBezSurf = DrawTrSurf::GetBezierSurface(a[1]);
+ if (n != 5 && (!aBSplSurf.IsNull() || !aBezSurf.IsNull()))
+ {
+ std::cout << "Incorrect parameters" << std::endl;
+ return 1;
+ }
+
+ if (!aBSplSurf.IsNull())
+ {
+ aBSplSurf->SetWeight(anIndex1, anIndex2, aWeight);
+ return 0;
+ }
+
+ if (!aBezSurf.IsNull())
+ {
+ aBezSurf->SetWeight(anIndex1, anIndex2, aWeight);
+ return 0;
+ }
+
+ std::cout << a[1] << " is not a B-spline nor a Bezier curve/surface" << std::endl;
+ return 1;
+}
+
//=======================================================================
//function : ModificationCommands
//purpose :
__FILE__,
samerange, g);
+ theCommands.Add("setweight",
+ "setweight curve/surf index1 [index2] weight"
+ "\n\t\tchanges a weight of a pole of B-spline curve/surface (index2 is useful for surfaces only)",
+ __FILE__,
+ setweight,g);
+
}
--- /dev/null
+puts "================"
+puts "OCC25706"
+puts "================"
+puts ""
+#######################################################################
+# Exception in conversion B-spline to rational
+#######################################################################
+
+bsplinecurve bc 2 2 0.0 3 1.0 3 0 0 0 1.0 0.5 1 0 1.0 1 0 0 1.0
+mkedge e1 bc
+
+dump bc
+
+setweight bc 2 0.5
+
+set info [dump bc]
+if { [regexp {rational} ${info}] } {
+ puts "OK : B-spline is rational"
+} else {
+ puts "Error : B-spline is non-rational"
+}
+
+mkedge result bc
+
+set 2dviewer 1
--- /dev/null
+puts "================"
+puts "OCC25706"
+puts "================"
+puts ""
+#######################################################################
+# Exception in conversion B-spline to rational
+#######################################################################
+
+2dbsplinecurve bc 2 2 0.0 3 1.0 3 0 0 1.0 0.5 1 1.0 1 0 1.0
+mkedge e1 bc
+
+dump bc
+
+setweight bc 2 0.5
+
+set info [dump bc]
+if { [regexp {rational} ${info}] } {
+ puts "OK : B-spline is rational"
+} else {
+ puts "Error : B-spline is non-rational"
+}
+
+mkedge result bc
+
+set 2dviewer 1
--- /dev/null
+puts "================"
+puts "OCC25706"
+puts "================"
+puts ""
+#######################################################################
+# Exception in conversion B-spline to rational
+#######################################################################
+
+bsplinesurf s \
+ 2 2 0 3 1 3 \
+ 2 2 0 3 1 3 \
+ 0.0 0.0 0.0 1 0.5 0.0 0.0 1 1.0 0.0 0.0 1 \
+ 0.0 0.5 0.0 1 0.5 0.5 1.0 1 1.0 0.5 0.0 1 \
+ 0.0 1.0 0.0 1 0.5 1.0 0.0 1 1.0 1.0 0.0 1
+mkface f1 s
+
+dump s
+
+setweight s 2 2 0.5
+
+set info [dump s]
+if { [regexp {rational} ${info}] } {
+ puts "OK : B-spline is rational"
+} else {
+ puts "Error : B-spline is non-rational"
+}
+
+mkface result s
+
+set 2dviewer 1