Table of Contents

Struct BoundingCube

Namespace
CADability
Assembly
CADability.dll

Represents a bounding cuboid, that is an extent in 3 dimensions

[JsonVersion(serializeAsStruct = true, version = 1)]
public struct BoundingCube : ISerializable, IJsonSerialize
Implements
Inherited Members

Constructors

BoundingCube(GeoPoint, double)

Constructs a equal sided BoundingCube from a center point and a "radius" (half width)

public BoundingCube(GeoPoint center, double halfSize)

Parameters

center GeoPoint

Center point

halfSize double

Half of the width

BoundingCube(params GeoPoint[])

Constructs a BoundingCube, that encloses all given points

public BoundingCube(params GeoPoint[] p)

Parameters

p GeoPoint[]

points to enclose

BoundingCube(IEnumerable<IGeoObject>)

Constructs the BoundingCube that encloses the extents (GetExtent(0.0)) of all given objects. For an empty enumeration the result is the EmptyBoundingCube.

public BoundingCube(IEnumerable<IGeoObject> objects)

Parameters

objects IEnumerable<IGeoObject>

the objects to enclose

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

Constructs a BoundingCube from minimum and maximum values

public BoundingCube(double Xmin, double Xmax, double Ymin, double Ymax, double Zmin, double Zmax)

Parameters

Xmin double

Minimum in x-direction

Xmax double

Maximum in x-direction

Ymin double

Minimum in y-direction

Ymax double

Maximum in y-direction

Zmin double

Minimum in z-direction

Zmax double

Maximum in z-direction

BoundingCube(SerializationInfo, StreamingContext)

Constructor required by deserialization

public BoundingCube(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Fields

UnitBoundingCube

BoundingCube defining the interval [0,1] in all directions

public static BoundingCube UnitBoundingCube

Field Value

BoundingCube

Xmax

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Xmax

Field Value

double

Xmin

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Xmin

Field Value

double

Ymax

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Ymax

Field Value

double

Ymin

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Ymin

Field Value

double

Zmax

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Zmax

Field Value

double

Zmin

The limits of the cube in the three coordinate directions. For the EmptyBoundingCube the minima are MaxValue and the maxima MinValue, so that MinMax(GeoPoint) can grow it from there. The fields may be set directly; IsEmpty and IsValid check the state.

public double Zmin

Field Value

double

Properties

DiagonalLength

The length of the space diagonal, i.e. the distance between the vertices (Xmin,Ymin,Zmin) and (Xmax,Ymax,Zmax). Often used as a measure for precision values relative to the size of an object, whereas Size is the sum of the three edge lengths.

public double DiagonalLength { get; }

Property Value

double

EmptyBoundingCube

Empty BoundingCube. Defined by the special values MinValue and MaxValue. Often used with the MinMax(GeoPoint) or MinMax(BoundingCube) Methods.

public static BoundingCube EmptyBoundingCube { get; }

Property Value

BoundingCube

InfiniteBoundingCube

Infinite BoundingCube. Ranging from MinValue to MaxValue.

public static BoundingCube InfiniteBoundingCube { get; }

Property Value

BoundingCube

IsEmpty

Returns true if this is the special empty cube

public bool IsEmpty { get; }

Property Value

bool

IsValid

True, if all limits are finite numbers (neither NaN nor infinite). The EmptyBoundingCube is valid in this sense; test for it with IsEmpty.

public bool IsValid { get; }

Property Value

bool

LineNumbers

Gets an array[12,2] of pairs of point indices defining the 12 edges of this cube. Indices are to the Points

public int[,] LineNumbers { get; }

Property Value

int[,]

Lines

Gets the 12 edges of the cube as a GeoPoint[12, 2] array

public GeoPoint[,] Lines { get; }

Property Value

GeoPoint[,]

MaxSide

Gets the length of the maximum side

public double MaxSide { get; }

Property Value

double

Points

Gets an array of the 8 vertices of this cube

public GeoPoint[] Points { get; }

Property Value

GeoPoint[]

Size

Gets the sum of width, height and deepth

public double Size { get; }

Property Value

double

Volume

Gets the product of width, height and deepth

public double Volume { get; }

Property Value

double

XDiff

Gets the extension in x direction

public double XDiff { get; }

Property Value

double

YDiff

Gets the extension in y direction

public double YDiff { get; }

Property Value

double

ZDiff

Gets the extension in z direction

public double ZDiff { get; }

Property Value

double

Methods

Clip(ICurve)

Clips the given curve by this cube: the curve is split at its intersections with the six face planes and those pieces whose middle point lies inside the cube are returned as trimmed clones. The curve itself is not changed.

public ICurve[] Clip(ICurve toClip)

Parameters

toClip ICurve

the curve to clip

Returns

ICurve[]

the parts of the curve inside the cube, an empty array when the curve lies completely outside

ClipAxis(Axis, out GeoPoint, out GeoPoint)

Clips the infinite line given by axis by this cube (see ClipLine(ref GeoPoint, ref GeoPoint)).

public bool ClipAxis(Axis axis, out GeoPoint startPoint, out GeoPoint endPoint)

Parameters

axis Axis

the line to clip

startPoint GeoPoint

start of the part of the line inside the cube, in the direction of the axis

endPoint GeoPoint

end of the part of the line inside the cube

Returns

bool

true, if the line passes through the cube; false if it misses the cube, the two points are then meaningless

ClipLine(ref GeoPoint, ref GeoPoint)

Clips the provided line (defined by start and end) by this cube. Returns true if the line interferes with this boundingcube, modifies the start and endpoint in the parameters if clipping occures

public bool ClipLine(ref GeoPoint start, ref GeoPoint end)

Parameters

start GeoPoint

Startpoint of the line, may be changed upon return

end GeoPoint

Endpoint of the line, may be changed upon return

Returns

bool

true if the line and this cube interfere

Contains(BoundingCube)

Returns true if this cube contains the provided cube. (<= will be checked)

public bool Contains(BoundingCube extn)

Parameters

extn BoundingCube

Cube to be checked

Returns

bool

true if there is containment

Contains(GeoPoint)

Returns true if this cube contains the provided point. (<= will be checked)

public bool Contains(GeoPoint p)

Parameters

p GeoPoint

The Point

Returns

bool

true if there is containment

Contains(GeoPoint, double)

Returns true if this cube contains the provided point. Points within the cube extended by precision will also be accepted.

public bool Contains(GeoPoint p, double prec)

Parameters

p GeoPoint

The Point

prec double

The precision by which the cube is extended

Returns

bool

true if there is containment

Disjoint(BoundingCube, BoundingCube)

Returns true if the two cubes are disjoint (do not overlap and do not touch)

public static bool Disjoint(BoundingCube b1, BoundingCube b2)

Parameters

b1 BoundingCube

First cube

b2 BoundingCube

Second cube

Returns

bool

true if disjoint

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

Expand(double)

Expands the bounding cube by the given value in all directions.

public void Expand(double w)

Parameters

w double

offset to expand with

GetCenter()

Returns the center of this BoundingCube

public GeoPoint GetCenter()

Returns

GeoPoint

GetExtent(Projection)

Returns the extent of the projected BoundingCube

public BoundingRect GetExtent(Projection pr)

Parameters

pr Projection

the projection

Returns

BoundingRect

the resulting 2-dimensional extent

GetHashCode()

public override int GetHashCode()

Returns

int

GetObjectData(IJsonWriteData)

Implements GetObjectData(IJsonWriteData): writes the six limits as a list of values.

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

the JSON writer

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 void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

GetPlanes()

Returns the 6 planes of the faces of this cube as PlaneSurfaces, in the order x=Xmin, y=Ymin, z=Zmin, z=Zmax, y=Ymax, x=Xmax (the same order as the faces of GetSides()). For a degenerated cube, where a face collapses to a line or a point, an empty array is returned.

public PlaneSurface[] GetPlanes()

Returns

PlaneSurface[]

the planes of the faces

GetSides()

Returns 6 planar faces, the faces of this cube

public Face[] GetSides()

Returns

Face[]

the faces

GetSolid()

Returns a solid cube as a Solid.

public Solid GetSolid()

Returns

Solid

the solid

Interferes(BoundingCube)

Checks the interference of this cube with the other provided cube

public bool Interferes(BoundingCube bc)

Parameters

bc BoundingCube

the other cube to test with

Returns

bool

true if the two cubes interfere (overlap)

Interferes(GeoPoint, GeoPoint, GeoPoint, GeoPoint)

Returns true if the provided tetrahedron (given by the four points tetra1..tetra4) and this BoundingCube interfere

public bool Interferes(GeoPoint tetra1, GeoPoint tetra2, GeoPoint tetra3, GeoPoint tetra4)

Parameters

tetra1 GeoPoint

1st tetrahedron vertex

tetra2 GeoPoint

2nd tetrahedron vertex

tetra3 GeoPoint

3rd tetrahedron vertex

tetra4 GeoPoint

4th tetrahedron vertex

Returns

bool

True if objects interfere

Interferes(GeoPoint, GeoVector, GeoVector, GeoVector)

Checks the interference of this cube with the provided parallelepiped (the affine projection of a cube)

public bool Interferes(GeoPoint loc, GeoVector dirx, GeoVector diry, GeoVector dirz)

Parameters

loc GeoPoint
dirx GeoVector
diry GeoVector
dirz GeoVector

Returns

bool

Interferes(GeoPoint, GeoVector, double, bool)

Returns true if the given line intersects the this bounding cube. Returns false otherwise.

public bool Interferes(GeoPoint start, GeoVector dir, double maxdist, bool onlyForward)

Parameters

start GeoPoint

Startpoint of the line

dir GeoVector

Direction of the line

maxdist double

Maximum allowable distance from the line

onlyForward bool

Set to true, if only the positive ray should be cinsidered

Returns

bool

Interferes(ref GeoPoint, ref GeoPoint)

Returns true if the given line segment intersects the this bounding cube. Returns false otherwise.

public bool Interferes(ref GeoPoint start, ref GeoPoint end)

Parameters

start GeoPoint

Start point of the line

end GeoPoint

End point of the line

Returns

bool

True if intersection

Interferes(ref GeoPoint, ref GeoPoint, ref GeoPoint)

Returns true when the triangle defined by tri1, tri2 and tri3 (including the inside of the triangle) and this BoundingCube interfere.

public bool Interferes(ref GeoPoint tri1, ref GeoPoint tri2, ref GeoPoint tri3)

Parameters

tri1 GeoPoint

First point of triangle

tri2 GeoPoint

Second point of triangle

tri3 GeoPoint

Third point of triangle

Returns

bool

true if interference, false otherwise

Interferes(GeoPoint[])

Checks the interference of this cube with the provided polyline. The array of points defines a polyline connecting consecutive points.

public bool Interferes(GeoPoint[] points)

Parameters

points GeoPoint[]

The polyline

Returns

bool

true when some part of the polyline interferes with this cube

Interferes(GeoPoint[], int[])

Checks the interference of this cube with the provided triangles. The triangles are defined by three points each. Each triple of indices in triangleIndex defines one triangle. Not only the edges of the triangle are checked but also the inner surface.

public bool Interferes(GeoPoint[] trianglePoint, int[] triangleIndex)

Parameters

trianglePoint GeoPoint[]

Array of vertives of the triangles

triangleIndex int[]

Indices to trianglePoint, each triple defines one triangle

Returns

bool

true if any of the provides triangles interferes with this cube

Interferes(Plane)

Returns true if the given plane intersects the this bounding cube. Returns false otherwise.

public bool Interferes(Plane plane)

Parameters

plane Plane

The plane to test with

Returns

bool

true if intersection

Interferes(Projection, BoundingRect)

Returns true, if the provided rectangle rect and this BoundingCube interfere with the provided projection.

public bool Interferes(Projection projection, BoundingRect rect)

Parameters

projection Projection

The projection

rect BoundingRect

The rectangle

Returns

bool

ture if interference, false otherwise

Interferes(PickArea)

Checks the interference of this cube with the provided area. The pickarea is either a rectangular prism of infinite length or a frustum.

public bool Interferes(Projection.PickArea area)

Parameters

area Projection.PickArea

Returns

bool

IsOnBounds(GeoPoint, double)

Tests whether the provided point toTest falls on the bounds of this cube with respect to precision.

public bool IsOnBounds(GeoPoint toTest, double precision)

Parameters

toTest GeoPoint

Point to test

precision double

Precision for the test

Returns

bool

True if on bounds, false otherwise

MinMax(BoundingCube)

Makes this BoundingCube include the provided BoundingCube. You can start with an EmptyBoundingCube

public void MinMax(BoundingCube b)

Parameters

b BoundingCube

Cube to be included

MinMax(GeoPoint)

Makes this BoundingCube include the provided point. You can start with an EmptyBoundingCube

public void MinMax(GeoPoint p)

Parameters

p GeoPoint

Point to be included

MinMax(IEnumerable<IGeoObject>)

Makes this BoundingCube include all the specified objects

public void MinMax(IEnumerable<IGeoObject> objects)

Parameters

objects IEnumerable<IGeoObject>

Modify(ModOp)

Modifies this cube according to the provided modification. If this modification contains a rotation the resulting cube will contain the rotated original cube. BoundingCubes are always axis aligned.

public void Modify(ModOp m)

Parameters

m ModOp

Modification

OnSameSide(params GeoPoint[])

Checks whether all given points lie outside of this cube beyond the same face, i.e. one of the six face planes separates all the points from the cube. If so, nothing spanned by these points (a line segment, a triangle, a tetrahedron) can interfere with the cube. The converse does not hold: false does not mean that there is an interference.

public bool OnSameSide(params GeoPoint[] pnts)

Parameters

pnts GeoPoint[]

the points to test

Returns

bool

true, if all points are beyond the same face of the cube

Set(double, double, double, double, double, double)

Sets all six limits of this cube at once.

public void Set(double Xmin, double Xmax, double Ymin, double Ymax, double Zmin, double Zmax)

Parameters

Xmin double

Minimum in x-direction

Xmax double

Maximum in x-direction

Ymin double

Minimum in y-direction

Ymax double

Maximum in y-direction

Zmin double

Minimum in z-direction

Zmax double

Maximum in z-direction

SetObjectData(IJsonReadData)

Implements SetObjectData(IJsonReadData). Does nothing, because a BoundingCube is serialized as a struct and read back by a constructor taking the stored values.

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

not used

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

Operators

operator +(BoundingCube, BoundingCube)

Returns the smallest cube that contains both cubes (the union of their extents), like MinMax(BoundingCube) but without changing the operands.

public static BoundingCube operator +(BoundingCube b1, BoundingCube b2)

Parameters

b1 BoundingCube

first cube

b2 BoundingCube

second cube

Returns

BoundingCube

the enclosing cube