5

I have been trying to render a complex set of points into a 3d visualization. I have a set of layers, each with a number of polygons, each polygon with a varying number of points.

I've toyed a great deal of .NET libraries (wrappers for OpenGL, DirectX, and others), and ultimately arrived at the super simple WPF 3D control with Helix Toolkit just to render a 3d point cloud visualization. My super simple code looks like this:

private void Render3D(List<Layer> layers) {
  var layerIndex = 0;
  var pts = new Point3DCollection();

  foreach (var layer in layers) {
    foreach (var shape in layer.Shapes) {
      foreach (var point in shape.Points) {
        pts.Add(new Point3D(point.Item1, point.Item2, layerIndex * .5));
      }
    }
    layerIndex++;
  }

  var vis = new PointsVisual3D() { Points = pts };
  _viewport.Children.Add(vis);
}

My XAML is as follows:

<Window xmlns:h="http://helix-toolkit.org/wpf">
  <h:HelixViewport3D Name="_viewport">
    <h:SunLight />
  </h:HelixViewport3D>
</Window>

The result of this code, along with my arranged data is as follows:

enter image description here

This is great, and I was tremendously excited to actually see my data in 3D, but I would like to go further and start actually rendering solid shapes from my point data, sort of like this:

enter image description here

I'm using .NET and would appreciate sticking to this platform if possible, but I'm open to other ideas. Hopefully this is agnostic enough to get a pointed answer.

Daniel
  • 10,864
  • 22
  • 84
  • 115
  • you got volumetric data or just the surface points?some sample would be a good idea to share (does not have to be big just a part ) idealy in ASCII format so anyone can read it without problems or need of some lib – Spektre Mar 23 '17 at 09:17
  • @Spektre I have surface points only -- no volumetric data. I don't have data handy but I can put some online after work. Each is just a set of x,y coordinates. The z-coordinate is contrived by multiplying a constant by the index of the layer. I would be happy with a dumbed-down version though, maybe even just of a cube or tetrahedron from a set of points. – Daniel Mar 23 '17 at 12:16
  • 1
    No you need to have a valid sample so some part of your shape would suffice (even cut). The point on this is create point topology maping the neighbors to some `u,v` coordinates (grid) and then just do a triangle strip slices ... as you got `z` coordinate alligned directly to grid then you need to just process 2 slices at a time something like this: [How can I connect two parallel 2d polygons to create a seamless 3d mesh?](http://stackoverflow.com/a/25076849/2521214) but I suspect your data have isotropic point density like most scanners do so there may be even simpler solution for this ... – Spektre Mar 23 '17 at 13:53
  • 1
    As far as I understand, your points represent samples of a surface. If that is the case, what you want to do is called surface reconstruction, which is an entire research area. Just pick a reconstruction method that fits your scenario and data. E.g. Poisson Surface Reconstruction is very widely used (but it requires surface normals). Or if they don't represent surface samples and you just want to visualize them as some kind of tubes or balls, check out [Metaballs](https://en.wikipedia.org/wiki/Metaballs). – Nico Schertler Mar 23 '17 at 17:16

1 Answers1

4

It really depends on the point data set you have. A robust method for reconstruction is ths Marching cubes (or marching tetras) algorithm. But if your data set is already organized, in the form of layers apparently like bellow i guess. enter image description here

Then some simpler methods could be used. I would proceed like so in this case : - Start by ordering your layers. - create a "for" loop that goes two layers by two layers :

Mesh MyMesh = new Mesh();
for (int i = 0; i< layers.Count -1; i++)
{
 Expand(layers[i+1]);
 Dictionary<int[],Point[]> localMesh = project(layers[i], layers[i+1]
 MyMesh.AddTriangles( Delaunay2D(localMesh));
}

The expand fonction just sparse your data points in perpendicularily to the layer normal. (to avoid overlaping point between two layers) the project function project the points of two consecutive layers in the same plane so that Delaunay triangulation can be perform. The dictionary allows you to keep track of point indices between projected ones and "real ones". Finaly use the Delaunay algorithm to create triangle (and use the dictionary to get the "real" coordinates from indices).

The loop can be very short and computation time fairly short with a little bit of code improvement.

Hope that helps somebody.

L Chougrani
  • 588
  • 4
  • 7