add documentation
diff --git a/CMakeLists.txt b/CMakeLists.txt
index efa919b..14f9b8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9ba9d9e..abad187 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,7 +17,7 @@
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
- "cppStandard": "c++17",
+ "cppStandard": "c++14",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
diff --git a/README.md b/README.md
index 9ba9d9e..20fff39 100644
--- a/README.md
+++ b/README.md
@@ -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
+ )
+ }
}
-```
\ No newline at end of file
+```
+
+For full example see `src/triangulate.cpp`
+
+## TODO
+
+* Benchmarks
+* Unit tests
diff --git a/src/delaunator.cpp b/src/delaunator.cpp
index c670efa..8600b09 100644
--- a/src/delaunator.cpp
+++ b/src/delaunator.cpp
@@ -6,7 +6,7 @@
#include <tuple>
#include <exception>
#include <cmath>
-#include "prettyprint.hpp"
+// #include "prettyprint.hpp"
#include <iostream>
using namespace std;
diff --git a/src/main.cpp b/src/triangulate.cpp
similarity index 92%
rename from src/main.cpp
rename to src/triangulate.cpp
index 295383a..fba4dec 100644
--- a/src/main.cpp
+++ b/src/triangulate.cpp
@@ -1,4 +1,3 @@
-// #include <iostream>
#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
#include "delaunator.h"
@@ -8,7 +7,7 @@
#include <exception>
#include <vector>
#include <initializer_list>
-#include "prettyprint.hpp"
+// #include "prettyprint.hpp"
#include <iostream>
using namespace std;
@@ -42,9 +41,7 @@
const double y = coordinates[1].GetDouble();
coords.push_back(x);
coords.push_back(y);
- // printf("coordinates %f %f \n", x, y);
}
- // Points points = {.x_vector = x_vector, .y_vector = y_vector};
return coords;
}
@@ -115,17 +112,8 @@
stream.open(output);
stream << out_json;
stream.close();
- // cout << output << endl;
} else {
puts(out_json);
}
-
- // cout << output << endl;
- // if (sizeof(argv) > 2) {
- // puts("ouput to file");
- // } else {
- // puts(out_json);
- // }
return 0;
- // cout << delaunator.triangles << endl;
}