openscad/openscad — Issue #80: Abort from CGALEvaluator::evaluateCGALMesh::PolyReducer::add_edges
Author: caliston
Created: 2012-02-03 15:35:46+00:00
State: open

This:

projection(cut=true)
translate([0,0,193]) rotate([0,90,0])
translate([20,20,122.6])
translate([182,355.6,-9])
translate([63.5,278.8,0])
rotate([0,0,180]) {
translate([9,-90,1.61])
cube([63.5,198.8,40]);
}

causes git 'head' ( 7a4b75630f619dfd64618d3f1c24da859f9e4a13 ) to abort:

$ openscad -o /tmp/foo.dxf cgal-abort-t2.scad
CGAL Cache insert: cube(size=[63.5,198.8,40],center=false); (10872 bytes)
CGAL Cache insert: multmatrix([[1,0,0,9],[0,1,0,-90],[0,0,1 (10872 bytes)
CGAL Cache insert: multmatrix([[-1,-1.22461e-16,0,0],[1.224 (10872 bytes)
CGAL Cache insert: multmatrix([[1,0,0,63.5],[0,1,0,278.8],[ (10872 bytes)
CGAL Cache insert: multmatrix([[1,0,0,182],[0,1,0,355.6],[0 (10872 bytes)
CGAL Cache insert: multmatrix([[1,0,0,20],[0,1,0,20],[0,0,1 (10872 bytes)
CGAL Cache insert: multmatrix([[2.22045e-16,0,1,0],[0,1,0,0 (10872 bytes)
CGAL Cache hit: multmatrix([[2.22045e-16,0,1,0],[0,1,0,0 (10872 bytes)
CGAL Cache insert: multmatrix([[1,0,0,0],[0,1,0,0],[0,0,1,1 (10872 bytes)
Aborted

Running this in the debugger, it appears to be from CGALEvaluator::evaluateCGALMesh::PolyReducer::add_edges where there's (src/CGALEvaluator.cc line 454):
if (this->edge_to_poly[std::pair(a, b)].first == 0)
this->edge_to_poly[std::pair(a, b)].first = pn;
else if (this->edge_to_poly[std::pair(a, b)].second == 0)
this->edge_to_poly[std::pair(a, b)].second = pn;
else
abort();

I think it might be that the above random selection of translations (distilled down from a very much larger hierarchical model) so happens to have the top of the cube exactly co-incident with the X-Y plane and the projection is getting confused. But I might gently point out that randomly aborting with no explanation isn't the most user-friendly interface ever :)

Is there any way to get a 'backtrace' of errors - 'error with polygon from shape defined on line XXX' so you know which of your hundred objects, which each go through dozens of transformations, is the culprit?

On another point, I tried some of the alternative versions of that code in that function that are #if 0-ed out, but none of them now compile.