how easy to make .off export a function call?

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

how easy to make .off export a function call?

boxcarmib
This post has NOT been accepted by the mailing list yet.
It's straightforward to save an object in .off format, and then using an external program i wrote, create an openscad program that describes the object as a polyhedron using the points and faces from the .off data.
My question is this, and its directed to those of you familiar with the openscad source:
How hard would it be to create a function that effectively calls the program logic that creates the .off export and returns a two element matrix of points and faces?
I'm thinking of a module that would work something like render() does, providing the points and faces for whatever has been defined at the point the function is called.
Having some programming experience I'd be interested in pursuing the development of such a function, but I'd like an opinion from someone who knows what's under the hood if this is just an impractical or staggeringly complex project.
Reply | Threaded
Open this post in threaded view
|

Re: how easy to make .off export a function call?

MichaelAtOz
Administrator
boxcarmib wrote
It's straightforward to save an object in .off format, and then using an external program i wrote, create an openscad program that describes the object as a polyhedron using the points and faces from the .off data.
My question is this, and its directed to those of you familiar with the openscad source:
How hard would it be to create a function that effectively calls the program logic that creates the .off export and returns a two element matrix of points and faces?
I'm thinking of a module that would work something like render() does, providing the points and faces for whatever has been defined at the point the function is called.
Having some programming experience I'd be interested in pursuing the development of such a function, but I'd like an opinion from someone who knows what's under the hood if this is just an impractical or staggeringly complex project.
Your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look. So I quoted it above.
You need to subscribe to the mailing list, and CLICK THE LINK in the registration email (check your spam folder).

Stand by for the philosophical discussion...
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: how easy to make .off export a function call?

Ronaldo
There is no resource in OpenSCAD language to  write a file. There is neither any way to get vertex and edge data for a given model. The only text output you may get is by echo() and it is directed to  the console window. 


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

Re: how easy to make .off export a function call?

kintel
Administrator

> On May 30, 2017, at 09:04, Ronaldo Persiano <[hidden email]> wrote:
>
> There is no resource in OpenSCAD language to  write a file. There is neither any way to get vertex and edge data for a given model. The only text output you may get is by echo() and it is directed to  the console window.
>
This could be made a UI feature though (e.g. select a node/subtree and inline it).
Here is some similar work in progress where I’m modifying the CSG export to resolve nodes like import() into a polyhedron:
https://github.com/openscad/openscad/pull/1882

 -Marius


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

Re: how easy to make .off export a function call?

wolf
In reply to this post by boxcarmib
Dead easy, at least for a Linux user.
If you run OpenSCAD from the command line - which I don't bother to do - you would just chain OpenSCAD > YourProgram > OpenSCAD and be done.
What I do is open MyProgram in its IDE, run it to create a .stl file, transfer focus from my IDE to OpenSCAD, press F4 (to refresh OpenSCAD) and then F5 or F6, as required.
Done.
BTW: MyProgram is written in such a way that it converts a .STL file into the format OpenSCAD needs to run its own polyhedron(Points,Faces) command. That way, I can have the benefits of both.
The advantage - to me- is that I get full control over what OpenSCAD does internally, without the need to study its internals. That includes ways and means to eliminate CGAL assertion errors, and it produces ways to dramatically speed up rendering.
But - because of the way the .STL file format is designed, this approach limits accuracy of output to three or four decimal places, instead of the six possible with 32 bit floats and the 19 decimals possible when using the full capabilities of existing 64 bit hardware.
What I would like to see is an polymorphic extension to polyhedron(), so that it accepts a suitably ordered list of points.
Because: Once the list of points is suitably ordered, the list of faces may be generated internally. Once you don't need to bother to create the list of faces, the need to do boolean operations decreases dramatically, and rendering time for complex shapes drops from hours to seconds.
To generate a suitably ordered list of points can readily be done with a for loop.

wolf
Reply | Threaded
Open this post in threaded view
|

Re: how easy to make .off export a function call?

boxcarmib
In reply to this post by boxcarmib
Am I correct then in the understanding that the current export to .off function is simply a hook into the underlying CSG library and that is why splitting it off into an openSCAD language function is problematic?

And if I understand what Kintel is saying, is he suggesting that a User Interface function might be fashioned to present an export function that would display an openSCAD program fragment that could then be copied and pasted into an openSCAD source file for subsequent processing?

And thanks to Wolf for sharing his approach... I was considering his approach as an alternate solution, so I'm grateful for the hints.
Reply | Threaded
Open this post in threaded view
|

Re: how easy to make .off export a function call?

kintel
Administrator
> On Jun 1, 2017, at 01:26, boxcarmib <[hidden email]> wrote:
>
> And if I understand what Kintel is saying, is he suggesting that a User
> Interface function might be fashioned to present an export function that
> would display an openSCAD program fragment that could then be copied and
> pasted into an openSCAD source file for subsequent processing?
>
Yes, something like that. It’s not yet planned, so details are not in place.

 -Marius



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org