MaxGraey / Delaunay-Voronoi-Implementations

Implementations of the algorithm for Delaunay triangulation on c++, AssemblyScript and Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is it

This repository contains source codes for the article on Habr (non-published) about different methods to build wasm-module from c++, AssemblyScript and Rust. These modules build the Delaunay triangulation of the plain. We use a port of this algorithm.

How to build

c++

It requires Emscripten

Create directory \output\libs\ to store temporary build files. Next build object files

emcc .\delaunay.cpp -o output\libs\delaunay.o -c
emcc .\bvh.cpp -o output\libs\bvh.o -c

Finally, build the module

emcc .\delaunay_api.cpp output\libs\delaunay.o output\libs\bvh.o -o output/delaunay.js -lembind -s MODULARIZE -s EXPORT_NAME=delaunay -s ALLOW_MEMORY_GROWTH=1 -Oz

AssemblyScript

It requires AssemblyScript

asc assembly/delaunay_api.ts -o build/delaunay.wasm --bindings esm --optimizeLevel 3 --converge --noAssert -Ospeed

Rust

It requires wasm-pack

wasm-pack build

Example application

Here is an example applicarion, which use the module from the Rust.

Python integration

./python_wasm/delaunay_wasm.py contains an example of the Python class, which loads the module from the Rust by using Wasmer.

About

Implementations of the algorithm for Delaunay triangulation on c++, AssemblyScript and Rust


Languages

Language:TypeScript 27.4%Language:Python 25.4%Language:Rust 24.3%Language:C++ 22.9%