i am crazy of openscad but openscad makes me crazy

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

i am crazy of openscad but openscad makes me crazy

steam30
This post has NOT been accepted by the mailing list yet.
This post was updated on .
hello guys,

version openscad 2015.03-2 / OS Windows 10 / OpenGl 4.4 (4.5 is not supported by my graphic card NVidia 840 M).

i am use Openscad with real pleasure from one year and i have a problem but i don't know if it is bug (it is more easy for my brain to think that !!!) or an error of a misunderstanding (probably )...

the common point at each time than this problem arrive, there is the Hull function and difference function.

an example of code with problem

prec=90;
difference() {
hull(){
translate ([-47,2,5])
         rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
translate ([47,2,5])
         rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
translate ([-52,2,22])
         rotate ([90,0,0]) cube ([10,10,2], center=false);
translate ([42,2,22])
         rotate ([90,0,0]) cube ([10,10,2], center=false);
}
// évidement
hull(){
translate ([-20,2,17])
         rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
translate ([20,2,17])
         rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
translate ([-25,2,22])
         rotate ([90,0,0]) cube ([10,10,2], center=false);
translate ([15,2,22])
         rotate ([90,0,0]) cube ([10,10,2], center=false);
}
}

and the rendering causes a small defect



as you see there is vertical part who don't exist. The result of rendering is for me is a piece in U form.

i have test on another computer on windows 10 but the result is the same. Grahic card is always a Nvidia (970).

at the start i have think that is a display problem  but when i export STL, the object had too this default.

STL result

If someone has the solution to this problem, I would be very grateful to him for his explanation

special thanks to the community and development team
Reply | Threaded
Open this post in threaded view
|

Re: i am crazy of openscad but openscad makes me crazy

MichaelAtOz
Administrator
The issue is related to, but not only, z-fighting.
With CSG, and a difference, or union, you cannot have two object sharing the same place/surface. The software doesn't know which should or shouldn't be subtracted or added.
So you need to, for difference - make the subtracted object extend a 'little' beyond the surface of the base object, for union - make the joined object embed a 'little' into the other object.
See the wiki.

And this change:

s=0.1;
s2=s*2;
prec=90;
difference() {
                hull(){
                        translate ([-47,2,5])
                                rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
                        translate ([47,2,5])
                                rotate ([90,0,0])  cylinder (2,r=5, $fn=prec);
                        translate ([-52,2,22])
                                rotate ([90,0,0]) cube ([10,10,2], center=false);
                        translate ([42,2,22])
                                rotate ([90,0,0]) cube ([10,10,2], center=false);
                }
                // évidement
                hull(){
                        translate ([-20,2+s,17])
                                rotate ([90,0,0])  cylinder (2+s2,r=5, $fn=prec);
                        translate ([20,2+s,17])
                                rotate ([90,0,0])  cylinder (2+s2,r=5, $fn=prec);
                        translate ([-25,2+s,22+s])
                                rotate ([90,0,0]) cube ([10,10,2+s2], center=false);
                        translate ([15,2+s,22+s])
                                rotate ([90,0,0]) cube ([10,10,2+s2], center=false);
}
}
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: i am crazy of openscad but openscad makes me crazy

MichaelAtOz
Administrator
In reply to this post by steam30
BTW, your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look.
You need to subscribe to the mailing list, and CLICK THE LINK in the registration email (check your spam folder).
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: i am crazy of openscad but openscad makes me crazy

steam30
This post has NOT been accepted by the mailing list yet.
Thanks for this quick and clear answer !

i am discover the problem of Z-buffering ...

greetings michael and have a nice day
Reply | Threaded
Open this post in threaded view
|

Re: i am crazy of openscad but openscad makes me crazy

Parkinbot
This post was updated on .
1. It is always better (and faster) to start a design like this in 2D (and stay in xy) and do all the nasty operations like hull, minkowsky and boolean operations before extrusion.
2. Avoid difference operations where the second operand exactly matches one or two "borders" (matching vertices, edges, and so on)  of the first operand. Usually the second operand can be easily enlarged. Similar rules apply for all boolean operations.
3. try to avoid rotations before going into boolean operations having operands with matching borders. At best avoid unnessecary rotations.

Following these guidelines will change your code into:

$fn= 90;
rotate([90,0,0])
linear_extrude(2)
difference()
{
  hull()
  {
    translate ([-47,5])  circle(5);
    translate ([47,5])  circle(5);
    translate ([42,22]) square(10);
    translate ([-52,22]) square(10);
  }
  hull()
  {
    translate ([-20,17])  circle(5);
    translate ([20,17])  circle(5);
    translate ([-25,23]) square(10);
    translate ([15,23]) square(10);
  }
}
Reply | Threaded
Open this post in threaded view
|

Re: i am crazy of openscad but openscad makes me crazy

steam30
thanks parkinbot for your advice.

In addition this code is more readable and faster to rendering.