Quantcast

Minkowski Sum and Cookie Cutter

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Minkowski Sum and Cookie Cutter

borelg
This post has NOT been accepted by the mailing list yet.
Dear Openscad Forum,

this is my first post here, but It has been a while since I have started to use Openscad, which I consider a great piece of software.

Anyway, I am having some issue with executing a piece of code. In fact, when I run the following code it gets incredibly slow:


$fn = 100;

minkowski()
{
    linear_extrude(height = 0.1)
        import("image.dxf");
    cylinder(h = 20, r1 = 2, r2 = 0.4, center = true);
}


And, with slow, I mean that the executing phase (not the rendering, which it takes even more) it takes hours!

The file "image.dxf" it's the vectorial image of the cookie cutter. I obtained this image using the following method:

- I extracted the contour of an image with Gimp
- I vectorized the bitmap image of the extracted contour using Inkscape and I converted the spline in the path with the extension "Flatten Bezier" ( i used 0.1 as parameter for this function).
- I saved the vetorial image as a DXF and I imported that in Openscad as you can see from the code.

My target is to obtain a cookie cutter that has sharp edges. I mean that I do not want just to extrude the image of the contour of the cutter, but I would like to give to this contour a slope. Thus, I thought about using the minkowski sum with a suitable structuring element such as a cone ( cylinder function).

Anyway, I believe that I am doing something in the wrong way, and that my code is written in a way that results very heavy to Openscad.

Do you have any suggestion in order to solve this issue?
If you have any advice about how to achieve my target in a different way, I would be grateful as well!

Thank you in advance!! :)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Minkowski Sum and Cookie Cutter

MichaelAtOz
Administrator
Welcome to the forum. 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.

I have copied your post below for others.

borelg wrote
Dear Openscad Forum,

this is my first post here, but It has been a while since I have started to use Openscad, which I consider a great piece of software.

Anyway, I am having some issue with executing a piece of code. In fact, when I run the following code it gets incredibly slow:


$fn = 100;

minkowski()
{
    linear_extrude(height = 0.1)
        import("image.dxf");
    cylinder(h = 20, r1 = 2, r2 = 0.4, center = true);
}


And, with slow, I mean that the executing phase (not the rendering, which it takes even more) it takes hours!

The file "image.dxf" it's the vectorial image of the cookie cutter. I obtained this image using the following method:

- I extracted the contour of an image with Gimp
- I vectorized the bitmap image of the extracted contour using Inkscape and I converted the spline in the path with the extension "Flatten Bezier" ( i used 0.1 as parameter for this function).
- I saved the vetorial image as a DXF and I imported that in Openscad as you can see from the code.

My target is to obtain a cookie cutter that has sharp edges. I mean that I do not want just to extrude the image of the contour of the cutter, but I would like to give to this contour a slope. Thus, I thought about using the minkowski sum with a suitable structuring element such as a cone ( cylinder function).

Anyway, I believe that I am doing something in the wrong way, and that my code is written in a way that results very heavy to Openscad.

Do you have any suggestion in order to solve this issue?
If you have any advice about how to achieve my target in a different way, I would be grateful as well!

Thank you in advance!! :)
Minkowski is notoriously slow, and using $fn=100 will make it much worse. Use a low $fn to test, only use a bigger value toward the end, and only as big as really needed (related to the resolution of whatever printer etc you will make it with).

You could try offset(), a for() loop for height with slightly thicker offsets as it gets higher?
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
|  
Report Content as Inappropriate

Re: Minkowski Sum and Cookie Cutter

Neon22
In reply to this post by borelg
The Minkowski takes a long time. not much to be done about it but consider a different approach.
Look at my similar ones Eschers and Jigsaw.
- http://www.thingiverse.com/thing:1034488
- http://www.thingiverse.com/thing:1200785
- http://www.thingiverse.com/thing:986432
they used the inkscape to openscad extension here:
- http://www.thingiverse.com/thing:1065500
The last one - jigsaw - has been manually edited to make one side thinner so there is a draft angle for easier use.
tp3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Minkowski Sum and Cookie Cutter

tp3
In reply to this post by MichaelAtOz
borelg wrote
> And, with slow, I mean that the executing phase (not the
> rendering, which it takes even more) it takes hours!
>
This is way too high resolution for a cookie cutter, both
the $fn=100 and also the 0.1 beziers.

The heart cookie cutter below is probably still higher
resolution than actually needed, but renders in less
than 4 minutes. The star even renders in just 14 seconds
because of the small amount of vertices in the 2D base
shape.

ciao,
  Torsten.


---snip---snap---snip---snap---snip---snap---snip---snap---
// CC BY-SA 4.0

$fa = 2;
$fs = 0.4;

height = 12;

module heart(w = 30) {
    translate([0, w * sqrt(2) / 2]) {
        rotate(-135) {
            square(w);
            translate([w / 2, 0]) circle(d = w);
            translate([0, w / 2]) circle(d = w);
        }
    }
}

module star(n = 5, r1 = 22, r2 = 40) {
    function r(a) = a % 2 == 0 ? r2 : r1;
    function p(a) = [ -sin(a), cos(a) ];

    assert(n >= 3);
    points = [ for (a = [0 : 2 * n - 1]) r(a) * p(180 / n * a) ];
    polygon(points);
}

module outline() {
    difference() {
        offset(0.01) children();
        children();
    }
}

module cut(height, base_height, r1, r2) {
    translate([0, 0, -base_height]) cylinder(r = 2 * r1, h = base_height);
    translate([0, 0, -0.01]) cylinder(r1 = r1, r2 = r2, h = height);
}

module cookie_cutter(height = 12, base_height = 1, r1 = 0.8, r2 = 0.2) {
    minkowski() {
        linear_extrude(0.01) outline() children();
        cut(height, base_height, r1, r2);
    }
}

cookie_cutter() heart(30);

// cookie_cutter() star(5, 22, 40);

---snip---snap---snip---snap---snip---snap---snip---snap---



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

Re: Minkowski Sum and Cookie Cutter

jorkki
This post has NOT been accepted by the mailing list yet.
Hello,
This is my first posting on the forum but I have been reading for a while and learning a lot from the masters, thanks!

This is a bit late for this Easter, but the Mrs. commissioned me to create an egg shaped cookie cutter to cut some bread and cheese properly for the occasion.
I remembered seeing Torsten's clever cutter here so all I needed was to find a suitable curve for the egg.

I found the work done by Mr. Itou and Mr. Yamamoto in Japan and that was all that was needed to add
an egg module to the Cutter.

module egg(len=35, n = 60) {
//Ref. http://www.geocities.jp/nyjp07/index_egg_by_Itou_E.html
        a=len*0.5;
        b=0.78*a;
        function p(t) = [ a*cos(t), b*cos(t/4)*sin(t) ];
        points=[ for (t= [-180 :360/n :180]) p(t)];
        polygon(points);
}

to use add e.g.:
cookie_cutter(20) egg(45, 60);

Loading...