gradientspace / geometry3Sharp

C# library for 2D/3D geometric computation, mesh algorithms, and so on. Boost license.
http://www.gradientspace.com
Boost Software License 1.0
1.71k stars 384 forks source link

Create mesh/triangles from 3D point cloud #141

Open flycast opened 4 years ago

flycast commented 4 years ago

I have a set of 3D points. I need to convert them into a triangulation/mesh. I may be a little confused here about my terminology. I see you fort tutorial where you cover the meshBuilder. It looks like I need to give a set or points and a set of triangles that have already been built. I do not have triangles. How do I build a set of triangles (Delauney) from the points?

FloP93 commented 4 years ago

I am also pretty new to it but as far as i understand it, the Triangles are just indices who tell the mesh, which 3 Points in your List belong to one Triangle (via Indexes). They are saved in a List. For example you have 9 points in your point cloud list. The way i built my Triangles was with a simple for loop:

List<Index3i> triangleList = new List<Index3i>();
for (int i = 0; i < pointCloud.Count - 2; i += 3)
{
    Index3i tempTriangle;
    tempTriangle = new Index3i(i, i + 1, i + 2);
    triangleList.Add(tempTriangle);
}

But again, i am also quite new to this, but this works for me, as my Points are ordered correctly in the list. I hope this gives you at least some kind of understanding which might help with your porblem

flycast commented 4 years ago

@FloP93 - Thanks for that. The big issue is what vertices belong together. That is the major part of the problem I need to solve. It seems the best way to solve that is using the Delaunay algorithm. I don't seem to find anything free that does this in 3D (as far as I can tell). I don't mind paying for a library that does this once I prove the concept I am working on. Matlab and some others promise this.

petrasvestartas commented 4 years ago

You can use Poisson Surface reconstruction as a Command Line interface. But you need to find a way to compute normals.

rms80 commented 4 years ago

you could try http://www.gradientspace.com/tutorials/2018/9/14/point-set-fast-winding if you are adventurous. Poisson Reconstruction probably works more reliably though.

To estimate normals you could use a PointAABBTree3 TreeTraversal to find k-nearest-neighbours, and then OrthogonalPlaneFit3 to fit a plane, that gives you a normal. They aren't necessarily consistent though, so then you need to do some kind of propagation to try to get them pointing in the same direction locally.

(this is all I can help with, good luck)

petrasvestartas commented 3 years ago

Does it mean that tutorial of fast point windingsworks only with pointclouds that have normals? I am talking about lion sculpture