Table of Contents

Struct box3d_t

Namespace
Hi.Geom
Assembly
HiGeom.dll

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

src IExpandToBox3d[]

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

src box3d_t

src

box3d_t(vec3d_t, vec3d_t)

Ctor.

public box3d_t(vec3d_t min, vec3d_t max)

Parameters

min vec3d_t

Min

max vec3d_t

Max

box3d_t(IEnumerable<IExpandToBox3d>)

Creates a box that encompasses all the provided expandable objects.

public box3d_t(IEnumerable<IExpandToBox3d> src)

Parameters

src IEnumerable<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

boxes IEnumerable<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

ps IEnumerable<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

minx double

Minimum X coordinate

miny double

Minimum Y coordinate

minz double

Minimum Z coordinate

maxx double

Maximum X coordinate

maxy double

Maximum Y coordinate

maxz double

Maximum Z coordinate

box3d_t(BinaryReader)

Creates a box from binary data.

public box3d_t(BinaryReader reader)

Parameters

reader BinaryReader

Binary reader to read the box data from

box3d_t(XElement)

Ctor.

public box3d_t(XElement src)

Parameters

src XElement

XML

Fields

Max

Maximum point of the box.

public vec3d_t Max

Field Value

vec3d_t

Min

Minimum point of the box.

public vec3d_t Min

Field Value

vec3d_t

Properties

BottomCenter

Center of the bottom surface.

public readonly vec3d_t BottomCenter { get; }

Property Value

vec3d_t

BottomView

Gets a transformation matrix for viewing the box from the bottom.

public readonly Mat4d BottomView { get; }

Property Value

Mat4d

Center

Center

public readonly vec3d_t Center { get; }

Property Value

vec3d_t

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

box3d_t

DiagonalLength

Diagonal length.

public readonly double DiagonalLength { get; }

Property Value

double

Dim

Dimension.

public readonly vec3d_t Dim { get; }

Property Value

vec3d_t

FrontView

Gets a transformation matrix for viewing the box from the front.

public readonly Mat4d FrontView { get; }

Property Value

Mat4d

HasVolume

Checks if the box has a positive volume (all dimensions are greater than zero).

public readonly bool HasVolume { get; }

Property Value

bool

InfiniteBox

Generate a infinite box which min~max is (-∞,-∞,-∞)~(∞,∞,∞).

public static box3d_t InfiniteBox { get; }

Property Value

box3d_t

IsAllNaN

True if all components of Min and Max are NaN.

public readonly bool IsAllNaN { get; }

Property Value

bool

IsFinite

True if the box is finite.

public readonly bool IsFinite { get; }

Property Value

bool

IsReversedPoleBox

True if the box is ReversedPoleBox

public readonly bool IsReversedPoleBox { get; }

Property Value

bool

IsometricView

Gets a transformation matrix for viewing the box from an isometric perspective.

public readonly Mat4d IsometricView { get; }

Property Value

Mat4d

LeftSideView

Gets a transformation matrix for viewing the box from the left side.

public readonly Mat4d LeftSideView { get; }

Property Value

Mat4d

NaN

Generate a nan box which min~max is (nan,nan,nan)~(nan,nan,nan).

public static box3d_t NaN { get; }

Property Value

box3d_t

NativeByteSize

Byte size of the struct as core.dll sees it: sizeof(box3d_t), two vec3d_t.

public static int NativeByteSize { get; }

Property Value

int

RearView

Gets a transformation matrix for viewing the box from the rear.

public readonly Mat4d RearView { get; }

Property Value

Mat4d

ReversedPoleBox

Generate a reversed pole box which min~max is (∞,∞,∞)~(-∞,-∞,-∞).

public static box3d_t ReversedPoleBox { get; }

Property Value

box3d_t

RightSideView

Gets a transformation matrix for viewing the box from the right side.

public readonly Mat4d RightSideView { get; }

Property Value

Mat4d

TopCenter

Center of the top surface.

public readonly vec3d_t TopCenter { get; }

Property Value

vec3d_t

TopView

Gets a transformation matrix for viewing the box from the top.

public readonly Mat4d TopView { get; }

Property Value

Mat4d

UnitBox

Generate a unit box which min~max is (0,0,0)~(1,1,1).

public static box3d_t UnitBox { get; }

Property Value

box3d_t

Volume

Gets the volume of the box.

public readonly double Volume { get; }

Property Value

double

XName

Name for XML IO.

public static string XName { get; }

Property Value

string

ZeroBox

Generate a zero box which min~max is (0,0,0)~(0,0,0).

public static box3d_t ZeroBox { get; }

Property Value

box3d_t

Methods

ApexAt(int)

Get Apex at the box.

public readonly vec3d_t ApexAt(int index)

Parameters

index int

index 0~7. all of 8 apex.

Returns

vec3d_t

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

other box3d_t

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

dst box3d_t

Destination box, expanded in place

Expanded(box3d_t)

The box expanded to include another box.

public readonly box3d_t Expanded(box3d_t src)

Parameters

src box3d_t

The 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

p vec3d_t

Point 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

ps IEnumerable<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

mat Mat4d

matrix

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

dst ICollection<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

otherBox box3d_t

other 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

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if 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

iter int

iterator

Returns

vec3d_t

Minif iter is 0; otherwise, return Max

ReadBin(BinaryReader)

Reads a box written by WriteBin(BinaryWriter): min then max.

public static box3d_t ReadBin(BinaryReader reader)

Parameters

reader BinaryReader

Binary 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

factory XFactory

ScaledFromCenter(double)

The box scaled from its center point.

public readonly box3d_t ScaledFromCenter(double s)

Parameters

s double

Scale 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

format string

The format to use for each component

formatProvider IFormatProvider

The 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

vec vec3d_t

translation vector

Returns

box3d_t

the translated box

WriteBin(BinaryWriter)

Writes box data to a binary writer.

public readonly void WriteBin(BinaryWriter writer)

Parameters

writer BinaryWriter

Binary writer to write the box data to

Operators

operator ==(box3d_t, box3d_t)

public static bool operator ==(box3d_t left, box3d_t right)

Parameters

left box3d_t
right box3d_t

Returns

bool

operator !=(box3d_t, box3d_t)

public static bool operator !=(box3d_t left, box3d_t right)

Parameters

left box3d_t
right box3d_t

Returns

bool