surface flattening

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

surface flattening

Postby looo » Sun Oct 16, 2016 8:47 pm

I think FreeCAD doesn't provide any surface flattening algorythm right now. As we need this for OpenGlider and it could be useful for FreeCAD too I wanted to start a small topic about it. My plan is to use a triangle mesh, map it to 2d with lscm[1] and let the deformed mesh relax with a finite element method [2]. I think it is done similarly in commercial programs [3].

If anyone has an idea/input on this topic I would be very pleased to hear it.

[1] http://www.cs.jhu.edu/~misha/Fall09/Levy02.pdf
[2] http://waset.org/publications/7534/surf ... ent-method
[3] https://www.youtube.com/watch?v=5shBx6Nj8II
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: surface flattening

Postby microelly2 » Mon Oct 17, 2016 4:41 am

good idea, i think it's time to have such tools.
I have to read the paper about lscm.
My idea was to analyse the curvature of a face and find the best places to cut and unroll,maybe it results into the same. :)
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Mon Oct 17, 2016 8:38 am

segmentation is another problem. it is covered in the lscm-paper shortly. But for sure automatic segmentation would be nice to have too.
lscm simply try to find a coresponding 2d map which minimize the angle difference of all triangles. this can be done by ls-solve one linear system.
the fem step is needed to minimize the internal work. so solution should represent the optimal unwrapped surface. in case the surface is developeable (eg cylinder, cone, oloid...) the solution should be the exact flatted surface.
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Thu Oct 20, 2016 10:16 pm

lscm is working :)
unwrapped_oloid.png
unwrapped_oloid.png (113.67 KiB) Viewed 4126 times
triplus
Posts: 8456
Joined: Mon Dec 12, 2011 4:45 pm

Re: surface flattening

Postby triplus » Thu Oct 20, 2016 11:13 pm

Such tool would likely be useful when forming a piece of metal to get basic material without much waste involved.

P.S. But said that its nice to see on how solid can be turned into surface and now going further to flatten that surface. But its hard to get excited about it if the final destination of such tools isn't for example Reverse Engineering WB. ;)
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Fri Oct 21, 2016 6:14 am

as I have already said we will use this in openglider too. so it will be a c++ shared library + python bindings... writing a interface to freecad shouldn't be that hard. But it makes no sense including it directly in freecad.
triplus
Posts: 8456
Joined: Mon Dec 12, 2011 4:45 pm

Re: surface flattening

Postby triplus » Fri Oct 21, 2016 1:02 pm

looo wrote:But it makes no sense including it directly in freecad.
Tools like selecting a face of the 3D model and convert it to the BSpline surface. Or to do the same and after flatten the surface (done in C++ with Python bindings)?

P.S. Where did we go wrong?
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Sat Oct 22, 2016 9:05 pm

I only thought about the need to have this in two different libraries. And I think it is most useful if the unwrapping is provided by a own library.

The fem step is more difficult then I thought. Somehow the mesh has to be fixed. But this is very difficult as it will influence the solution. Constraining one point is ok, but then the solution will rotate about this point.
double_curvature.png
double_curvature.png (115.42 KiB) Viewed 3953 times
constraints.png
constraints.png (60.25 KiB) Viewed 3953 times
ickby
Posts: 2906
Joined: Wed Oct 05, 2011 7:36 am

Re: surface flattening

Postby ickby » Sun Oct 23, 2016 7:19 am

Typically this problem is solved by using a krylov type solver and removing the nullspace from the solution. In this case all translation and rotations. This makes the matrix regular and hence the system solvable without influencing the solution.
looo
Posts: 2664
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Sun Oct 23, 2016 9:51 am

thanks for the hint. I will look if eigen does provide such a solver.
right now i am using sparse cg method which is quite fast on the symmetric matrix. I think there should be also the possibility to rotate the mesh so that one triangle edge align to y=0 and then fix one point of the edge and y of the other point of the edge. I will have a look what's the nicer solution.
Last edited by looo on Sun Oct 23, 2016 4:53 pm, edited 1 time in total.