Table of Contents

Class CylindricalSurface

Namespace
CADability.GeoObject
Assembly
CADability.dll

A cylindrical surface which implements ISurface. The surface represents a circular or elliptical cylinder. The u parameter always describes a circle or ellipse, the v parameter a Line.

public class CylindricalSurface : ISurfaceImpl, ISurface, IOctTreeInsertable, ISurfaceOfRevolution, ISerializable, IDeserializationCallback, IExportStep, ISurfaceOfArcExtrusion, ISurfaceOfExtrusion, ICylinder, ISurfaceWithRadius, IJsonSerialize
Inheritance
CylindricalSurface
Implements
Derived
Inherited Members
Extension Methods

Constructors

CylindricalSurface()

Empty constructor for the JSON deserialization (IJsonSerialize); the data is set by SetObjectData(IJsonReadData).

protected CylindricalSurface()

CylindricalSurface(GeoPoint, GeoVector, GeoVector, GeoVector)

Creates a cylindrical surface. The length of directionX and directionY specify the radius. The axis is perpendicular to directionX and directionY (right hand). The u parameter starts at location+directionX, the v parameter increments along the axis and is 0 at location.

public CylindricalSurface(GeoPoint location, GeoVector directionX, GeoVector directionY, GeoVector directionZ)

Parameters

location GeoPoint
directionX GeoVector
directionY GeoVector
directionZ GeoVector

the direction of the axis, along which the v parameter increments; it should be perpendicular to directionX and directionY, but may also form a left handed system with them

CylindricalSurface(SerializationInfo, StreamingContext)

Constructor for the legacy binary deserialization (ISerializable).

protected CylindricalSurface(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

The serialized data

context StreamingContext

The source of the deserialization

Fields

toCylinder

The transformation which maps the unit cylinder (axis = z-axis, radius 1, located at the origin) onto this cylinder; the surface is defined by this transformation alone. The u parameter is the angle on the unit circle, the v parameter the z coordinate.

protected ModOp toCylinder

Field Value

ModOp

toUnit

The inverse of toCylinder, cached to speed up computations like PositionOf(GeoPoint).

protected ModOp toUnit

Field Value

ModOp

Properties

Axis

The direction of the axis of the cylinder, the same as ZAxis. Its length is the scale of the v parameter: the point on the axis with parameter v is Location + v*Axis.

public GeoVector Axis { get; }

Property Value

GeoVector

IsRealCylinder

This surface is a round cylinder, not an elliptical cylinder

public bool IsRealCylinder { get; }

Property Value

bool

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

Location

The point on the axis where the v parameter is 0: the surface point at (0, 0) is Location + XAxis. Read only; use Modify(ModOp) to move the surface.

public GeoPoint Location { get; }

Property Value

GeoPoint

Oriented

Returns true, if this surface divides the space into two parts. If the surfaces is Oriented Orientation(GeoPoint) returns a valid result

public override bool Oriented { get; }

Property Value

bool

OutwardOriented

True when the normal of the surface points away from the axis (XAxis, YAxis and ZAxis form a right handed system), false when it points towards the axis, as it does for the surface of a hole.

public bool OutwardOriented { get; }

Property Value

bool

RadiusX

The radius in direction of XAxis (the length of that vector). For a circular cylinder this is the radius; an elliptical cylinder has different RadiusX and RadiusY.

public double RadiusX { get; }

Property Value

double

RadiusY

The radius in direction of YAxis (the length of that vector). Equal to RadiusX for a circular cylinder.

public double RadiusY { 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

VPeriod

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

public override double VPeriod { get; }

Property Value

double

XAxis

The vector from the axis to the surface point with u = 0 (in the cross section v = 0). Its length is RadiusX.

public GeoVector XAxis { get; }

Property Value

GeoVector

YAxis

The vector from the axis to the surface point with u = π/2 (in the cross section v = 0). Its length is RadiusY. Together with XAxis and ZAxis it may form a left handed system; then the normal points inward (see OutwardOriented).

public GeoVector YAxis { get; }

Property Value

GeoVector

ZAxis

The direction of the axis, identical to Axis. The v parameter increases in this direction; one unit of v is the length of this vector.

public GeoVector ZAxis { get; }

Property Value

GeoVector

Methods

AxisLine(double, double)

Returns the part of the axis which corresponds to the v interval [vmin, vmax] as a Line, e.g. for displaying the axis of a face on this surface: it starts at the point of the axis with v = vmin and ends at the point with v = vmax.

public Line AxisLine(double vmin, double vmax)

Parameters

vmin double

The v parameter of the start point

vmax double

The v parameter of the end point

Returns

Line

The line segment on the axis

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

GetDualSurfaceCurves(BoundingRect, ISurface, BoundingRect, List<GeoPoint>, List<Tuple<double, double, double, double>>)

Returns intersectionCurves

public override IDualSurfaceCurve[] GetDualSurfaceCurves(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, List<GeoPoint> seeds, List<Tuple<double, double, double, double>> extremePositions)

Parameters

thisBounds BoundingRect

Bounds for this surface

other ISurface

Other surface

otherBounds BoundingRect

Bounds of other surface

seeds List<GeoPoint>

3d points known to lie on the intersection curves (typically the intersection points of the edges of one face with the other face), used as starting points for the intersection curves; may be null

extremePositions List<Tuple<double, double, double, double>>

Positions (u1, v1, u2, v2) where the surfaces have an extremum of their distance, as returned by GetExtremePositions(BoundingRect, ISurface, BoundingRect, out List<Tuple<double, double, double, double>>). Entries may be double.NaN. They are used to find closed intersection curves which do not cross the bounds; may be null

Returns

IDualSurfaceCurve[]

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.

GetExtremePositions(BoundingRect, ISurface, BoundingRect, out List<Tuple<double, double, double, double>>)

Find positions in the uv system, where the connection of the points are perpendicular on both surfaces. the resulting list extremePositions may be only partially filled, the missing uv values may be double.NaN, because this is what we need in most cases.

public override int GetExtremePositions(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, out List<Tuple<double, double, double, double>> extremePositions)

Parameters

thisBounds BoundingRect
other ISurface
otherBounds BoundingRect
extremePositions List<Tuple<double, double, double, double>>

Returns

int

GetImplicitPolynomial()

Returns the implicit form of the surface: a polynomial in x, y and z which is zero exactly for the points of the surface and whose value approximates the (signed) distance of a point from the surface. It is used to speed up intersections and distance computations with other surfaces. The base implementation returns null; the elementary surfaces (e.g. CylindricalSurface, ToroidalSurface) override it.

public override Polynom GetImplicitPolynomial()

Returns

Polynom

The implicit polynomial, or null when not available for this type of surface

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[]

GetModified(ModOp)

Returns a clone of this surface modified by the given ModOp.

public override ISurface GetModified(ModOp m)

Parameters

m ModOp

how to modify

Returns

ISurface

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

GetObjectData(IJsonWriteData)

Writes the data of this surface for the JSON serialization (IJsonSerialize).

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

Receives the data

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

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[]

GetTangentCurves(GeoVector, double, double, double, double)

Returns curves where direction is perpendicular to the normal vector

public override ICurve2D[] GetTangentCurves(GeoVector direction, double umin, double umax, double vmin, double vmax)

Parameters

direction GeoVector
umin double
umax double
vmin double
vmax double

Returns

ICurve2D[]

GetTouchingPoints(BoundingRect, ISurface, BoundingRect)

Overrides GetTouchingPoints(BoundingRect, ISurface, BoundingRect): returns the points, where this surface and other touch each other (are tangential)

public override GeoPoint[] GetTouchingPoints(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)

Parameters

thisBounds BoundingRect

the uv bounds of this surface, in which touching points are searched

other ISurface

the other surface

otherBounds BoundingRect

the uv bounds of the other surface, in which touching points are searched

Returns

GeoPoint[]

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

HitTest(BoundingCube, out GeoPoint2D)

Overrides HitTest(BoundingCube, out GeoPoint2D): true, when the unbounded cylinder passes through bc. uv is then the position of a point of the cylinder inside bc.

In the system of the unit cylinder (toUnit) the box is a parallelepiped K and the cylinder is r == 1, where r is the distance from the z-axis. K is convex and connected, so the cylinder passes through K exactly when the smallest r in K is at most 1 and the largest is at least 1. The largest r is at a corner, because r is a convex function. The smallest r is 0, when the axis passes through the box, otherwise it is on an edge of K: the outline of the projection of K onto the xy-plane consists of projected edges. An edge may enter and leave the cylinder while both of its ends are outside, which the former implementation missed: it only looked at edges with their ends on different sides.

This is called for many boxes when the faces are sorted into an octtree (Face.HitBoundingCube), so the cheap cases come first and nothing is allocated.

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

Parameters

bc BoundingCube
uv GeoPoint2D

Returns

bool

HitTest(BoundingCube, double, double, double, double)

Checks whether this surface restricted by the provided parameters interferes with the provided cube.

public override bool HitTest(BoundingCube cube, double umin, double umax, double vmin, double vmax)

Parameters

cube BoundingCube

Bounding cube for the test

umin double

Minimum for the u parameter

umax double

Maximum for the u parameter

vmin double

Minimum for the v parameter

vmax double

Maximum for the v parameter

Returns

bool

true if the cube and the surface interfere

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(BoundingRect, ISurface, BoundingRect, GeoPoint)

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, GeoPoint seed)

Parameters

thisBounds BoundingRect

Bounds for this surface

other ISurface

Other surface

otherBounds BoundingRect

Bounds of other surface

seed GeoPoint

A 3d point on the intersection curve which is sought: of all intersection curves only the one passing through this point is returned

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

IsExtruded(GeoVector)

returns true, if the provided direction can be interpreted as an extrusion direction of the surface

public override bool IsExtruded(GeoVector direction)

Parameters

direction GeoVector

Returns

bool

IsParallel(BoundingRect, ISurface, BoundingRect)

Returns a double value, if this surface is parallel to the other surface. Returns double.MaxValue otherwise. In most cases the bounds may be ignored.

public override double IsParallel(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)

Parameters

thisBounds BoundingRect
other ISurface
otherBounds BoundingRect

Returns

double

IsRotated(Axis)

returns true, if the provided direction can be interpreted as a surface of rotation around the provided rotationAxis

public override bool IsRotated(Axis rotationAxis)

Parameters

rotationAxis Axis

the axis to test

Returns

bool

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

OnDeserialization(object)

Implements OnDeserialization(object) for the legacy binary deserialization: recomputes the cached inverse transformation after all fields have been read.

public void OnDeserialization(object sender)

Parameters

sender object

Not used

Orientation(GeoPoint)

Returns the orientation of the provided point. The sign of the result may be used to distinguish between inside and outside.

public override double Orientation(GeoPoint p)

Parameters

p GeoPoint

Returns

double

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

PositionOf(GeoPoint)

Returns the u/v position of the given point. It is assumed that the point is on the surface, if not the result is undetermined.

public override GeoPoint2D PositionOf(GeoPoint p)

Parameters

p GeoPoint

point

Returns

GeoPoint2D

position

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

SetObjectData(IJsonReadData)

Restores this surface from the JSON data written by GetObjectData(IJsonWriteData) (IJsonSerialize).

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

The data to read

ToString()

public override string ToString()

Returns

string

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