# Terrain modeling

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

## Terrain modeling

 I've been using OpenSCAD with terrain heights from SRTM and also the OS Terrain 50 data  for the UK see http://kitwallace.tumblr.com/tagged/terrain  I'm using Python to extract the height matrix and surface() to generate the object. Files of around 200 x 200 ie. 40,000 points render in about 6 minutes but much larger areas seem never to terminate.  Sharp edges are rather pixilated. So I'm wondering what algorithm is used in the triangulation of surfaces and whether there is scope for improvment.  I'm also tempted to learn about STL by writing my own generator in Python so I'd welcome any hints on suitable algorithms.
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 I've been playing around with similar things and found this project to be very useful:It include a useful function that takes a height map and generates an STL file directly. You can use it like this:from stltools import stlgenerator heightmap = ...stlgenerator.generate_from_heightmap_array(heightmap, '3dmodel.stl') I haven't hit an upper limit on size yet. ---------Brad Pitcher On Mon, Feb 24, 2014 at 3:49 PM, kitwallace wrote: I've been using OpenSCAD with terrain heights from SRTM and also the OS Terrain 50 data  for the UK see  http://kitwallace.tumblr.com/tagged/terrain I'm using Python to extract the height matrix and surface() to generate the object. Files of around 200 x 200 ie. 40,000 points render in about 6 minutes but much larger areas seem never to terminate.  Sharp edges are rather pixilated. So I'm wondering what algorithm is used in the triangulation of surfaces and whether there is scope for improvment.  I'm also tempted to learn about STL by writing my own generator in Python so I'd welcome any hints on suitable algorithms. -- View this message in context: http://forum.openscad.org/Terrain-modeling-tp6985.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad http://openscad.org - https://flattr.com/thing/121566 _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 Great tip - thanks That looks pretty much as I was planning for a simple triangulation with each grid square converted to 2 triangles.  I  see the normals are all set to 0 -1 0 so I guess most software ignores the supplied normal althiugh OpenSCAD does provide computed normals I don't understand why the flat base is triangulated with the same grid as the surface when 2 triangles would have done, since this doubles the STL size. Chris On Tue, Feb 25, 2014 at 12:16 AM, Brad Pitcher [via OpenSCAD] wrote: I've been playing around with similar things and found this project to be very useful:It include a useful function that takes a height map and generates an STL file directly. You can use it like this:from stltools import stlgenerator heightmap = ...stlgenerator.generate_from_heightmap_array(heightmap, '3dmodel.stl') I haven't hit an upper limit on size yet. ---------Brad Pitcher On Mon, Feb 24, 2014 at 3:49 PM, kitwallace wrote: I've been using OpenSCAD with terrain heights from SRTM and also the OS Terrain 50 data  for the UK see  http://kitwallace.tumblr.com/tagged/terrain I'm using Python to extract the height matrix and surface() to generate the object. Files of around 200 x 200 ie. 40,000 points render in about 6 minutes but much larger areas seem never to terminate.  Sharp edges are rather pixilated. So I'm wondering what algorithm is used in the triangulation of surfaces and whether there is scope for improvment.  I'm also tempted to learn about STL by writing my own generator in Python so I'd welcome any hints on suitable algorithms. -- View this message in context: http://forum.openscad.org/Terrain-modeling-tp6985.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad http://openscad.org - https://flattr.com/thing/121566 _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566 If you reply to this email, your message will be added to the discussion below: http://forum.openscad.org/Terrain-modeling-tp6985p6986.html To unsubscribe from Terrain modeling, click here. NAML
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 Just to report back on my efforts, I learnt quite a bit about STL and supporting tools writing my own terrain STL generation which I wrote up here: http://kitwallace.tumblr.com/post/78433659932/generating-stl-for-terrain-modelsBottom line is that the Python code was about 100 times faster than OpenSCAD on this special case.  The only change from the obvious faceting of a grid was to chose the triangulation of a square along the diagonal with the lesser gradient.
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 kitwallace wrote Bottom line is that the Python code was about 100 times faster than OpenSCAD on this special case.  The only change from the obvious faceting of a grid was to chose the triangulation of a square along the diagonal with the lesser gradient. Just pure surface generation is a lot faster with the unstable branch too, Marius made some quite impressive improvements. The main issue is that as soon as an object with lots of vertices is passed to any CGAL operation, it grinds to a halt. I've converted a grayscale 480x300 pixel picture (http://www.flickr.com/photos/96851846@N05/11740684974/). That stats are quite different: OpenSCAD release version: 45 minutes OpenSCAD development version: 3 seconds! (Print time: 1:53 hours) Note that just a single difference() resulted in a change from 3 seconds to 30 minutes. So there's still a lot room for future improvement. -- Torsten
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 In reply to this post by kitwallace Very cool. Did you use SolidPython? I've been using that library, and loving it.
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 I wanted to understand STL so its just plain Python with numpy - links to Python code on Github are in the blog post.
Reply | Threaded
Open this post in threaded view
|

## Re: Terrain modeling

 In reply to this post by tp3 Polyhedron is very fast with my version 2014.10.02 I had originally made solids with multiple polyhedron statements and successfully printed off the result with mattercontrol but then was investigating an issue after some time and discovered my models had multiple intersecting vertices. After converting my code to make a single polyhedron with a superset of all data, I found my renders were changed from hour long to a few seconds. Now I routinely run renders with 100,000 + facets and get times of around a minute or less.