Class Box3d
Lightweight 3d box. An orthogonal box which the edges are all parallel with Cartesian Coordinate. The data contains in a Box3d is Min and Max.
public class Box3d : IExpandToBox3d, IEquatable<Box3d>, IStlSource, IGetStl, IMakeXmlSource, IBinaryIo, IWriteBin, IDuplicate
- Inheritance
-
Box3d
- Implements
- Inherited Members
- Extension Methods
Constructors
Box3d()
Ctor.
public Box3d()
Box3d(NoInit)
public Box3d(Box3d.NoInit noInit)
Parameters
Box3d(params IExpandToBox3d[])
Creates a box that encompasses all the provided expandable objects.
public Box3d(params IExpandToBox3d[] src)
Parameters
src
IExpandToBox3d[]Array of objects that can expand to a box
Box3d(Vec3d, Vec3d)
Ctor.
public Box3d(Vec3d min, Vec3d max)
Parameters
Box3d(box3d)
Ctor.
public Box3d(box3d src)
Parameters
src
box3dsrc
Box3d(IEnumerable<IExpandToBox3d>)
Creates a box that encompasses all the provided expandable objects.
public Box3d(IEnumerable<IExpandToBox3d> src)
Parameters
src
IEnumerable<IExpandToBox3d>Collection of objects that can expand to a box
Box3d(double, double, double, double, double, double)
Creates a box with the specified minimum and maximum coordinates.
public Box3d(double minx, double miny, double minz, double maxx, double maxy, double maxz)
Parameters
minx
doubleMinimum X coordinate
miny
doubleMinimum Y coordinate
minz
doubleMinimum Z coordinate
maxx
doubleMaximum X coordinate
maxy
doubleMaximum Y coordinate
maxz
doubleMaximum Z coordinate
Box3d(BinaryReader)
Creates a box from binary data.
public Box3d(BinaryReader reader)
Parameters
reader
BinaryReaderBinary reader to read the box data from
Box3d(XElement)
Ctor.
public Box3d(XElement src)
Parameters
src
XElementXML
Properties
BottomCenter
Center of the bottom surface.
public Vec3d BottomCenter { get; }
Property Value
BottomView
Gets a transformation matrix for viewing the box from the bottom.
public Mat4d BottomView { get; }
Property Value
Center
Center
public Vec3d Center { get; }
Property Value
CenterUnitBox
Generate a center unit box which min~max is (-0.5,-0.5,-0.5)~(0.5,0.5,0.5).
public static Box3d CenterUnitBox { get; }
Property Value
DiagonalLength
Diagonal length.
public double DiagonalLength { get; }
Property Value
Dim
Dimension.
public Vec3d Dim { get; }
Property Value
FrontView
Gets a transformation matrix for viewing the box from the front.
public Mat4d FrontView { get; }
Property Value
HasVolume
Checks if the box has a positive volume (all dimensions are greater than zero).
public bool HasVolume { get; }
Property Value
IsAllNaN
True if all components of Min and Max are NaN.
public bool IsAllNaN { get; }
Property Value
IsFinite
True if the box is finite.
public bool IsFinite { get; }
Property Value
IsReversedPoleBox
True if the box is ReversedPoleBox
public bool IsReversedPoleBox { get; }
Property Value
IsometricView
Gets a transformation matrix for viewing the box from an isometric perspective.
public Mat4d IsometricView { get; }
Property Value
LeftSideView
Gets a transformation matrix for viewing the box from the left side.
public Mat4d LeftSideView { get; }
Property Value
Max
Maximum point of the box.
public Vec3d Max { get; set; }
Property Value
Min
Minimum point of the box.
public Vec3d Min { get; set; }
Property Value
NaN
Generate a nan box which min~max is (nan,nan,nan)~(nan,nan,nan).
public static Box3d NaN { get; }
Property Value
NativeByteSize
Gets the native byte size of a Box3d (2 Vec3d objects).
public static int NativeByteSize { get; }
Property Value
RearView
Gets a transformation matrix for viewing the box from the rear.
public Mat4d RearView { get; }
Property Value
ReversedPoleBox
Generate a reversed pole box which min~max is (∞,∞,∞)~(-∞,-∞,-∞).
public static Box3d ReversedPoleBox { get; }
Property Value
RightSideView
Gets a transformation matrix for viewing the box from the right side.
public Mat4d RightSideView { get; }
Property Value
TopCenter
Center of the top surface.
public Vec3d TopCenter { get; }
Property Value
TopView
Gets a transformation matrix for viewing the box from the top.
public Mat4d TopView { get; }
Property Value
UnitBox
Generate a unit box which min~max is (0,0,0)~(1,1,1).
public static Box3d UnitBox { get; }
Property Value
Volume
Gets the volume of the box.
public double Volume { get; }
Property Value
XName
Name for XML IO.
public static string XName { get; }
Property Value
ZeroBox
Generate a zero box which min~max is (0,0,0)~(0,0,0).
public static Box3d ZeroBox { get; }
Property Value
Methods
ApexAt(int)
Get Apex at the box.
public Vec3d ApexAt(int index)
Parameters
index
intindex 0~7. all of 8 apex.
Returns
Duplicate(params object[])
Creates a deep copy of the object, excluding any source file references.
public object Duplicate(params object[] res)
Parameters
res
object[]Optional parameters that may be needed during the duplication process
Returns
- object
A new instance that is a deep copy of the original object
Equals(Box3d)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Box3d other)
Parameters
other
Box3dAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
Expand(Box3d)
Expands this box to include another box.
public Box3d Expand(Box3d src)
Parameters
src
Box3dThe box to include
Returns
- Box3d
This box after expansion
Expand(Vec3d)
Expands the box to include the specified point.
public Box3d Expand(Vec3d p)
Parameters
p
Vec3dPoint to include in the box
Returns
- Box3d
This box after expansion
ExpandToBox3d(Box3d)
Expands the destination box. This function is usually used to compute the bounding box of elements.
public void ExpandToBox3d(Box3d dst)
Parameters
dst
Box3dDestination box
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetStl()
Generate Stl.
public Stl GetStl()
Returns
- Stl
stl
GetTransformedBoundingBox(Mat4d)
Get the bounding box of the transformed box.
public Box3d GetTransformedBoundingBox(Mat4d mat)
Parameters
mat
Mat4dmatrix
Returns
GetTris(ICollection<Tri3d>)
Generates triangles representing the box's surfaces.
public int GetTris(ICollection<Tri3d> dst)
Parameters
dst
ICollection<Tri3d>Collection to add the triangles to
Returns
- int
The number of triangles added (12)
IsOverlapped(Box3d)
Is the box overlapped to otherBox
.
public bool IsOverlapped(Box3d otherBox)
Parameters
otherBox
Box3dother box
Returns
- bool
is overlapped
MakeXmlSource(string, string)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile)
Parameters
baseDirectory
stringThe base directory for resolving relative paths
relFile
stringThe relative file path for the XML source
Returns
- XElement
An XML element representing the object's state
MemberAt(int)
Get member at the location.
public Vec3d MemberAt(int iter)
Parameters
iter
intiterator
Returns
ReadBin(BinaryReader)
Reads box data from a binary reader.
public void ReadBin(BinaryReader reader)
Parameters
reader
BinaryReaderBinary reader to read the box data from
ScaleFromCenter(double)
Scales the box from its center point.
public Box3d ScaleFromCenter(double s)
Parameters
s
doubleScale factor
Returns
- Box3d
This box after scaling
Set(Box3d)
public Box3d Set(Box3d src)
Parameters
src
Box3dsrc
Returns
- Box3d
this
Set(box3d)
public Box3d Set(box3d src)
Parameters
src
box3dsrc
Returns
- Box3d
this
Set(double, double, double, double, double, double)
Sets the box coordinates to the specified values.
public Box3d Set(double minx, double miny, double minz, double maxx, double maxy, double maxz)
Parameters
minx
doubleMinimum X coordinate
miny
doubleMinimum Y coordinate
minz
doubleMinimum Z coordinate
maxx
doubleMaximum X coordinate
maxy
doubleMaximum Y coordinate
maxz
doubleMaximum Z coordinate
Returns
- Box3d
This box after modification
SetToTransformedBoundingBox(Mat4d)
Set the box to the bounding box of the matrix-transformed box.
public Box3d SetToTransformedBoundingBox(Mat4d mat)
Parameters
mat
Mat4dmatrix
Returns
- Box3d
this
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Translate(Vec3d)
Translate the box.
public Box3d Translate(Vec3d vec)
Parameters
vec
Vec3dtranslation vector
Returns
- Box3d
this
WriteBin(BinaryWriter)
Writes box data to a binary writer.
public void WriteBin(BinaryWriter writer)
Parameters
writer
BinaryWriterBinary writer to write the box data to