Signed Cloud to mesh distance

Feel free to ask any question here
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Signed Cloud to mesh distance

Post by olivier.martin »

Hello all,

I do not understand exactly how the signed distance work when computing a cloud to mesh distance.

I have imported a tree mesh in .obj format in cloud compare. This mesh is the "hull" of a tree crown (i.e the part of the tree with leaves and branches). Then, I have imported the point cloud of the same tree two years later and I tried to make a cloud to mesh distance in order to quanrtify the growth of the tree. The resulting distances make sense and seems to be good. However I expected that the sign of the distances should be different inside and outside of the mesh but it is not the case. There are just few points showing a negative distance inside the crown but most of the points are positive inside and outside of the mesh.

Thus, I was wondering how the signed distance are computed and if there is a way to know if a point is inside or outside of the volume made by the mesh ?
I can provide images and data if it could help understand and solve my problem...

Thanks a lot
Regards

Olivier
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Signed Cloud to mesh distance

Post by daniel »

Indeed, images and/or data would help me ;)

Are the mesh triangles correctly oriented? Because the sign is deduced from the order of the vertices of the nearest triangle (assuming the vertices are in the so called 'direct' mode).
Daniel, CloudCompare admin
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Re: Signed Cloud to mesh distance

Post by olivier.martin »

Image 1 : Mesh of the tree crown at t0, and point cloud at t1 (black points we can see around the mesh)

Image


Image 2 : Point cloud at t1. The color gradients is for the distance to the mesh computed with C2M, from blue (negative) to red (positive).

Image

You are probably right, it should be a problem with the orientation of the triangles as some triangles are green and others are blue (Image 1). I don't know how to solve this problem. So, as you can see on the image 2 the sign of the distance are not right (not what I expected), points in the middle of the crown should be blue and those at the periphery red (or the contrary)

In order to check if its come from my mesh, I tried to compute a poison surface with cloudcompare using the vertex of my alpha-shape mesh and C2M gives good result (image 3 and 4)... However this mesh is not good enough to me (too "loose").

Image 3 : Poison surface made using vertex of my alpha-shape mesh of the tree crown at t0, and point cloud at t1.

Image

Image 4 : Point cloud at t1. The color gradients is for the distance to the mesh (poison surface) computed with C2M, from blue (negative) to red (positive). Here the color made sense, negative points (the most blue) are the points external to the mesh, and positive points (the most red) are inside the mesh.

Image

Do you think that the problem indeed come from the orientation of triangles ? If yes, I need to re-orient the triangles but I don't know how, what do you mean by vertices are in the 'direct' mode ?


I also give to you the data if it could help you answer my question :
- My mesh of the tree at t0 : https://www.dropbox.com/s/39hir2w2e3bht ... 3.obj?dl=0
- The point cloud of the vertices of my mesh : https://www.dropbox.com/s/1zkvlbob7i21n ... 3.txt?dl=0
- The point cloud at t1 : https://www.dropbox.com/s/fua91g90r6nw8 ... 5.txt?dl=0

Thanks a lot for your help

Olivier
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Signed Cloud to mesh distance

Post by daniel »

Indeed, this mesh is really strange. Some faces are inverted (the blue ones) and you also have those tubular structures that border the main faces:
strange_mesh.jpg
strange_mesh.jpg (73.39 KiB) Viewed 5862 times
Luckily the triangles and segments are separated (see the 'triangles17' and 'segments18' sub-meshes). At least we can isolate them.

From there I sampled points on the triangles only (Edit > Mesh > Sample points) and I re-oriented the normals properly (Edit > Normals > Orient > With Minimum Spanning Tree). If the output normals are globally inverted, simply invert them (Edit > Normals > Invert):
clean_normals.jpg
clean_normals.jpg (22.79 KiB) Viewed 5862 times
You can eventually use this cloud with the qPoissonRecon plugin:
clean_poisson.jpg
clean_poisson.jpg (15.53 KiB) Viewed 5862 times
And use the resulting mesh to compute the distances:
clean_distances.jpg
clean_distances.jpg (114.6 KiB) Viewed 5862 times
You can download my project file from here: https://drive.google.com/folderview?id= ... sp=sharing (you'll need the latest 2.6.3 beta version to update it).
Daniel, CloudCompare admin
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Re: Signed Cloud to mesh distance

Post by olivier.martin »

Hello Daniel,

Thanks a lot. Your method works well. I was wondering if there is a way to do the re-orientation of the nomals and run the qpoisonRecon plugin in command line mode ? I want to do this method in batch but I did'nt find the command line for these two steps in the wiki...

Olivier
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Signed Cloud to mesh distance

Post by daniel »

Nope. You could do the re-orientation (if we add the option) but PoissonRecon is a plugin and plugins can't be called in command line mode.

However, the author of PoissonRecon (Misha Kazhdan) does provide a separate tool that you could use in your command line mode (http://www.cs.jhu.edu/~misha/Code/Poiss ... ersion8.0/). I can add the normal reorientation option to the command line in the TODO list if you wish.
Daniel, CloudCompare admin
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Re: Signed Cloud to mesh distance

Post by olivier.martin »

Ok, thanks. Yes it could be nice to use re-orientation in command line mode.

Olivier
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Signed Cloud to mesh distance

Post by daniel »

Okay I've added a new option to the command line tool: '-ORIENT_NORMS_MST [number of neighbors]'.

You can test it with the 2.6.3 beta version (already online).

P.S.: are all your canopy meshes composed of the 3 sets (faces / segments / points)? Have you figured out how to load only the faces?
Daniel, CloudCompare admin
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Re: Signed Cloud to mesh distance

Post by olivier.martin »

Thanks.
I didn't export all my meshes yet, but the format will be exactly the same with 3 sets for sure. I didn't find the way to load only the faces with cloudcompare. I'll working on the function that export my mesh in R to try to have only the faces ... or maybe try to find other functions.
olivier.martin
Posts: 16
Joined: Wed Apr 29, 2015 10:24 pm
Location: Québec, Canada

Re: Signed Cloud to mesh distance

Post by olivier.martin »

I found a way to export only the triangles of my meshes. But, the problem with the triangles orientation still persist. So I kept your method of i) sampled points on faces ii) re-orientation of the normals (spanning tree) and iii) made another mesh with PoisonSurface. However, on certain meshes (quite "accurate" or "rough" meshes) the normals are not well oriented on all faces and the resulting mesh do not correspond to the initial one. I tried to play with the parameter of normal orientation (neighbors) but it doesn't really change the results. See pictures for an example.

My mesh:

Image

The poison mesh after reorientation of the normals on the sampled point :

Image


Any idea to obtain a better mesh ?

Thanks in advance

Olivier

PS: here the mesh in .obj of the example : https://www.dropbox.com/s/bikpf6s3jef82 ... 4.obj?dl=0
Post Reply