CGAL error - the sequence matters

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

CGAL error - the sequence matters

Johan Jonker
Hello everyone,

As many of you I sometimes suffer from these difficult CGALL errors. I managed to deal with them this time and maybe it can help others to fix their problems.

It's a long time since I added something to this forum. So maybe this is old news. Sorry for that.


I designed an object that is in fact some kind of soprano saxophone.

The object the combination of
- a complex shaped body
- a serie of toneholes consisting of
 -- a deepened circular plane a bit larger that the tonehole diameter
 -- a raised conical edge around each tonehole
 -- the tonehole that is a circular hole in the body
- a serie of posts consisting of
 -- one ore two small pillars with one or two holes in the  

The first sequence I tried was:
1) make the body shape
2) use difference to make the deepened planes
3) add a raised plane
4) use difference to take out the toneholes
5) add solid posts
6) use difference to take out the holes from the posts
7) intersect with a cube of 20cm to divide it into 4 printable parts.

What I found out that the sequence
- difference/union/difference/union/difference/intersection
appears to be a very complex process and causes CGAL errors.

I changed the sequence

1a) make the body shape
1b) use difference to make the deepened planes
1c) use difference to take out the toneholes
1d) intersect with a cube of 20cm to divide it into 4 printable parts.

2) add the raised edges by first
2a) making the raised planes
2b) use difference to take out the toneholes
2c) intersect with a cube of 20cm to divide it into 4 printable parts.

3) add solid posts by
3a) create the posts
3b) use difference to take out the holes from the posts
3c) intersect with a cube of 20cm to divide it into 4 printable parts.

This appears to render without CGAL errors without any change in the shape.


Conclusion: It is better to use the multiple times the same difference/intersection function on a lower level of the shape than once on the end of a completed complex construction.
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

Ronaldo
That is weird because I think all boolean expressions are factored in a normalization form. And you would have the same normalized expression in both cases.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

Johan Jonker
Maybe. I will try to reproduce it with an example.

Op 26-6-2017 om 19:03 schreef Ronaldo [via OpenSCAD]:
That is weird because I think all boolean expressions are factored in a normalization form. And you would have the same normalized expression in both cases.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/CGAL-error-the-sequence-matters-tp21738p21758.html
To unsubscribe from CGAL error - the sequence matters, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

Ronaldo
I have built a simple code, based on your two strategies,  to test my assumption. 

module A() cube();
module B() cube();
module C() cube();
module D() cube();
module E() cube();
module F() cube();
module G() cube();

module initial()
intersection() {
    union() {
        difference() {
            union() {
                difference() { A(); B(); }
                C();
            }
            D();
        }
        difference() { E(); F(); }
    }
    G();
}

module modified() {
    intersection() {
        difference() { A(); B(); D(); }
        G();
    }
    intersection() {
        difference(){ C(); D(); }
        G();
    }
    intersection() {
        difference() { E(); F(); }
        G();
    }
}

initial();
//modified();

The modules A() to G() represent parts of your design (simplifyed here to be just a cube() ). The last two modules represent the two strategies for building the whole thing. If we preview this code and see the expression by Design/Display CSG Products.. we get:

previewing initial():

CSG before normalization:

(((((cube9 - cube11) + cube13) - cube15) + (cube18 - cube20)) * cube22)


CSG after normalization:

(((((cube9 * cube22) - cube11) - cube15) + ((cube13 * cube22) - cube15)) + ((cube18 * cube22) - cube20))


previewing modified() :


CSG before normalization:

(((((cube6 * cube12) - cube8) - cube10) + ((cube16 * cube20) - cube18)) + ((cube24 * cube28) - cube26))


CSG after normalization:

(((((cube6 * cube12) - cube8) - cube10) + ((cube16 * cube20) - cube18)) + ((cube24 * cube28) - cube26))


Note that in both cases the normalization leads to the same expression. Remains to know if CGAL is called with the normalized expression.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

MichaelAtOz
Administrator
Ronaldo wrote
Note that in both cases the normalization leads to the same expression.
Remains to know if CGAL is called with the normalized expression.
CGAL is not normalised.
OpenCSG preview is.
reference
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

Ronaldo
Well, that answers my question. Let us wait for the Johan's case study.

2017-06-26 17:29 GMT-03:00 MichaelAtOz <[hidden email]>:
CGAL is not normalised.
OpenCSG preview is.
reference
<https://github.com/openscad/openscad/pull/1980#issuecomment-296511710>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

Johan Jonker
I am a bit confused now. I tried all my earlier versions of wich I thought had the problem. They all render without problems. . So I cannot reproduce the problem to show the difference.

So maybe this post must be seen as some kind of false alarm. Maybe better to remove the whole topic to prevent more confusion?
Reply | Threaded
Open this post in threaded view
|

Re: CGAL error - the sequence matters

MichaelAtOz
Administrator
I think you can edit the post, 'More' drop down on the right.
So you can add an update there. Maybe good to have it for posterity.
If you really want the thread deleted let me know.
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!