Skip to content

Commit

Permalink
Merge pull request #16 from ViRGIS-Team/mesh-changes
Browse files Browse the repository at this point in the history
Add face data to the C API and update C# Pinvoke examples
  • Loading branch information
runette authored May 2, 2021
2 parents f9ff0a3 + 6977af8 commit 81126b1
Show file tree
Hide file tree
Showing 15 changed files with 345 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2

- name: Install Conda
uses: conda-incubator/setup-miniconda@v1.7.0
uses: conda-incubator/setup-miniconda@v2

- name: Install PDAL
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/osx_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2

- name: Install Conda
uses: conda-incubator/setup-miniconda@v1.7.0
uses: conda-incubator/setup-miniconda@v2

- name: Install PDAL
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
> Doxyfile
- name: Run Doxygen
uses: mattnotmitt/doxygen-action@v1.2.0
uses: mattnotmitt/doxygen-action@v1.3.0
with:
doxyfile-path: 'docs/Doxyfile'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2

- name: Install Conda
uses: conda-incubator/setup-miniconda@v1.7.0
uses: conda-incubator/setup-miniconda@v2

- name: Install PDAL
shell: pwsh
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tests/pdal/test_pdalc_*.c
.DS_Store
# Build directory
/build
bin/
obj/

# Prerequisites
*.d
Expand All @@ -28,6 +30,7 @@ tests/pdal/test_pdalc_*.c
*.o
*.obj
*.elf
*.sln

# Linker output
*.ilk
Expand Down Expand Up @@ -72,4 +75,4 @@ Data/
Doxyfile
*.tcl

Testing/
Testing/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Version 2.1.0

This version adds

- Access to face data in PDAL using the `GetMeshSize` and `getAllTriangles` methods,
- Updates the sample C# P/Invoke scripts to add the Mesh functions and remove depedencies on Unity. Asdded .csproj files and improved some signatures
- added more examples to readme.

# Version 2.0.0

This was the first version released through conda.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,74 @@ An example of the use of the API is given in the `csharp` folder which contains

NOTE - these scripts are provided for information only as examples and are not supported in any way!

## Example C# Program

``` c#
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](https://github.com/gradientspace/geometry3Sharp) only.

Note that `BcpData` is a custom data structure that holds the Point Cloud in a form suitable to create a [Baked PointCloud](https://medium.com/realities-io/point-cloud-rendering-7bd83c6220c8) 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.

# For Developers

## Build on Windows
Expand Down
58 changes: 13 additions & 45 deletions csharp/Config.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/******************************************************************************
* Copyright (c) 2019, Simverge Software LLC. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
Expand All @@ -27,10 +28,9 @@ this list of conditions and the following disclaimer in the documentation
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
using System;

namespace Pdal
{
Expand All @@ -39,19 +39,17 @@ public class PdalConfiguration
public static void ConfigurePdal()
{
Config config = new Config();
Debug.Log("GDAL Data Path: " + config.GdalData);
Debug.Log("Proj4 Data Path: " + config.Proj4Data);

Debug.Log("PDAL Version Integer: " + config.VersionInteger);
Debug.Log("PDAL Version Major: " + config.VersionMajor);
Debug.Log("PDAL Version Minor: " + config.VersionMinor);
Debug.Log("PDAL Version Patch: " + config.VersionPatch);

Debug.Log("PDAL Full Version: " + config.FullVersion);
Debug.Log("PDAL Version: " + config.Version);
Debug.Log("PDAL SHA1: " + config.Sha1);
Debug.Log("PDAL Debug Info: " + config.DebugInfo);
}

Console.WriteLine("PDAL Version Integer: " + config.VersionInteger);
Console.WriteLine("PDAL Version Major: " + config.VersionMajor);
Console.WriteLine("PDAL Version Minor: " + config.VersionMinor);
Console.WriteLine("PDAL Version Patch: " + config.VersionPatch);

Console.WriteLine("PDAL Full Version: " + config.FullVersion);
Console.WriteLine("PDAL Version: " + config.Version);
Console.WriteLine("PDAL SHA1: " + config.Sha1);
Console.WriteLine("PDAL Debug Info: " + config.DebugInfo);
}
}

/**
Expand Down Expand Up @@ -109,39 +107,9 @@ public class Config
*/
public Config()
{
//string cwd = Environment.CurrentDirectory;

string gdalPath = Application.streamingAssetsPath;
GdalData = Path.Combine(gdalPath, "gdal-data");
Proj4Data = Path.Combine(gdalPath, "proj");
}

/// The path to the GDAL data directory
public string GdalData
{
get
{
StringBuilder buffer = new StringBuilder(256);
getGdalDataPath(buffer, (uint) buffer.Capacity);
return buffer.ToString();
}

set { setGdalDataPath(value); }
}

/// The path to the proj4 data directory
public string Proj4Data
{
get
{
StringBuilder buffer = new StringBuilder(256);
getProj4DataPath(buffer, (uint) buffer.Capacity);
return buffer.ToString();
}

set { setProj4DataPath(value); }
}

/// The PDAL full version string with dot-separated major, minor, and patch version numbers and PDAL commit SHA1
public string FullVersion
{
Expand Down
Loading

0 comments on commit 81126b1

Please sign in to comment.