Struct CMapBuilder

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

§Combinatorial map builder structure

§Example

use honeycomb_core::cmap::{CMap2, CMap3, CMapBuilder};

let builder_2d = CMapBuilder::<2, _>::from_n_darts(10);
let map_2d: CMap2<f64> = builder_2d.build()?;
assert_eq!(map_2d.n_darts(), 11); // 10 + null dart = 11

let builder_3d = CMapBuilder::<3, _>::from_n_darts(10);
let map_3d: CMap3<f64> = builder_3d.build()?;
assert_eq!(map_3d.n_darts(), 11); // 10 + null dart = 11

Implementations§

Source§

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

§Regular methods

Source

pub fn from_n_darts(n_darts: usize) -> Self

Create a builder structure for a map with a set number of darts.

Source

pub fn from_grid_descriptor(grid_descriptor: GridDescriptor<D, T>) -> Self

Create a builder structure from a GridDescriptor.

Source

pub fn from_cmap_file(file_path: impl AsRef<Path> + Debug) -> Self

Create a builder structure from a cmap file.

§Panics

This function may panic if the file cannot be loaded, or basic section parsing fails.

Source

pub fn from_vtk_file(file_path: impl AsRef<Path> + Debug) -> Self

Create a builder structure from a VTK file.

§Panics

This function may panic if the file cannot be loaded.

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

pub fn build(self) -> Result<<Self as Builder>::MapType, BuilderError>
where Self: Builder,

Consumes the builder and produce a combinatorial map object.

§Return / Errors

This method return a Result taking the following values:

  • Ok(map: _) if generation was successful,
  • Err(BuilderError) otherwise. See BuilderError for possible failures.

Depending on the dimension D associated with this structure, the map will either be a CMap2 or CMap3. If D isn’t 2 or 3, this method will not be available as it uses a trait not implemented for other values of D. This is necessary to handle the multiple return types as Rust is slightly lacking in terms of comptime capabilities.

§Panics

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

Source§

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

§2D pre-definite structures

Source

pub fn unit_grid(n_square: usize) -> Self

Create a CMapBuilder with a predefinite GridDescriptor value.

§Arguments
  • n_square: usize – Number of cells along each axis.
§Return

This function return a builder structure with pre-definite parameters set to generate a specific map.

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) -> Self

Create a CMapBuilder with a predefinite GridDescriptor value.

§Arguments
  • n_square: usize – Number of cells along each axis.
§Return

This function return a builder structure with pre-definite parameters set to generate a specific map.

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

CMAP2_GRID

Source§

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

§3D pre-definite structures

Source

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

Create a CMapBuilder with a predefinite GridDescriptor value.

§Arguments
  • n_cells_per_axis: usize – Number of cells along each axis.
§Return

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

TODO: add a figure

Source

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

UNIMPLEMENTED

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<const D: usize, T> !UnwindSafe for CMapBuilder<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 + Sync + Send>

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 + Sync + Send>

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
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.