Table of Contents

Class Shell

Namespace
CADability.GeoObject
Assembly
CADability.dll

A shell is a set of connected Faces: neighbouring faces share their Edges, and the faces are oriented consistently, so that the surface normals of all faces point to the same side (outward for the shell of a Solid). A shell is closed when every edge belongs to two faces (see OpenEdges); a closed shell can bound a Solid (MakeSolid(Shell)), an open shell is a free standing surface, e.g. a sheet metal part. Shells are created by the methods of Make3D (extrusion, rotation, sewing of faces), by FromFaces(Face[], bool) from faces that already share their edges, or come from the file imports. A shell is also an IGeoObject that can be added to a Model.

public class Shell : IGeoObjectImpl, IGeoObject, ILayer, IStyle, IOctTreeInsertable, IComparable, IFeedBack, ICloneable, ISerializable, IColorDef, IGeoObjectOwner, IDeserializationCallback, IExportStep, IJsonSerialize, IJsonSerializeDone
Inheritance
Shell
Implements
Inherited Members
Extension Methods

Constructors

Shell()

Creates an empty shell without faces. Not for direct use: call Construct(), which honours Constructor, and set the faces afterwards.

protected Shell()

Shell(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected Shell(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Fields

Constructed

When set, this delegate is called at the end of the Shell constructor for every new shell, e.g. to attach user data to it.

public static Shell.ConstructedDelegate Constructed

Field Value

Shell.ConstructedDelegate

Constructor

When set, Construct() calls this delegate instead of creating a Shell, so that an application can substitute a derived class for every shell CADability creates (also when reading files).

public static Shell.ConstructionDelegate Constructor

Field Value

Shell.ConstructionDelegate

OnPaintTo3D

Static hook called at the beginning of PaintTo3D(IPaintTo3D) for every shell. Set it to replace or extend the way shells are displayed; when the handler returns true, the default painting of the faces is skipped. Null by default.

public static Shell.PaintTo3DDelegate OnPaintTo3D

Field Value

Shell.PaintTo3DDelegate

State

Records which normalizations (see Shell.ShellFlags) have already been applied to this shell. Maintained by CADability and saved with the shell; not meant to be set by applications.

public Shell.ShellFlags State

Field Value

Shell.ShellFlags

Properties

ColorDef

The color of this shell. Setting it sets the same color on all faces of the shell (the faces determine the color of the display, also of the edges); the change is undoable and raises the change events.

public ColorDef ColorDef { get; set; }

Property Value

ColorDef

Edges

Returns all the edges of this Shell. Each egde is unique in the array but may belong to two different faces.

public Edge[] Edges { get; }

Property Value

Edge[]

Faces

Returns all Faces of this shell. Do not modify the returned array since it is (for better performance) the original array contained in this Shell.

public Face[] Faces { get; }

Property Value

Face[]

FeatureAxis

The axes of the rotationally symmetric parts of this shell (cylindrical holes, bosses, fillets etc.): for each group of connected faces on a surface of revolution an invisible Line along the axis of that surface, a little longer than the faces. The user data "CADability.AxisOf" of each line holds the face it was derived from. The lines are computed on first access and cached; the context menu uses them to show the axes, the parametric actions as reference objects.

public GeoObjectList FeatureAxis { get; }

Property Value

GeoObjectList

Genus

The genus of this closed shell from the Euler-Poincare formula V - E + F - H = 2 - 2*G (H: the number of holes in the faces). A shell without through holes has genus 0, a tube has genus 1, and every cut-out in the wall of a tube adds 1. The shell must consist of a single connected component.

public int Genus { get; }

Property Value

int

IsClosed

Checks whether the shall is closed, i.e. all edges of all faces connect two faces of this shell.

public bool IsClosed { get; }

Property Value

bool

Layer

Fully implements Layer. Stores the layer in a private member. Setting raises the WillChangeEvent and DidChangeEvent.

public override Layer Layer { get; set; }

Property Value

Layer

Name

The name of the shell.

public string Name { get; set; }

Property Value

string

NameOrEmpty

The Name of this shell, or an empty string when no name has been set (Name returns null then).

public string NameOrEmpty { get; }

Property Value

string

OpenEdges

Returns all edges, which have only a PrimaryFace. If there are edges with references to faces, which do not belong to this shell, these references are removed and the edges are treated as open edges.

public Edge[] OpenEdges { get; }

Property Value

Edge[]

OpenEdgesExceptPoles

The open edges of this shell (see OpenEdges) without the poles, i.e. without the edges of zero length that start and end at the same vertex (like the apex of a cone). Empty for a closed shell.

public Edge[] OpenEdgesExceptPoles { get; }

Property Value

Edge[]

OwnedItems

Returns an array of objects owned by this object. E.g. a face is owned by a shell.

public override IGeoObject[] OwnedItems { get; }

Property Value

IGeoObject[]

PreferredStyle

Returns the preferred style for this objects, see Style.EDefaultFor.

public override Style.EDefaultFor PreferredStyle { get; }

Property Value

Style.EDefaultFor

Vertices

All vertices of the faces of this shell, each vertex once. The array is collected anew on each access.

public Vertex[] Vertices { get; }

Property Value

Vertex[]

Methods

AddAndRemoveFaces(IEnumerable<Face>, IEnumerable<Face>)

Modifies this shell by removing the faces in facesToRemove and adding the faces in facesToAdd, which replace them, e.g. to remove a feature and close the resulting gap with new faces. The new faces are connected among each other (see ConnectFaces(Face[], double)) and with the remaining faces: their open edges are merged with the open edges left by the removed faces where vertices and geometry coincide; if the new faces turn out to be oriented the wrong way, they are all reversed. The new faces take the color of the shell (or of its solid). The change is undoable.

public bool AddAndRemoveFaces(IEnumerable<Face> facesToAdd, IEnumerable<Face> facesToRemove)

Parameters

facesToAdd IEnumerable<Face>

the faces to add

facesToRemove IEnumerable<Face>

the faces of this shell to remove

Returns

bool

true if the shell is closed afterwards (no open edges), false otherwise

AddFaces(IEnumerable<Face>)

Not implemented: does nothing and returns false. Use AddAndRemoveFaces(IEnumerable<Face>, IEnumerable<Face>) to add faces to a shell.

public bool AddFaces(IEnumerable<Face> faces)

Parameters

faces IEnumerable<Face>

ignored

Returns

bool

always false

AddFeature(string, IEnumerable<Face>)

Marks faces as belonging to the feature name (see GetFeatures()). A face can belong to several features. The faces are not checked to be faces of this shell.

public void AddFeature(string name, IEnumerable<Face> faces)

Parameters

name string

the name of the feature, see GetNewFeatureName() for an unused name

faces IEnumerable<Face>

the faces of the feature

AddInnerHole(Face[])

Adds the faces of a cavity to this shell. The faces must form a closed shell inside of this shell, oriented towards the cavity (i.e. reversed with respect to a solid of the shape of the cavity).

public void AddInnerHole(Face[] faces)

Parameters

faces Face[]

AddParametricProperty(ParametricProperty)

Adds a ParametricProperty to this shell: a named, modifiable property (e.g. the distance between two faces) defined by faces, edges and vertices of this shell, which the user can change later to modify the shell. Parametric properties are usually created by the parametric actions (ParametricsDistanceAction etc.); they are saved and cloned with the shell.

public void AddParametricProperty(ParametricProperty parametricProperty)

Parameters

parametricProperty ParametricProperty

the property to add

AssertOutwardOrientation()

Makes sure the faces of this shell are oriented outward, i.e. the surface normals point away from the enclosed volume, as required for the shell of a solid. A face is looked for whose normal certainly points outward (a ray along the normal from an inner point of the face does not hit the shell again, or a ray from outside hits it first); if none is found, all faces are assumed to be inverted. The orientation of that face is then propagated to all other faces across their common edges, so that the shell is also consistently oriented afterwards. The shell should be closed, for an open shell the result is ambiguous. Not undoable.

public void AssertOutwardOrientation()

Centroid(double)

Returns the center of gravity (centroid) of the solid enclosed by this shell, assuming a homogeneous material. The calculation is based on a triangulation with the provided precision, see GetMassProperties(double, out double, out GeoPoint, out double[,]).

public GeoPoint Centroid(double precision)

Parameters

precision double

The precision of the triangulation

Returns

GeoPoint

The center of gravity

Clone()

Clones this GeoObject.

public override IGeoObject Clone()

Returns

IGeoObject

the cloned GeoObject

Clone(Dictionary<Edge, Edge>, Dictionary<Vertex, Vertex>, Dictionary<Face, Face>)

Clones the shell and fills the dictionaries with original to cloned references

public Shell Clone(Dictionary<Edge, Edge> clonedEdges, Dictionary<Vertex, Vertex> clonedVertices = null, Dictionary<Face, Face> clonedFaces = null)

Parameters

clonedEdges Dictionary<Edge, Edge>
clonedVertices Dictionary<Vertex, Vertex>
clonedFaces Dictionary<Face, Face>

Returns

Shell

CloseEdgeLoop(List<Edge>, bool)

Takes a (closed) loop of edges of this shell as parameter sortedEdges and tries to create a shell, which connects the edges. It heals the hole, described by sortedEdges. The edges are sorted so that following the edges they go clockwise around the hole to fix.

public HashSet<Face> CloseEdgeLoop(List<Edge> sortedEdges, bool addToShell)

Parameters

sortedEdges List<Edge>

Edges, which only have the PrimaryFace set (the SecondaryFace must be null)

addToShell bool

true: the new faces are connected to this shell, the edges in sortedEdges get the new face as their secondary face; false: the new faces get their own edges and this shell remains unchanged

Returns

HashSet<Face>

CloseOpenEdges(Dictionary<Edge, ISurface>)

Close all open edges by adding new faces

public bool CloseOpenEdges(Dictionary<Edge, ISurface> proposedSurfaces = null)

Parameters

proposedSurfaces Dictionary<Edge, ISurface>

Returns

bool

true, if the Shell is now closed, false otherwise

CombineConnectedFaces()

Adjacent faces that share a common surface are replaced by a single face

public int CombineConnectedFaces()

Returns

int

Number of faces that have been combined

CombineFaces(HashSet<Face>, HashSet<Edge>)

Extends the set faces by all faces reachable from them across edges that are not in barrier: neighbours are added repeatedly until no more faces can be reached. Used to collect the faces of a feature or of a part of a shell that is delimited by a loop of edges.

public static void CombineFaces(HashSet<Face> faces, HashSet<Edge> barrier)

Parameters

faces HashSet<Face>

the faces to start with, receives the collected faces

barrier HashSet<Edge>

the edges that must not be crossed

ConnectFaces(Face[], double)

Connects independent faces to the topology of a shell: vertices of open edges of different faces that lie within precision of each other are merged into a single vertex, and open edges which then connect the same two vertices with the same geometry are merged into a single edge shared by the two faces. Afterwards the faces can be used in FromFaces(Face[], bool). Edges that are already shared are not affected; the orientation of the faces is not changed.

public static void ConnectFaces(Face[] toConnect, double precision)

Parameters

toConnect Face[]

the faces to connect

precision double

maximum distance between vertices that are merged

ConnectedSameGeometryEdges(IEnumerable<Edge>)

Collect all edges, which are connected to the provided edges and have the same geometry

public static HashSet<Edge> ConnectedSameGeometryEdges(IEnumerable<Edge> edges)

Parameters

edges IEnumerable<Edge>

Returns

HashSet<Edge>

ConnectedSameGeometryFaces(IEnumerable<Face>)

Collect all faces which are connected to the provided faces and are part of the same surface geometry (like two halves of a cylinder, which are connected by a "seam" edge)

public static HashSet<Face> ConnectedSameGeometryFaces(IEnumerable<Face> faces)

Parameters

faces IEnumerable<Face>

Returns

HashSet<Face>

Construct()

Creates an empty shell, or an instance of the class Constructor provides. Set its faces with SetFaces(Face[]), or use FromFaces(Face[], bool), which does both.

public static Shell Construct()

Returns

Shell

the new shell

Contains(GeoPoint)

Tests whether toTest lies inside the volume enclosed by this shell. The shell must be closed and oriented outward (see AssertOutwardOrientation()). The test looks for a face whose center can be reached from the point without crossing the shell and decides by the direction of the surface normal there; it returns false when no such face is found. Points on the surface are not reliably classified.

public bool Contains(GeoPoint toTest)

Parameters

toTest GeoPoint

the point to test

Returns

bool

true if the point is inside

CopyAll(Shell)

Makes this shell take over the faces, edges and parametric properties of toCopyFrom (the objects themselves, not copies; the faces are re-owned by this shell). Used to replace the contents of a shell by a modified clone of itself in an undoable way: the previous state is recorded for undo and the change events are raised.

public void CopyAll(Shell toCopyFrom)

Parameters

toCopyFrom Shell

the shell whose contents are taken over

CopyGeometry(IGeoObject)

Copies the geometrical aspects of the given GeoObject to this GeoObject. Both objects must be of the same type. The attributes are not copied.

public override void CopyGeometry(IGeoObject toCopyFrom)

Parameters

toCopyFrom IGeoObject

Decompose()

Decomposes the object into simpler objects, see Decompose(). The default implementation returns null: the object cannot be decomposed.

public override GeoObjectList Decompose()

Returns

GeoObjectList

the parts, or null

FeatureFromEdges(Edge[], Face[])

edgeLoop must be a closed set of edges on this shell. The shell will be splitted at this loop. All edges in edgeLoop join one of the faces in facesToCutoff. These parts of the shell will not be used. At this loop, which remains open in the first step, the resulting shell will be closed by faces with surfaces from facesToCutOff.

public Shell FeatureFromEdges(Edge[] edgeLoop, Face[] facesToCutOff)

Parameters

edgeLoop Edge[]

a closed loop of edges of this shell, at which the shell is split

facesToCutOff Face[]

faces of this shell adjacent to the loop: the part of the shell containing them is cut off and their surfaces close the resulting shell

Returns

Shell

FeatureFromFace(Face)

Tries to find a feature like a drill hole or a part sticking out of the shell starting with this face. The rule is that faces connected with the face toStartWith are combined until the open edges have the same underlying surface. There might be one or two loops of such open edges (two loops for a hole going through the body).

public Shell FeatureFromFace(Face toStartWith)

Parameters

toStartWith Face

Returns

Shell

FeatureFromFaces(IEnumerable<Face>, out IEnumerable<Face>, out List<Face>, out bool)

Tries to find a "feature" containing the faces facesToStartWith. There is no simple way to find such a feature. Maybe, the facesToStartWith already make a feature. This would be the case, when the outer connection edges of these faces build a single closed loop. SameSurface

public bool FeatureFromFaces(IEnumerable<Face> facesToStartWith, out IEnumerable<Face> featureFaces, out List<Face> connection, out bool isGap)

Parameters

facesToStartWith IEnumerable<Face>
featureFaces IEnumerable<Face>
connection List<Face>
isGap bool

Returns

bool

Exceptions

NotImplementedException

FeatureFromLoops(IEnumerable<Edge>, out IEnumerable<Face>, out List<Face>, out bool)

Tries to find a "feature" which is disconnected from the remaining shell by the provided edges in loopEdges.

public bool FeatureFromLoops(IEnumerable<Edge> loopEdges, out IEnumerable<Face> featureFaces, out List<Face> connection, out bool isGap)

Parameters

loopEdges IEnumerable<Edge>

unsorted edges, which seperate the feature from the shell

featureFaces IEnumerable<Face>

faces (of this shell), which belong to the feature

connection List<Face>

new faces, which close the open shell of the feature and the open shell of the remaining shell

isGap bool

the feature is a gap (e.g. a drilling hole) and not some extra part of the shell

Returns

bool

true, if such a feature was found

FeaturesFromEdges(ICollection<Edge>)

Extracts the parts of this shell delimited by the edges bounds as separate closed shells. The edges must form closed loops that separate the faces of this shell into parts (e.g. the edges where a boss meets the base body). For each part, each loop is closed with a new face (cap) on the surface of the faces adjacent to the loop on the other side, the part is cloned, connected with its caps and oriented outward. Parts for which no cap could be made are skipped; this shell is not modified.

public List<Shell> FeaturesFromEdges(ICollection<Edge> bounds)

Parameters

bounds ICollection<Edge>

the edges that delimit the parts

Returns

List<Shell>

a closed shell for each part, empty when the edges do not separate the shell

FeaturesFromEdges(List<Edge[]>, List<IEnumerable<Face>>, List<IEnumerable<Face>>, IEnumerable<Face>)

Returns "features" of the shell. A feature is a subset of the faces of the shell, which is seperated by the provided loops. Since such a feature has open edges, there is also a face or multiple faces, which close the feature to make it to a solid.

public void FeaturesFromEdges(List<Edge[]> loops, List<IEnumerable<Face>> features, List<IEnumerable<Face>> lids, IEnumerable<Face> startWith)

Parameters

loops List<Edge[]>

the closed loops of edges, which delimit the features

features List<IEnumerable<Face>>

receives the features found: each is the set of faces reachable from startWith without crossing the loops

lids List<IEnumerable<Face>>

receives the faces, which close a feature to a solid; currently only passed on to the recursive calls, nothing is added

startWith IEnumerable<Face>

the faces to start from; the feature grows from these across all edges, which are not in loops

FindSameForm(Face[], double, FindSameFormSearchMode)

Find other instances of the "form" given by the parameter form. The faces in form must be a subset of faces of this shell. Returned are other subsets of faces of this shell that describe the same form.

public Face[][] FindSameForm(Face[] form, double precision, Shell.FindSameFormSearchMode mode)

Parameters

form Face[]
precision double
mode Shell.FindSameFormSearchMode

Returns

Face[][]

FindSnapPoint(SnapPointFinder)

Asks the object to add its snap points (end points, centres, intersections...) of the kinds that spf asks for. The default implementation adds none; objects with geometry override it.

public override void FindSnapPoint(SnapPointFinder spf)

Parameters

spf SnapPointFinder

definition and collection of the snap points

ForgetRememberedFaces()

Remove all UserData added by RememberFaces()()

public void ForgetRememberedFaces()

FreeCachedMemory()

Forwards FreeCachedMemory() to all faces of this shell. Currently nothing is released.

public void FreeCachedMemory()

FromFaces(params Face[])

Creates a shell from faces, which must already be connected, i.e. neighbouring faces share their edges (as the faces of an existing shell do). The faces are neither checked nor connected; see FromFaces(Face[], bool) to connect independent faces, or SewFaces(Face[], bool), which also sorts the faces into several shells. The faces become owned by the shell.

public static Shell FromFaces(params Face[] faces)

Parameters

faces Face[]

the faces of the shell

Returns

Shell

the new shell

FromFaces(Face[], bool)

Creates a shell from faces. With connect set, the faces are connected first (see ConnectFaces(Face[], double)): vertices and open edges of different faces which coincide within eps are merged, so that independent faces (e.g. from an import) become a connected shell. Otherwise the faces must already share their edges. The faces become owned by the shell.

public static Shell FromFaces(Face[] faces, bool connect = false)

Parameters

faces Face[]

the faces of the shell

connect bool

true: merge coinciding edges and vertices of the faces first

Returns

Shell

the new shell

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

GetConnectedFaceSets()

Returns the connected components of the faces of this shell: two faces belong to the same component when there is a path from one to the other via common edges. For a closed shell each component is itself a closed shell, i.e. the outer hull or one of the holes (see GetHullAndHoles()). This is a purely topological operation, it makes no assumption about orientation or closedness and can also be used on open shells.

public List<HashSet<Face>> GetConnectedFaceSets()

Returns

List<HashSet<Face>>

The connected components, each face of this shell is contained in exactly one of them

GetCorrespondingEdge(Edge, Dictionary<Face, List<Face>>)

Finds the edge of this shell that corresponds to original, an edge of another (e.g. an earlier) version of this shell, after the faces have been matched with RememberFaces() and GetRememberedMultiDictionary(Shell): among the edges between the faces corresponding to the two faces of original, the one whose midpoint is closest to the midpoint of the original is returned.

public Edge GetCorrespondingEdge(Edge original, Dictionary<Face, List<Face>> dictionary)

Parameters

original Edge

the edge of the other shell; it must have two faces, which must be keys of dictionary

dictionary Dictionary<Face, List<Face>>

maps the faces of the other shell to the corresponding faces of this shell

Returns

Edge

the corresponding edge, or null when a face of original has no counterpart or the counterparts have no common edge

GetEnclosedPart(Path, double)

Preliminary: Returns the enclosed part of the shell which is inside the border

public Shell GetEnclosedPart(Path closedBorder, double precision)

Parameters

closedBorder Path
precision double

Returns

Shell

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

GetFeatures()

Returns the named features of this shell. A feature is a set of faces of the shell marked with a name (see AddFeature(string, IEnumerable<Face>)); a face may belong to several features. The names are stored as user data of the faces, so they survive cloning and saving.

public Dictionary<string, HashSet<Face>> GetFeatures()

Returns

Dictionary<string, HashSet<Face>>

the faces of each feature by feature name, empty when no features have been defined

GetGauge(Face, out HashSet<Face>, out HashSet<Face>)

Determines the thickness (gauge) of the material at the face startHere, e.g. of a sheet metal part: looks for a face of this shell that is parallel to startHere with opposite orientation (the other side of the material) and returns the distance between them. Both sides are then extended across tangential edges (bends) as long as the thickness stays the same, so that frontSide and backSide contain all faces of the two surfaces of the sheet.

public double GetGauge(Face startHere, out HashSet<Face> frontSide, out HashSet<Face> backSide)

Parameters

startHere Face

the face to start with, becomes part of frontSide

frontSide HashSet<Face>

receives the faces on the side of startHere

backSide HashSet<Face>

receives the faces on the opposite side

Returns

double

the thickness, or MaxValue when there is no opposite parallel face

GetHullAndHoles()

Returns the outer hull and the holes (cavities) of this shell as sets of faces. If there are no holes, the hull contains all faces and holes is empty. The connected components are provided by GetConnectedFaceSets(), the hull is identified by the enclosed volume: the normals of a hole point into the cavity, so a hole encloses a negative volume, and since the holes are located inside the hull, the hull is the component with the greatest absolute volume. It is the only component with a positive volume, unless the shell is inverted, as it is used as an intermediate result of union and difference: then all signs are reversed and the hull is the only component with a negative volume. The shell must be closed, otherwise the volumes and hence the result are meaningless.

public (HashSet<Face> hull, HashSet<Face>[] holes) GetHullAndHoles()

Returns

(HashSet<Face> hull, HashSet<Face>[] holes)

The faces of the outer hull and the faces of each hole

GetLineIntersection(GeoPoint, GeoVector)

Intersects the infinite line through location with direction direction with all faces of this shell (see GetLineIntersection(GeoPoint, GeoVector)). The points are in no particular order; a point on an edge may be returned once for each face of the edge.

public GeoPoint[] GetLineIntersection(GeoPoint location, GeoVector direction)

Parameters

location GeoPoint

a point on the line

direction GeoVector

direction of the line

Returns

GeoPoint[]

the intersection points, empty when the line misses the shell

GetMassProperties(double, out double, out GeoPoint, out double[,])

Computes volume, center of gravity and inertia tensor of the solid enclosed by this shell in a single pass over the triangulation. Like Volume(double) this requires a closed shell with outward oriented faces, otherwise the results are meaningless.

All moments are calculated as surface integrals over the triangles (divergence theorem), the same principle Volume(double) uses. The integrands are polynomials of degree 3 at most, so a 4 point quadrature rule which is exact for cubic polynomials makes the values exact for the triangulated body. The deviation of the curved surface from its triangles is handled by the same correction as in Volume(double): the material between the triangle and the surface (volume 3/4*area*sag) is added as an additional lump, which sits above the centroid of the triangle at 2/5 of the sag.

A homogeneous material with density 1 is assumed, i.e. the mass is the volume. Multiply the tensor by the density to get the physical inertia tensor.

public void GetMassProperties(double precision, out double volume, out GeoPoint centerOfGravity, out double[,] inertiaTensor)

Parameters

precision double

The precision of the triangulation

volume double

The enclosed volume

centerOfGravity GeoPoint

The center of gravity

inertiaTensor double[,]

The symmetric 3x3 inertia tensor with respect to the center of gravity

GetNewFeatureName()

Returns a feature name that is not yet used in this shell: the localized default name (string table entry "Solid.NewFeatureName") followed by a number greater than all numbers already in use.

public string GetNewFeatureName()

Returns

string

a new feature name

GetObjectData(IJsonWriteData)

Writes the data of this base class (user data, layer, style, user attributes and actuator) for the JSON serialization (IJsonSerialize). Derived classes override it, call the base implementation and add their own properties.

public override void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

receives the data

GetOffset(double, bool, Dictionary<Edge, Edge>)

Creates the offset of this shell: each face is replaced by its offset face at distance dist (see GetOffset(double, Dictionary<Vertex, Vertex>)), the gaps at convex edges and vertices are closed by new faces and the material at concave edges is trimmed. Self intersections of this raw offset are then resolved, which may split the result into several shells. This shell is prepared first (oriented outward, periodic faces split, vertices and edges recalculated), which modifies it.

public Shell[] GetOffset(double dist, bool allowOpenEdges = true, Dictionary<Edge, Edge> parallelEdges = null)

Parameters

dist double

the offset distance, positive outward with respect to the orientation of the shell

allowOpenEdges bool

true: shells with open edges are accepted as result, false: only closed shells are returned

parallelEdges Dictionary<Edge, Edge>

if provided, receives for each edge of this shell the corresponding edge of the raw offset (which may not have survived the resolution of self intersections)

Returns

Shell[]

the offset shells, empty when no valid offset could be made

GetOrientedLineIntersection(GeoPoint, GeoVector, out bool)

Intersects the infinite line through location with direction direction with all faces of this shell. For each intersection point the result contains the line parameter (location + par*direction) and whether the line leaves the shell there in the direction of the surface normal (true) or enters it (false), see GetOrientedLineIntersection(GeoPoint, GeoVector, out bool). The entries are not sorted. isBoundaryCase is set when an intersection point lies on an edge, the line is tangential to a face there, or an intersection is at location itself: the result is then not reliable for an inside/outside test and a different line should be tried.

public List<(double, bool)> GetOrientedLineIntersection(GeoPoint location, GeoVector direction, out bool isBoundaryCase)

Parameters

location GeoPoint

a point on the line

direction GeoVector

direction of the line

isBoundaryCase bool

true if the result is ambiguous

Returns

List<(double, bool)>

line parameter and orientation of each intersection

GetPlaneIntersection(PlaneSurface)

Returns the curves that result from a planar intersection of this shell with the provided plane. The curves are properly clipped.

public ICurve[] GetPlaneIntersection(PlaneSurface pl)

Parameters

pl PlaneSurface

The plane to intersect with

Returns

ICurve[]

Array of intersection curves

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

GetRememberedDictionary(Shell)

Returns a dictionary from the other shell to this shell of corresponding faces. If a face had been split, only a single face is in the value part of the dictionary entry

public Dictionary<Face, Face> GetRememberedDictionary(Shell other)

Parameters

other Shell

Returns

Dictionary<Face, Face>

GetRememberedMultiDictionary(Shell)

Returns a dictionary from the other shell to this shell of corresponding faces. The value of this dictionary is a list, which may contain one or more faces (e.g. if faces have been splitted)

public Dictionary<Face, List<Face>> GetRememberedMultiDictionary(Shell other)

Parameters

other Shell

Returns

Dictionary<Face, List<Face>>

GetShadow(Plane)

Returns a SimpleShape with the outline and holes of the shadow of the projection of the shell perpendicular on the provided plane.

public SimpleShape GetShadow(Plane onThisPlane)

Parameters

onThisPlane Plane

Returns

SimpleShape

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

HasOpenEdgesExceptPoles()

Returns true if this shell has open edges (edges with only one face) other than poles. A pole, like the apex of a cone, is an edge of zero length that starts and ends at the same vertex; it is open by nature and does not make the shell open. Use this rather than OpenEdges to decide whether a shell can be made a solid.

public bool HasOpenEdgesExceptPoles()

Returns

bool

true if the shell is open

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

InertiaTensor(double)

Returns the inertia tensor of the solid enclosed by this shell with respect to its center of gravity, assuming a homogeneous material of density 1 (i.e. the mass is the volume). The diagonal contains the moments of inertia Ixx, Iyy, Izz, the off diagonal elements are the (negated) products of inertia. The calculation is based on a triangulation with the provided precision, see GetMassProperties(double, out double, out GeoPoint, out double[,]).

public double[,] InertiaTensor(double precision)

Parameters

precision double

The precision of the triangulation

Returns

double[,]

The symmetric 3x3 inertia tensor

InertiaTensor(double, GeoPoint)

Returns the inertia tensor of the solid enclosed by this shell with respect to the provided referencePoint, assuming a homogeneous material of density 1 (i.e. the mass is the volume).

public double[,] InertiaTensor(double precision, GeoPoint referencePoint)

Parameters

precision double

The precision of the triangulation

referencePoint GeoPoint

The point the tensor refers to

Returns

double[,]

The symmetric 3x3 inertia tensor

IsInside(GeoPoint)

public bool IsInside(GeoPoint toTest)

Parameters

toTest GeoPoint

the point to test

Returns

bool

true if the point is inside the closed shell

IsOutwardOriented()

Determines the orientation of this closed shell with a ray from a point of a face along its normal: the last intersection of the ray with the shell is where the ray leaves the enclosed volume, and the orientation of the face there tells whether the normals point outward. Faces where the ray hits an edge or touches a face are skipped.

public bool IsOutwardOriented()

Returns

bool

MakeRegularSurfaces(double)

Replaces the NurbsSurfaces of the faces of this shell by the elementary surfaces (plane, cylinder, cone, sphere, torus) they approximate within maxError, where there are such surfaces. The 2d curves of the edges on the modified faces are recomputed, and the 3d curves of edges between two modified faces are recomputed as intersections of the new surfaces. Imported NURBS surfaces often are such elementary surfaces, which are handled faster and more precisely.

public void MakeRegularSurfaces(double maxError)

Parameters

maxError double

maximum distance between the NURBS surface and the replacing elementary surface

MakeThick(double, double)

Makes a solid with walls of constant thickness from this (usually open) shell, e.g. a sheet metal part from its middle surface: the solid is bounded by the offsets of this shell at innerDist and outerDist (measured along the surface normals, the thickness is their difference) and by new faces that connect the two offsets along the open edges of this shell. A distance of 0 uses the shell itself. This shell is prepared first (oriented outward, periodic faces split, vertices and edges recalculated), which modifies it.

public Solid MakeThick(double innerDist, double outerDist)

Parameters

innerDist double

offset distance of the first boundary

outerDist double

offset distance of the second boundary; the order of the two distances does not matter

Returns

Solid

the solid, or null when the two distances are equal or the solid could not be constructed

Modify(ModOp)

Modifies this GeoObject with the given modification operation (includes moving, rotating, reflecting, scaling etc.).

public override void Modify(ModOp m)

Parameters

m ModOp

Operation to be applied

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

PaintTo3DList(IPaintTo3D, ICategorizedDislayLists)

Adds this object as a whole to the display lists, in the category of its layer. Suitable for simple objects like curves and text; composite objects (solids, shells, blocks) override it and add their parts by category.

public override void PaintTo3DList(IPaintTo3D paintTo3D, ICategorizedDislayLists lists)

Parameters

paintTo3D IPaintTo3D

the paint interface of the view

lists ICategorizedDislayLists

the display lists to add to

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

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

RecalcVertices()

Merges vertices of this shell that have (almost) the same position (within 1e-8 of the size of the shell) into a single vertex and repairs the connections of the faces afterwards. Needed after operations that may have created duplicate vertices, e.g. when edges have been recomputed.

public void RecalcVertices()

RememberFaces()

Set marker (as UserData) on the faces, so that we can later, when the shell has been modified, find corresponding faces and edges

public void RememberFaces()

RemoveFeature(List<Face>)

Removes a feature, e.g. a hole or a boss, from this shell: the faces in facesToRemove are removed and the gaps they leave in the remaining faces are closed. Currently this only works when each loop of edges that connects the feature with the rest of the shell is a hole in a single remaining face: that hole is removed (see RemoveHole(int)) and the face covers the area again. In all other cases the shell is left unchanged. The change is undoable.

public bool RemoveFeature(List<Face> facesToRemove)

Parameters

facesToRemove List<Face>

the faces of the feature

Returns

bool

currently always false, also when the feature has been removed

RemoveFeature(string)

Removes the feature name: the mark is removed from all faces of this shell, the faces themselves stay. Nothing happens when there is no such feature.

public void RemoveFeature(string name)

Parameters

name string

the name of the feature

ReverseOrientation()

Reverses the orientation of all faces of this shell (see ReverseOrientation()), so that the surface normals point to the other side: an outward oriented shell becomes inward oriented, as needed for a cavity. Not undoable, no change events are raised.

public void ReverseOrientation()

SameForm(Shell, double, out ModOp)

Returns true, if this shell and the other shell describe the same form. The two shells may be at different positions in 3d space, but may not be rotated, i.e. must have the same orientation in 3d space.

public bool SameForm(Shell other, double precision, out ModOp translation)

Parameters

other Shell

the other shell

precision double

maximum difference in the geometry of the two shells accepted as still beeing equal

translation ModOp

how to move the other shell to coincide with this shell

Returns

bool

SameGeometry(Shell)

A quick test whether this shell and other might have the same geometry: the numbers of faces, edges and vertices must be equal and the volumes must coincide within a thousandth of the size of the shell. This is not a full comparison; use SameForm(Shell, double, out ModOp) to compare the faces.

public bool SameGeometry(Shell other)

Parameters

other Shell

the other shell

Returns

bool

false if the shells certainly differ, true if they agree in these properties

SetFaces(Face[])

Sets the faces of a shell. The faces must all be connected to form a single shell, they may have free edges. This is not checked. This method does not accumulate the faces.

public void SetFaces(Face[] faces)

Parameters

faces Face[]

The new faces that build the shell

SetObjectData(IJsonReadData)

Reads the data written by GetObjectData(IJsonWriteData) back from the JSON serialization. Derived classes override it, call the base implementation and read their own properties. Objects referenced by the data may still be incomplete at this time, see IJsonSerializeDone.

public override void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

provides the data

SignedVolume(IEnumerable<Face>, double)

Computes the signed volume enclosed by the provided faces. The faces must form a closed shell, otherwise the result is meaningless. The sign follows the orientation: faces with outward pointing normals (a hull) enclose a positive volume, faces with inward pointing normals (a hole or cavity) enclose a negative volume.

public static double SignedVolume(IEnumerable<Face> shellFaces, double precision)

Parameters

shellFaces IEnumerable<Face>

The faces of a closed shell

precision double

The precision of the triangulation

Returns

double

The signed enclosed volume

SignedVolume(IEnumerable<Face>, double, GeoPoint)

SignedVolume(IEnumerable<Face>, double) with the tetrahedra spanned from reference instead of from the origin. For a closed shell the result does not depend on the reference point, but the contribution of a single face does - so whoever sums faces from different sources must use the same reference point for all of them. A reference near the shell also keeps the per face contributions small.

public static double SignedVolume(IEnumerable<Face> shellFaces, double precision, GeoPoint reference)

Parameters

shellFaces IEnumerable<Face>
precision double
reference GeoPoint

Returns

double

SplitPeriodicFaces()

Splits all faces of this shell on periodic surfaces that contain a seam edge (see SplitPeriodicFace()) into faces without seams, e.g. a full cylinder into two halves. Boolean operations and offsets are simpler on shells without seams. The split faces replace the originals and the neighbouring faces are connected to the new edges. The change is undoable.

public void SplitPeriodicFaces()

TestIntersection(List<ICurve>)

Tests whether any of the curves in toTestWith intersects a face of this shell. Only intersection points within the parameter range of the curve (0 to 1, i.e. on the curve itself and not on its extension) count.

public bool TestIntersection(List<ICurve> toTestWith)

Parameters

toTestWith List<ICurve>

the curves to test

Returns

bool

true if at least one curve intersects the shell

Volume(double)

The volume enclosed by this shell, computed by SignedVolume(IEnumerable<Face>, double) from a triangulation of the faces. The shell must be closed, otherwise the result is meaningless. The sign follows the orientation: positive for an outward oriented shell, negative for an inward oriented one (a cavity).

public double Volume(double precision)

Parameters

precision double

precision of the triangulation, which limits the precision of the result: the edges deviate by up to this value, the triangles inside the faces by about five times this value (see GetTriangulation(double, out GeoPoint[], out GeoPoint2D[], out int[], out BoundingCube)). When a face cannot be triangulated that finely (a triangulation stops at a maximum number of triangles, and when it stopped half way, the volume was far worse than with a coarser precision: a sphere of radius 3 was off by 1e-8 at 1e-4, by 9e-4 at 1e-7), all faces are triangulated again with a ten times coarser precision, until each face is complete.

Returns

double

the signed volume