Skip to content
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

rotate_extrude doesn't work with objects with 'holes' #112

Closed
donbright opened this issue May 11, 2012 · 2 comments
Closed

rotate_extrude doesn't work with objects with 'holes' #112

donbright opened this issue May 11, 2012 · 2 comments
Milestone

Comments

@donbright
Copy link
Sponsor Member

As discussed on the mailing list in May 2012 by David Goodenough, nop head, et al, the rotate_extrude code doesn't seem to work as one would obviously expect with 2d- objects that have 'holes' in them.

Minimal Example

module donut() {
rotate_extrude()
translate([5,0,0])
difference() {
circle(r=2);
circle(r=1);
}
}

difference()
{
donut();
cube([10,10,10]);
}

Expected Result:

A hollow torus in F5 + F6 modes

Actual Result;

A hollow torus in F5 mode
A solid torus in F6 mode

Possible starting point for solution:

hack into src/PolySetCGALEvaluator.cc and do some debugging of the DXF rotation code.


A speculative stab at a possible direction to go if trying to make a fix:

IMHO the issue may be in src/PolySetCGALEvaluator.cc

Right now we have this:

PolySet *PolySetCGALEvaluator::evaluatePolySet(const RotateExtrudeNode &node)
{
. . .
// Before extruding, union all (2D) children nodes
// to a single DxfData, then tesselate this into a PolySet
. . .
}

IE, it 'unions' everything, the holes with the bodies, and then passes it to the rotateDxfData() function.


From pure speculation it would appear that the solution is not so trivial. My first thought would be to try to 'split' the given 2d object into 'holes' and 'solids', and then rotate each of those separately. Then, your final CGAL output object would actually be a combination of 3d Nef Polyhedron objects.

For example, take your hollow donut problem. I think it might be possible to split the two circles into a 'body' circle and a 'hole' circle. This is actually possible using CGAL's 2d geometry code, you can do 'shell iteration' to separate out these components. And in theory, somehow these components can be kept track of in code.

Then, the 'body' circle gets rotated into a 3d CGAL Nef Polyhedron, namely a torus. Then the same is done for the 'hole' circle resulting in a second 3d Nef Poly torus. You then have two 3-dimensional shapes, a larger torus and a smaller torus, the latter inside of the former. The trick is that, since you have stored the 'relationship' between your components, you can then tell CGAL's 3d code to 'subtract' the 'hole' torus from the 'body' torus.


update --- this is basically a way to 'automate' the solution that nop head wrote about on the mailing list.

-DB

@kintel
Copy link
Member

kintel commented Feb 11, 2014

The OpenCSG part of this is fixed in unstable. The CGAL aspects look very similar to one of the cases mentioned in #495

@kintel kintel added the CGAL label Feb 11, 2014
@kintel kintel added this to the 2014 QX milestone Aug 18, 2014
@kintel
Copy link
Member

kintel commented Aug 18, 2014

This was fixed together with #495. Tests updated.

@kintel kintel closed this as completed Aug 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants