Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reserve #52

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Stubs for the new decimater
  • Loading branch information
ranjeethmahankali committed Jan 27, 2025
commit 4610a2f7e4b15edb32e2f5dcffb2eb1dbd47ac07
51 changes: 51 additions & 0 deletions src/decimate/hausdorff.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use super::Decimater;
use crate::{Adaptor, Error, HasTopology, PolyMeshT, FH, HH, VH};

pub struct HausdorffDecimater<A>
where
A: Adaptor<3>,
{
ptbuf: Vec<A::Vector>,
fpoints: Vec<Vec<A::Vector>>,
max_tol: A::Scalar,
}

impl<A> HausdorffDecimater<A>
where
A: Adaptor<3>,
{
pub fn new(mesh: &PolyMeshT<3, A>, max_tol: A::Scalar) -> Self {
HausdorffDecimater {
ptbuf: Vec::with_capacity(mesh.num_vertices()),
fpoints: vec![Vec::new(); mesh.num_faces()],
max_tol,
}
}
}

impl<A> Decimater<PolyMeshT<3, A>> for HausdorffDecimater<A>
where
A: Adaptor<3>,
A::Scalar: PartialOrd,
{
type Cost = A::Scalar;

fn collapse_cost(&self, mesh: &PolyMeshT<3, A>, h: HH) -> Option<Self::Cost> {
todo!()
}

fn before_collapse(&mut self, mesh: &PolyMeshT<3, A>, h: HH) -> Result<(), Error> {
Ok(()) // Nothing to do.
}

fn after_collapse(&mut self, mesh: &PolyMeshT<3, A>, v: VH) -> Result<(), Error> {
todo!()
}
}

fn triangle_dist_sq<A>(p: &A::Vector, a: &A::Vector, b: &A::Vector, c: &A::Vector) -> A::Scalar
where
A: Adaptor<3>,
{
todo!("Implement point to triangle squared distance");
}
1 change: 1 addition & 0 deletions src/decimate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Out of the box, this module also provides the following implementations of
*/

pub mod edge_length;
pub mod hausdorff;
pub mod quadric;

use crate::Queue;
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ pub mod use_glam;
mod subdiv;

#[cfg(feature = "decimate")]
pub mod decimate;
mod decimate;

#[cfg(feature = "decimate")]
pub use decimate::{
edge_length::EdgeLengthDecimater, quadric::Quadric, quadric::QuadricDecimater,
quadric::QuadricType, Decimater, HasDecimation,
edge_length::EdgeLengthDecimater, hausdorff::HausdorffDecimater, quadric::Quadric,
quadric::QuadricDecimater, quadric::QuadricType, Decimater, HasDecimation,
};

pub use edit::EditableTopology;
Expand Down