Patch to implement stl_dim to get boundary information about an imported STL mesh

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

Patch to implement stl_dim to get boundary information about an imported STL mesh

Berend Dekens
Hello again,

To solve my own problem, here are 2 patches to add boundary information
extraction to OpenSCAD. I've added a small example to show how the
boundaries can be used to quickly align objects.

The 2nd patch is actually a fix because I based my original version on
the 2011-09 version from the Ubuntu repository and I botched the way the
new function attempts to register itself.

Regards,
Berend Dekens

0001-Implemented-stl_dim-using-dxf_dim-as-a-guide-line.patch (7K) Download Attachment
0002-Fix-small-error-in-the-way-the-stl_dim-module-is-add.patch (740 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Patch to implement stl_dim to get boundary information about an imported STL mesh

Len Trigg
Wouldn't it be better to have one method for calculating the bounds of any object (i.e. including those constructed entirely within scad), rather than dealing with dxf/stl/native all differently?
Cheers,
Len.

Berend Dekens <[hidden email]> wrote:
Hello again,

To solve my own problem, here are 2 patches to add boundary information
extraction to OpenSCAD. I've added a small example to show how the
boundaries can be used to quickly align objects.

The 2nd patch is actually a fix because I based my original version on
the 2011-09 version from the Ubuntu repository and I botched the way the
new function attempts to register itself.

Regards,
Berend Dekens


OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
Reply | Threaded
Open this post in threaded view
|

Re: Patch to implement stl_dim to get boundary information about an imported STL mesh

Berend Dekens
First off, the wrapper to access the info is custom; the function to get boundaries of groups of polygons is already part of the engine (as you probably know).

Since this is my first look under the hood of OpenSCAD I'd say the first problem is that you need a handle to a mesh in order to get its dimensions. Something that can be worked around if the information comes from an import, but afaik something that is not possible at the moment?

Perhaps its possible to extend openscad into something like this:
mesh = mymodule();
i = mesh.min_x();

But that would require the assembly of the 3D model during the evaluation of the code (building the AST). As I understand from the feedback from the IRC channel, these two steps are currently completely separated.

On another note: while it is helpful to be able to do this in general, normally you know the size of the object you are creating in openscad. The only time you do not directly control this is during imports; so is it really needed to do this for all objects in the engine?

Regards,
Berend

On 15-12-2011 18:17, Len Trigg wrote:
Wouldn't it be better to have one method for calculating the bounds of any object (i.e. including those constructed entirely within scad), rather than dealing with dxf/stl/native all differently?
Cheers,
Len.

Berend Dekens [hidden email] wrote:
Hello again,

To solve my own problem, here are 2 patches to add boundary information 
extraction to OpenSCAD. I've added a small example to show how the 
boundaries can be used to quickly align objects.

The 2nd patch is actually a fix because I based my original version on 
the 2011-09 version from the Ubuntu repository and I botched the way the 
new function attempts to register itself.

Regards,
Berend Dekens

OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: Patch to implement stl_dim to get boundary information about an imported STL mesh

kintel
Administrator
In reply to this post by Berend Dekens
Hi Berend,

Thanks for the patch!
I think API changes like this needs some time to mature, which includes looking at how such functionality could be made more  complete or orthogonal. I've created a branch called stl_dim on github where we can continue this exploration.

 -Marius