honeycomb_core::cmap

Struct CMapBuilder

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

Combinatorial map builder structure.

§Example

use honeycomb_core::prelude::{CMap2, CMapBuilder};

let builder = CMapBuilder::default().n_darts(10);
let map: CMap2<f64> = builder.build()?;

assert_eq!(map.n_darts(), 11); // 10 + null dart = 11

Implementations§

Source§

impl<T: CoordsFloat> CMapBuilder<T>

Source

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

Available on crate feature utils only.

Set the GridDescriptor that will be used when building the map.

Source§

impl<T: CoordsFloat> CMapBuilder<T>

Source

pub fn unit_grid(n_square: usize) -> Self

Available on crate feature utils only.

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 predefinite parameters to generate a specific map.

The map generated by this predefinite 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

Available on crate feature utils only.

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 predefinite parameters to generate a specific map.

The map generated by this predefinite 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<T>

Source

pub fn vtk_file(self, file_path: impl AsRef<Path> + Debug) -> Self

Available on crate feature io only.

Import and set the VTK file that will be used when building the map.

§Panics

This function may panic if the file cannot be loaded.

Source§

impl<T: CoordsFloat> CMapBuilder<T>

Source

pub fn n_darts(self, n_darts: usize) -> Self

Set the number of dart that the created map will contain.

Source

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

Add the specified attribute that the created map will contain.

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> CMapBuilder<T>

Source

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

Consumes the builder and produce a CMap2 object.

§Return / Errors

This method return a Result taking the following values:

  • Ok(map: CMap2) – Map generation was successful.
  • Err(BuilderError) – There was an error during construction. See BuilderError for details.
§Panics

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

§Example

See CMapBuilder example.

Trait Implementations§

Source§

impl<T> Default for CMapBuilder<T>
where T: CoordsFloat + Default,

Source§

fn default() -> CMapBuilder<T>

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

impl<T: CoordsFloat> From<GridDescriptor<T>> for CMapBuilder<T>

Available on crate feature utils only.

Create a CMapBuilder from a GridDescriptor.

This implementation is roughly equivalent to the following:

// setup grid descriptor
let gridd = GridDescriptor::default();
// ...

// `CMapBuilder::from(gridd)`, or:
let builder = CMapBuilder::<f64>::default().grid_descriptor(gridd);
Source§

fn from(value: GridDescriptor<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: CoordsFloat, P: AsRef<Path> + Debug> From<P> for CMapBuilder<T>

Available on crate feature io only.

Create a CMapBuilder from an imported VTK file.

This implementation is roughly equivalent to the following:

// `CMapBuilder::from_vtk_file("some/path/to/file.vtk")`, or:
let builder = CMapBuilder::<f64>::default().vtk_file("some/path/to/file.vtk");

§Panics

This function may panic if the file cannot be loaded.

Source§

fn from(value: P) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for CMapBuilder<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for CMapBuilder<T>

§

impl<T> Send for CMapBuilder<T>

§

impl<T> Sync for CMapBuilder<T>

§

impl<T> Unpin for CMapBuilder<T>
where T: Unpin,

§

impl<T> !UnwindSafe for CMapBuilder<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>

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

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

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

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

Convert &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)

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

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

§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further 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, 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.