forked from delfrrr/delaunator-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(delaunator VERSION 0.1.0) | ||
set (CMAKE_CXX_STANDARD 17) | ||
set (CMAKE_CXX_STANDARD 14) | ||
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/includes") | ||
execute_process(COMMAND bash "-c" "(cd ${CMAKE_CURRENT_SOURCE_DIR} && ./fetch-includes.sh)") | ||
endif() | ||
# message("PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
add_executable(main src/main.cpp) | ||
add_executable(triangulate src/triangulate.cpp) | ||
add_library(delaunator src/delaunator.cpp) | ||
target_include_directories (main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
target_include_directories (main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/prettyprint") | ||
target_include_directories (triangulate PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
target_include_directories (triangulate PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/prettyprint") | ||
target_include_directories (delaunator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/rapidjson/include") | ||
target_include_directories (delaunator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/includes/prettyprint") | ||
target_link_libraries(main delaunator) | ||
target_link_libraries(triangulate delaunator) | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) | ||
# include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
# delaunator-cpp | ||
|
||
**c_cpp_properties.json** | ||
A really fast C++ library for | ||
[Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) of 2D points. | ||
|
||
``` | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "CPP Mac", | ||
"includePath": [ | ||
"${workspaceFolder}/**", | ||
"/usr/include/**" | ||
], | ||
"defines": [], | ||
"macFrameworkPath": [ | ||
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks" | ||
], | ||
"compilerPath": "/usr/bin/clang", | ||
"cStandard": "c11", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "clang-x64", | ||
"compileCommands": "${workspaceFolder}/build/compile_commands.json" | ||
} | ||
], | ||
"version": 4 | ||
delaunator-cpp is a C++ port from https://github.com/mapbox/delaunator a JavaScript implementation of very fast 2D Delaunay algorithm. | ||
|
||
## Features | ||
|
||
* Probably the fastest C++ open source 2D Delaunay implementation | ||
* Roughly 3 times faster then JS version. | ||
* Example showing triangulation of GeoJson points | ||
|
||
## Usage | ||
|
||
```CPP | ||
#include "delaunator.h" | ||
#include <cstdio> | ||
|
||
//... | ||
int main(int, char* argv[]) { | ||
//... | ||
const vector<double> coords = {/* x0, y0, x1, y1, ... */}; | ||
Delaunator delaunator(coords); //triangulation happens here | ||
for(long int i = 0; i < delaunator.triangles.size(); i+=3) { | ||
printf( | ||
"Triangle points: [[%f, %f], [%f, %f], [%f, %f]]\n", | ||
delaunator.coords[2 * delaunator.triangles[i]], //tx0 | ||
delaunator.coords[2 * delaunator.triangles[i] + 1], //ty0 | ||
delaunator.coords[2 * delaunator.triangles[i + 1]], //tx1 | ||
delaunator.coords[2 * delaunator.triangles[i + 1] + 1], //ty1 | ||
delaunator.coords[2 * delaunator.triangles[i + 2]], //tx2 | ||
delaunator.coords[2 * delaunator.triangles[i + 2] + 1], //ty2 | ||
) | ||
} | ||
} | ||
``` | ||
``` | ||
For full example see `src/triangulate.cpp` | ||
## TODO | ||
* Benchmarks | ||
* Unit tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters