Skip to content

Commit

Permalink
Merge pull request #200 from autotwin/removal
Browse files Browse the repository at this point in the history
default remove no voxels #199
  • Loading branch information
mrbuche authored Nov 12, 2024
2 parents 881abae + d66fb47 commit 1c9266d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum Commands {
#[arg(long, short = 'z', value_name = "NEL")]
nelz: Option<usize>,

/// Voxel IDs to remove from the mesh [default: 0]
/// Voxel IDs to remove from the mesh
#[arg(long, short, value_name = "ID")]
remove: Option<Vec<u8>>,

Expand Down
2 changes: 1 addition & 1 deletion src/voxel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Voxels {
fn filter_voxel_data(data: &VoxelData, remove: Option<Vec<u8>>) -> (VoxelDataSized<NSD>, Blocks) {
#[cfg(feature = "profile")]
let time = Instant::now();
let mut removed_data = remove.unwrap_or(vec![0]);
let mut removed_data = remove.unwrap_or_default();
removed_data.sort();
removed_data.dedup();
let filtered_voxel_data_combo: VoxelDataSized<4> = data
Expand Down
2 changes: 1 addition & 1 deletion src/voxel/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Voxels {
#[pymethods]
impl Voxels {
/// Converts the voxels type into a finite elements type.
#[pyo3(signature = (remove=[0].to_vec(), scale=[1.0, 1.0, 1.0], translate=[0.0, 0.0, 0.0]))]
#[pyo3(signature = (remove=[].to_vec(), scale=[1.0, 1.0, 1.0], translate=[0.0, 0.0, 0.0]))]
pub fn as_finite_elements(
&self,
remove: Option<Vec<u8>>,
Expand Down
2 changes: 1 addition & 1 deletion src/voxel/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const VOXELS_GOLD: [[usize; 3]; NUM_ELEMENTS] = [
#[test]
fn filter() {
let spn = Voxels::from_npy("tests/input/letter_f_3d.npy").unwrap();
let (filtered_voxel_data, element_blocks) = filter_voxel_data(spn.get_data(), None);
let (filtered_voxel_data, element_blocks) = filter_voxel_data(spn.get_data(), Some(vec![0]));
assert_eq!(element_blocks.len(), NUM_ELEMENTS);
BLOCKS_GOLD
.iter()
Expand Down
8 changes: 4 additions & 4 deletions tests/fem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn compare_files(
) {
let voxels = Voxels::from_spn(spn_path, nel).unwrap();
let fem = voxels
.into_finite_elements(None, &scale, &translate)
.into_finite_elements(Some(vec![0]), &scale, &translate)
.unwrap();
fem.write_inp(file_path).unwrap();
let mut gold = String::new();
Expand Down Expand Up @@ -73,7 +73,7 @@ mod read_inp {
fn letter_f_3d() {
let voxels = Voxels::from_spn("tests/input/letter_f_3d.spn", [4, 5, 3]).unwrap();
let fem = voxels
.into_finite_elements(None, &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.into_finite_elements(Some(vec![0]), &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.unwrap();
fem.write_inp("target/letter_f_3d.inp").unwrap();
let read = FiniteElements::from_inp("target/letter_f_3d.inp").unwrap();
Expand Down Expand Up @@ -119,7 +119,7 @@ mod write_mesh {
fn letter_f_3d() {
let voxels = Voxels::from_spn("tests/input/letter_f_3d.spn", [4, 5, 3]).unwrap();
let fem = voxels
.into_finite_elements(None, &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.into_finite_elements(Some(vec![0]), &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.unwrap();
fem.write_mesh("target/letter_f_3d.mesh").unwrap();
}
Expand All @@ -131,7 +131,7 @@ mod write_vtk {
fn letter_f_3d() {
let voxels = Voxels::from_spn("tests/input/letter_f_3d.spn", [4, 5, 3]).unwrap();
let fem = voxels
.into_finite_elements(None, &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.into_finite_elements(Some(vec![0]), &[1.0, 1.0, 1.0], &[0.0, 0.0, 0.0])
.unwrap();
fem.write_vtk("target/letter_f_3d.vtk").unwrap();
}
Expand Down

0 comments on commit 1c9266d

Please sign in to comment.