Enum Subblocks

Source
pub enum Subblocks {
    Regular {
        count: [u32; 3],
        subblocks: Array<RegularSubblock>,
        mode: Option<SubblockMode>,
    },
    Freeform {
        subblocks: Array<FreeformSubblock>,
    },
}
Expand description

Stores sub-blocks of a block model.

Variants§

§

Regular

Divide each parent block into a regular grid of count cells. Sub-blocks each covers a non-overlapping cuboid subset of that grid.

Sub-blocks are described by the parents and corners arrays. Those arrays must be the same length and matching rows in each describe the same sub-block. Each row in parents is an IJK index on the block model grid. Each row of corners is $(i_{min}, j_{min}, k_{min}, i_{max}, j_{max}, k_{max})$, all integers, that refer to the vertices of the sub-block grid within the parent block. For example:

  • A block with minimum size in the corner of the parent block would be (0, 0, 0, 1, 1, 1).

  • If the subblock_count is (5, 5, 3) then a sub-block covering the whole parent would be (0, 0, 0, 5, 5, 3).

Sub-blocks must stay within their parent, must have a non-zero size in all directions, and should not overlap. Further restrictions can be applied by the mode field, see SubblockMode for details.

Example of regular sub-blocks

Fields

§count: [u32; 3]

The sub-block grid size.

Must be greater than zero in all directions. If mode is octree then these must also be powers of two but they don’t have to be equal.

§subblocks: Array<RegularSubblock>

Array with RegularSubblock type storing the sub-block parent indices and corners relative to the sub-block grid within the parent.

§mode: Option<SubblockMode>

If present this further restricts the sub-block layout.

§

Freeform

Divide each parent block into any number and arrangement of non-overlapping cuboid regions.

Sub-blocks are described by the parents and corners arrays. Each row in parents is an IJK index on the block model grid. Each row of corners is $(i_{min}, j_{min}, k_{min}, i_{max}, j_{max}, k_{max})$ in floating-point and relative to the parent block, running from 0.0 to 1.0 across the parent. For example:

  • A sub-block covering the whole parent will be (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) no matter the size of the parent.

  • A sub-block covering the bottom third of the parent block would be (0.0, 0.0, 0.0, 1.0, 1.0, 0.3333) and one covering the top two-thirds would be (0.0, 0.0, 0.3333, 1.0, 1.0, 1.0), again no matter the size of the parent.

Sub-blocks must stay within their parent, must have a non-zero size in all directions, and shouldn’t overlap.

Fields

§subblocks: Array<FreeformSubblock>

Array with FreeformSubblock type storing the sub-block parent indices and corners relative to the parent.

Implementations§

Source§

impl Subblocks

Source

pub fn len(&self) -> u64

The number of sub-blocks.

Source

pub fn is_empty(&self) -> bool

True if there are no sub-blocks.

Source

pub fn mode(&self) -> Option<SubblockMode>

Returns the optional sub-block mode.

Currently this will always be None for free-form sub-blocks.

Trait Implementations§

Source§

impl Clone for Subblocks

Source§

fn clone(&self) -> Subblocks

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Subblocks

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Subblocks

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for Subblocks

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Subblocks

Source§

fn eq(&self, other: &Subblocks) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Subblocks

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Subblocks

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,