[][src]Enum density_mesh_core::DensityMeshGenerator

pub enum DensityMeshGenerator {
    Uninitialized,
    FindingPoints {
        settings: GenerateDensityMeshSettings,
        map: DensityMap,
        tries: usize,
        remaining: Vec<(Coord, Scalar, Scalar)>,
        points: Vec<Coord>,
        progress_current: usize,
        progress_limit: usize,
    },
    Triangulate {
        settings: GenerateDensityMeshSettings,
        map: DensityMap,
        points: Vec<Coord>,
        progress_limit: usize,
    },
    Extrude {
        points: Vec<Coord>,
        triangles: Vec<Triangle>,
        size: Scalar,
        progress_limit: usize,
    },
    BakeFinalMesh {
        points: Vec<Coord>,
        triangles: Vec<Triangle>,
        progress_limit: usize,
    },
    Completed {
        mesh: DensityMesh,
        progress_limit: usize,
    },
}

Density mesh generator state object. It allows you to process mesh generation in steps and track progress or cancel generation in the middle of the process.

Examples

use density_mesh_core::*;

let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap();
let settings = GenerateDensityMeshSettings {
    points_separation: 0.5,
    visibility_threshold: 0.0,
    steepness_threshold: 0.0,
    ..Default::default()
};
let mut generator = DensityMeshGenerator::new(vec![], map, settings);
loop {
    match generator.process().unwrap().get_mesh_or_self() {
        Ok(mesh) => {
            println!("{:#?}", mesh);
            return;
        },
        Err(gen) => generator = gen,
    }
}

Variants

Uninitialized
FindingPoints

Fields of FindingPoints

settings: GenerateDensityMeshSettingsmap: DensityMaptries: usizeremaining: Vec<(Coord, Scalar, Scalar)>

[(coordinate, value, steepness)]

points: Vec<Coord>progress_current: usizeprogress_limit: usize
Triangulate

Fields of Triangulate

settings: GenerateDensityMeshSettingsmap: DensityMappoints: Vec<Coord>progress_limit: usize
Extrude

Fields of Extrude

points: Vec<Coord>triangles: Vec<Triangle>size: Scalarprogress_limit: usize
BakeFinalMesh

Fields of BakeFinalMesh

points: Vec<Coord>triangles: Vec<Triangle>progress_limit: usize
Completed

Fields of Completed

mesh: DensityMeshprogress_limit: usize

Implementations

impl DensityMeshGenerator[src]

pub fn new(
    points: Vec<Coord>,
    map: DensityMap,
    settings: GenerateDensityMeshSettings
) -> Self
[src]

Creates new generator instance. Check struct documentation for examples.

Arguments

  • points - List of initial points.
  • map - Density map.
  • settings - Density mesh generation settings.

Returns

New generator instance.

pub fn progress(&self) -> (usize, usize, Scalar)[src]

Get processing progress.

Returns

(current, limit, percentage)

pub fn is_done(&self) -> bool[src]

Check if mesh generation is done.

Returns

True if process is completed.

pub fn get_mesh_or_self(self) -> Result<DensityMesh, Self>[src]

Tries to get inner generated mesh when ready, otherwise gets itself. This function consumes generator!

Returns

Result with mesh (Ok) when completed, or self (Err) when still processing.

Examples

use density_mesh_core::*;

let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap();
let settings = GenerateDensityMeshSettings {
    points_separation: 0.5,
    visibility_threshold: 0.0,
    steepness_threshold: 0.0,
    ..Default::default()
};
let mut generator = DensityMeshGenerator::new(vec![], map, settings);
match generator.get_mesh_or_self() {
    Ok(mesh) => println!("{:#?}", mesh),
    Err(gen) => generator = gen,
}

pub fn process(self) -> Result<Self, GenerateDensityMeshError>[src]

Process mesh generation. Check struct documentation for examples. This function consumes generator!

Returns

Result with self when processing step was successful, or error.

Trait Implementations

impl Clone for DensityMeshGenerator[src]

impl Debug for DensityMeshGenerator[src]

impl Default for DensityMeshGenerator[src]

impl<'de> Deserialize<'de> for DensityMeshGenerator[src]

impl PartialEq<DensityMeshGenerator> for DensityMeshGenerator[src]

impl Serialize for DensityMeshGenerator[src]

impl StructuralPartialEq for DensityMeshGenerator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.