IBSplineCurve_DG Interface
Indices are 0based
A standalone bspline curve can be created via IObjectGenerator_DG.Create("IBSplineCurve_DG") > IBSplineCurve_DG query.
Implements also: ICurve_DG, IGeometricObject_DG, IObject_DG.
If this curve defines an edge or otherwise is part of a model, after any modification IGeometry_DG.SetModified()
has to be called for the change to appear in 3D view.
 Init
 Init1
 InitFromPoints
 InitFromPoints1
 InitFromPoints2
 Interpolate
 Interpolate1
 Interpolate2
 Interpolate3
 GetDegree
 SetDegree
 GetKnotCount
 GetKnot
 GetKnots
 SetKnot
 SetKnot1
 SetKnots
 GetMultiplicity
 GetMultiplicities
 SetMultiplicity
 SetMultiplicity1
 GetPoleCount
 GetPole
 GetPoles
 SetPole
 SetPole1
 GetWeight
 SetWeight
 GetWeights
 IsClosed
 IsPeriodic
 SetPeriodic
 IsRational
 GetPoint
 GetJet1
 GetJet2
 GetJetN
 GetContinuity
 GetEndParameter
 GetEndPoint
 InsertKnot
 InsertKnots
 RemoveKnot
 Reverse
 SetRange
 NormalizePeriodic
 SetOrigin
 SetOrigin1
 ModifyPoint
 ModifyPointAndTangent
 GetEndKnotIndex
 GetKnotSequence
 GetKnotDistributionType
 FindParameter
void Init(IPointArray_DG poles, IArrayDouble_DG knots, IArrayInt_DG multiplicities, int degree, bool periodic)
Creates a nonrational Bspline curve. Raises an exception if the following conditions are not met:
0 < degree <= MaxDegree(=14 in this version)
knots.GetCount() = multiplicities.GetCount() >= 2
knots[i] < knots[i+1] (Knots are increasing)
For internal knots 1 <= multiplicities[i] <= degree
On a non periodic curve the first and last multiplicities are not greater than degree+1 (Set them to degree+1 to make ends of the curve coinside with the the first and the last poles).
On a periodic curve the first and the last multicities must be the same.
On nonperiodic curves poles.GetCount() == Sum(multiplicities[i])  degree  1 >= 2
On periodic curves poles.GetCount == Sum(multiplicities[i]), except the first and the last.
void Init1(IPointArray_DG poles, IArrayDouble_DG weights, IArrayDouble_DG knots, IArrayInt_DG multiplicities, int degree, bool periodic, bool rational)
Creates a rational or nonrational Bspline curve. Raises an exception if the following conditions are not met:
0 < degree <= MaxDegree(=14 in this version)
weights.GetCount() = poles.GetCount()
knots.GetCount() = multiplicities.GetCount() >= 2
knots[i] < knots[i+1] (Knots are increasing)
1 <= multiplicities[i] <= degree
On a non periodic curve the first and last multiplicities are not greater than degree+1 (Set them to degree+1 to make ends of the curve coinside with the the first and the last poles).
On a periodic curve the first and the last multicities must be the same.
On nonperiodic curves poles.GetCount() == Sum(multiplicities[i])  degree  1 >= 2
On periodic curves poles.GetCount == Sum(multiplicities[i]), except the first and the last.
void InitFromPoints(IPointArray_DG points, int degreeMin, int degreeMax, Continuity_DG continuity, double tolerance)
Approximates a BSpline Curve passing through an array of points. The resulting BSpline will have: Degree will in the range [Degmin,Degmax]; Continuity at least continuity; Distance from the points lower than tolerance.
Defaults: degreeMin=4. degreeMax=8, continuity=eCont_C2, tolerance=1.0e3
void InitFromPoints1(IPointArray_DG points, IArrayDouble_DG parameters, int degreeMin, int degreeMax, Continuity_DG continuity, double tolerance)
Approximates a BSpline Curve passing through an array of points at the specified parameters. The resulting BSpline will have: Degree will in the range [Degmin,Degmax]; Continuity at least continuity; Distance from the points lower than tolerance.
Defaults: degreeMin=4. degreeMax=8, continuity=eCont_C2, tolerance=1.0e3
void InitFromPoints2(IPointArray_DG points, double smoothingWeight0, double smoothingWeight1, double smoothingWeight2, int degreeMax, Continuity_DG continuity, double tolerance)
Approximates a BSpline Curve passing through an array of points using variational smoothing algorithm, which minimizes function: smoothingWeight0*CurveLength + smoothingWeight1*Curvature + smoothingWeight2*Torsion.
Defaults: degreeMax=8, continuity=eCont_C2, tolerance=1.0e3
void Interpolate(IPointArray_DG points, bool periodic, double tolerance)
Defines this curve as a constrained BSpline passing through points. If periodic is true, the curve will be periodic and closed. In this case.
Raises an exception if the following conditions are not met:
Size of points is greater than one.
Points are not closer than tolerance to each other,
Defaults: tolerance=1.0e3
void Interpolate1(IPointArray_DG points, IArrayDouble_DG parameters, bool periodic, double tolerance)
Defines this curve as a constrained BSpline passing through points. If periodic is true, the curve will be periodic and closed. In this case.
Raises an exception if the following conditions are not met:
Points are not closer than tolerance to each other,
Size of points is greater than one.
If periodic is false, size of parameters is equal to size of points.
If periodic is true, size of parameters is equal to size of points plus one.
Defaults: tolerance=1.0e3
void Interpolate2(IPointArray_DG points, Vect_DG tangentStart, Vect_DG tangentEnd, bool scale, IArrayDouble_DG paramsOrNull, bool periodic, double tolerance)
Defines this curve as a constrained BSpline passing through points. If periodic is true, the curve will be periodic and closed. In this case.
if scale is true, only direction of the tangents is important. The tangents will be scaled internally so that they have the length of the size of the derivative of the Lagrange interpolation used in the algorithm.
Raises an exception if the following conditions are not met:
Points are not closer than tolerance to each other,
Size of points is greater than one.
If paramsOrNull is not null:
If periodic is false, size of paramsOrNull is equal to size of points.
If periodic is true, size of paramsOrNull is equal to size of points plus one.
Defaults: tolerance=1.0e3
void Interpolate3(IPointArray_DG points, IPointArray_DG tangents, IArrayBool_DG tangentFlags, bool scale, IArrayDouble_DG paramsOrNull, bool periodic, double tolerance)
Defines this curve as a constrained BSpline passing through points. If periodic is true, the curve will be periodic and closed.
points, tangents and tangentFlags must have the same size as points. Vectors in tangents array specify tangents at points where tangentFlags is true.
if scale is true, only direction of the tangents is important. The tangents will be scaled internally so that they have the length of the size of the derivative of the Lagrange interpolation used in the algorithm.
Raises an exception if the following conditions are not met:
Points are not closer than tolerance to each other,
Size of points is greater than one.
If paramsOrNull is not null:
If periodic is false, size of paramsOrNull is equal to size of points.
If periodic is true, size of paramsOrNull is equal to size of points plus one.
Defaults: tolerance=1.0e3
int GetDegree()
void SetDegree(int degree)
Increases the degree to the specifies number. Poles, weights and multiplicities are modified; Knots are not changed. Nothing is done if degree is not greater than the current degree.
Raises an exceptions if degree is greater than MaxDegree(=14 in this version).
int GetKnotCount()
double GetKnot(int index)
The index must be in [0, GetKnotCount()1] range.
IArrayDouble_DG GetKnots()
void SetKnot(int index, double knot)
The index must be in [0, GetKnotCount()1] range.
void SetKnot1(int index, double knot, int multiplicity)
multiplicity must be <= degree and greater than the previous multiplicity of the knot.
The index must be in [0, GetKnotCount()1] range.
void SetKnots(IArrayDouble_DG knots)
The knots array must be increasing and have size GetKnotCount().
int GetMultiplicity(int indexKnot)
The indexKnot must be in [0, GetKnotCount()1] range.
IArrayInt_DG GetMultiplicities()
void SetMultiplicity(int indexKnot, int multiplicity)
Increases multiplicity to the specified number. Nothing is done if multiplicity is lower or equal to the current multiplicity.
If multiplicity is greater than degree, degree is used.
The indexKnot must be in [0, GetKnotCount()1] range.
void SetMultiplicity1(int indexKnot0, int indexKnot1, int multiplicity)
Increases multiplicity of knots with indices in [indexKnot0, indexKnot1] range to the specified number. Nothing is done if multiplicity is lower or equal to the current multiplicity.
If multiplicity is greater than degree, degree is used.
indexKnot0 and indexKnot1 must be in [0, GetKnotCount()1] range.
int GetPoleCount()
Point_DG GetPole(int index)
The index must be in [0, GetPoleCount()1] range.
IPointArray_DG GetPoles()
void SetPole(int index, Point_DG pt)
The index must be in [0, GetPoleCount()1] range.
void SetPole1(int index, Point_DG pt, double weight)
The index must be in [0, GetPoleCount()1] range.
double GetWeight(int indexPole)
The indexPole must be in [0, GetPoleCount()1] range.
void SetWeight(int index, double weight)
The indexPole must be in [0, GetPoleCount()1] range.
IArrayDouble_DG GetWeights()
bool IsClosed()
bool IsPeriodic()
void SetPeriodic(bool periodic)
bool IsRational()
Point_DG GetPoint(double u)
void GetJet1(double u, out Point_DG pt, out Vect_DG v1)
Returns point and tangent vector at the specified parameter
void GetJet2(double u, out Point_DG pt, out Vect_DG v1, out Vect_DG v2)
Returns point, tangent vector and the second derivative at the specified parameter
Vect_DG GetJetN(double u, int n)
Returns nth derivative at the specified parameter
Continuity_DG GetContinuity()
double GetEndParameter(bool first)
Point_DG GetEndPoint(bool first)
void InsertKnot(double u, int multiplicity, double tolerance, bool add)
If u is an existing knot up to tolerance, the multiplicity is increased by multiplicity if add is true
or to multiplicity if add is false.
Nothing is done if u is not in the parameter range or <=0. multiplicity must not be greater than the degree.
Defaults: tolerance = 0.0, add = true
void InsertKnots(IArrayDouble_DG knots, IArrayInt_DG multiplicities, double tolerance, bool add)
For each u = knots[i], m = multiplicities[i],
if u is an existing knot up to tolerance: If add is true, the multiplicity is increased by m. If add is false, and the current multiplicity is less than m it is increased to m.
If u is not an existing knot, it is inserted as a new knot with multiplicity m.
Nothing is done if u is not on the parameter range or m <= 0 or m > MaxDegree(=14 in this version).
Defaults: tolerance = 0.0, add = true
void RemoveKnot(int indexKnot, int multiplicity)
Reduces multiplicity of the knot. If multiplicity is equal to 0, the knot is removed. The array of poles is also modified.
The indexKnot must be in [0, GetKnotCount()1] range.
void Reverse()
Changes direction of parametrization. The knot sequence is modified. The FirstParameter and the LastParameter are not modified. The StartPoint of the initial curve becomes the EndPoint of the reversed curve and the EndPoint of the initial curve becomes the StartPoint of the reversed curve.
void SetRange(double min, double max)
Segments this curve between min and max. Either of these values can be outside the bounds of the curve, but max must be greater than min. All data structures of this curve are modified, but the knots located between min and max are retained.
The degree of the curve is not modified. Warnings : Even if this curve is not closed it can become closed after the segmentation for example if min or max are out of the bounds of the curve or if the curve makes a loop.
void NormalizePeriodic(ref double u)
No action taken if the curve is not periodic. Otherwise modifies the [in,out] parameter to make it belong to the period.
void SetOrigin(int indexKnot)
Assigns the knot of the index as the origin of this periodic BSpline curve. The knots and poles tables are modified. Raises an exception if this curve is not periodic.
The indexKnot must be in [0, GetKnotCount()1] range.
void SetOrigin1(double u, double tolerance)
Sets the origin of a periodic curve at knot u. If u is not a knot up to the tolerance, a new knot is inseted. Poles are modified also. Raises an exception if this curve is not periodic.
void ModifyPoint(double u, Point_DG pt, int indexPoleFrom, int indexPoleTo, out int firstModifiedPole, out int lastModifiedPole)
Moves the point at parameter u on this curve to pt. indexPoleFrom and indexPoleTo are the indexes of the first and the last poles to be moved.
The out firstModifiedPole and lastModifiedPole parameters are the indexes of the first and last poles, which were actually modified.
The indexPole* must specify a subrange of [0, GetPoleCount()1].
int ModifyPointAndTangent(double u, Point_DG pt, Vect_DG tangent, double tolerance, int startingCondition, int endingCondition)
Moves the point at parameter u on this curve to pt.
Modifies shape to ensure that tangent at the point is the specified vector.
startingCondition = 1 means that the first end is allowed to move. endingCondition = 1 means that the last point is allowed move.
startingCondition = 0 means that the first point cannot move. endingCondition = 0 means that the last point cannot move. startingCondition = 1 means the first point and tangent cannot move endingCondition = 1 means the last point and tangent cannot move.
Returns error status != 0 if it is not possible to modify the curve under the specified conditions.
int GetEndKnotIndex(bool first)
IArrayDouble_DG GetKnotSequence()
Returns the knots sequence of this curve. In this sequence, knots with a multiplicity greater than 1 are repeated. In the case of a nonperiodic curve the length of the sequence
is equal to the sum of the multiplicities of the knots. This sum is also equal to : 'Number of poles' + Degree + 1.
In the case of a periodic curve, if there are k periodic knots, the period is knot[k]  knot[0]. The initial sequence is built by writing knots 0 to k, which are repeated
according to their corresponding multiplicities. Continuity of the curve at the knot of index 0 (or k) is equal to c = degree + 1  mult[0]. c knots are then inserted at the beginning and end of the initial sequence:
the c values of knots preceding the first item knot[k] in the initial sequence are inserted at the beginning; the period is subtracted from these c values;
the c values of knots following the last item knot[0] in the initial sequence are inserted at the end; the period is added to these c values.
The length of the sequence must therefore be equal to: 'Number of poles' + 2*degree  mult[0] + 2.
Example For a nonperiodic BSpline curve of degree 2 where:
the array of knots is: { k1 k2 k3 k4 },
with associated multiplicities: { 3 1 2 3 }, the knot sequence is: K = { k1 k1 k1 k2 k3 k3 k4 k4 k4 }
For a periodic BSpline curve of degree 4 , which is "C1" continuous at the first knot, and where :
the periodic knots are: { k1 k2 k3 (k4) } (3 periodic knots: the points of parameter k1 and k4 are identical, the period is p = k4  k1),
with associated multiplicities: { 3 1 2 (3) }, the degree of continuity at knots k1 and k4 is: degree + 1  Mult[i] = 2. Two supplementary knots are added at the beginning and end of the sequence:
At the beginning: the two knots preceding k4 minus the period; in this example, this is k3  p both times;
at the end: the two knots following k1 plus the period; in this example, this is k2 + p and k3 + p. The knot sequence is therefore: K = { k3p k3p k1 k1 k1 k2 k3 k3 k4 k4 k4 k2+p k3+p }
int GetKnotDistributionType()
Returns: 0 (Non Uniform), 1 (Uniform), 2 (Quasi Uniform) or 3 (Piecewise Bezier).
If all the knots differ by a positive constant from the preceding knot, the BSpline Curve can be :
Uniform if all the knots are of multiplicity 1;
QuasiUniform, if all the knots are of multiplicity 1, except for the first and last knot, which have multiplicity degree + 1;
PiecewiseBezier if the first and last knots have multiplicity degree + 1 and if interior knots have multiplicity degree.
Otherwise the curve is non uniform.
void FindParameter(double u, double tolerance, out int i0, out int i1, bool withKnotRepetition)
If withKnotRepetition is false, returns in i0 index of first knot which is not greater than u. If u counsides with the knot up to
the tolerance, i1 will be set equal to i0, otherwise i1 will be set equal to i0 + 1. If u is smaller than the first knot less tolerance, i0 = 1, i1 = 0 is returned. If u is greater than the last knot plus tolerance, i0 = 'size of the knot array', i1 = i0 + 1 is returned.
If withKnotRepetition is true, the knot array in the above is considered modified by inserting copies of knots with multiplicity greater than one.
