1)
The Ab3d.PowerToys library does not provide an efficient way to show point clouds. It would be possible to show each position in a point cloud as a 3D box or a 3D sphere but this would be very inefficient.
To show a point cloud in a much more efficient way you should use Ab3d.DXEngine library that can render may 3D positions are pixels with custom size and color. This is done by using a PixelVisual3D object that can render millions of 3D positions (on a decent graphics card).
See an example:
[Image:
https://www.ab4d.com/images/DXEngineGall...Engine.png]
You can also control the size and color of individual pixel:
[Image:
https://www.ab4d.com/images/DXEngineGall...ptions.png]
What is more, there is also an OptimizedPointMesh class that can be used in case of even bigger points clouds. This class can optimized the number of pixels that are actually sent to the graphics card and can improve performance by reducing the number of rendered pixels:
[Image:
https://www.ab4d.com/images/DXEngineGall...Engine.PNG]
Please check the Ab3d.DXEngine samples from more info - the samples can be get from GitHub:
https://github.com/ab4d/Ab3d.DXEngine.Wpf.Samples
Note that for camera controls (rotation, zooming, etc.) you will also need a Ab3d.PowerToys library that provides camera and other helper functions.
Both Ab3d.PowerToys and Ab3d.DXEngine libraries are built for WPF applications. But you can also integrate both libraries into WinForms applications. See the following sample on how to do that:
https://github.com/ab4d/Ab3d.DXEngine.WinForms.Sample
2)
I do not know the exact structure of the .xyz file format, but if this is a text file where each 3D position is defined in one row, then you can use the following code:
Code:
// Reads file with a 3D positions in each line. The x, y and z values are separated by space, comma or semi-column.
// Lines with comments should start by hash ('#')
private List<Point3D> ReadXyzFile(string fileName)
{
var allLines = System.IO.File.ReadAllLines(fileName);
var splitChars = new char[] { ' ', ',', ';' };
var allPositions = new List<Point3D>(allLines.Length); // preallocate list to number of lines so the list does not need to be resized when elements are added to it
foreach (var oneLine in allLines)
{
var trimmedLine = oneLine.Trim();
if (trimmedLine.Length == 0 || trimmedLine[0] == '#') // skip empty lines and comments
continue;
var lineParts = trimmedLine.Split(splitChars);
if (lineParts.Length != 3) // Invalid number of line parts
continue;
var x = float.Parse(lineParts[0], NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);
var y = float.Parse(lineParts[1], NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);
var z = float.Parse(lineParts[2], NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);
allPositions.Add(new Point3D(x, y, z));
}
return allPositions;
}
For example, this can read the following file:
Code:
# Corners of a tetrahedron
#
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0