Lattice structure

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lattice structure

s.dwivedi
This post has NOT been accepted by the mailing list yet.
Hello guys ,

I am writing this message to inquire about the possibility of producing lattice structures within openscad platform please see the attached image files ... if anyone has tried them before , would be of great help

with many thanks
Saumyam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

MichaelAtOz
Administrator
s.dwivedi wrote
Hello guys ,

I am writing this message to inquire about the possibility of producing lattice structures within openscad platform please see the attached image files ... if anyone has tried them before , would be of great help

with many thanks
Saumyam
A simple lattice structure would be straight forward and a good model to learn OpenSCAD with.
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
|  
Report Content as Inappropriate

Re: Lattice structure

MichaelAtOz
Administrator
In reply to this post by s.dwivedi
p.s. Your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look.
You need to subscribe to the mailing list, and CLICK THE LINK in the registration email.
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
|  
Report Content as Inappropriate

Re: Lattice structure

Parkinbot
In reply to this post by s.dwivedi
OpenSCAD has the problem that rendering can get extremly slow whenever Boolean operations over a large number of objects come into play. And this is the front door for producing lattice structures - define a large object and difference a union of a large number of smaller objects from it.  

However, while this is a known major drawback of OpenSCAD, there is a (somehow clumsy) work-around, which I use frequently to bypass this problem. I never found out, why the discussion about this was so rudely cut by the moderator, but you can read it up here: http://forum.openscad.org/rendering-for-paper-assembly-manual-tp20108p20126.html

I call the approach lazy union, because it bypasses intersection checks for non intersecting elements by definition (note that it can't be used for intersecting objects). To apply it, you have to generate the objects by code and stuff them all into a single polyhedron call. I gave some example code for it.
But it depends on your programming skills, whether you will be able to use it.  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

Ronaldo
If all your latices are extrusions as the left image latice seems to be, you may create a 2D latice and linear_extrude it:

n = 15;
h = 11;
sx = 120;
sy = 100;
th = 1;

module latice(sx,sy,h,th,n)
  linear_extrude(height=h)
    difference(){
      square([sx,sy]);
      m = ceil(n*sy/sx); echo(m);
      for(i=[0:n], j=[0:2*m])
        translate([(i+(j%2)/2)*sx/n, j*sx/n/2])
          rotate(45)
            square(sx/n/sqrt(2)-th,center=true);
    }

latice(sx,sy,h,th,n);
//translate([0,0,h]) cube([sx,sy,th]);
//translate([0,0,h+th]) latice(sx,sy,h,th,n);
The render of latice() alone is very fast. But, uncommenting the following two lines, the render time starts to bother.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

s.dwivedi
this seems to work absolutely fine however I am not able to grasp the programming bit, could you be more elaborate

from what I have understood , you define a certain latice in 2d followed by extrusion command , can you explain afterwards ?

also can we do same with a circular mesh structure


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

MichaelAtOz
Administrator
I don't suppose this is part of your class work?
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
|  
Report Content as Inappropriate

Re: Lattice structure

s.dwivedi
this is the design I intend to develop as a scaffold system
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

Parkinbot
In reply to this post by MichaelAtOz
That is exactly the point. Anything beyond linear_extruding a 2d object, is exactly where the problem starts. Try to render (F6) the following small piece - about 6 minutes on my machine. Then just multiply any dimension sx, sy, or sz by just 2 and watch how render time grows.  


$fn = 20;
n = 2; // joints per 10mm
sx = 20;
sy = 30;
sz = 10;
th = 1;


lattice();
module lattice()
{
 
  for(x=[0:10/n:sx], y=[0:10/n:sy], z=[0:10/n:sz] )
    translate([sx/2-x,sy/2-y,sz/2-z])
    sphere(th);
 
  for(x=[0:10/n:sx], z=[0:10/n:sz] ) // y bars
    translate([sx/2-x,0,sz/2-z])
    rotate([90, 0])
    cylinder(r=th/2, h=sy, center = true);

  for(y=[0:10/n:sy], z=[0:10/n:sz] ) // y bars
    translate([0, sy/2-y,sz/2-z])
    rotate([0, 90])
    cylinder(r=th/2, h=sx, center = true);

  for(x=[0:10/n:sx], y=[0:10/n:sy] ) // z bars
    translate([sx/2-x, sy/2-y])
    cylinder(r=th/2, h=sz, center = true);
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

jon_bondy
I am not sure what "That is exactly the point" means, Parkinbot. I
reviewed the thread, and was still unclear.  A number of points were
made in the thread.  Exactly what is it that your example, below,
demonstrates, please.

Jon


On 3/24/2017 8:07 AM, Parkinbot wrote:

> That is exactly the point. Anything beyond linear_extruding a 2d object, is
> exactly where the problem starts. Try to render (F6) the following small
> piece - about 6 minutes on my machine. Then just multiply any dimension sx,
> sy, or sz by just 2 and watch how render time grows.
> <http://forum.openscad.org/file/n21013/lattice.png>
>
>
>> $fn = 20;
>> n = 2; // joints per 10mm
>> sx = 20;
>> sy = 30;
>> sz = 10;
>> th = 1;
>>
>>
>> lattice();
>> module lattice()
>> {
>>    
>>    for(x=[0:10/n:sx], y=[0:10/n:sy], z=[0:10/n:sz] )
>>      translate([sx/2-x,sy/2-y,sz/2-z])
>>      sphere(th);
>>    
>>    for(x=[0:10/n:sx], z=[0:10/n:sz] ) // y bars
>>      translate([sx/2-x,0,sz/2-z])
>>      rotate([90, 0])
>>      cylinder(r=th/2, h=sy, center = true);
>>
>>    for(y=[0:10/n:sy], z=[0:10/n:sz] ) // y bars
>>      translate([0, sy/2-y,sz/2-z])
>>      rotate([0, 90])
>>      cylinder(r=th/2, h=sx, center = true);
>>
>>    for(x=[0:10/n:sx], y=[0:10/n:sy] ) // z bars
>>      translate([sx/2-x, sy/2-y])
>>      cylinder(r=th/2, h=sz, center = true);
>> }
>


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

Re: Lattice structure

doug.moen
Parkinbot is pointing out that the "obvious" way of constructing a 3-D lattice in OpenSCAD (unioning together the lattice elements) is likely to be unacceptably slow, so you need to resort to other techniques. Linear_extrude of a 2-D lattice works, as long as your lattice can be described that way, and so far, s.dwivedi's examples are all linear-extrudeable. The more general approach is to use polyhedron, but that's more difficult. Once you have a big lattice, you have to be careful not to union it with other shapes, or the performance problem reappears. This issue (complex lattices vs boolean operations) is a limitation in the design of OpenSCAD.

On 24 March 2017 at 08:15, jon <[hidden email]> wrote:
I am not sure what "That is exactly the point" means, Parkinbot. I reviewed the thread, and was still unclear.  A number of points were made in the thread.  Exactly what is it that your example, below, demonstrates, please.

Jon



On 3/24/2017 8:07 AM, Parkinbot wrote:
That is exactly the point. Anything beyond linear_extruding a 2d object, is
exactly where the problem starts. Try to render (F6) the following small
piece - about 6 minutes on my machine. Then just multiply any dimension sx,
sy, or sz by just 2 and watch how render time grows.
<http://forum.openscad.org/file/n21013/lattice.png>


$fn = 20;
n = 2; // joints per 10mm
sx = 20;
sy = 30;
sz = 10;
th = 1;


lattice();
module lattice()
{
      for(x=[0:10/n:sx], y=[0:10/n:sy], z=[0:10/n:sz] )
     translate([sx/2-x,sy/2-y,sz/2-z])
     sphere(th);
      for(x=[0:10/n:sx], z=[0:10/n:sz] ) // y bars
     translate([sx/2-x,0,sz/2-z])
     rotate([90, 0])
     cylinder(r=th/2, h=sy, center = true);

   for(y=[0:10/n:sy], z=[0:10/n:sz] ) // y bars
     translate([0, sy/2-y,sz/2-z])
     rotate([0, 90])
     cylinder(r=th/2, h=sx, center = true);

   for(x=[0:10/n:sx], y=[0:10/n:sy] ) // z bars
     translate([sx/2-x, sy/2-y])
     cylinder(r=th/2, h=sz, center = true);
}



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




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

Re: Lattice structure

cacb
In reply to this post by Parkinbot
On 24. mars 2017 13:07, Parkinbot wrote:
> That is exactly the point. Anything beyond linear_extruding a 2d object, is
> exactly where the problem starts. Try to render (F6) the following small
> piece - about 6 minutes on my machine. Then just multiply any dimension sx,
> sy, or sz by just 2 and watch how render time grows.
> <http://forum.openscad.org/file/n21013/lattice.png>

I tried your code on my new Linux machine using 2015.03-1 and found it
(F6) completed in 2 minutes and 48 seconds. I also translated your
OpenSCAD code into AngelScript and ran it through my Carve based boolean
engine on the same computer. It completed in 23 seconds, with a result
that looks similar to openSCAD.

Elsewhere, doug moen mentions that "This issue (complex lattices vs
boolean operations) is a limitation in the design of OpenSCAD."

One could argue that it is probably not so much a limitation in the
design of OpenSCAD but perhaps more a question of the characteristics of
the boolean engines (CGAL vs. Carve).

One thing I found was that creating subgroups (spheres+ybars, xbars,
zbars) was helpful in speeding things up in my code. I am guessing it is
because of bounding box checks.

As mentioned before, I am going to release my carve based engine on
github when I get around to it (need to learn git as well).

Carsten Arnholm

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

lattice_openscad.png (85K) Download Attachment
lattice_angelcad.png (87K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

Ronaldo
In reply to this post by s.dwivedi
s.dwivedi wrote
this seems to work absolutely fine however I am not able to grasp the programming bit, could you be more elaborate

from what I have understood , you define a certain latice in 2d followed by extrusion command , can you explain afterwards ?

also can we do same with a circular mesh structure
In my last code, the for is responsible to generate the array of squares corresponding to the holes of the latice. Subtracting this array from a rectangle with the latice dimensions give us a 2D section of the latice. The linear_extrude makes it emerge to the 3D world.

To have a latice with a shape that is no longer a rectange, it is just a question of changing the square([sx,sy]) by another 2D polygon like a circle for instance. You may try using

translate([sx,sy]/2) scale([sx,sy]/2)  circle(1,$fn=16);

instead of square([sx,sy]) . This will give you a planar latice anyway.

If your latice has to be deformed, let's say, to a spherical shape, this code is not useful anymore because there is no way to apply non-linear transforms to an OpenSCAD object. In this last case, the only way I know is to define the latice (or its holes, to be precise) as a lazzy union of (deformed) polyhedra, as Parkinbot and doug moen pointed out.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

doug.moen
In reply to this post by cacb
Well, I think that even 23 seconds is a long time for such a trivial construction. It really ought to be a fraction of a second. Suppose you wanted a 100x100x100 grid, instead of 2x4x6? With linear scaling, that would be more than 7 days of rendering, but union scales non-linearly in OpenSCAD, and probably in Carv as well.

On 24 March 2017 at 15:40, Carsten Arnholm <[hidden email]> wrote:
On 24. mars 2017 13:07, Parkinbot wrote:
That is exactly the point. Anything beyond linear_extruding a 2d object, is
exactly where the problem starts. Try to render (F6) the following small
piece - about 6 minutes on my machine. Then just multiply any dimension sx,
sy, or sz by just 2 and watch how render time grows.
<http://forum.openscad.org/file/n21013/lattice.png>

I tried your code on my new Linux machine using 2015.03-1 and found it (F6) completed in 2 minutes and 48 seconds. I also translated your OpenSCAD code into AngelScript and ran it through my Carve based boolean engine on the same computer. It completed in 23 seconds, with a result that looks similar to openSCAD.

Elsewhere, doug moen mentions that "This issue (complex lattices vs boolean operations) is a limitation in the design of OpenSCAD."

One could argue that it is probably not so much a limitation in the design of OpenSCAD but perhaps more a question of the characteristics of the boolean engines (CGAL vs. Carve).

One thing I found was that creating subgroups (spheres+ybars, xbars, zbars) was helpful in speeding things up in my code. I am guessing it is because of bounding box checks.

As mentioned before, I am going to release my carve based engine on github when I get around to it (need to learn git as well).

Carsten Arnholm

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



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

Re: Lattice structure

MichaelAtOz
Administrator
It's all in the facets

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
|  
Report Content as Inappropriate

Re: Lattice structure

s.dwivedi
In reply to this post by Ronaldo
this explains it very clearly , the code seems to work fine.While extruding it followed by rendering the final object it takes a few minutes.Open SCAD does offer a good environment to perform a range of operations.

Prior to the start of my work while doing initial research I came across an article that describes possibility of generating so called  'Selective space structures' , that enables to generate these reticulated mesh arrays , I believe it involves complex algorithm designs but nonetheless OpenScad works fine


http://www.georgehart.com/rp/10-3.html


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lattice structure

cacb
In reply to this post by doug.moen
On 2017-03-25 00:54, doug moen wrote:
> Well, I think that even 23 seconds is a long time for such a trivial
> construction. It really ought to be a fraction of a second.

Of course one wants everything at no cost, but that is not going to
happen. It is better to evaluate what the main factors are and what
realistically can be achieved. The number of facets is obviously one
major factor, but it isn't the only answer.

My little example showed it is possible to improve ~an order of
magnitude just by using another boolean engine. There are also other
paths to pursue, such as multi-threaded processing, which I will try at
some stage. The numbers I gave were just snapshots of current working
implementations for comparison, both single threaded.

Another thing I tried was observing memory use. I factored the
dimensions up by 2 and watched memory use. For this relatively small
model, OpenSCAD/CGAL required more than 6GB of ram (64bit), which seems
hard to justify. That alone is a major performance issue. My Carve-based
engine was never higher than 400MB ram for the same problem, so you are
looking at an order of magnitude difference there.

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
|  
Report Content as Inappropriate

Re: Lattice structure

nophead
So is there anything that would prevent CGAL being replaced by Carve? Does it miss some features?

I don't think it would be too hard to speed up CGAL by many orders of magnitude that may be naive. It obviously does make any attempt to skip the facets that need no modification in a union, which is often all of them.

On 25 March 2017 at 11:14, <[hidden email]> wrote:
On 2017-03-25 00:54, doug moen wrote:
Well, I think that even 23 seconds is a long time for such a trivial
construction. It really ought to be a fraction of a second.

Of course one wants everything at no cost, but that is not going to happen. It is better to evaluate what the main factors are and what realistically can be achieved. The number of facets is obviously one major factor, but it isn't the only answer.

My little example showed it is possible to improve ~an order of magnitude just by using another boolean engine. There are also other paths to pursue, such as multi-threaded processing, which I will try at some stage. The numbers I gave were just snapshots of current working implementations for comparison, both single threaded.

Another thing I tried was observing memory use. I factored the dimensions up by 2 and watched memory use. For this relatively small model, OpenSCAD/CGAL required more than 6GB of ram (64bit), which seems hard to justify. That alone is a major performance issue. My Carve-based engine was never higher than 400MB ram for the same problem, so you are looking at an order of magnitude difference there.

Carsten Arnholm

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


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

Re: Lattice structure

nophead
Sorry typed the opposite of what I meant.


I don't think it would be too hard to speed up CGAL by many orders of magnitude, but that may be naive. It obviously doesn't make any attempt to skip the facets that need no modification in a union, which is often all of them.

On 25 March 2017 at 12:25, nop head <[hidden email]> wrote:
So is there anything that would prevent CGAL being replaced by Carve? Does it miss some features?

I don't think it would be too hard to speed up CGAL by many orders of magnitude that may be naive. It obviously does make any attempt to skip the facets that need no modification in a union, which is often all of them.

On 25 March 2017 at 11:14, <[hidden email]> wrote:
On 2017-03-25 00:54, doug moen wrote:
Well, I think that even 23 seconds is a long time for such a trivial
construction. It really ought to be a fraction of a second.

Of course one wants everything at no cost, but that is not going to happen. It is better to evaluate what the main factors are and what realistically can be achieved. The number of facets is obviously one major factor, but it isn't the only answer.

My little example showed it is possible to improve ~an order of magnitude just by using another boolean engine. There are also other paths to pursue, such as multi-threaded processing, which I will try at some stage. The numbers I gave were just snapshots of current working implementations for comparison, both single threaded.

Another thing I tried was observing memory use. I factored the dimensions up by 2 and watched memory use. For this relatively small model, OpenSCAD/CGAL required more than 6GB of ram (64bit), which seems hard to justify. That alone is a major performance issue. My Carve-based engine was never higher than 400MB ram for the same problem, so you are looking at an order of magnitude difference there.

Carsten Arnholm

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



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

Re: Lattice structure

cacb
In reply to this post by nophead
On 2017-03-25 13:25, nop head wrote:
> So is there anything that would prevent CGAL being replaced by Carve?
> Does it miss some features?

Well, esoteric features (IMHO) like Minkowski is not there, so if you
consider it essential it will need an independent implementation. It is
a 3d boolean engine, you still need e.g. Clipper for 2d.

Carsten Arnholm

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