Struct box3d_t
Lightweight 3d box: a sequential-layout value type of two vec3d_t fields, the
48-byte mirror of the C++ geom::box3<vec3d_t>. An orthogonal box whose edges are all
parallel with the Cartesian coordinate axes; the data is Min and Max.
It has no in-place mutating method: write Min/Max on a variable, field
or array element (never on a property receiver), or build a new value with
Expanded(vec3d_t), Translated(vec3d_t), ScaledFromCenter(double) and
GetTransformedBoundingBox(Mat4d). Bound accumulation goes through
ExpandToBox3d(ref box3d_t), which takes the destination by reference.
public struct box3d_t : IExpandToBox3d, IEquatable<box3d_t>, IStlSource, IGetStl, IMakeXmlSource, IWriteBin, IFormattable, IToPresentDto, IGetSelectionName
- Implements
- Inherited Members
- Extension Methods
Constructors
box3d_t(params IExpandToBox3d[])
Creates a box that encompasses all the provided expandable objects.
public box3d_t(params IExpandToBox3d[] src)
Parameters
srcIExpandToBox3d[]Array of objects that can expand to a box
box3d_t(box3d_t)
Copy ctor. Assignment copies a box3d_t just as well; this overload stays for the call sites that spell the copy out.
public box3d_t(box3d_t src)
Parameters
srcbox3d_tsrc
box3d_t(vec3d_t, vec3d_t)
Ctor.
public box3d_t(vec3d_t min, vec3d_t max)
Parameters
box3d_t(IEnumerable<IExpandToBox3d>)
Creates a box that encompasses all the provided expandable objects.
public box3d_t(IEnumerable<IExpandToBox3d> src)
Parameters
srcIEnumerable<IExpandToBox3d>Collection of objects that can expand to a box
box3d_t(IEnumerable<box3d_t>)
Creates a box that encompasses all the provided boxes. The value-typed box3d_t has no covariant path to IEnumerable<T>, and this overload also spares the boxing.
public box3d_t(IEnumerable<box3d_t> boxes)
Parameters
boxesIEnumerable<box3d_t>Boxes to include
box3d_t(IEnumerable<vec3d_t>)
Creates a box that encompasses all the provided points. The value-typed vec3d_t has no covariant path to IEnumerable<T>, and this overload also spares the boxing.
public box3d_t(IEnumerable<vec3d_t> ps)
Parameters
psIEnumerable<vec3d_t>Points to include in the box
box3d_t(double, double, double, double, double, double)
Creates a box with the specified minimum and maximum coordinates.
public box3d_t(double minx, double miny, double minz, double maxx, double maxy, double maxz)
Parameters
minxdoubleMinimum X coordinate
minydoubleMinimum Y coordinate
minzdoubleMinimum Z coordinate
maxxdoubleMaximum X coordinate
maxydoubleMaximum Y coordinate
maxzdoubleMaximum Z coordinate
box3d_t(BinaryReader)
Creates a box from binary data.
public box3d_t(BinaryReader reader)
Parameters
readerBinaryReaderBinary reader to read the box data from
box3d_t(XElement)
Ctor.
public box3d_t(XElement src)
Parameters
srcXElementXML
Fields
Max
Maximum point of the box.
public vec3d_t Max
Field Value
Min
Minimum point of the box.
public vec3d_t Min
Field Value
Properties
BottomCenter
Center of the bottom surface.
public readonly vec3d_t BottomCenter { get; }
Property Value
BottomView
Gets a transformation matrix for viewing the box from the bottom.
public readonly Mat4d BottomView { get; }
Property Value
Center
Center
public readonly vec3d_t 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_t CenterUnitBox { get; }
Property Value
DiagonalLength
Diagonal length.
public readonly double DiagonalLength { get; }
Property Value
Dim
Dimension.
public readonly vec3d_t Dim { get; }
Property Value
FrontView
Gets a transformation matrix for viewing the box from the front.
public readonly Mat4d FrontView { get; }
Property Value
HasVolume
Checks if the box has a positive volume (all dimensions are greater than zero).
public readonly bool HasVolume { get; }
Property Value
InfiniteBox
Generate a infinite box which min~max is (-∞,-∞,-∞)~(∞,∞,∞).
public static box3d_t InfiniteBox { get; }
Property Value
IsAllNaN
True if all components of Min and Max are NaN.
public readonly bool IsAllNaN { get; }
Property Value
IsFinite
True if the box is finite.
public readonly bool IsFinite { get; }
Property Value
IsReversedPoleBox
True if the box is ReversedPoleBox
public readonly bool IsReversedPoleBox { get; }
Property Value
IsometricView
Gets a transformation matrix for viewing the box from an isometric perspective.
public readonly Mat4d IsometricView { get; }
Property Value
LeftSideView
Gets a transformation matrix for viewing the box from the left side.
public readonly Mat4d LeftSideView { get; }
Property Value
NaN
Generate a nan box which min~max is (nan,nan,nan)~(nan,nan,nan).
public static box3d_t NaN { get; }
Property Value
NativeByteSize
Byte size of the struct as core.dll sees it: sizeof(box3d_t), two vec3d_t.
public static int NativeByteSize { get; }
Property Value
RearView
Gets a transformation matrix for viewing the box from the rear.
public readonly Mat4d RearView { get; }
Property Value
ReversedPoleBox
Generate a reversed pole box which min~max is (∞,∞,∞)~(-∞,-∞,-∞).
public static box3d_t ReversedPoleBox { get; }
Property Value
RightSideView
Gets a transformation matrix for viewing the box from the right side.
public readonly Mat4d RightSideView { get; }
Property Value
TopCenter
Center of the top surface.
public readonly vec3d_t TopCenter { get; }
Property Value
TopView
Gets a transformation matrix for viewing the box from the top.
public readonly Mat4d TopView { get; }
Property Value
UnitBox
Generate a unit box which min~max is (0,0,0)~(1,1,1).
public static box3d_t UnitBox { get; }
Property Value
Volume
Gets the volume of the box.
public readonly 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_t ZeroBox { get; }
Property Value
Methods
ApexAt(int)
Get Apex at the box.
public readonly vec3d_t ApexAt(int index)
Parameters
indexintindex 0~7. all of 8 apex.
Returns
Equals(box3d_t)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(box3d_t other)
Parameters
otherbox3d_tAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
ExpandToBox3d(ref box3d_t)
Expands the destination box.
This function is usually used to compute the bounding box of elements.
box3d_t is a value type, so the destination is passed by reference
(the C++ expand_to_box3d(box3&) shape); an implementation writes
dst = dst.Expanded(...) or forwards ref dst to its parts.
public readonly void ExpandToBox3d(ref box3d_t dst)
Parameters
dstbox3d_tDestination box, expanded in place
Expanded(box3d_t)
The box expanded to include another box.
public readonly box3d_t Expanded(box3d_t src)
Parameters
srcbox3d_tThe box to include
Returns
- box3d_t
the expanded box
Expanded(vec3d_t)
The box expanded to include the specified point.
public readonly box3d_t Expanded(vec3d_t p)
Parameters
pvec3d_tPoint to include in the box
Returns
- box3d_t
the expanded box
Expanded(IEnumerable<vec3d_t>)
The box expanded to include all specified points.
public readonly box3d_t Expanded(IEnumerable<vec3d_t> ps)
Parameters
psIEnumerable<vec3d_t>The points to include in the box.
Returns
- box3d_t
the expanded box
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetSelectionName()
The selection name “Box” (the class carried it as a [DisplayName], which is not
valid on a struct; GetSelectionName(object) reads this instead).
public readonly string GetSelectionName()
Returns
- string
“Box”
GetStl()
Generate Stl.
public readonly Stl GetStl()
Returns
- Stl
stl
GetTransformedBoundingBox(Mat4d)
Get the bounding box of the transformed box.
public readonly box3d_t GetTransformedBoundingBox(Mat4d mat)
Parameters
matMat4dmatrix
Returns
- box3d_t
the axis-aligned box that contains the eight transformed apexes
GetTris(ICollection<tri3d_t>)
Generates triangles representing the box's surfaces.
public readonly int GetTris(ICollection<tri3d_t> dst)
Parameters
dstICollection<tri3d_t>Collection to add the triangles to
Returns
- int
The number of triangles added (12)
IsOverlapped(box3d_t)
Is the box overlapped to otherBox.
public readonly bool IsOverlapped(box3d_t otherBox)
Parameters
otherBoxbox3d_tother box
Returns
- bool
is overlapped
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public readonly XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
MemberAt(int)
Get member at the location.
public readonly vec3d_t MemberAt(int iter)
Parameters
iterintiterator
Returns
ReadBin(BinaryReader)
Reads a box written by WriteBin(BinaryWriter): min then max.
public static box3d_t ReadBin(BinaryReader reader)
Parameters
readerBinaryReaderBinary reader to read the box data from
Returns
- box3d_t
the box
Reg(XFactory)
Registers this type's deserializer with the given XFactory
(or Default when factory is
null). Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory
ScaledFromCenter(double)
The box scaled from its center point.
public readonly box3d_t ScaledFromCenter(double s)
Parameters
sdoubleScale factor
Returns
- box3d_t
the scaled box
ToPresentDto()
Convert box3d_t to presentation DTO (Data Transfer Object) for JSON serialization. The returned object includes type metadata for web API presentation.
public readonly object ToPresentDto()
Returns
- object
DTO dictionary with Type, Min, Max keys
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
ToString(string, IFormatProvider)
Returns a string representation of the box formatted according to the specified format.
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format to use for each component
formatProviderIFormatProviderThe format provider to use
Returns
- string
A formatted string representation of the box
Translated(vec3d_t)
The box translated by vec.
public readonly box3d_t Translated(vec3d_t vec)
Parameters
vecvec3d_ttranslation vector
Returns
- box3d_t
the translated box
WriteBin(BinaryWriter)
Writes box data to a binary writer.
public readonly void WriteBin(BinaryWriter writer)
Parameters
writerBinaryWriterBinary writer to write the box data to
Operators
operator ==(box3d_t, box3d_t)
public static bool operator ==(box3d_t left, box3d_t right)
Parameters
Returns
operator !=(box3d_t, box3d_t)
public static bool operator !=(box3d_t left, box3d_t right)