A high performance 2D and 3D line simplification algorithm. Uses Ramer-Douglas-Peucker Line Simplification.
- Simplify 2D and 3D lines
- Written in C++ with python bindings. Can be used standalone in a C++ project with CMake as well.
- Based on high-performance Simplify.js
The python library can be installed as so:
pip install simplifyline
Example Use:
from simplifyline import simplify_line_2d, MatrixDouble
mat2D = MatrixDouble([[0.0, 0.0], [1.0, 1.0], [2.0, 2.0], [3.0, 3.0]])
results_mat2D = simplify_line_2d(mat2D, max_distance=0.1, high_quality=True)
results = np.array(results_mat2D)
np.testing.assert_array_equal(results, np.array([[0.0, 0.0], [3.0, 3.0]]))
See documentation for more details.
You can build the project manually in two ways: using python setup.py
, or in pure CMake
The root directory setup.py file has been modified to build with CMake. This is meant for python users that need to build manually (for some reason) but are not actively developing or changing the code.
- Install conda or create a python virtual environment (Why?). I recommend conda for Windows users.
pip install .
- Call from root directory
Building happens entirely with CMake. This is meant really only for the library developers who are working on C++ and Python in an edit-compile cycle.
mkdir cmake-build && cd cmake-build
cmake ..
- Note - For windows also add-DCMAKE_GENERATOR_PLATFORM=x64
cmake --build . -j$(nproc) --config Release
Build options:
SPL_BUILD_BENCHMARKS:BOOL=ON // SPL - Build Benchmarks
SPL_BUILD_EXAMPLES:BOOL=ON // SPL - Build Examples
SPL_BUILD_PYMODULE:BOOL=ON // SPL -Build Python Module
SPL_BUILD_TESTS:BOOL=ON // SPL - Build Tests
SPL_BUILD_WERROR:BOOL=OFF // SPL - Add Werror flag to build (turns warnings into errors)
SPL_WITH_OPENMP:BOOL=ON // SPL - Build with OpenMP Support
This is meant for advanced python users who are actively developing the extension.
- Install conda or create a python virtual environment (Why?). I recommend conda for Windows users.
- Perform
CMake
build as described above cd cmake-build && cmake --build . --target python-package --config Release
cd lib/python_package && pip install -e .
. This installs the library in develop/edit mode. To update the python extension in your python virtual environment all you need to do is run step 3 again.