Table of Contents

Class NurbsSurface

Namespace
CADability.GeoObject
Assembly
CADability.dll

A NURBS surface implementing ISurface.

public class NurbsSurface : ISurfaceImpl, ISurface, IOctTreeInsertable, ISerializable, IDeserializationCallback, IExportStep
Inheritance
NurbsSurface
Implements
Inherited Members
Extension Methods

Constructors

NurbsSurface(Ellipse[], double[])

Creates a NURBS surface which passes through the provided ellipses (or circles), e.g. the cross sections of a pipe along a curved path. The u parameter follows the ellipses (the surface is rational of degree 2 in u), the v parameter runs from the first to the last ellipse (degree 3, interpolated through the poles of the ellipses). All ellipses must have the same shape (full ellipses or the same kind of arc) so that their BSpline representations have the same number of poles.

public NurbsSurface(Ellipse[] throughEllis, double[] knots = null)

Parameters

throughEllis Ellipse[]

The ellipses the surface passes through, in the order of the v parameter

knots double[]

Optional v parameter values for the ellipses; when null they are derived from the distances of the poles

NurbsSurface(GeoPoint[,], double[,], double[], double[], int, int, bool, bool)

Creates a new NURBS surface with the given data.

public NurbsSurface(GeoPoint[,] poles, double[,] weights, double[] uKnots, double[] vKnots, int uDegree, int vDegree, bool uPeriodic, bool vPeriodic)

Parameters

poles GeoPoint[,]

the poles

weights double[,]

the weight of the poles

uKnots double[]

the knots in u direction (multiple knots may have the same value)

vKnots double[]

the knots in v direction (multiple knots may have the same value)

uDegree int

the degree in u direction

vDegree int

the degree in v direction

uPeriodic bool

closed in u direction

vPeriodic bool

closed in v direction

NurbsSurface(GeoPoint[,], double[,], double[], double[], int[], int[], int, int, bool, bool)

Creates a new NURBS surface with the given data.

public NurbsSurface(GeoPoint[,] poles, double[,] weights, double[] uKnots, double[] vKnots, int[] uMults, int[] vMults, int uDegree, int vDegree, bool uPeriodic, bool vPeriodic)

Parameters

poles GeoPoint[,]

the poles

weights double[,]

the weight of the poles

uKnots double[]

the knots in u direction (no duplicate values)

vKnots double[]

the knots in v direction (no duplicate values)

uMults int[]

the multiplicities in u direction

vMults int[]

the multiplicities in v direction

uDegree int

the degree in u direction

vDegree int

the degree in v direction

uPeriodic bool

closed in u direction

vPeriodic bool

closed in v direction

NurbsSurface(GeoPoint[,], int, int, bool, bool)

Creates a new NURBS surface which interpolates the provided points. The surface will contain the provided points exactely and smoothly interpolated inbetween. The points are organized in a two dimensional array resembling the u and v direction (first and second index) of the NURBS surface

public NurbsSurface(GeoPoint[,] throughPoints, int maxUDegree, int maxVDegree, bool uPeriodic, bool vPeriodic)

Parameters

throughPoints GeoPoint[,]

Points to be interpolated

maxUDegree int

The maximum degree in respect of the first index

maxVDegree int

The maximum degree in respect of the second index

uPeriodic bool

Periodicy in respect of the first index

vPeriodic bool

Periodicy in respect of the second index

NurbsSurface(GeoPoint[,], int, int, double[], double[], bool, bool)

Creates a NURBS surface which interpolates the provided points, like the constructor without knots: the surface contains the points exactly and is smoothly interpolated in between. The parameters uKnots and vKnots are currently ignored; the parameter values of the points are derived from the chord lengths of the point rows and columns.

public NurbsSurface(GeoPoint[,] throughPoints, int maxUDegree, int maxVDegree, double[] uKnots, double[] vKnots, bool uPeriodic, bool vPeriodic)

Parameters

throughPoints GeoPoint[,]

Points to be interpolated; the first index is the u direction, the second the v direction

maxUDegree int

The maximum degree in u (reduced when there are fewer points)

maxVDegree int

The maximum degree in v (reduced when there are fewer points)

uKnots double[]

Intended as the parameter values of the points in u direction, currently ignored

vKnots double[]

Intended as the parameter values of the points in v direction, currently ignored

uPeriodic bool

True when the surface is closed in u direction (the last row of points connects to the first)

vPeriodic bool

True when the surface is closed in v direction (the last column of points connects to the first)

NurbsSurface(SerializationInfo, StreamingContext)

Constructor for the legacy binary deserialization (ISerializable).

protected NurbsSurface(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

The serialized data

context StreamingContext

The source of the deserialization

Properties

IsRuled

returns wheather the surface is linear in u or v direction

public override RuledSurfaceMode IsRuled { get; }

Property Value

RuledSurfaceMode

IsUPeriodic

Returns true, if this surface is periodic in the u direction (e.g. a cylinder) false otherwise.

public override bool IsUPeriodic { get; }

Property Value

bool

IsVPeriodic

Returns true, if this surface is periodic in the v direction (e.g. a torus) false otherwise.

public override bool IsVPeriodic { get; }

Property Value

bool

Poles

The control points of the surface; the first index runs in u direction, the second in v direction. This is the internal array: changing its entries does not update the surface.

public GeoPoint[,] Poles { get; }

Property Value

GeoPoint[,]

UDegree

The polynomial degree of the surface in u direction. A degree of 1 means that the lines of constant v are straight (see IsRuled).

public int UDegree { get; }

Property Value

int

UKnotSpanCount

Number of knot spans (intervals between distinct knot values) in u direction. See GetPatchExtent(int, int, bool).

public int UKnotSpanCount { get; }

Property Value

int

UKnots

The knot vector in u direction with each knot repeated according to its multiplicity (the form the constructors which take knots and degrees expect). A new array on each access.

public double[] UKnots { get; }

Property Value

double[]

UPeriod

Returns the u priod of this surface if it is u periodic 0.0 otherwise

public override double UPeriod { get; }

Property Value

double

VDegree

The polynomial degree of the surface in v direction. A degree of 1 means that the lines of constant u are straight (see IsRuled).

public int VDegree { get; }

Property Value

int

VKnotSpanCount

Number of knot spans (intervals between distinct knot values) in v direction. See GetPatchExtent(int, int, bool).

public int VKnotSpanCount { get; }

Property Value

int

VKnots

The knot vector in v direction with each knot repeated according to its multiplicity (the form the constructors which take knots and degrees expect). A new array on each access.

public double[] VKnots { get; }

Property Value

double[]

VPeriod

Returns the v priod of this surface if it is v periodic 0.0 otherwise

public override double VPeriod { get; }

Property Value

double

Weights

The weights of the control points, with the same indices as Poles, or null for a non-rational surface. This is the internal array: changing its entries does not update the surface.

public double[,] Weights { get; }

Property Value

double[,]

isRational

True when the surface is rational, i.e. it has weights and at least one of them differs from 1 (e.g. a surface built from exact circles). A non-rational surface is evaluated with the faster non-rational algorithm.

public bool isRational { get; }

Property Value

bool

Methods

Clone()

Returns an identical but independant copy of this surface

public override ISurface Clone()

Returns

ISurface

CopyData(ISurface)

Copies the data of the given surface to this surface. The two surfaces are guaranteed to be of the same type. (Used after Clone() and Modify(ModOp) to restore the original values).

public override void CopyData(ISurface CopyFrom)

Parameters

CopyFrom ISurface

where to copy the data from

Derivation2At(GeoPoint2D, out GeoPoint, out GeoVector, out GeoVector, out GeoVector, out GeoVector, out GeoVector)

Returns the point, the two first derivations and the three second derivations of the surface at the provided parameter position.

public override void Derivation2At(GeoPoint2D uv, out GeoPoint location, out GeoVector du, out GeoVector dv, out GeoVector duu, out GeoVector dvv, out GeoVector duv)

Parameters

uv GeoPoint2D

Point in the parameter space

location GeoPoint

Resulting 3D point

du GeoVector

Resulting derivation in u

dv GeoVector

Resulting derivation in v

duu GeoVector
dvv GeoVector
duv GeoVector

DerivationAt(GeoPoint2D, out GeoPoint, out GeoVector, out GeoVector)

Returns the point and the two derivations of the suface in a single call. It returns the same result as calling PointAt(GeoPoint2D), VDirection(GeoPoint2D) und VDirection(GeoPoint2D) succesively but is often faster than the three seperate calls.

public override void DerivationAt(GeoPoint2D uv, out GeoPoint location, out GeoVector du, out GeoVector dv)

Parameters

uv GeoPoint2D

Point in the parameter space

location GeoPoint

Resulting 3D point

du GeoVector

Resulting derivation in u

dv GeoVector

Resulting derivation in v

FixedU(double, double, double)

Returns a curve where the u parameter of this surface is fixed and the v parameter starts a vmin and ends at vmax

public override ICurve FixedU(double u, double vmin, double vmax)

Parameters

u double
vmin double
vmax double

Returns

ICurve

FixedV(double, double, double)

Returns a curve where the v parameter of this surface is fixed and the u parameter starts a umin and ends at umax

public override ICurve FixedV(double v, double umin, double umax)

Parameters

v double
umin double
umax double

Returns

ICurve

GetCanonicalForm(double, BoundingRect?)

Returns a simpler form of this surface: SurfaceOfLinearExtrusion might be a cylinder, NURBS might be a sphere etc. Returns null, if there is no simpler form

public override ISurface GetCanonicalForm(double precision, BoundingRect? bounds)

Parameters

precision double

maximal allowed deviation of the new surface

bounds BoundingRect?

the part of the parameter space in which the surfaces must coincide; null: the natural bounds of this surface

Returns

ISurface

GetCanonicalFormOld(double, BoundingRect?)

Previous implementation of GetCanonicalForm(double, BoundingRect?): tries to find an elementary surface (plane, cylinder, cone, sphere, torus) which coincides with this NURBS surface by checking whether its parameter lines are lines and circles. Kept for reference; not used by CADability.

public ISurface GetCanonicalFormOld(double precision, BoundingRect? bounds)

Parameters

precision double

The maximum allowed distance between the NURBS surface and the elementary surface

bounds BoundingRect?

The part of the parameter space to check, or null for the whole surface

Returns

ISurface

The elementary surface, or null when none was found

GetExtrema()

Returns an array of points in parametric space where there are extrema in direction of x-, y- or z-axis. The normal vector in a extremum is parallel to one of the axis and the surface has a relative maximum or minimum in this direction.

public override GeoPoint2D[] GetExtrema()

Returns

GeoPoint2D[]

s.a.

GetKnotSpan(int, int)

The uv rectangle of the knot span with the provided indices. The indices refer to the distinct knot values, i.e. uKnotIndex may range from 0 to UKnotSpanCount-1.

public BoundingRect GetKnotSpan(int uKnotIndex, int vKnotIndex)

Parameters

uKnotIndex int
vKnotIndex int

Returns

BoundingRect

GetLineIntersection(GeoPoint, GeoVector)

Returns the intersectionpoints of this surface with the line given by the parameters. Teh returned point are in the parametric (u/v) space of this surface.

public override GeoPoint2D[] GetLineIntersection(GeoPoint startPoint, GeoVector direction)

Parameters

startPoint GeoPoint

startpoint of the line

direction GeoVector

direction of the line

Returns

GeoPoint2D[]

GetMaximumExtent()

Returns the whole parameter range in which the surface is defined: from the first to the last knot in u and in v. Unlike GetNaturalBounds(out double, out double, out double, out double) it does not depend on the bounds a face has set.

public BoundingRect GetMaximumExtent()

Returns

BoundingRect

The rectangle of the parameter space covered by the knot vectors

GetModified(ModOp)

Implements GetModified(ModOp).

public override ISurface GetModified(ModOp m)

Parameters

m ModOp

how to modify

Returns

ISurface

modified surface

GetNaturalBounds(out double, out double, out double, out double)

Returns the natural bounds of the surface. The returned values may be infinite

public override void GetNaturalBounds(out double umin, out double umax, out double vmin, out double vmax)

Parameters

umin double
umax double
vmin double
vmax double

GetNonPeriodicSurface(ICurve[])

public override ISurface GetNonPeriodicSurface(ICurve[] orientedCurves)

Parameters

orientedCurves ICurve[]

3d curves describing the outline that will be used on the resulting surface

Returns

ISurface

GetNormal(GeoPoint2D)

Returns the normal vector (perpendicular to the surface) at the given u/v point

public override GeoVector GetNormal(GeoPoint2D uv)

Parameters

uv GeoPoint2D

position of normal

Returns

GeoVector

normal vector

GetOffsetSurface(double)

Returns a surface that is "parallel" to this surface, i.e. each point on this surface corresponds a point on the returned surface that has the same (u,v) coordinates and has the 3d coordinates oft the point plus offset*Normal at this point

public override ISurface GetOffsetSurface(double offset)

Parameters

offset double

Offset to this surface

Returns

ISurface

The offset surface

GetPatchExtent(BoundingRect, bool)

public override BoundingCube GetPatchExtent(BoundingRect uvPatch, bool rough)

Parameters

uvPatch BoundingRect
rough bool

true: a quickly computed extent which may be larger than necessary is sufficient (ignored here)

Returns

BoundingCube

GetPatchExtent(int, int, bool)

Returns the extent of the surface patch on the knot span [uKnots[uKnotIndex], uKnots[uKnotIndex+1]] x [vKnots[vKnotIndex], vKnots[vKnotIndex+1]] (indices refer to distinct knot values, see UKnotSpanCount and GetKnotSpan(int, int)). The returned box is guaranteed to contain the patch. With rough==true the convex hull property of the poles influencing the span is used: very fast, but the box may be considerably larger than the patch. With rough==false the box is close to the smallest enclosing box: extrema on the four boundary curves and Newton iterations for inner extrema yield a reference box (a lower bound, since it only contains points on the surface), and the Bézier hull of the span is subdivided until it (almost) matches the reference box. The result of the subdivision is returned, so the guarantee to contain the patch is preserved. Tight boxes are cached, the cache is invalidated when the surface is modified.

public BoundingCube GetPatchExtent(int uKnotIndex, int vKnotIndex, bool rough = false)

Parameters

uKnotIndex int

index of the knot span in u direction (referring to distinct knot values)

vKnotIndex int

index of the knot span in v direction (referring to distinct knot values)

rough bool

true: fast pole hull, false: tight box

Returns

BoundingCube

GetPlaneIntersection(PlaneSurface, double, double, double, double, double)

Returns the intersection curve(s) of this surface with the given plane. An empty array is returned if there is no intersection. umin, umax, vmin, vmax define the Parameterspace of this surface (not of the PlaneSurface) for the intersection. It is also the periodic domain in which the 2d curve for this surface will be returned, if this surface is periodic. the resulting curves may exceed the area provided by umin, umax, vmin, vmax.

public override IDualSurfaceCurve[] GetPlaneIntersection(PlaneSurface pl, double umin, double umax, double vmin, double vmax, double precision)

Parameters

pl PlaneSurface

plane to intersect with

umin double

minimum u value of the parameter space of this surface to consider

umax double

maximum u value of the parameter space of this surface to consider

vmin double

minimum v value of the parameter space of this surface to consider

vmax double

maximum v value of the parameter space of this surface to consider

precision double

maximum allowed deviation of the resulting curves from the exact intersection

Returns

IDualSurfaceCurve[]

intersection curves

GetProjectedCurve(ICurve, double)

Returns the projection of the given curve in 2D coordinates. Should only be used for curves that are close to the surface.

public override ICurve2D GetProjectedCurve(ICurve curve, double precision)

Parameters

curve ICurve

the 3d curve to project onto this surface

precision double

maximum allowed deviation of the resulting 2d curve (mapped onto the surface) from the provided curve

Returns

ICurve2D

GetPropertyEntry(IFrame)

Gets the IPropertyEntry to display this surface in the property grid (may be null)

public override IPropertyEntry GetPropertyEntry(IFrame frame)

Parameters

frame IFrame

Returns

IPropertyEntry

GetSafeParameterSteps(double, double, double, double, out double[], out double[])

Gets spans of the parameterspace that are guaranteed to contain only one inflection point. The returned intu should contain umin as first and umax as last value (same with v)

public override void GetSafeParameterSteps(double umin, double umax, double vmin, double vmax, out double[] intu, out double[] intv)

Parameters

umin double
umax double
vmin double
vmax double
intu double[]
intv double[]

GetSaveUSteps()

Returns u values which subdivide the parameter range into intervals that GetExtrema() searches one by one for extrema in direction of the axes. Each interval must contain at most one extremum per axis direction (the periodic surfaces return quarter circles). The base implementation returns an empty array, which makes GetExtrema() find nothing.

protected override double[] GetSaveUSteps()

Returns

double[]

Ascending u values from the start to the end of the parameter range, or an empty array

GetSaveVSteps()

Returns v values which subdivide the parameter range into intervals that GetExtrema() searches one by one for extrema in direction of the axes, see GetSaveUSteps(). The base implementation returns an empty array.

protected override double[] GetSaveVSteps()

Returns

double[]

Ascending v values from the start to the end of the parameter range, or an empty array

GetSimpleSurface(double, out ISurface, out ModOp2D)

Returns true if this NurbsSurface can be represented as a simpler surface. Simple surfaces have better performances.

public bool GetSimpleSurface(double precision, out ISurface simpleSurface, out ModOp2D reparametrisation)

Parameters

precision double

The precision within the simpler surface must approximate this surface (0.0: use global Precision)

simpleSurface ISurface

the found surface or null

reparametrisation ModOp2D

the needed reparametrisation of the uv space from this surface to the surface found

Returns

bool

true, if simpler form exists

GetUSingularities()

returns the values for the u parameter where this surface is singular i.e. changing v with this u parameter fixed doesn't change the 3D point.

public override double[] GetUSingularities()

Returns

double[]

list of u singularities

GetVSingularities()

returns the values for the v parameter where this surface is singular i.e. changing u with this v parameter fixed doesn't change the 3D point.

public override double[] GetVSingularities()

Returns

double[]

list of v singularities

GetZMinMax(Projection, double, double, double, double, ref double, ref double)

Gets the minimum and maximumm valus for the z-coordinate of a rectangular patch (in parametric space) of this surface under a certain projection

public override void GetZMinMax(Projection p, double umin, double umax, double vmin, double vmax, ref double zMin, ref double zMax)

Parameters

p Projection

the projection

umin double

left bound of the rectangular patch

umax double

right bound of the rectangular patch

vmin double

bottom bound of the rectangular patch

vmax double

top bound of the rectangular patch

zMin double

returned minimum

zMax double

returned maximum

HasDiscontinuousDerivative(out ICurve2D[])

Tells whether there are lines in the parameter space across which the first derivative (and thus the normal) of the surface jumps. This is the case for a NurbsSurface of degree 1 with inner knots, which consists of planar or ruled strips with sharp bends between them. Faces on such a surface are split along these lines before they are triangulated or intersected.

public override bool HasDiscontinuousDerivative(out ICurve2D[] discontinuities)

Parameters

discontinuities ICurve2D[]

The 2d curves (in the u/v system) along which the derivative is discontinuous; null when the result is false

Returns

bool

true when there are discontinuities, false for the usual smooth surfaces

HitTest(BoundingCube, out GeoPoint2D)

Returns true, if this surface interferes with the provided cube. If this is the case uv will contain a point (in the parameter system of the surface) which is inside the cube

public override bool HitTest(BoundingCube cube, out GeoPoint2D uv)

Parameters

cube BoundingCube
uv GeoPoint2D

Returns

bool

Intersect(BoundingRect, ISurface, BoundingRect)

Returns the intersection curves between this surface and the provided other surface. Both surfaces are bound by rectangles.

public override ICurve[] Intersect(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)

Parameters

thisBounds BoundingRect

Bounds for this surface

other ISurface

Other surface

otherBounds BoundingRect

Bounds of other surface

Returns

ICurve[]

Array of intersection curves

Intersect(ICurve, BoundingRect, out GeoPoint[], out GeoPoint2D[], out double[])

Returns the intersection of the provided curve with this surface. The result may be empty.

public override void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds)

Parameters

curve ICurve

The curve to be intersected with

uvExtent BoundingRect

The part of the parameter space of this surface in which intersection points are searched. It is also the periodic domain in which the u/v values of the intersection points are returned

ips GeoPoint[]

Resulting 3d intersection points

uvOnFaces GeoPoint2D[]

u/v values of the intersection points on this surface

uOnCurve3Ds double[]

u parameter of intersection points on the curve

IsVanishingProjection(Projection, double, double, double, double)

Returns true if the given projection makes the surface disappear, i.e. degenerate to an edge.

public override bool IsVanishingProjection(Projection p, double umin, double umax, double vmin, double vmax)

Parameters

p Projection

the projection

umin double
umax double
vmin double
vmax double

Returns

bool

true if vanishing, falso otherwise

Make3dCurve(ICurve2D)

Returns a 3-dimensional curve from the given 2-dimensional curve. the 2-dimensional curve is interpreted in the u/v system of the surface.

public override ICurve Make3dCurve(ICurve2D curve2d)

Parameters

curve2d ICurve2D

the base curve

Returns

ICurve

corresponding 3-d curve

MaxDist(GeoPoint2D, GeoPoint2D, out GeoPoint2D)

Returns the maximum distance between the surface and the straight 3d line connecting the surface points at sp and ep, i.e. the error made when the segment from sp to ep in the parameter space is replaced by a straight line in 3d. The triangulation uses it to decide whether an edge of a triangle must be subdivided. The base implementation only samples the distance at 1/4, 1/2 and 3/4 of the segment; the elementary surfaces override it with exact computations.

public override double MaxDist(GeoPoint2D sp, GeoPoint2D ep, out GeoPoint2D mp)

Parameters

sp GeoPoint2D

Start point in the parameter space

ep GeoPoint2D

End point in the parameter space

mp GeoPoint2D

The u/v position where the maximum distance was found

Returns

double

The maximum distance found

Modify(ModOp)

Modifies this surface with the given operation

public override void Modify(ModOp m)

Parameters

m ModOp

how to modif

PointAt(GeoPoint2D)

Returns the 3-dimensional point at the given u/v point

public override GeoPoint PointAt(GeoPoint2D uv)

Parameters

uv GeoPoint2D

position

Returns

GeoPoint

point

ReverseOrientation()

Reverses the orientation of this surface. The normal vector will point to the other side after this operation. The returned ModOp2D determins how (u,v) coordinates of the parameter space have to be transformed to define the same 3d point.

public override ModOp2D ReverseOrientation()

Returns

ModOp2D

Transformation of the parameter space

SameGeometry(BoundingRect, ISurface, BoundingRect, double, out ModOp2D)

Returns true if this surface and the other surface are geometrically identical, i.e. describe the same surface in 3D space. The may have a different u/v system. The returned firstToSecond contains the ModOp to convert from the u/v system of the first surface to the second surface.

public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond)

Parameters

thisBounds BoundingRect

Bounds for this surface

other ISurface

Other surface

otherBounds BoundingRect

Bounds of other surface

precision double

Required precision

firstToSecond ModOp2D

Transformation between different u/v systems

Returns

bool

True if the surfaces are geometrically equal

TrimmU(double, double)

Returns a new NURBS surface which is the part of this surface between the u parameters u0 and u1: the knot vector is clamped to this interval, the v direction stays unchanged. This surface is not modified.

public NurbsSurface TrimmU(double u0, double u1)

Parameters

u0 double

The new start of the u parameter range

u1 double

The new end of the u parameter range

Returns

NurbsSurface

The trimmed surface, or null when this surface is not initialized

TrimmV(double, double)

Returns a new NURBS surface which is the part of this surface between the v parameters v0 and v1: the knot vector is clamped to this interval, the u direction stays unchanged. This surface is not modified.

public NurbsSurface TrimmV(double v0, double v1)

Parameters

v0 double

The new start of the v parameter range

v1 double

The new end of the v parameter range

Returns

NurbsSurface

The trimmed surface, or null when this surface is not initialized

UDirection(GeoPoint2D)

Returns the direction at the given u/v point in direction of the u-axis

public override GeoVector UDirection(GeoPoint2D uv)

Parameters

uv GeoPoint2D

position

Returns

GeoVector

direction

VDirection(GeoPoint2D)

Returns the direction at the given u/v point in direction of the v-axis

public override GeoVector VDirection(GeoPoint2D uv)

Parameters

uv GeoPoint2D

position

Returns

GeoVector

direction