Skip to content

Straight Skeletons via Kinetic Triangulation, in Java

License

Notifications You must be signed in to change notification settings

micycle1/grassfire4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grassfire4j

A kinetic straight‑skeleton (wavefront‑collapse / “grassfire”) implementation in Java.

Overview

This project is the first full kinetic straight‑skeleton implementation available in Java. Compared to the other notable Java implementation, campskeleton, which uses Felkel’s edge‑collision approach, grassfire4j uses a triangulation + kinetic event queue approach with careful tie‑breaking and degenerate‑case handling. In practice this yields better behaviour and significantly improved performance on polygonal inputs.

The core algorithm is derived from a Python implementation by bmmeijers. I forked that project to rearchitect and improve it (using some ideas from the the academic surfer2 C++ project), then ported and adapted the Python fork to Java.

Features

  • Kinetic (wavefront‑collapse) straight‑skeleton computed entirely in Java.
  • Accepts JTS Polygon inputs; supports polygons with holes.
  • Adapter-based input pipeline (InputMesh) makes it easy to plug in user-supplied adapters for other input types.
  • Supports variable edge weights.
  • Produces a Skeleton model with nodes, kinetic vertices and skeleton segments suitable for visualisation or export.

Usage

Example

WKTReader reader = new WKTReader();
Polygon polygon = (Polygon) reader.read(
		"POLYGON ((0 0, 20 0, 20 10, 10 10, 10 20, 0 20, 0 0))");

var skeleton = Grassfire.computeSkeleton(polygon);
MultiLineString bones = skeleton.asMultiLineString();

System.out.println(bones.toText());

Maven / Gradle

grassfire4j is available for Maven / Gradle via JitPack.

Illustrations

About

Straight Skeletons via Kinetic Triangulation, in Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages