3d offset

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

3d offset

Greg Frost
I just discovered the power of offset for 2d shapes. It can make the development of designs with parameterised fits quite easy. Having the equivalent functionality for 3d models would be extremely useful. You can do some similar operations using minkowski with spheres, but performance limitations mean you end up having to limit the complexity of the sphere which in turn can affect the accuracy of the offset and can result in some funny faceting.

Is a 3d version of offset planned? Im guessing this would be far less computationally intensive than minkowski, so it would be far more useful in designs. Could this perhaps be a GSoC project? I really have no idea of the complexity.

Greg
Reply | Threaded
Open this post in threaded view
|

Re: 3d offset

Greg Frost
One of the great things about offset is that you can apply it in two directions to smooth or fillet an object. 3d smoothing and filleting would be one of the major advantages of a 3d offset() function.

Example of how arbitrary shapes can be smoothed and filleted.
Reply | Threaded
Open this post in threaded view
|

Re: 3d offset

Greg Frost
I guess I should give the code example to show how easy it is to smooth and fillet 2d shapes with offset():
module shape()
{    
    polygon([[0,0],[30,0],[30,30],[15,15],[0,45]]);
}

module smooth(r=3)
{
    $fn=30;
    offset(r=r)
    offset(r=-r)
    children();
}

module fillet(r=3)
{
    $fn=30;
    offset(r=-r)
    offset(r=r)
    children();
}

translate([0,0])
{
    translate([0,-15,0])
    resize([30,0,0])
    text("Original");

    shape();
}
    
translate([40,0])
{
    translate([0,-15,0])
    resize([30,0,0])
    text("Smooth()");

    smooth()
    shape();
}

translate([80,0])
{
    translate([0,-15,0])
    resize([30,0,0])
    text("Fillet()");

    fillet()
    shape();
}

translate([120,0])
{
    translate([0,-15,0])
    resize([30,0,0])
    text("Smooth()Fillet()");
    smooth()
    fillet()
    shape();
}
Reply | Threaded
Open this post in threaded view
|

Re: 3d offset

cacb
On 2015-03-21 08:07, Greg Frost wrote:
> I guess I should give the code example to show how easy it is to smooth
> and fillet 2d shapes with offset():

Thank you for these great examples!

I had wondered how to do 2d filleting, and this appears to be the
answer. Simply using offset() twice is a neat trick. Your example also
illustrates the "children()" feature in a clean way, another bonus for
me. Great stuff, I am going to use it. Thanks again.

Carsten Arnholm


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

Re: 3d offset

Chow Loong Jin
In reply to this post by Greg Frost
On Fri, Mar 20, 2015 at 03:38:43PM -0700, Greg Frost wrote:
> I just discovered the power of offset for 2d shapes. It can make the
> development of designs with parameterised fits quite easy. Having the
> equivalent functionality for 3d models would be extremely useful. You can do
> some similar operations using minkowski with spheres, but performance
> limitations mean you end up having to limit the complexity of the sphere
> which in turn can affect the accuracy of the offset and can result in some
> funny faceting.

I'd definitely welcome this. I can't recall how many times I've had to disable
all the fillet()[1] calls in my designs while iterating just to save some render
time.

> Is a 3d version of offset planned? Im guessing this would be far less
> computationally intensive than minkowski, so it would be far more useful in
> designs. Could this perhaps be a GSoC project? I really have no idea of the
> complexity.

I read somewhere that a simpler implementation of 3d offset without involving
minkowski could involve translating each face outward along its normal, trimming
off the intersecting bits somehow, and then filling in the gaps somehow.

[1] https://github.com/clothbot/ClothBotCreations/blob/master/utilities/fillet.scad

--
Kind regards,
Loong Jin

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 3d offset

Chow Loong Jin
On Mon, Mar 23, 2015 at 05:06:28PM +0800, Chow Loong Jin wrote:

> On Fri, Mar 20, 2015 at 03:38:43PM -0700, Greg Frost wrote:
> > I just discovered the power of offset for 2d shapes. It can make the
> > development of designs with parameterised fits quite easy. Having the
> > equivalent functionality for 3d models would be extremely useful. You can do
> > some similar operations using minkowski with spheres, but performance
> > limitations mean you end up having to limit the complexity of the sphere
> > which in turn can affect the accuracy of the offset and can result in some
> > funny faceting.
>
> I'd definitely welcome this. I can't recall how many times I've had to disable
> all the fillet()[1] calls in my designs while iterating just to save some render
> time.
>
> > Is a 3d version of offset planned? Im guessing this would be far less
> > computationally intensive than minkowski, so it would be far more useful in
> > designs. Could this perhaps be a GSoC project? I really have no idea of the
> > complexity.
>
> I read somewhere that a simpler implementation of 3d offset without involving
> minkowski could involve translating each face outward along its normal, trimming
> off the intersecting bits somehow, and then filling in the gaps somehow.
>
> [1] https://github.com/clothbot/ClothBotCreations/blob/master/utilities/fillet.scad
>
Hmm, FreeCAD seems to have a working implementation of 3D offset. Does anyone
know more? Perhaps we could just port their algorithm into OpenSCAD.

[1] http://www.freecadweb.org/wiki/index.php?title=Part_Offset

--
Kind regards,
Loong Jin

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 3d offset

kintel
Administrator
They use the offset from OpenCascade. If anyone wants to tinker, see here: https://github.com/tpaviot/oce/blob/master/src/Geom/Geom_OffsetSurface.cxx