-
Notifications
You must be signed in to change notification settings - Fork 56
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
120GB Adjacency Matrix when running PolygonMesh::put_together_same_attrs
#89
Comments
oh and here's my code (using master branch) use std::error::Error;
use truck_meshalgo::prelude::*;
use truck_stepio::r#in::*;
use truck_topology::compress::*;
pub fn main() -> Result<(), Box<dyn Error>> {
let file = std::fs::read_to_string("test.step")?;
let mut polymesh = PolygonMesh::default();
let table = Table::from_step(&file).expect("shit");
for shell in table.shell.values() {
println!("First Pass");
let shell = table.to_compressed_shell(shell)?;
let mut poly = shell.robust_triangulation(0.01).to_polygon();
println!("Optimize");
poly.put_together_same_attrs(TOLERANCE * 50.0)
.remove_degenerate_faces()
.remove_unused_attrs();
polymesh.merge(poly);
}
obj::write(&polymesh, std::fs::File::create("test.obj")?)?;
Ok(())
} |
Looking at the code responsible only confuses me. What unit of measurement is 'tolerance' in? What is the purpose of culling the UV and Normal attribute streams as well? |
Thank you for your comment. I cannot say for sure because I do not know the error message, but I think there are NAN values in some normals because some degenerate surfaces are included in the STEP file. For example, try adding a process to remove NANs as follows. use std::error::Error;
use truck_meshalgo::prelude::*;
use truck_stepio::r#in::*;
// ---- added
fn nan2zero(x: &mut f64) {
if x.is_nan() {
*x = 0.0;
}
}
// ----
pub fn main() -> Result<(), Box<dyn Error>> {
let file = std::fs::read_to_string("test.step")?;
let mut polymesh = PolygonMesh::default();
let table = Table::from_step(&file).expect("shit");
for shell in table.shell.values() {
println!("First Pass");
let shell = table.to_compressed_shell(shell)?;
let mut poly = shell.robust_triangulation(0.01).to_polygon();
// ---- added
poly.normals_mut().iter_mut().for_each(|n| {
nan2zero(&mut n.x);
nan2zero(&mut n.y);
nan2zero(&mut n.z);
});
// ----
println!("Optimize");
poly.put_together_same_attrs(TOLERANCE * 50.0)
.remove_degenerate_faces()
.remove_unused_attrs();
polymesh.merge(poly);
}
obj::write(&polymesh, std::fs::File::create("test.obj")?)?;
Ok(())
} |
Unfortunately still does the memory thing :( |
it literally crashes my computer all i want is a triangle mesh lol.
Jokes aside, I'm getting this issue when I'm optimizing the triangulization of a step file with 176241 IDs, or 121361 verts (i think). This specifically only happens with the final attribute set of the Normals.
Github won't let me upload the .obj file of the mesh before the optim step, so i'll figure out how to get that here.
The text was updated successfully, but these errors were encountered: