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>
impl<const D: usize, T: CoordsFloat> GridBuilder<D, T>
Sourcepub fn len_per_cell(self, len_per_cell: [T; D]) -> Self
pub fn len_per_cell(self, len_per_cell: [T; D]) -> Self
Set values for all dimensions
Sourcepub fn split_cells(self, split: bool) -> Self
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.
Sourcepub fn add_attribute<A: AttributeBind + 'static>(self) -> Self
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>
impl<T: CoordsFloat> GridBuilder<2, T>
Sourcepub fn unit_grid(n_cells_per_axis: usize) -> CMap2<T>
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:
Sourcepub fn unit_triangles(n_square: usize) -> CMap2<T>
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:
Sourcepub fn build(self) -> Result<CMap2<T>, GridBuilderError>
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. SeeGridBuilderErrorfor possible failures.
§Panics
This method may panic if type casting goes wrong during parameters parsing.
Source§impl<T: CoordsFloat> GridBuilder<3, T>
impl<T: CoordsFloat> GridBuilder<3, T>
Sourcepub fn hex_grid(n_cells_per_axis: usize, cell_length: T) -> CMap3<T>
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:
Sourcepub fn tet_grid(n_cells_per_axis: usize, cell_length: T) -> CMap3<T>
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:
Sourcepub fn build(self) -> Result<CMap3<T>, GridBuilderError>
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. SeeGridBuilderErrorfor possible failures.
§Panics
This method may panic if type casting goes wrong during parameters parsing.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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