Table of Contents

Class GeneralCurve

Namespace
CADability.GeoObject
Assembly
CADability.dll

A base implementation of ICurve

public abstract class GeneralCurve : IGeoObjectImpl, ISerializable, IFeedBack, ICloneable, IColorDef, ICurve, IGeoObject, ILayer, IStyle, IOctTreeInsertable, IComparable, ILineWidth, ILinePattern
Inheritance
GeneralCurve
Implements
Derived
Inherited Members

Constructors

GeneralCurve()

protected GeneralCurve()

GeneralCurve(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected GeneralCurve(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Fields

Constructor

public static GeneralCurve.ConstructionDelegate Constructor

Field Value

GeneralCurve.ConstructionDelegate

Properties

ColorDef

Sets and gets the color of the object

public ColorDef ColorDef { get; set; }

Property Value

ColorDef

Description

Returns a textual description of the GeoObject. Mainly used for debugging purposes

public override string Description { get; }

Property Value

string

EndDirection

The direction of the curve at the endpoint. If the curve is closed, this is the direction where the parameter is 1.0.

public virtual GeoVector EndDirection { get; }

Property Value

GeoVector

EndPoint

The endpoint of the curve. If the curve is closed, this is the point where the parameter is 1.0.

public virtual GeoPoint EndPoint { get; set; }

Property Value

GeoPoint

IsClosed

Determines, whether the curve is closed or open.

public virtual bool IsClosed { get; }

Property Value

bool

IsComposed

Returns true, if the curve is composed of other curves. Paths and Polylines are composed curves.

public virtual bool IsComposed { get; }

Property Value

bool

IsSingular

Determines, whether this curve is singular, i.e. it is only a point, returns the same value for each parameter

public virtual bool IsSingular { get; }

Property Value

bool

Length

The arc length of the curve, from its points. Derived classes, which know a closed form or the derivative, should override this. The length used to be estimated from the tetrahedron hull, which is up to several tenths of a percent too short.

public virtual double Length { get; }

Property Value

double

LinePattern

The line pattern of the object, or null when none is set. For GeoObjects setting it raises the change events and is undoable.

public LinePattern LinePattern { get; set; }

Property Value

LinePattern

LineWidth

The line width of the object, or null when none is set. For GeoObjects setting it raises the change events and is undoable.

public LineWidth LineWidth { get; set; }

Property Value

LineWidth

StartDirection

The direction of the curve at the start-point. If the curve is closed, this is the direction where the parameter is 0.0.

public virtual GeoVector StartDirection { get; }

Property Value

GeoVector

StartPoint

The start-point of the curve. If the curve is closed, this is the point where the parameter is 0.0.

public virtual GeoPoint StartPoint { get; set; }

Property Value

GeoPoint

SubCurves

Returns subcurves of composed curves. Paths and Polylines are composed curves.

public virtual ICurve[] SubCurves { get; }

Property Value

ICurve[]

Methods

Approximate(bool, double)

Returns a Path or a Polyline that approximates the curve with lines or lines and arcs.

public virtual ICurve Approximate(bool linesOnly, double maxError)

Parameters

linesOnly bool

true: no arcs, only lines

maxError double

Maximum derivation from the exact curve

Returns

ICurve

The Approximation

CloneModified(ModOp)

Returns a modified copy of this curve

public virtual ICurve CloneModified(ModOp m)

Parameters

m ModOp

modification

Returns

ICurve

modified copy

DirectionAt(double)

Returns the direction of the curve at a specified point. The parameter position of the start-point is 0.0, the parameter position of the endpoint is 1.0. Directions of a position outside this interval may be undefined.

public abstract GeoVector DirectionAt(double Position)

Parameters

Position double

Position on the curve

Returns

GeoVector

The requested direction

DistanceTo(GeoPoint)

Returns the minimal distance of point p to the curve.

public virtual double DistanceTo(GeoPoint p)

Parameters

p GeoPoint

Returns

double

GetBasePoints()

protected abstract double[] GetBasePoints()

Returns

double[]

GetBoundingCube()

Returns a bounding cube of the object. The object must fir into this cube. There may be a smaller cube that contains the object if it is to expensive to calculate the exact cube.

public override BoundingCube GetBoundingCube()

Returns

BoundingCube

the bounding cube

GetExtent(Projection, ExtentPrecision)

Returns the 2d extent of the object as it appears in the given projection, in the coordinates of the projection's plane (not in pixels).

public override BoundingRect GetExtent(Projection projection, ExtentPrecision extentPrecision)

Parameters

projection Projection

the projection

extentPrecision ExtentPrecision

Exact for the exact extent, Raw for a quick estimate that may be larger

Returns

BoundingRect

the extent in the projection's 2d coordinates

GetExtent(double)

Gets the 3-dimensional extent of an object

public override BoundingCube GetExtent(double precision)

Parameters

precision double

Precision of the test

Returns

BoundingCube

The minmax cube

GetObjectData(SerializationInfo, StreamingContext)

Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.

public override void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

GetPlanarState()

Determins the state of the curve in space. A curve may be either Planar (e.g. a cicle), NonPlanar (e.g. a polyline with vertices that dont shear a common plane) or UnderDetermined (e.g. a line defines a sheaf of planes (Ebenenbüschel))

public virtual PlanarState GetPlanarState()

Returns

PlanarState

GetPlane()

Determins the plane in which the curve resides. Throws CurveException if the curve's PlanarState is NonPlanar or UnderDetermined.

public virtual Plane GetPlane()

Returns

Plane

The plane

GetProjectedCurve(Plane)

Orthogonally projects this curve into the given plane. Returns the 2D curve in the coordinate system of the given plane.

public virtual ICurve2D GetProjectedCurve(Plane p)

Parameters

p Plane

The plane this curve will be projected on

Returns

ICurve2D

The 2D curve in the given plane

GetQuadTreeItem(Projection, ExtentPrecision)

Returns an item for a 2d quad tree of the projected objects, used for hit tests in a projection: it knows the 2d extent of the object, whether a 2d rectangle hits it, and the depth (z position) of the object at a 2d point. Composite objects (blocks, solids, paths) return a collection of the items of their parts.

public override IQuadTreeInsertableZ GetQuadTreeItem(Projection projection, ExtentPrecision extentPrecision)

Parameters

projection Projection

the projection

extentPrecision ExtentPrecision

precision of the extent, see GetExtent(Projection, ExtentPrecision)

Returns

IQuadTreeInsertableZ

the item for the quad tree

GetSelfIntersections()

Returns the self intersection position of this curve. The returned array contains pairs of parameter values. Each intersectionpoint corresponds to two parameters.

public virtual double[] GetSelfIntersections()

Returns

double[]

Parameters of the intersection points

GetShowProperties(IFrame)

Should be overridden and return a IPropertyEntry derived object that handles the display and modification of the properties of the IGeoObject derived object. Default implementation return null.

public override IPropertyEntry GetShowProperties(IFrame Frame)

Parameters

Frame IFrame

Returns

IPropertyEntry

HitTest(ref BoundingCube, double)

Tests whether an object is touched by the provided cube

public override bool HitTest(ref BoundingCube cube, double precision)

Parameters

cube BoundingCube

To test with

precision double

Required precision

Returns

bool

true if the object strikes the cube

HitTest(Projection, BoundingRect, bool)

Tests whether an object is inside or touched by the rectangle when projected with the provided projection

public override bool HitTest(Projection projection, BoundingRect rect, bool onlyInside)

Parameters

projection Projection

The projection for the test

rect BoundingRect

The rectangle to test the position

onlyInside bool

true: the object must be totaly inside the rectangle, false: the object must be totaly or partially inside the rectangle

Returns

bool

true when the test succeedes, false otherwise

HitTest(PickArea, bool)

Tests whether an object is inside or touched by the provided area

public override bool HitTest(Projection.PickArea area, bool onlyInside)

Parameters

area Projection.PickArea

The area to check for

onlyInside bool

true: the object must be totaly inside the area, false: the object must be totaly or partially inside the area

Returns

bool

true when the test succeedes, false otherwise

InvalidateSecondaryData()

protected virtual void InvalidateSecondaryData()

IsInPlane(Plane)

Determines whether the curve resides in the given plane.

public virtual bool IsInPlane(Plane p)

Parameters

p Plane

The plane for the test

Returns

bool

true, when the curve resides in the plane

MakeTetraederHull()

protected void MakeTetraederHull()

PaintTo3D(IPaintTo3D)

Paints the object with the methods of paintTo3D: lines, triangles, text... The views implement IPaintTo3D (with OpenGL or GDI) and collect what the object paints in a display list, so this is called rarely, after PrepareDisplayList(double) has done the expensive work (triangulation, approximation).

public override void PaintTo3D(IPaintTo3D paintTo3D)

Parameters

paintTo3D IPaintTo3D

where to paint

ParameterToPosition(double)

convert the parameter, which is in a natural system (0..2*pi for circle, first knot to last knot for bspline) to the 0..1 normalized position

public virtual double ParameterToPosition(double parameter)

Parameters

parameter double

Returns

double

the position, 0..1 when inside the bounds

PointAndDerivativesAt(ICurve, double, int)

Helper for calculating higher derivatives of any curve: the point and the first two derivatives come from TryPointDeriv2At(double, out GeoPoint, out GeoVector, out GeoVector) (or DirectionAt(double)), higher derivatives are computed numerically. Curves which know their higher derivatives should implement them on their own.

public static IReadOnlyList<GeoVector> PointAndDerivativesAt(ICurve curve, double position, int grad)

Parameters

curve ICurve

The curve

position double

Where to calculate the derivatives

grad int

Number of derivatives

Returns

IReadOnlyList<GeoVector>

element 0 is the point (as a vector), element i is the i-th derivative

PointAndDerivativesAt(double, int)

Returns all derivatives up to grad. The first vector is actually the point at this position.

public virtual IReadOnlyList<GeoVector> PointAndDerivativesAt(double position, int grad)

Parameters

position double

Where to calculate the derivatives

grad int

Number of derivatives. grad==2 returns the point, the first and the second derivative

Returns

IReadOnlyList<GeoVector>

Sequence of derivatives: element 0 = point-vector (P), 1 = first derivative (P'), 2 = second (P''), … . Length ≥ grad+1.

PointAt(double)

Returns the point of the given position. The parameter position of the start-point is 0.0, the parameter position of the endpoint is 1.0. Points of a position outside this interval may be undefined. The correlation between the parameter Position and the resulting point may be not linear.

public abstract GeoPoint PointAt(double Position)

Parameters

Position double

Position on the curve

Returns

GeoPoint

The requested point

Position(GeoPoint, GeoVector, double)

Returns the smallest parameter value (l) where the provided line hits the object so that the point fromHere + l * direction is on or close to the object. The result may be negative. Return double.MaxValue if there is no such point.

public override double Position(GeoPoint fromHere, GeoVector direction, double precision)

Parameters

fromHere GeoPoint

Startpoint of the line

direction GeoVector

Direction of the line

precision double

Precision for the test

Returns

double

Position on the line

PositionAtLength(double)

Returns the parameter of the point at the given position. The position must be in the interval [0, Length]. The correlation between the parameter Position and the resulting position is linear. The result is usually used for PointAt(double) or DirectionAt(double).

public virtual double PositionAtLength(double position)

Parameters

position double

Position on the curve

Returns

double

The requested position

PositionOf(ICurve, GeoPoint, ref double)

Finds the parameter of the point on curve closest to p with a Levenberg-Marquardt minimisation, starting at u. The parameter stays within [0,1].

public static bool PositionOf(ICurve curve, GeoPoint p, ref double u)

Parameters

curve ICurve

The curve

p GeoPoint

The point to find the foot point for

u double

Start value, the result on success

Returns

bool

true, if the minimisation converged

PositionOf(GeoPoint)

Returns the parametric position of the point on the curve. This function is inverse to DirectionAt(double). If the given point is not on the curve, the result is the position of a point on the curve, that is close to the given point, but not necessary of the closest point.

public virtual double PositionOf(GeoPoint p)

Parameters

p GeoPoint

Point, for which the position is requested

Returns

double

the requested position

PositionOf(GeoPoint, Plane)

Similar to the PointAt(double) method. Returns the same result, if the point is on the curve. If the point is not on the curve the problem is looked at in the given plane. i.e. the closest point on the projected 2d curve from the projected 2d point is used.

public virtual double PositionOf(GeoPoint p, Plane pl)

Parameters

p GeoPoint

Point, whos position is requested

pl Plane

Plane for the computation of the closest point

Returns

double

the requested position

PositionOf(GeoPoint, double)

Similar to PositionOf(GeoPoint). If the point is not on the curve and there are several solutions then the solution closest to the parameter prefer will be returned.

public virtual double PositionOf(GeoPoint p, double prefer)

Parameters

p GeoPoint

Point, for which the position is requested

prefer double

preferable solution close to this value

Returns

double

the requested position

PositionToParameter(double)

convert the position (which is in the 0..1 interval) to the natural parameter value

public virtual double PositionToParameter(double position)

Parameters

position double

Returns

double

PrepareDisplayList(double)

Called before PaintTo3D(IPaintTo3D) is called, should implement the time consuming work for the display (like calculationg the triangulation of Faces or Polylines of Curves). Not normally used by user code.

public override void PrepareDisplayList(double precision)

Parameters

precision double

Required precision

Reverse()

Reverses the direction of the curve.

public abstract void Reverse()

SameGeometry(ICurve, double)

Returns true, if this curve and the provided curve describe the same curve in space (maybe opposite direction)

public virtual bool SameGeometry(ICurve other, double precision)

Parameters

other ICurve

The curve to be compared with

precision double

The required precision

Returns

bool

true, if geometrically equal

Split(double)

Splits the curve at the given position. The position must be in the interval 0..1 and the curve must not be closed. For closed curves Split(double, double).

public abstract ICurve[] Split(double Position)

Parameters

Position double

Where to split

Returns

ICurve[]

the splitted curve(s)

Split(double, double)

Splits the closed curve into two open curves at the given positions.

public virtual ICurve[] Split(double Position1, double Position2)

Parameters

Position1 double

first Position

Position2 double

second Position

Returns

ICurve[]

the splitted curve(s)

TangentPosition(GeoVector)

Returns a list of positions where the curve has the same or opposite direction as the given direction. Mainly used for visualisation purposes. If there are no such points (which is true in most cases) An empty array should be returned.

public virtual double[] TangentPosition(GeoVector direction)

Parameters

direction GeoVector

Returns

double[]

Trim(double, double)

Modifies start and endpoint of this curve. StartPos must be less than EndPos. if StartPos is less than 0.0 or EndPos greater than 1.0 this only works for lines and (circular or elliptical) arcs.

public abstract void Trim(double StartPos, double EndPos)

Parameters

StartPos double

New start position

EndPos double

New end position

TryPointDeriv2At(double, out GeoPoint, out GeoVector, out GeoVector)

Tries to get the point and the first and second derivative of the curve at the specified position. (0..1) Some curves do not implement the second derivative and hence will return false.

public virtual bool TryPointDeriv2At(double position, out GeoPoint point, out GeoVector deriv, out GeoVector deriv2)

Parameters

position double

Position where to calculate point and derivatives

point GeoPoint

The point at the required position

deriv GeoVector
deriv2 GeoVector

The second derivative at the provided parameter

Returns

bool