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!
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

surface flattening

Post by looo »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: surface flattening

Post by microelly2 »

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. :)
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Post by looo »

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.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Post by looo »

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

Re: surface flattening

Post by triplus »

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. ;)
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Post by looo »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: surface flattening

Post by triplus »

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?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Post by looo »

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 7937 times
constraints.png
constraints.png (60.25 KiB) Viewed 7937 times
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: surface flattening

Post by ickby »

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.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Post by looo »

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.
Post Reply