How can I "fill in" a convex hull with points in PCL (C++) - point-cloud-library

I have a pointcloud of a plane (which I extracted using RANSAC).
But it has some holes here and there and also the edges aren't so smooth.
So I thought maybe I could first get a Convex hull of the pointcloud and then somehow fill in the convex hull with points to get a perfectly filled plane.
I made the convex hull like this and checked that it works well.
chull.setInputCloud(in_cloud);
chull.setDimension(2);
chull.reconstruct(*out_cloud);
The hull is in the shape I want it to be and it would be perfect if the inside were just filled in with points.
Does anyone know how I would be able to do it?
In case this isn't possible (or is very inefficient) here are the ways I thought of that could lead to my wanted results
(This is the way I wrote about above.) Find the convex hull of a plane, fill the inside of it with points.
Create a plane of points using the coefficients of the plane I got through RANSAC. Cropout the points that are inside the convex hull using the CropHull function.
Forget about Convex hulls, and just find a way to fill in holes in the original pointcloud of the plane.
Any related help would be much appreciated!
Thanks!

Related

Clipping and triangulating a triangle with a non convex polygon

I'm starting with a single 2D triangle that I want to clip with a (potentially) convex 2D polygon. It's not self-intersecting, but may 'keep' or 'discard' the intersecting area based on the winding order.
I want to end up with a triangulation, i.e. a list of n vertices and m triangles, defined by 3 vertices each, of the clipped region in 2D space.
What would be the easiest (for me as a developer), and what the fastest (in terms of computation) way to achieve this?
If I a right, you want to clip inside the polygon, i.e. get the intersection between the triangle and the polygon.
As the triangle is a convex shape, the Sutherland-Hodgman algorithm is appropriate and no too difficult to implement (https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm).
Notice that if the intersection is not simply connected, the resulting polygon will be connected, with double edges joining the would-be parts. Some cleanup might be required.
After finding the intersection, you re-triangulate using the ear-clipping method or a more efficient one (https://en.wikipedia.org/wiki/Polygon_triangulation).
Alternatively, you can triangulate the polygon and perform the clipping of every triangle with the original one.
The triangle-triangle clipping problem is again solved with Sutherland-Hodgman, somewhat simplified as the input polygons have a constant size, and their intersection is convex and at worse an hexagon. Trigulation of a convex polygon is immediate.

make polygons from points extracted by concave hull

I would like to make a file including polygon or lines from boundary points extracted from point cloud by concave hull method as shown in below page.
http://ait-survey.com/wp-content/uploads/2015/08/concave_hull_polygon1.png
Boundary points are 3D coordinates.
Also I would like to make polygon file import in AutoCAD.
Let me know how to make it.
That's a interesting problem. I would start with:
Identify the outer circle around the points, as shown here: http://through-the-interface.typepad.com/through_the_interface/2011/02/creating-the-smallest-possible-circle-around-2d-autocad-geometry-using-net.html
Run through the circle degrees (0 to 2PI), find the closest point. That should give you the order of the points, counter-clockwise.
Draw the polyline
I do not have a code 'ready-to-use'... may have some time late this week. But what do you think about the approach?

Subtraction and addition of convex polygons

I have two 2D convex polygons. I want to
subtract one from the other one and
add one to the other one
The resulting polygon must be either concave or a - better - a set of convex polygons (e.g. triangles).
Do you have any idea how I can accomplish this?

Determining the cut of any given polygon and pyramid

I am trying to implement in C++ a function that determines the cut of any given polygon and pyramid.
This has actually turned out to be far simpler than I had first imagined.
Firstly for each edge of the pyramid, test line-plane intersection (the given polygon is a plane, made up of 3 points). This will result in the new vertices at the cutting plane.
Secondly, since the polygon is not an infinite plane one needs to test for line-line intersection between the polygon edges (three) and each of the edges.
Indeed, this is not a simple problem. For simplicity, let's assume that there are no parallel line segments.
First determine the plane where your convex polygon is in. Then detemerine the intersection of that plane with the pyramid. This results in a second convex polygon.
Now you should find the intersection of the two convex polygons. How this can be done, you can find here.

Voronoi diagram using custom (great circle) distance

I want to create a Voronoi diagram on several pairs of
latitudes/longitudes, but want to use the great circle distance
between them, not the (inaccurate) Pythagorean distance.
Can I make qhull/qvoronoi or some other Linux program do this?
I considered mapping the points to 3D, having qvoronoi create a 3D
Voronoi diagram[1], and intersecting the result with the unit sphere, but
I'm not sure that's easy.
[1] I realize the 3D distance between two latitudes/longitudes (the
"through the Earth" path) isn't the same as the great circle distance,
but it's easy to prove that this transformation preserves relative
distances, which is all that matters for a Voronoi diagram.
I assume you've found this article. From that, it seems like you have the right idea by using a 3D embedding. Your question is then how to intersect the result with the sphere.
First of all you need to consider how you're going to represent the voronoi diagram. If you want to work in lat/long coordinates in a 2D plane, then your voronoi diagram will contain curved edges, so maybe it is best to just use a 3D representation.
If you use a program like qvoronoi, you should in theory only need the inifinite hyperplane data (generated by Fo). This gives you the equation of the plane and the two points it corresponds to. Usually you only need to use the voronoi diagram to test for inclusion within regions, and the hyperplanes should be enough for that.
See also this question: Algorithm to compute a Voronoi diagram on a sphere?

Resources