pdal-c is a C API for the Point Data Abstraction Library (PDAL) and is compatible with PDAL 1.7 and later.
pdal-c is released under the BSD 3-clause license.
The library can be installed as a package on Windows, Mac and Linux using Conda.
conda install -c conda-forge pdal-c
The conda package includes a tool called test_pdalc
. Run this to confirm that the API configuration is correct and to report on the version of PDAL that the API is connected to.
This interface is suitable for use with C# and with Unity.
There is a Unity Package Manager (UPM) package for PDAL based on this library.
The library is dependent on PDAL and has currently been tested up to v2.2.0.
An example of the use of the API is given in the csharp
folder which contains an integration to PDAL in C#.
NOTE - these scripts are provided for information only as examples and are not supported in any way!
using System;
using System.Collections.Generic;
using Pdal;
using Newtonsoft.Json;
using g3;
namespace pdal_mesh
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Config pdal = new Config();
Console.WriteLine(pdal.Version);
List<object> pipe = new List<object>();
pipe.Add(".../CAPI/tests/data/las/1.2-with-color.las");
pipe.Add(new
{
type = "filters.splitter",
length = 1000
});
pipe.Add(new
{
type = "filters.delaunay"
});
string json = JsonConvert.SerializeObject(pipe.ToArray());
Pipeline pl = new Pipeline(json);
long count = pl.Execute();
Console.WriteLine($"Point Count is {count}");
using (PointViewIterator views = pl.Views) {
views.Reset();
while (views.HasNext())
{
PointView view = views.Next;
if (view != null)
{
Console.WriteLine($"Point Count is {view.Size}");
Console.WriteLine($"Triangle Count is {view.MeshSize}");
BpcData pc = view.GetBakedPointCloud();
DMesh3 mesh = view.getMesh();
}
}
}
}
}
}
This takes a LAS file, splits the file into tiles and then creates a Delaunay Triangulation (i.e. Mesh) for each one.
This code uses the sample bindings as-is and has a dependency on Geometry3Sharp only.
Note that BcpData
is a custom data structure that holds the Point Cloud in a form suitable to create a Baked PointCloud suitable for rendering as a VFX graph in Unity. This is an efficient way to display point cloud data in VR and I have used it successfully with point clouds of 10 million points.
The library can be built on Windows using the following command - which assumes that you are in a conda environment that has the conda-forge pdal
package loaded:
cd CAPI
make.bat
The library can be built on Linux and Mac using the following command - which assumes that you are in a conda environment that has the conda-forge pdal
package loaded:
cd CAPI
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCONDA_BUILD=OFF .
make
make install
This project enforces the PDAL code styles, which can checked as follows :
- On Windows - as per
astylerc
- On Linux by running
./check_all.bash