use remesh::prelude::*;
#[test]
fn test_f64_collapse_2() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.5, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 0.5],
];
let indices = vec![0, 1, 2, 1, 4, 2, 2, 3, 0, 1, 0, 4, 2, 4, 3, 0, 3, 4];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(0.7)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 5, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 18, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_1() -> Result<(), RemeshError> {
let vertices = vec![
[-0.84472865, -0.5237583, -0.48401418],
[-0.84472865, -0.5237583, 0.51598585],
[-0.84472865, -0.023758292, -0.48401418],
[0.15527135, -0.5237583, -0.48401418],
[-0.34472865, -0.5237583, 0.015985817],
[-0.84472865, -0.2737583, 0.015985817],
[-0.34472865, -0.2737583, -0.48401418],
[-0.84472865, -0.5237583, 0.015985817],
];
let indices = vec![
0, 7, 5, 1, 4, 5, 2, 6, 0, 7, 0, 4, 2, 4, 6, 0, 3, 4, 0, 5, 2, 4, 2, 5, 0, 6, 3, 4, 3, 6,
5, 7, 1, 4, 1, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(0.5)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_2() -> Result<(), RemeshError> {
let vertices = vec![
[-0.84472865, -0.5237583, -0.48401418],
[-0.84472865, -0.5237583, 0.51598585],
[-0.84472865, -0.023758292, -0.48401418],
[0.15527135, -0.5237583, -0.48401418],
[-0.34472865, -0.5237583, 0.015985817],
[-0.84472865, -0.2737583, 0.015985817],
[-0.34472865, -0.2737583, -0.48401418],
[-0.84472865, -0.5237583, 0.015985817],
];
let indices = vec![
0, 7, 5, 1, 4, 5, 2, 6, 0, 7, 0, 4, 2, 4, 6, 0, 3, 4, 0, 5, 2, 4, 2, 5, 0, 6, 3, 4, 3, 6,
5, 7, 1, 4, 1, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(1.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_3() -> Result<(), RemeshError> {
let vertices = vec![
[-1.3545021, -1.0532312, -0.2397142],
[-1.3545021, -1.0532312, 0.7602858],
[-1.3545021, -0.55323124, -0.2397142],
[-0.35450208, -1.0532312, -0.2397142],
[-0.8545021, -1.0532312, 0.2602858],
[-1.3545021, -0.80323124, 0.2602858],
[-0.8545021, -0.80323124, -0.2397142],
[-1.3545021, -1.0532312, 0.2602858],
[-0.8545021, -1.0532312, -0.2397142],
[-1.1045021, -0.80323124, 0.010285795],
];
let indices = vec![
0, 7, 5, 1, 4, 5, 2, 6, 0, 7, 0, 4, 2, 9, 6, 0, 8, 4, 0, 5, 2, 9, 2, 5, 0, 6, 8, 4, 3, 6,
5, 7, 1, 4, 1, 7, 4, 8, 3, 6, 3, 8, 6, 9, 4, 5, 4, 9,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(1.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(2)?;
assert_eq!(result_vertices.len(), 5, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 18, "result_indices.len() mismatch");
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(1.1)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(2)?;
assert_eq!(result_vertices.len(), 4, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 12, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_4() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.5, 0.0, 0.0],
];
let indices = vec![
0, 5, 3, 5, 0, 2, 3, 2, 4, 0, 6, 2, 0, 4, 6, 2, 1, 4, 2, 6, 1, 4, 1, 6, 3, 5, 2, 4, 0, 3,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_5() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.5, 0.0, 0.0],
[0.0, 0.5, 0.5],
[0.5, 0.5, 0.5],
[0.25, 0.5, 1.0],
[0.0, 0.5, 1.0],
];
let indices = vec![
7, 5, 10, 0, 2, 5, 3, 9, 8, 1, 8, 2, 6, 2, 0, 10, 5, 9, 7, 4, 0, 3, 4, 7, 8, 4, 3, 2, 6, 1,
8, 9, 2, 5, 2, 9, 6, 4, 1, 7, 10, 3, 9, 3, 10, 6, 0, 4, 7, 0, 5, 1, 4, 8,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 7, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 30, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_6() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.5, 0.5],
[0.5, 0.5, 0.5],
];
let indices = vec![
0, 2, 5, 1, 7, 2, 6, 4, 0, 3, 4, 6, 7, 4, 3, 2, 0, 1, 7, 3, 2, 5, 2, 3, 0, 4, 1, 6, 5, 3,
6, 0, 5, 1, 4, 7,
];
let (result_vertices, result_indices) =
IsotropicRemesh::<f64, _, false>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_7() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.5, 0.5],
[0.5, 0.5, 0.5],
[0.25, 0.5, 0.0],
[0.25, 0.5, 1.0],
[0.75, 0.5, 0.0],
];
let indices = vec![
6, 4, 8, 9, 7, 3, 8, 4, 10, 1, 7, 2, 4, 6, 3, 3, 7, 4, 10, 4, 7, 1, 2, 5, 6, 8, 0, 7, 9, 2,
5, 2, 9, 8, 10, 1, 7, 1, 10, 6, 0, 5, 5, 0, 1, 8, 1, 0, 9, 3, 5, 6, 5, 3,
];
let (result_vertices, result_indices) =
IsotropicRemesh::<f64, _, false>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 7, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 30, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_8_n() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.5, 0.0, 0.0],
];
let indices = vec![
0, 5, 3, 5, 0, 2, 3, 2, 4, 0, 6, 2, 0, 4, 6, 2, 1, 4, 2, 6, 1, 4, 1, 6, 3, 5, 2, 4, 0, 3,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(10)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_9_n() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.5, 0.0, 0.0],
[0.0, 0.5, 0.5],
];
let indices = vec![
5, 7, 0, 5, 0, 2, 3, 2, 4, 0, 6, 2, 0, 4, 6, 2, 1, 4, 2, 6, 1, 4, 1, 6, 3, 5, 2, 3, 7, 5,
3, 4, 7, 4, 0, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(10)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_10_n() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 0.35355338, 0.35355338],
];
let indices = vec![1, 0, 3, 1, 2, 4, 3, 0, 2, 3, 2, 1, 0, 1, 4, 2, 0, 4];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 4, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 12, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_11_n() -> Result<(), RemeshError> {
let vertices = vec![
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.5, 0.0, 1.0],
[0.0, 1.0, 1.0],
[0.5, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.5, 0.5],
[0.5, 0.5, 0.5],
[0.25, 0.5, 0.0],
[0.25, 0.5, 1.0],
[0.75, 0.5, 0.0],
];
let indices = vec![
6, 4, 8, 9, 7, 3, 8, 4, 10, 1, 7, 2, 4, 6, 3, 3, 7, 4, 10, 4, 7, 1, 2, 5, 6, 8, 0, 7, 9, 2,
5, 2, 9, 8, 10, 1, 7, 1, 10, 6, 0, 5, 5, 0, 1, 8, 1, 0, 9, 3, 5, 6, 5, 3,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f64, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(1)?;
assert_eq!(result_vertices.len(), 7, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 30, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_12_n() -> Result<(), RemeshError> {
let vertices = vec![
[-1.3919225, 0.79981124, -0.2719897],
[-1.3919225, -0.38369077, 1.2062045],
[1.3399366, 0.79981124, -0.2719897],
[-1.3919225, 0.29927406, 0.4109751],
[-1.3919225, -1.1789197, 1.3684515], [1.3399366, 0.29927406, 0.4109751],
[-0.025992602, 0.79981124, -0.2719897],
[1.3399366, 0.8357471, -1.1677188],
[-0.025992602, 0.29927406, 0.4109751],
[-0.025992602, 0.8357471, -1.1677188],
[1.3399366, -0.38369077, 1.2062045],
[1.3399366, -1.1789197, 1.3684515],
[-0.025992602, -0.38369077, 1.2062045],
[-0.025992602, -1.1789197, 1.3684515],
[-1.3919225, 0.8357471, -1.1677188],
];
let indices = vec![
9, 11, 13, 0, 3, 8, 0, 8, 6, 6, 8, 5, 6, 5, 2, 8, 3, 1, 8, 1, 12, 1, 4, 13, 1, 13, 12, 5,
8, 12, 5, 12, 10, 12, 13, 11, 12, 11, 10, 5, 11, 7, 7, 2, 5, 5, 10, 11, 14, 4, 3, 4, 1, 3,
13, 4, 14, 13, 14, 9, 9, 14, 0, 9, 0, 6, 7, 9, 6, 7, 6, 2, 9, 7, 11, 3, 0, 14,
];
let (result_vertices, result_indices) =
IsotropicRemesh::<f32, _, false>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(3)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_13_n() -> Result<(), RemeshError> {
let vertices = vec![
[-1.3919225, 0.79981124, -0.2719897],
[-1.3919225, -0.38369077, 1.2062045],
[1.3399366, 0.79981124, -0.2719897],
[-1.3919225, -1.1789197, 1.3684515],
[1.3399366, 0.29927406, 0.4109751],
[-0.025992602, 0.79981124, -0.2719897],
[1.3399366, 0.8357471, -1.1677188],
[1.3399366, -0.38369077, 1.2062045],
[1.3399366, -1.1789197, 1.3684515],
[-1.3919225, 0.8357471, -1.1677188],
];
let indices = vec![
5, 4, 2, 5, 0, 1, 1, 3, 8, 4, 5, 1, 4, 1, 7, 1, 8, 7, 4, 8, 6, 6, 2, 4, 4, 7, 8, 9, 3, 0,
3, 1, 0, 8, 3, 9, 8, 9, 6, 6, 9, 0, 6, 0, 5, 6, 5, 2,
];
let (result_vertices, result_indices) =
IsotropicRemesh::<f32, _, false>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.without_flip_edges()?
.run(3)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_14_n() -> Result<(), RemeshError> {
let vertices = vec![
[-1.0, -1.0, -1.0],
[-1.0, -1.0, 1.0],
[-1.0, 1.0, -1.0],
[-1.0, 1.0, 1.0],
[1.0, -1.0, -1.0],
[1.0, -1.0, 1.0],
[1.0, 1.0, -1.0],
[1.0, 1.0, 1.0],
[0.0, 0.0, 1.0],
];
let indices = vec![
1, 3, 0, 4, 6, 5, 1, 5, 8, 6, 2, 7, 2, 0, 3, 6, 4, 2, 8, 5, 7, 3, 7, 2, 7, 5, 6, 0, 4, 1,
5, 1, 4, 8, 7, 3, 3, 1, 8, 0, 2, 4,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(2)?;
assert_eq!(result_vertices.len(), 9, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 42, "result_indices.len() mismatch");
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.1)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(2)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_15_n() -> Result<(), RemeshError> {
let vertices = vec![
[-0.031503566, 0.015962794, 0.02158191],
[0.020436637, -0.024037197, -0.010061838],
[-0.06047619, -0.0040372014, -0.010061838],
[-0.021503575, 0.015962794, 0.028910778],
[-0.043147333, -0.024037197, 0.01158192],
[-0.06047619, -0.0440372, -0.010061838],
[-0.053147323, -0.024037197, -6.184727e-5],
[-0.031503566, -0.0440372, 0.02158191],
[-0.043147333, -0.0440372, 0.01158192],
[-0.021503575, -0.0040372014, 0.028910778],
[0.020436637, 0.015962794, -0.010061838],
[-0.031503566, -0.024037197, 0.02158191],
[-0.043147333, 0.015962794, 0.01158192],
[-0.06047619, 0.015962794, -0.010061838],
[-0.031503566, -0.0040372014, 0.02158191],
[-0.06047619, -0.024037197, -0.010061838],
[-0.021503575, -0.024037197, 0.028910778],
[-0.043147333, -0.0040372014, 0.01158192],
[-0.021503575, -0.0440372, 0.028910778],
[-0.053147323, -0.0440372, -6.184727e-5],
[-0.053147323, 0.015962794, -6.184727e-5],
[-0.053147323, -0.0040372014, -6.184727e-5],
];
let indices = vec![
20, 12, 0, 19, 5, 1, 13, 10, 1, 1, 5, 15, 2, 13, 1, 15, 2, 1, 15, 5, 19, 15, 19, 6, 2, 15,
6, 2, 6, 21, 13, 2, 21, 13, 21, 20, 0, 3, 10, 1, 18, 7, 8, 6, 19, 8, 4, 6, 4, 8, 7, 4, 7,
11, 4, 21, 6, 4, 17, 21, 17, 4, 11, 17, 11, 14, 17, 20, 21, 17, 12, 20, 12, 17, 14, 12, 14,
0, 7, 8, 1, 18, 11, 7, 18, 16, 11, 16, 14, 11, 16, 9, 14, 9, 0, 14, 9, 3, 0, 8, 19, 1, 1,
10, 9, 10, 3, 9, 1, 9, 16, 1, 16, 18, 13, 20, 10, 20, 0, 10,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(10.0)?
.run(9)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_16_n() -> Result<(), RemeshError> {
let vertices = vec![
[-1.0, -1.0, -1.0],
[-1.0, -1.0, 1.0],
[-1.0, 1.0, -1.0],
[-1.0, 1.0, 1.0],
[1.0, -1.0, -1.0],
[1.0, -1.0, 1.0],
[1.0, 1.0, -1.0],
[1.0, 1.0, 1.0],
[0.3, 0.3, 1.0],
];
let indices = vec![
1, 2, 0, 3, 6, 2, 7, 4, 6, 5, 0, 4, 6, 0, 2, 1, 3, 2, 3, 7, 6, 7, 5, 4, 5, 1, 0, 6, 4, 0,
3, 1, 5, 3, 5, 8, 5, 7, 8, 7, 3, 8,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(9)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_17_n() -> Result<(), RemeshError> {
let vertices = vec![
[-1.0, -1.0, -1.0],
[-1.0, -1.0, 1.0],
[-1.0, 1.0, -1.0],
[-1.0, 1.0, 1.0],
[1.0, -1.0, -1.0],
[1.0, -1.0, 1.0],
[1.0, 1.0, -1.0],
[1.0, 1.0, 1.0],
[-1.0, -0.3, -0.3],
[-0.3, 1.0, -0.3],
[1.0, 0.3, -0.3],
[0.3, -1.0, -0.3],
[-0.3, 0.3, -1.0],
[-1.0, 0.3, 0.3],
[0.3, 1.0, 0.3],
[1.0, -0.3, 0.3],
[-0.3, -1.0, 0.3],
[0.3, -0.3, -1.0],
[-0.3, -0.3, 1.0],
[0.3, 0.3, 1.0],
];
let indices = vec![
3, 6, 9, 7, 4, 10, 5, 0, 11, 6, 0, 12, 1, 3, 13, 3, 7, 14, 7, 5, 15, 5, 1, 16, 6, 4, 17, 3,
1, 18, 7, 3, 19, 1, 2, 8, 2, 0, 8, 0, 1, 8, 6, 2, 9, 2, 3, 9, 4, 6, 10, 6, 7, 10, 0, 4, 11,
4, 5, 11, 0, 2, 12, 2, 6, 12, 3, 2, 13, 2, 1, 13, 7, 6, 14, 6, 3, 14, 5, 4, 15, 4, 7, 15,
1, 0, 16, 0, 5, 16, 4, 0, 17, 0, 6, 17, 1, 5, 18, 5, 3, 18, 3, 5, 19, 5, 7, 19,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.run(10)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_18_n() -> Result<(), RemeshError> {
let vertices = vec![
[-0.48333335, -0.48333335, -0.44444448],
[-0.48333335, -0.48333335, 0.5555556],
[-0.48333335, 0.51666665, -0.44444448],
[-0.48333335, 0.51666665, 0.5555556],
[0.51666665, -0.48333335, -0.44444448],
[0.51666665, -0.48333335, 0.5555556],
[0.51666665, 0.51666665, -0.44444448],
[0.51666665, 0.51666665, 0.5555556],
[-0.44329354, 0.04258569, 0.090636715],
];
let indices = vec![
0, 1, 8, 3, 1, 5, 8, 1, 3, 2, 7, 6, 6, 5, 4, 4, 1, 0, 2, 4, 0, 6, 7, 5, 2, 6, 4, 8, 2, 0,
8, 3, 2, 4, 5, 1, 3, 5, 7, 2, 3, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(6.0)?
.run(2)?;
assert_eq!(result_vertices.len(), 9, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 42, "result_indices.len() mismatch");
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(7.0)?
.run(2)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_threshold(std::f32::consts::FRAC_1_SQRT_2)?
.run(2)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_19_n() -> Result<(), RemeshError> {
let vertices = vec![
[-0.5, -0.5, -0.5],
[-0.5, -0.5, 0.5],
[-0.5, 0.5, -0.5],
[-0.5, 0.5, 0.5],
[0.5, -0.5, -0.5],
[0.5, -0.5, 0.5],
[0.5, 0.5, -0.5],
[0.5, 0.5, 0.5],
];
let indices = vec![
0, 1, 3, 3, 1, 5, 2, 7, 6, 6, 5, 4, 4, 1, 0, 2, 4, 0, 6, 7, 5, 2, 6, 4, 3, 2, 0, 4, 5, 1,
3, 5, 7, 2, 3, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(45.1)?
.run(10)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_20_n() -> Result<(), RemeshError> {
let vertices = vec![
[-0.5, -0.5, -0.5],
[-0.5, -0.5, 0.5],
[-0.5, 0.5, -0.5],
[-0.5, 0.5, 0.5],
[0.5, -0.5, -0.5],
[0.5, -0.5, 0.5],
[0.5, 0.5, -0.5],
[0.5, 0.5, 0.5],
[-0.5, 0.5, 0.0],
[0.0, 0.5, 0.5],
[-0.5, -0.5, 0.0],
];
let indices = vec![
10, 2, 0, 10, 4, 5, 9, 5, 7, 2, 6, 0, 9, 3, 1, 8, 3, 9, 7, 4, 6, 6, 9, 7, 7, 5, 4, 5, 9, 1,
6, 4, 0, 9, 6, 8, 8, 6, 2, 8, 1, 3, 8, 10, 1, 4, 10, 0, 10, 5, 1, 10, 8, 2,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(10.0)?
.run(10)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_ce_21() -> Result<(), RemeshError> {
let vertices = vec![
[-0.5, -0.5, -0.5],
[-0.5, -0.5, 0.5],
[-0.5, 0.5, -0.5],
[-0.5, 0.5, 0.5],
[0.5, -0.5, -0.5],
[0.5, -0.5, 0.5],
[0.5, 0.5, -0.5],
[0.5, 0.5, 0.5],
[0.0125, 0.0125, -0.5],
[-0.4329311, 0.04305224, 0.032716494],
[0.5, 0.0125, -0.0125],
[-0.0125, 0.5, -0.0125],
];
let indices = vec![
6, 8, 2, 1, 9, 0, 5, 7, 3, 6, 10, 4, 1, 0, 5, 7, 10, 6, 2, 11, 6, 11, 2, 3, 0, 4, 5, 3, 9,
1, 6, 4, 8, 5, 3, 1, 8, 0, 2, 8, 4, 0, 9, 2, 0, 9, 3, 2, 10, 5, 4, 10, 7, 5, 11, 7, 6, 11,
3, 7,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(2.0)?
.with_split_edges(SplitStrategy::Disabled)?
.with_default_collapse_multiplier()?
.without_smooth_weight()?
.with_flip_edges(FlipStrategy::Disabled)?
.with_coplanar_angle_threshold(11.0)?
.run(10)?;
assert_eq!(result_vertices.len(), 8, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 36, "result_indices.len() mismatch");
Ok(())
}
#[test]
fn test_qem_collapse_1() -> Result<(), RemeshError> {
let vertices = [
[-1.0, -1.0, -1.0],
[-1.0, -1.0, 1.0],
[-1.0, 1.0, -1.0],
[-1.0, 1.0, 1.0],
[1.0, -1.0, -1.0],
[1.0, -1.0, 1.0],
[1.0, 1.0, -1.0],
[1.0, 1.0, 1.0],
[0.29328793, 0.9999999, 0.33217692],
];
let indices = [
0, 1, 2, 2, 3, 6, 6, 7, 4, 4, 5, 0, 2, 6, 0, 2, 1, 3, 5, 4, 7, 1, 0, 5, 4, 0, 6, 7, 3, 1,
5, 7, 1, 7, 6, 8, 6, 3, 8, 3, 7, 8,
];
let (result_vertices, result_indices) = IsotropicRemesh::<f32, _>::new(&vertices, &indices)?
.with_target_edge_length(3.0)?
.with_collapse_edges(CollapseStrategy::Qem)?
.with_collapse_qem_threshold(0.5)?
.without_split_edges()?
.without_smooth_weight()?
.without_flip_edges()?
.run(1)?;
assert_eq!(result_vertices.len(), 6, "result_vertices.len() mismatch");
assert_eq!(result_indices.len(), 24, "result_indices.len() mismatch");
Ok(())
}