Ronaldo is right. The problem is not well-defined if you provide just a line
section between two points and want it to cut a 2D object into two pieces.
You will admit that not every pair of two points will define a line section
describing a regular fold. So what should your code do in the following
case:
http://forum.openscad.org/file/t887/foldit.png
Will it shorten the fold line at the blue end and extend it on the yellow
end? Not so easy, even if you would specify some well-designed rules for
automated behaviour.
It might work with simple polygons and some rule set like "snap each end
of the line section to the nearest point on the polygon outline"... You will
have to add (and implement) a bunch of further rules to avoid
ill-definedness and ambiguities like both ends snapping to the same point,
or something like this:
http://forum.openscad.org/file/t887/foldit1.png
These snap rules (which indeed lead into artificial intelligence) are
necessary, because in general your user will not (always) be able to specify
a pair points exactly.
My opinion: Due to its lack of interactiveness, OpenSCAD is not the right
approach to implement such a solution. It will not disclose any vertex
coordinates to you (so you can't use any boolean operations to define your
2D-object) and you will not be able to define a reasonable user interface
other than by editing parameters in code or by customizer.
You could try a 2D-Drawing program with built-in snapping and some scripting
facilities, like Corel Draw. I would use a reasonable language that supports
mouse interactivity and at best allows for GUI application programming.
OpenSCAD is far away from this.
--
Sent from: http://forum.openscad.org/
I can see your point, but I was assuming that the user would know enough
about the shape they were feeding into my module to be able to specify a
line that did cut the shape into two sections. I'm not expecting the
module to work for all possible combinations of a 2D shape and a line - just
for ones that someone might plausibly want to use my module with.
I was hoping at one point that cutting the shape with a thin rectangle using
the difference() operator would return multiple children in the case where
the operation cut the first child into more than one part, but I have tested
this and it's not the case. I asked the question in the hope that someone
with more experience of OpenSCAD might know some simple hack like this that
would return the result I wanted, but it doesn't look like there is, so I
have an answer to my question at least.
Thanks people for taking the time to reply.
On 09/09/17 19:08, Parkinbot wrote:
Ronaldo is right. The problem is not well-defined if you provide just a
line
section between two points and want it to cut a 2D object into two pieces.
You will admit that not every pair of two points will define a line
section
describing a regular fold. So what should your code do in the following
case:
http://forum.openscad.org/file/t887/foldit.png
Will it shorten the fold line at the blue end and extend it on the yellow
end? Not so easy, even if you would specify some well-designed rules for
automated behaviour.
It might work with simple polygons and some rule set like "snap each end
of the line section to the nearest point on the polygon outline"... You
will
have to add (and implement) a bunch of further rules to avoid
ill-definedness and ambiguities like both ends snapping to the same point,
or something like this:
http://forum.openscad.org/file/t887/foldit1.png
These snap rules (which indeed lead into artificial intelligence) are
necessary, because in general your user will not (always) be able to
specify
a pair points exactly.
My opinion: Due to its lack of interactiveness, OpenSCAD is not the right
approach to implement such a solution. It will not disclose any vertex
coordinates to you (so you can't use any boolean operations to define your
2D-object) and you will not be able to define a reasonable user interface
other than by editing parameters in code or by customizer.
You could try a 2D-Drawing program with built-in snapping and some
scripting
facilities, like Corel Draw. I would use a reasonable language that
supports
mouse interactivity and at best allows for GUI application programming.
OpenSCAD is far away from this.
--
Sent from: http://forum.openscad.org/
I can see your point, but I was assuming that the user would know enough
about the shape they were feeding into my module to be able to specify a
line that did cut the shape into two sections. I'm not expecting the
module to work for all possible combinations of a 2D shape and a line - just
for ones that someone might plausibly want to use my module with.
I was hoping at one point that cutting the shape with a thin rectangle using
the difference() operator would return multiple children in the case where
the operation cut the first child into more than one part, but I have tested
this and it's not the case. I asked the question in the hope that someone
with more experience of OpenSCAD might know some simple hack like this that
would return the result I wanted, but it doesn't look like there is, so I
have an answer to my question at least.
Thanks people for taking the time to reply.
On 09/09/17 19:08, Parkinbot wrote:
Ronaldo is right. The problem is not well-defined if you provide just a
line
section between two points and want it to cut a 2D object into two pieces.
You will admit that not every pair of two points will define a line
section
describing a regular fold. So what should your code do in the following
case:
http://forum.openscad.org/file/t887/foldit.png
Will it shorten the fold line at the blue end and extend it on the yellow
end? Not so easy, even if you would specify some well-designed rules for
automated behaviour.
It might work with simple polygons and some rule set like "snap each end
of the line section to the nearest point on the polygon outline"... You
will
have to add (and implement) a bunch of further rules to avoid
ill-definedness and ambiguities like both ends snapping to the same point,
or something like this:
http://forum.openscad.org/file/t887/foldit1.png
These snap rules (which indeed lead into artificial intelligence) are
necessary, because in general your user will not (always) be able to
specify
a pair points exactly.
My opinion: Due to its lack of interactiveness, OpenSCAD is not the right
approach to implement such a solution. It will not disclose any vertex
coordinates to you (so you can't use any boolean operations to define your
2D-object) and you will not be able to define a reasonable user interface
other than by editing parameters in code or by customizer.
You could try a 2D-Drawing program with built-in snapping and some
scripting
facilities, like Corel Draw. I would use a reasonable language that
supports
mouse interactivity and at best allows for GUI application programming.
OpenSCAD is far away from this.
--
Sent from: http://forum.openscad.org/