[−][src]Enum density_mesh_core::generator::DensityMeshGenerator
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.
Variants
Fields of FindingPoints
Fields of Triangulate
Fields of Completed
mesh: DensityMeshprogress_limit: usizeImplementations
impl DensityMeshGenerator[src]
pub fn new(
points: Vec<Coord>,
map: DensityMap,
settings: GenerateDensityMeshSettings
) -> Self[src]
points: Vec<Coord>,
map: DensityMap,
settings: GenerateDensityMeshSettings
) -> Self
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]
pub fn is_done(&self) -> bool[src]
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::prelude::*; let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap(); let settings = GenerateDensityMeshSettings { points_separation: 0.5.into(), 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. This function consumes generator!
Returns
Self if ok or mesh generation error.
Examples
use density_mesh_core::prelude::*; let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap(); let settings = GenerateDensityMeshSettings { points_separation: 0.5.into(), 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, } }
pub fn process_wait(self) -> Result<DensityMesh, GenerateDensityMeshError>[src]
Process mesh generation until it returns either mesh or error. This function consumes generator!
Returns
Density mesh or mesh generation error.
Examples
use density_mesh_core::prelude::*; let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap(); let settings = GenerateDensityMeshSettings { points_separation: 0.5.into(), visibility_threshold: 0.0, steepness_threshold: 0.0, ..Default::default() }; assert_eq!( DensityMeshGenerator::new(vec![], map, settings).process_wait(), Ok(DensityMesh { points: vec![ Coord { x: 0.0, y: 1.0 }, Coord { x: 0.0, y: 0.0 }, Coord { x: 1.0, y: 1.0 }, Coord { x: 1.0, y: 0.0 }, ], triangles: vec![ Triangle { a: 0, b: 2, c: 1 }, Triangle { a: 2, b: 3, c: 1 }, ], }), );
pub fn process_wait_tracked<F>(
self,
f: F
) -> Result<DensityMesh, GenerateDensityMeshError> where
F: FnMut(usize, usize, Scalar), [src]
self,
f: F
) -> Result<DensityMesh, GenerateDensityMeshError> where
F: FnMut(usize, usize, Scalar),
Process mesh generation with callback that gets called on progress update until it returns either mesh or error. This function consumes generator!
Arguments
f- Callback with progress arguments:(current, limit, percentage).
Returns
Density mesh or mesh generation error.
Examples
use density_mesh_core::prelude::*; let map = DensityMap::new(2, 2, 1, vec![1, 2, 3, 1]).unwrap(); let settings = GenerateDensityMeshSettings { points_separation: 0.5.into(), visibility_threshold: 0.0, steepness_threshold: 0.0, ..Default::default() }; assert_eq!( DensityMeshGenerator::new(vec![], map, settings) .process_wait_tracked(|c, l, p| println!("Progress: {}% ({} / {})", p * 100.0, c, l)), Ok(DensityMesh { points: vec![ Coord { x: 0.0, y: 1.0 }, Coord { x: 0.0, y: 0.0 }, Coord { x: 1.0, y: 1.0 }, Coord { x: 1.0, y: 0.0 }, ], triangles: vec![ Triangle { a: 0, b: 2, c: 1 }, Triangle { a: 2, b: 3, c: 1 }, ], }), );
Trait Implementations
impl Clone for DensityMeshGenerator[src]
fn clone(&self) -> DensityMeshGenerator[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for DensityMeshGenerator[src]
impl Default for DensityMeshGenerator[src]
impl<'de> Deserialize<'de> for DensityMeshGenerator[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<DensityMeshGenerator> for DensityMeshGenerator[src]
fn eq(&self, other: &DensityMeshGenerator) -> bool[src]
fn ne(&self, other: &DensityMeshGenerator) -> bool[src]
impl Serialize for DensityMeshGenerator[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for DensityMeshGenerator[src]
Auto Trait Implementations
impl RefUnwindSafe for DensityMeshGenerator
impl Send for DensityMeshGenerator
impl Sync for DensityMeshGenerator
impl Unpin for DensityMeshGenerator
impl UnwindSafe for DensityMeshGenerator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,