After the excellent addition to the Voxel Remeshing I've been trying to find a workflow to create clean 3D models for printing, which implies decimation too.
The current workflow uses a modified voxel_remeshing.rs example, which performs both the remeshing and the decimation at once.
use std::path::Path;
use baby_shark::{
io::stl::{StlReader, StlWriter},
mesh::polygon_soup::data_structure::PolygonSoup,
mesh::traits::Mesh,
algo::merge_points::merge_points,
remeshing::voxel::VoxelRemesher,
mesh::corner_table::prelude::CornerTableF,
decimation::{edge_decimation::ConstantErrorDecimationCriteria, prelude::EdgeDecimator},
};
fn main() {
type Mesh = PolygonSoup<f32>;
let mut reader = StlReader::new();
let mesh: Mesh = reader
.read_stl_from_file(Path::new("./assets/head.stl"))
.expect("Read mesh");
let mut remesher = VoxelRemesher::default().with_voxel_size(0.02);
let remeshed = remesher.remesh(&mesh).unwrap();
let faces = remeshed.vertices().map(|v| *remeshed.vertex_position(&v)).collect::<Vec<_>>();
let indexed_faces = merge_points(&faces);
let mut mesh = CornerTableF::from_vertices_and_indices(&indexed_faces.points, &indexed_faces.indices);
let decimation_criteria = ConstantErrorDecimationCriteria::new(0.1f32);
let mut decimator = EdgeDecimator::new().decimation_criteria(decimation_criteria);
decimator.decimate(&mut mesh);
StlWriter::new()
.write_stl_to_file(&mesh, Path::new("remeshed.stl"))
.expect("Write mesh");
}
The results of the remeshing show that there might be some artifacts causing noise on the surface. I performed some tests using a generic head model (included here
head.zip
) as follows:
Remeshing the head, then performing decimation with precision 0.01 and 0.1 (0.1 is more or less the desired polygons density) -> At 0.1 the artifacts create creases and bump on otherwise smooth surfaces.
Using the Blender remesh then performing the baby_shark decimation at 0.1 -> A similar result occurrs, suggesting that the voxel remeshing is now creating good meshes
Using the baby_shark remesh with a Blender decimation to 10% (it creates a similarly dense mesh) as a control, which is much cleaner at the moment.
Hopefully this could be a good benchmark and a goal for the remeshing process in baby_shark.
After the excellent addition to the Voxel Remeshing I've been trying to find a workflow to create clean 3D models for printing, which implies decimation too.
The current workflow uses a modified voxel_remeshing.rs example, which performs both the remeshing and the decimation at once.
The results of the remeshing show that there might be some artifacts causing noise on the surface. I performed some tests using a generic head model (included here head.zip ) as follows:
Hopefully this could be a good benchmark and a goal for the remeshing process in baby_shark.