discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Surface() from PNG and difference()

M
MLewis
Wed, Apr 29, 2015 5:01 PM

Hoping someone can give me a hand here:

I've got a PNG that I want to "stamp" into the side of an object. To test
this, I created the following code:

*** BEGIN CODE ***
logo="M3logo1.png";

wid=58;
logox = 587;
logoy = 623;

difference(){
cube([wid,wid,2]);
translate([wid/4,wid/4,3])
scale([.5wid/logox,.5wid/logoy,.02])
surface(file=logo,invert=true);

}
*** END CODE ***

As shown below, it previews (F5) correctly. However, the GUI is very
sluggish with this render.
When I attempt to render (F6), however, I get nothing:

The original PNG:
http://forum.openscad.org/file/n12517/M3logo1.png

The Preview:
http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png

The Attempt to Render:
http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png

One other data point: I've increased my caches in the GUI, but when I run
"OpenSCAD -o foo.stl LogoTest.scad" from the command line, I get "WARNING:
GeometryEvaluator: Node didn't fit into cache" errors (three of them), the
process runs forever (as far as I can tell) and uses 99ish% of the CPU.

Any help that anyone can provide would be greatly appreciated. Thanks a lot!

Mike Lewis

--
View this message in context: http://forum.openscad.org/Surface-from-PNG-and-difference-tp12517.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hoping someone can give me a hand here: I've got a PNG that I want to "stamp" into the side of an object. To test this, I created the following code: *** BEGIN CODE *** logo="M3logo1.png"; wid=58; logox = 587; logoy = 623; difference(){ cube([wid,wid,2]); translate([wid/4,wid/4,3]) scale([.5*wid/logox,.5*wid/logoy,.02]) surface(file=logo,invert=true); } *** END CODE *** As shown below, it previews (F5) correctly. However, the GUI is very sluggish with this render. When I attempt to render (F6), however, I get nothing: The original PNG: <http://forum.openscad.org/file/n12517/M3logo1.png> The Preview: <http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png> The Attempt to Render: <http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png> One other data point: I've increased my caches in the GUI, but when I run "OpenSCAD -o foo.stl LogoTest.scad" from the command line, I get "WARNING: GeometryEvaluator: Node didn't fit into cache" errors (three of them), the process runs forever (as far as I can tell) and uses 99ish% of the CPU. Any help that anyone can provide would be greatly appreciated. Thanks a lot! Mike Lewis -- View this message in context: http://forum.openscad.org/Surface-from-PNG-and-difference-tp12517.html Sent from the OpenSCAD mailing list archive at Nabble.com.
PF
Peter Falke
Wed, Apr 29, 2015 6:00 PM

Your .png is quiet big.
A resolution of 587 * 623 is a lot.
Try to figure out how many triangles this surface would have: 731 402.
This will bring Openscad to its knees.
I havent checked the manual, but I seem to remember that there is a limit
of 100*100 for the surface command.

Hope it helps.

P.S.: the 2 screen shots dont display

2015-04-29 19:01 GMT+02:00 MLewis revmikelewis@gmail.com:

Hoping someone can give me a hand here:

I've got a PNG that I want to "stamp" into the side of an object. To test
this, I created the following code:

*** BEGIN CODE ***
logo="M3logo1.png";

wid=58;
logox = 587;
logoy = 623;

difference(){
cube([wid,wid,2]);
translate([wid/4,wid/4,3])
scale([.5wid/logox,.5wid/logoy,.02])
surface(file=logo,invert=true);

}
*** END CODE ***

As shown below, it previews (F5) correctly. However, the GUI is very
sluggish with this render.
When I attempt to render (F6), however, I get nothing:

The original PNG:
http://forum.openscad.org/file/n12517/M3logo1.png

The Preview:
http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png

The Attempt to Render:
http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png

One other data point: I've increased my caches in the GUI, but when I run
"OpenSCAD -o foo.stl LogoTest.scad" from the command line, I get "WARNING:
GeometryEvaluator: Node didn't fit into cache" errors (three of them), the
process runs forever (as far as I can tell) and uses 99ish% of the CPU.

Any help that anyone can provide would be greatly appreciated. Thanks a
lot!

Mike Lewis

--
View this message in context:
http://forum.openscad.org/Surface-from-PNG-and-difference-tp12517.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

Your .png is quiet big. A resolution of 587 * 623 is a lot. Try to figure out how many triangles this surface would have: 731 402. This will bring Openscad to its knees. I havent checked the manual, but I seem to remember that there is a limit of 100*100 for the surface command. Hope it helps. P.S.: the 2 screen shots dont display 2015-04-29 19:01 GMT+02:00 MLewis <revmikelewis@gmail.com>: > Hoping someone can give me a hand here: > > I've got a PNG that I want to "stamp" into the side of an object. To test > this, I created the following code: > > *** BEGIN CODE *** > logo="M3logo1.png"; > > wid=58; > logox = 587; > logoy = 623; > > difference(){ > cube([wid,wid,2]); > translate([wid/4,wid/4,3]) > scale([.5*wid/logox,.5*wid/logoy,.02]) > surface(file=logo,invert=true); > > } > *** END CODE *** > > As shown below, it previews (F5) correctly. However, the GUI is very > sluggish with this render. > When I attempt to render (F6), however, I get nothing: > > The original PNG: > <http://forum.openscad.org/file/n12517/M3logo1.png> > > The Preview: > <http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png> > > The Attempt to Render: > <http://forum.openscad.org/file/n12517/Screen_Shot_2015-04-29_at_11.png> > > One other data point: I've increased my caches in the GUI, but when I run > "OpenSCAD -o foo.stl LogoTest.scad" from the command line, I get "WARNING: > GeometryEvaluator: Node didn't fit into cache" errors (three of them), the > process runs forever (as far as I can tell) and uses 99ish% of the CPU. > > Any help that anyone can provide would be greatly appreciated. Thanks a > lot! > > > Mike Lewis > > > > -- > View this message in context: > http://forum.openscad.org/Surface-from-PNG-and-difference-tp12517.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- stempeldergeschichte@googlemail.com <karsten@rohrbach.de> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben. Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. P.S. In case my e-mail is shorter than you enjoy: I am currently trying short replies instead of no replies at all. Please let me know, if you like to read more. Enjoy!
TP
Torsten Paul
Wed, Apr 29, 2015 6:04 PM

On 04/29/2015 07:01 PM, MLewis wrote:

I've got a PNG that I want to "stamp" into the side of an object. To test
this, I created the following code:

Try scaling down the image a bit. The way surface() creates the object is
not ideal for this type of usage as it creates a huge number of vertices
making the difference very slow.
The option to import images as 2D shape will hopefully come soon, that
would probably make things quite a bit faster, e.g.
(https://github.com/openscad/openscad/pull/1110). To get a similar result
it would be possible to convert the image to DXF using inkscape.

With size 200x212 the model renders in 48 seconds on my notebook.

ciao,
Torsten.

On 04/29/2015 07:01 PM, MLewis wrote: > I've got a PNG that I want to "stamp" into the side of an object. To test > this, I created the following code: > Try scaling down the image a bit. The way surface() creates the object is not ideal for this type of usage as it creates a huge number of vertices making the difference very slow. The option to import images as 2D shape will hopefully come soon, that would probably make things quite a bit faster, e.g. (https://github.com/openscad/openscad/pull/1110). To get a similar result it would be possible to convert the image to DXF using inkscape. With size 200x212 the model renders in 48 seconds on my notebook. ciao, Torsten.
EN
Ed Nisley
Wed, Apr 29, 2015 6:38 PM

On 04/29/2015 01:01 PM, MLewis wrote:

logox = 587;
logoy = 623;

There's the problem: too many pixels.

In round numbers, anything over about 300x300 pixels produces too many
polygons / faces, causing OpenSCAD to grind to a halt while chewing up
all available memory & swap space in a vain attempt to perform CSG.

Scaling the PNG image by 1/8 = 75x81 ran for 9 s and by 1/4 = 150x163
ran for 40 s. With more patience, 300x326 would eventually finish.

The PNG is transparent and the logo ran right up to the edges. I laid it
over a white background and added a thin white border, which eliminated
the "degenerate polygon" complaints.

The "invert=true" option produces nasty undercuts on the
reduced-resolution images, because the grayscale works the wrong way. I
think you'll get better results with a white logo on a black background,
regardless of the resolution.

I found much of that out the hard way while making 3D printed cookie
presses:

http://softsolder.com/2012/11/28/automated-cookie-cutters-fine-tuning/

Gritty resolution sufficed for those...

--
Ed
softsolder.com

On 04/29/2015 01:01 PM, MLewis wrote: > logox = 587; > logoy = 623; There's the problem: too many pixels. In round numbers, anything over about 300x300 pixels produces too many polygons / faces, causing OpenSCAD to grind to a halt while chewing up all available memory & swap space in a vain attempt to perform CSG. Scaling the PNG image by 1/8 = 75x81 ran for 9 s and by 1/4 = 150x163 ran for 40 s. With more patience, 300x326 would eventually finish. The PNG is transparent and the logo ran right up to the edges. I laid it over a white background and added a thin white border, which eliminated the "degenerate polygon" complaints. The "invert=true" option produces nasty undercuts on the reduced-resolution images, because the grayscale works the wrong way. I think you'll get better results with a white logo on a black background, regardless of the resolution. I found much of that out the hard way while making 3D printed cookie presses: http://softsolder.com/2012/11/28/automated-cookie-cutters-fine-tuning/ Gritty resolution sufficed for those... -- Ed softsolder.com