Skip to content

Commit 809d0d6

Browse files
committed
Initial commit
1 parent 0a135ac commit 809d0d6

File tree

312 files changed

+132889
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+132889
-1
lines changed

Diff for: CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(TriangleMeshDistance)
3+
set(CMAKE_CXX_STANDARD 17)
4+
5+
add_subdirectory(tests)

Diff for: README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
11
# TriangleMeshDistance
2-
Header only, single file, simple and efficient C++ library to compute the signed distance function to a triangle mesh
2+
Header only, single file, simple and efficient C++ library to compute the signed distance function to a triangle mesh.
3+
4+
The distance computation to the triangle collection is accelerated with a sphere bounding volume hierarchy. The signed of the distance is resolved with the method presented in *"Generating Signed Distance Fields From Triangle Meshes"* by Bærentzen, Andreas & Aanæs, Henrik. (2002).
5+
6+
## Example
7+
```cpp
8+
// Declare mesh vertices and triangles
9+
std::vector<std::array<double, 3>> vertices;
10+
std::vector<std::array<int, 3>> triangles;
11+
12+
// Initialize TriangleMeshDistance
13+
tmd::TriangleMeshDistance mesh_distance(vertices, triangles);
14+
15+
// Query TriangleMeshDistance
16+
tmd::Result result = mesh_distance.signed_distance({ x, y, z });
17+
18+
// Print result
19+
std::cout << "Signed distance: " << result.distance << std::endl;
20+
std::cout << "Nearest point: " << result.nearest_point << std::endl;
21+
std::cout << "Nearest entity: " << result.nearest_entity << std::endl;
22+
std::cout << "Nearest triangle index: " << result.triangle_id << std::endl;
23+
```
24+
25+
26+
## What you need to know about TriangleMeshDistance
27+
- `TriangleMeshDistance` keeps a copy of the vertex and triangle data passed as input.
28+
- Additionally, the pseudonormals required to compute signed distances are calculated and stored at building time.
29+
- `TriangleMeshDistance` can be declared empty and constructed multiple times with different meshes. This can potentially reuse memory allocations.
30+
-

0 commit comments

Comments
 (0)