Triangulate a surface with vtk from points AND normals - mesh

I have a set of points in 3D that lie on a surface and I also have the normals at every point.
I would like to generate a surface triangulation with this information. In addition I could tell the algorithm to use what points lie on the boundary if that is needed.
So, I have quite a bit of information:
* points
* normals
* boundary
How do I triangulate a surface with this information using vtk?
A surface reconstruction algorithm is like using a bomb for this problem since I have all this information that I would like to use. This information comes from a simulation so I know the surface exists and that is quite smooth.
I would like the answer to be cast in terms of either what vtk function to use and if available (and that would be great) examples using this function.
Thank you so much in advance.

You can use the vtkSurfaceReconstruction filter to create a surface from a set of 3D points.

You could try the point cloud library
Point Cloud Library

Just the 3D points would be good enough. Since you know that your surface is smooth, you can perform a Delaunay triangulation of the points (vtkDelaunay3D) and apply a subdivision filter for smoothening (vtkButterflySubdivisionFilter).
Delaunay3D triangulation

Related

2D shape detection in 3D pointcloud

I'm working on a project to detect the position and orientation of a paper plane.
To collect the data, I'm using an Intel Realsense D435, which gives me accurate, clean depth data to work with.
Now I arrived at the problem of detecting the 2D paper plane silhouette from the 3D point cloud data.
Here is an example of the data (I put the plane on a stick for testing, this will not be in the final implementation):
https://i.stack.imgur.com/EHaEr.gif
Basically, I have:
A 3D point cloud with points on the plane
A 2D shape of the plane
I would like to calculate what rotations/translations are needed to align the 2D shape to the 3D point cloud as accurate as possible.
I've searched online, but couldn't find a good way to do it. One way would be to use Iterative Closest Point (ICP) to first take a calibration pointcloud of the plane in a known orientation, and align it with the current orientation. But from what I've heard, ICP doesn't perform well if the pointclouds aren't kind of already closely aligned at the start.
Any help is appreciated! Coding language doesn't matter.
Does your 3d point cloud have outliers? How many in what way?
How did you use ICP exactly?
One way would be using ICP, with a hand-crafted initial guess using
pcl::transformPointCloud (*cloud_in, *cloud_icp, transformation_matrix);
(to mitigate the problem that ICP needs to be close to work.)
What you actually want is the plane-model that describes the position and orientation of your point-cloud right?
A good estimator of your underlying function can be found with: pcl::ransac
pcl::ransace model consensus
You can then get the computedModel coefficents.
Now finding the correct transformation is just: How to calculate transformation matrix from one plane to another?

Inverted faces in surface mesh produced by Polygonal Surface Reconstruction

I'm trying to use Polygonal Surface Reconstruction with building point cloud to create simplified building models.
I did first tests with this CGAL code example and got first promising results.
As an example, I used this point cloud with vertex normals correctly oriented and got the following result from PSR. Some faces are clearly inverted (dark faces with normals pointing inside the watertight mesh and therefore not visible).
I was wondering if there a way to fix this face orientation error. I've noticed orientation methods on Polygon mesh but I don't really know to apply them to the resulting PSR surface mesh. As far as logic is concerned making normal point outwards should not be too complicated I guess.
Thanks in advance for any help
You can use the function reverse_face_orientations in the Polygon mesh processing package.
Note that this package has several functions that can help you to correct/modify your mesh.

3d surface triangulation of an open surface with CGAL

I'm a newbie to CGAL library. However, I think it's a very suitable package for what I want to do.
I have a set of points representing a 3D surface (as shown in figure 1).
I want to fit a 3d triangulation on this surface. The surface is not closed and therefore does not occupy a volume. The code provided in poisson_reconstruction_example.cpp seems appropriate for this job. But the problem is that as a part of poisson_reconstruction algorithm it closes the ends and underneath of the surface to make it a volume (see figure2).
I was wondering:
1- Is there a way to do the triangulation on the surface just defined by the points, without getting a closed surface which encloses a finite volume?
This means that the final triangulation has boundary edges.
I'm happy with any Upsampling or smoothing which may be needed.
2- If the answer to the first question is no, then, is there any way to guarantee that the input points are the vertices of the generated triangles?
The poisson surface reconstruction generates a close surface that interpolates the point cloud given as input. It requires as input a point set with normals.
If you need a algorithm that only uses input points in the output, you can try the Advancing Front Surface Reconstruction algorithm.

CGAL 3D surface mesh generation for unbounded implicit surfaces

This is again a question about the CGAL 3D surface mesher.
http://doc.cgal.org/latest/Surface_mesher/index.html#Chapter_3D_Surface_Mesh_Generation
With the definition
Surface_3 surface(sphere_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 64.0)); // bounding sphere
(as given too in the example code) I define an implicit surface given by 'sphere function' and a Sphere_3 of radius 8.
The difference is now, that the zeros of 'sphere function' are (contrary to its now misleading name) no longer bounded and inside Sphere_3. Instead 'sphere_function' represents an unbounded surface (think of x^2 + y^2 - z^2 - 1 = 0) and my intention is to triangularize its part that is in the Sphere_3.
In my examples up to now this worked quite well, if only for some annoying problem, I do not know how to overcome: The boundaries, where the implicit surface meets the Sphere, are very "rough" or "jagged" in a more than acceptable amount.
I already tried the 'Manifold_with_boundary_tag()', but it gave no improvements.
One road to improve the output that I am contemplating, is converting the triangulated mesh (a C2t3) into a Polyhedron_3 and this in a Nef_polyhedron and intersect that with a Nef_polyhedron well approximating a slightly smaller Sphere. But this seems a bit like shooting with cannons for sparrows, nevertheless I have currently no better idea and googling gave me also no hint. So my question: What to do about this problem? Can it be done with CGAL (and moderate programming effort) or is it necessary or better to use another system?
(Just for explanation for what I need this: I try to develop a program that constructs 3D-printable models of algebraic surfaces and having a smooth and also in the boundaries smooth triangulation is my last step that is missing before I can hand the surface over to OpenSCAD to generate a solid body of constant thickness).
The only solution I see is to use the 3D Mesh Generation with sharp feature preservation and no criteria on the cells. You will have to provide the intersection of the bounding sphere with the surface yourself.
There is one example with two intersecting spheres in the user manual.

How to get one non-manifod mesh with adaptive point distribution

all
I try to obtain one triangle mesh from one point cloud. The mesh is expected to be manifold, the triangles are well shaped or equilateral and the distribution of the points are adaptive in terms of the curvature.
There are valuable information provided on this website.
robust algorithm for surface reconstruction from 3D point cloud?
Mesh generation from points with x, y and z coordinates
I try Poisson reconstruction algorithm, but the triangles are not well shaped.
So I need to improve the quality of the triangles. I learn that centroidal voronoi tessellation(CVT) can achieve that, but I don't know whether the operation will introduce non-manifold vertices and self-intersection. I hope to get some information about it from you.
The mesh from the following post looks pretty good.
How to fill polygon with points regularly?
Delaunay refinement algorithm is used. Can delaunay refinement algorithm apply to triangle mesh directly? Do I first need to delaunay triangulation of the point cloud of the mesh, and then use the information from delaunay triangulation to perform delaunay refinement?
Thanks.
Regards
Jogging
I created the image in the mentioned post: You can insert all points into a Delaunay triangulation and then create a Zone object (area) consisting of these triangles. Then you call refine(pZone,...) to get a quality mesh. Other options are to create the Zone from constraint edges or as the result of a boolean operation. However, this library is made for 2D and 2.5D. The 3D version will not be released before 2014.
Do you know the BallPivoting approach?