Table of Contents

Class CylindricalSurfaceNP

Namespace
CADability.GeoObject
Assembly
CADability.dll

A cylindrical surface, defined by a point (location), and axis (zAxis). The axis (zAxis) and the two vectors xAxis and yAxis build an orthogonal coordinate system. xAxis and yAxis have the same length, which define the radius of the cylinder. The length of the zAxis is the domain of the cylindrical surface. points outside this domain are defined, but not used. The 2d u/v system is defined by the plane through "location" which is spanned by xAxis and yAxis. For each point on the surface, there is a point in this plane, which is found by intersecting the line from (location-zAxis) to the surface point with the u/v plane. Thus all points of the domain on the surface are within an annulus with the cylinder radius and a hole of half the cylinder radius. The u/v system is not periodic and has no poles (except of the 2d origin, which is at the infinite end of the axis). When the orthogonal system of xAxis, yAxis and zAxis is right handed, the normal vectors point to the outside, otherwise they point to the inside. Circles, ellipses and lines in 3d correspond to circles, ellipses and lines in 2d. 3d ellipses with their center at (location-zAxis) degenerate to lines in 2d.

public class CylindricalSurfaceNP : ISurfaceImpl, ISurface, IOctTreeInsertable, IJsonSerialize, ISerializable, IRestrictedDomain, ICylinder, ISurfaceWithRadius
Inheritance
CylindricalSurfaceNP
Implements
Inherited Members
Extension Methods

Constructors

CylindricalSurfaceNP()

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

protected CylindricalSurfaceNP()

CylindricalSurfaceNP(GeoPoint, GeoVector, GeoVector, GeoVector)

Creates the cylinder from its coordinate system: xAxis and yAxis are perpendicular to zAxis, have the same length, which is the radius, and span the u/v plane through location; zAxis is the axis of the cylinder and its length is the length of the usable part, which starts at location. The normals point outward when the three vectors form a right-handed system, inward otherwise (see OutwardOriented).

public CylindricalSurfaceNP(GeoPoint location, GeoVector xAxis, GeoVector yAxis, GeoVector zAxis)

Parameters

location GeoPoint

the center of the circle at the start of the usable part

xAxis GeoVector

the direction of u in the u/v plane, with the radius as length

yAxis GeoVector

the direction of v in the u/v plane, perpendicular to xAxis, with the radius as length

zAxis GeoVector

the axis of the cylinder, with the length of the usable part as length

CylindricalSurfaceNP(GeoPoint, double, GeoVector, bool, ICurve[])

Creates a cylinder with the given radius about the axis through center in direction axis, whose usable part is the smallest interval along the axis that contains all of orientedCurves, typically the edges of the face that is going to use the surface. GetNonPeriodicSurface(ICurve[]) uses this to replace a periodic cylinder.

public CylindricalSurfaceNP(GeoPoint center, double radius, GeoVector axis, bool outwardOriented, ICurve[] orientedCurves)

Parameters

center GeoPoint

a point on the axis

radius double

the radius of the cylinder

axis GeoVector

the direction of the axis

outwardOriented bool

true when the normals shall point away from the axis, false when they shall point to the axis (a hole)

orientedCurves ICurve[]

curves on the cylinder (e.g. the edges of a face) that define the extent of the usable part along the axis

CylindricalSurfaceNP(SerializationInfo, StreamingContext)

Constructor for the legacy binary deserialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.

protected CylindricalSurfaceNP(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

the data of the object

context StreamingContext

the source of the deserialization

Properties

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

OutwardOriented

True when the normals of the surface point away from the axis, i.e. when the x, y and z axes form a right-handed system; false when they point to the axis (the surface of a hole).

public bool OutwardOriented { get; }

Property Value

bool

UvChangesWithModification

True when Modify(ModOp) (e.g. a rotation) changes the u/v parameter system in a way that 2d curves on the surface are no longer valid afterwards. This is the case for the non-periodic surfaces (CylindricalSurfaceNP, ConicalSurfaceNP, SphericalSurfaceNP), whose parameter system is bound to the global axes; Edge recomputes the 2d curves of its faces after a modification when this is true. False for the elementary surfaces, which carry their parameter system with them.

public override bool UvChangesWithModification { get; }

Property Value

bool

Methods

AdaptToCurves(IEnumerable<ICurve>)

Returns a new cylinder with the same axis, radius and orientation whose usable part along the axis is the smallest interval that contains curves, see CylindricalSurfaceNP(GeoPoint, double, GeoVector, bool, ICurve[]). Called e.g. when faces are merged and the edges of the result must fit into the domain of the surface.

public ISurface AdaptToCurves(IEnumerable<ICurve> curves)

Parameters

curves IEnumerable<ICurve>

curves on the cylinder (e.g. edges) that the domain must contain

Returns

ISurface

the adapted surface; this surface is not modified

Clip(ICurve2D)

Clip the provided curve at the bounds of the domain. The result are pairs of parameters of the curve, which define segments, that are inside the domain.

public double[] Clip(ICurve2D curve)

Parameters

curve ICurve2D

Returns

double[]

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

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 p, out GeoVector du, out GeoVector dv, out GeoVector duu, out GeoVector dvv, out GeoVector duv)

Parameters

uv GeoPoint2D

Point in the parameter space

p GeoPoint
du GeoVector

Resulting derivation in u

dv GeoVector

Resulting derivation in v

duu GeoVector
dvv GeoVector
duv GeoVector

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

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

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

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

GetObjectData(IJsonWriteData)

Writes the location and the three axes for the JSON serialization (IJsonSerialize).

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

receives the properties

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

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

IsInside(GeoPoint2D)

True, if the provided uv value is inside the definition domain

public bool IsInside(GeoPoint2D uv)

Parameters

uv GeoPoint2D

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

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

PerpendicularFoot(GeoPoint)

Returns a list of perpendicular foot points of the surface. The list may be empty

public override GeoPoint2D[] PerpendicularFoot(GeoPoint fromHere)

Parameters

fromHere GeoPoint

Source point for the perpendicular foot

Returns

GeoPoint2D[]

Array of foot-points, may be empty

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

RestrictedPointAt(GeoPoint2D)

Same as PointAt(GeoPoint2D), but when uv is outside the definition domain, the resulting point is forced inside the domain

public GeoPoint RestrictedPointAt(GeoPoint2D uv)

Parameters

uv GeoPoint2D

Returns

GeoPoint

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)

Reads the data written by GetObjectData(IJsonWriteData) for the JSON deserialization (IJsonSerialize).

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

provides the properties

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