Sheathing a model

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

Sheathing a model

jsc
I'm trying to create a "sheathe" for a model. Not quite sure how to describe this clearly... what I would like is a version of a model that monotonically grows in area in the z plane. Imagine a sheathe for a sword, or a pistol holster, or a mold with no overhangs. All cross sections in z must contain or be equal to all lower cross sections, or else you would not be able to remove the model from its sheathe.

I don't think this is possible in OpenSCAD. If I were writing a program to do this on an arbitrary mesh, I might select all polygons with downward facing normals and "extrude" them along the Z axis an arbitrary distance. A partial solution that occurred to me would be to take a projection at increments up the model, union them with all the lower projections, and incrementally hull them together, but this will lose some detail in the surface.

I would love to be proven wrong. Any suggestions would be welcome.
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

Whosawhatsis
Have you tried using hull()? Whether it will produce ideal results will depend on the shape of your object, but it will certainly be the easiest way if it works.

On Wednesday, April 23, 2014 at 12:35 PM, jsc wrote:

I'm trying to create a "sheathe" for a model. Not quite sure how to describe
this clearly... what I would like is a version of a model that monotonically
grows in area in the z plane. Imagine a sheathe for a sword, or a pistol
holster, or a mold with no overhangs. All cross sections in z must contain
or be equal to all lower cross sections, or else you would not be able to
remove the model from its sheathe.

I don't think this is possible in OpenSCAD. If I were writing a program to
do this on an arbitrary mesh, I might select all polygons with downward
facing normals and "extrude" them along the Z axis an arbitrary distance. A
partial solution that occurred to me would be to take a projection at
increments up the model, union them with all the lower projections, and
incrementally hull them together, but this will lose some detail in the
surface.

I would love to be proven wrong. Any suggestions would be welcome.



--
Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

Oskar
In reply to this post by jsc
You can get the result you want with minkowski() together with a cube([c,c,h]) where c is the horizontal clearance and h the sheat length.
jsc
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

jsc
In reply to this post by Whosawhatsis
Hull would not be appropriate for two reasons. First, it would fill in any concave curves on the lower boundary that should not be filled (imagine a wine glass without base, or one of those "black hole on a bed sheet" illustrations; that would get turned into a cone); and secondly, it would not implement the "no overhangs" property (a sphere remains a sphere), although you could deal with the second issue by hulling the model with an offset version of itself. Still, the first objection stands, I don't want to lose any concave curves on the lower surface.
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

Len Trigg
In reply to this post by jsc
You can use 3d minkowski, although it will be quite slow for complex objects. e.g:


// A shape to make a sheath for

module tosheath() {

translate([0,0,7]) rotate([60,0,0]) {

cube([10,10,10], center=true);

translate([2,2,2]) cube(6);

translate([7,7,1]) cube([8,8,8], center=true);

}

}


// Assumes centered on x,y, bottom aligned on z=0

module sheath(depth=5) {

intersection() {

minkowski() {

child(0);

cube([0.1,0.1,depth]);

}

translate([-25,-25,0]) cube([50,50, depth]);

}

}


depth=25;

translate([-20,0,0]) tosheath();

sheath(depth) tosheath();




On 24 April 2014 07:35, jsc <[hidden email]> wrote:
I'm trying to create a "sheathe" for a model. Not quite sure how to describe
this clearly... what I would like is a version of a model that monotonically
grows in area in the z plane. Imagine a sheathe for a sword, or a pistol
holster, or a mold with no overhangs. All cross sections in z must contain
or be equal to all lower cross sections, or else you would not be able to
remove the model from its sheathe.

I don't think this is possible in OpenSCAD. If I were writing a program to
do this on an arbitrary mesh, I might select all polygons with downward
facing normals and "extrude" them along the Z axis an arbitrary distance. A
partial solution that occurred to me would be to take a projection at
increments up the model, union them with all the lower projections, and
incrementally hull them together, but this will lose some detail in the
surface.

I would love to be proven wrong. Any suggestions would be welcome.



--
View this message in context: http://forum.openscad.org/Sheathing-a-model-tp7728.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/openscad
http://openscad.org - https://flattr.com/thing/121566
jsc
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

jsc
Ah, good old minkowski, the Swiss Army knife (or should that be Swiss Army sledgehammer) of OpenSCAD.

Thanks, Oskar and Len, that sounds like it would work, I'll give it a try. Very ingenious. Out of curiosity, is this a common use for minkowski I was just unaware of, or did you two both independently come up with the idea of minkowski with a long thin cube in response to my question on the spot?

Len Trigg wrote
You can use 3d minkowski, although it will be quite slow for complex objects.
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

Brad Pitcher
I think it is a known, but perhaps not widely known, trick of minkowski. I have also used that trick, after reading a blog post about it somewhere.

---------
Brad Pitcher


On Wed, Apr 23, 2014 at 3:13 PM, jsc <[hidden email]> wrote:
Ah, good old minkowski, the Swiss Army knife (or should that be Swiss Army
sledgehammer) of OpenSCAD.

Thanks, Oskar and Len, that sounds like it would work, I'll give it a try.
Very ingenious. Out of curiosity, is this a common use for minkowski I was
just unaware of, or did you two both independently come up with the idea of
minkowski with a long thin cube in response to my question on the spot?


Len Trigg wrote
> You can use 3d minkowski, although it will be quite slow for complex
> objects.





--
View this message in context: http://forum.openscad.org/Sheathing-a-model-tp7728p7733.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/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

szabi
Well, if the height of your design is $z$ centered around 0 (i.e. $-z/2$ to $z/2$), could you not:

intersection() {
    cube([bigvalue, bigvalue, z], center=true)
    hull() {
        design()
        translate([0,0,z]) design()
}


?

I think that would be faster than Minkowski. And your properties would hold?

/SZ

Szelp, André Szabolcs

+43 (650) 79 22 400


On Thu, Apr 24, 2014 at 12:22 AM, Brad Pitcher <[hidden email]> wrote:
I think it is a known, but perhaps not widely known, trick of minkowski. I have also used that trick, after reading a blog post about it somewhere.

---------
Brad Pitcher


On Wed, Apr 23, 2014 at 3:13 PM, jsc <[hidden email]> wrote:
Ah, good old minkowski, the Swiss Army knife (or should that be Swiss Army
sledgehammer) of OpenSCAD.

Thanks, Oskar and Len, that sounds like it would work, I'll give it a try.
Very ingenious. Out of curiosity, is this a common use for minkowski I was
just unaware of, or did you two both independently come up with the idea of
minkowski with a long thin cube in response to my question on the spot?


Len Trigg wrote
> You can use 3d minkowski, although it will be quite slow for complex
> objects.





--
View this message in context: http://forum.openscad.org/Sheathing-a-model-tp7728p7733.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/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
jsc
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

jsc
No, if your design has concave surfaces on the bottom, they would get filled in by the hull.

szabi wrote
Well, if the height of your design is $z$ centered around 0 (i.e. $-z/2$ to
$z/2$), could you not:

intersection() {
    cube([bigvalue, bigvalue, z], center=true)
    hull() {
        design()
        translate([0,0,z]) design()
}

?

I think that would be faster than Minkowski. And your properties would hold?
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

szabi
You're right concaves on the bottom are indeed "unnecessarily" filled in.

Szelp, André Szabolcs

+43 (650) 79 22 400


On Wed, May 21, 2014 at 7:15 PM, jsc <[hidden email]> wrote:
No, if your design has concave surfaces on the bottom, they would get filled
in by the hull.


szabi wrote
> Well, if the height of your design is $z$ centered around 0 (i.e. $-z/2$
> to
> $z/2$), could you not:
>
> intersection() {
>     cube([bigvalue, bigvalue, z], center=true)
>     hull() {
>         design()
>         translate([0,0,z]) design()
> }
>
> ?
>
> I think that would be faster than Minkowski. And your properties would
> hold?





--
View this message in context: http://forum.openscad.org/Sheathing-a-model-tp7728p8055.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/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

James Newton
In reply to this post by Len Trigg
The minkowski method would be ideal, but (as you say) it is impossibly slow for a complex object (e.g. imported STL file).

I got a /little/ closer with this:

difference() {
        translate([0,0,-mold_height])
                cylinder(r1 = mold_diameter, r2 = mold_diameter, mold_height);

        for ( i = [0 : slice : mold_height] ) {
                scale(model_scale+(i/500)) translate(model_translate+[0,0,i]) rotate(model_rotate)
                        import(model_filename);
                }
        }

where slice is set to something like 1 or 0.5. It's "good enough" but not perfect. The surface is left with little "shelves" every slice height. The increase in scale helps that a bit.

But ran into a problem I don't understand. It's "restoring" some of the mold after previous subtractions of the model from the mold. e.g. if there is an indent in the bottom of the model (as in the example above) then the mold base gets "put back" as i increases so that eventually, as i reaches mold_height, so does the mold base in that area. Other parts of the model stay gone, but concave surfaces on the side "pressed" into the mold are not removed. I'll try to find a way to post a picture.

Any ideas for any other way to take an existing STL file and "extrude" it into something that can be subtracted from a mold base? Even some other software?
Reply | Threaded
Open this post in threaded view
|

Re: Sheathing a model

szabi
I don't quite see why you use scale(model_scale+(i/500))
the /500 seem arbitrary.

Szelp, André Szabolcs

+43 (650) 79 22 400


On Wed, Jun 25, 2014 at 3:06 AM, James Newton <[hidden email]> wrote:
The minkowski method would be ideal, but (as you say) it is impossibly slow
for a complex object (e.g. imported STL file).

I got a /little/ closer with this:

difference() {
        translate([0,0,-mold_height])
                cylinder(r1 = mold_diameter, r2 = mold_diameter, mold_height);

        for ( i = [0 : slice : mold_height] ) {
                scale(model_scale+(i/500)) translate(model_translate+[0,0,i])
rotate(model_rotate)
                        import(model_filename);
                }
        }

where slice is set to something like 1 or 0.5. It's "good enough" but not
perfect. The surface is left with little "shelves" every slice height. The
increase in scale helps that a bit.

But ran into a problem I don't understand. It's "restoring" some of the mold
after previous subtractions of the model from the mold. e.g. if there is an
indent in the bottom of the model (as in the example above) then the mold
base gets "put back" as i increases so that eventually, as i reaches
mold_height, so does the mold base in that area. Other parts of the model
stay gone, but concave surfaces on the side "pressed" into the mold are not
removed. I'll try to find a way to post a picture.

Any ideas for any other way to take an existing STL file and "extrude" it
into something that can be subtracted from a mold base? Even some other
software?



--
View this message in context: http://forum.openscad.org/Sheathing-a-model-tp7728p8782.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/openscad
http://openscad.org - https://flattr.com/thing/121566