GridBuilder

Struct GridBuilder 

Source
pub struct GridBuilder<const D: usize, T: CoordsFloat> { /* private fields */ }
Expand description

§Grid builder structure

§Generics

  • const D: usize – Dimension of the grid. Should be 2 or 3.
  • T: CoordsFloat – Generic FP type that will be used by the map’s vertices.

§Example

use honeycomb_core::cmap::CMap3;
use honeycomb_kernels::grid_generation::{GridBuilder};

let map: CMap3<f64> = GridBuilder::<3, f64>::default()
    .n_cells([2, 3, 2])
    .len_per_cell([1.0; 3])
    .build()?;

Implementations§

Source§

impl<const D: usize, T: CoordsFloat> GridBuilder<D, T>

Source

pub fn n_cells(self, n_cells: [usize; D]) -> Self

Set values for all dimensions

Source

pub fn len_per_cell(self, len_per_cell: [T; D]) -> Self

Set values for all dimensions

Source

pub fn lens(self, lens: [T; D]) -> Self

Set values for all dimensions

Source

pub fn origin(self, origin: [T; D]) -> Self

Set origin (most bottom-left vertex) of the grid

Source

pub fn split_cells(self, split: bool) -> Self

Indicate whether to split cells of the grid

In 2D, this will result in triangular cells.

In 3D, this will result in tetrahedral cells.

Source

pub fn add_attribute<A: AttributeBind + 'static>(self) -> Self

Add the attribute A to the attributes the created map will contain.

§Usage

Each attribute must be uniquely typed, i.e. a single type or struct cannot be added twice to the builder / map. This includes type aliases as these are not distinct from the compiler’s perspective.

If you have multiple attributes that are represented using the same data type, you may want to look into the Newtype pattern here and here

Source§

impl<T: CoordsFloat> GridBuilder<2, T>

Source

pub fn unit_grid(n_cells_per_axis: usize) -> CMap2<T>

Create a combinatorial map representing a 2D orthogonal grid.

The map generated by this pre-definite value corresponds to an orthogonal mesh, with an equal number of cells along each axis:

CMAP2_GRID

Source

pub fn unit_triangles(n_square: usize) -> CMap2<T>

Create a combinatorial map representing a 2D orthogonal grid.

The map generated by this pre-definite value corresponds to an orthogonal mesh, with an equal number of cells along each axis. Each cell is split diagonally (top left to bottom right) to form triangles:

CMAP2_GRID

Source

pub fn build(self) -> Result<CMap2<T>, GridBuilderError>

Consumes the builder and produce a combinatorial map object.

This method is only available for D == 2 or D == 3.

§Return / Errors

This method return a Result taking the following values:

  • Ok(map: CMap2<T>) if generation was successful,
  • Err(GridBuilderError) otherwise. See GridBuilderError for possible failures.
§Panics

This method may panic if type casting goes wrong during parameters parsing.

Source§

impl<T: CoordsFloat> GridBuilder<3, T>

Source

pub fn hex_grid(n_cells_per_axis: usize, cell_length: T) -> CMap3<T>

Create a combinatorial map representing a 3D orthogonal grid.

The map generated by this pre-definite value corresponds to an orthogonal mesh, with an equal number of cells along each axis:

CMAP2_GRID

Source

pub fn tet_grid(n_cells_per_axis: usize, cell_length: T) -> CMap3<T>

Create a combinatorial map representing a 3D orthogonal grid.

The map generated by this pre-definite value corresponds to an orthogonal mesh, with an equal number of cells along each axis. each hexahedral cell is cut into 5 tetrahedra; this pattern is repeated with added symmetry to produce a conformal mesh:

CMAP2_GRID

Source

pub fn build(self) -> Result<CMap3<T>, GridBuilderError>

Consumes the builder and produce a combinatorial map object.

This method is only available for D == 2 or D == 3.

§Return / Errors

This method return a Result taking the following values:

  • Ok(map: CMap3<T>) if generation was successful,
  • Err(GridBuilderError) otherwise. See GridBuilderError for possible failures.
§Panics

This method may panic if type casting goes wrong during parameters parsing.

Trait Implementations§

Source§

impl<const D: usize, T: CoordsFloat> Default for GridBuilder<D, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const D: usize, T> Freeze for GridBuilder<D, T>
where T: Freeze,

§

impl<const D: usize, T> !RefUnwindSafe for GridBuilder<D, T>

§

impl<const D: usize, T> Send for GridBuilder<D, T>

§

impl<const D: usize, T> Sync for GridBuilder<D, T>

§

impl<const D: usize, T> Unpin for GridBuilder<D, T>
where T: Unpin,

§

impl<const D: usize, T> !UnwindSafe for GridBuilder<D, T>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.