dcel — planar subdivisions for unit-side tessellations

A Scala 3 library that models edge-to-edge tessellations of unit-side polygons as a Doubly Connected Edge List, with builders, validation, symmetry analysis, and SVG / DOT export.

dcel is the geometric model behind the Tessella editor. It represents edge-to-edge tessellations of unit-side polygons as a Doubly Connected Edge List — a classical planar-subdivision data structure in which every edge is split into two oppositely oriented half-edges, and each half-edge knows its origin vertex, its incident face, its twin, its predecessor, and its successor. On top of that base, the library provides builders, validation, topology and geometry operations, symmetry and uniformity analysis, and import/export.

The library is published for Scala 3 on the JVM and on Scala.js. A Scala Native build is scaffolded but blocked on Spire’s Native support.

Status: early development (pre-1.0). The API may still change between minor versions; pin a version in production.

Install

Add to your build.sbt:

libraryDependencies += "io.github.scala-tessella" %% "dcel" % "0.1.0"
// Use %%% instead of %% for Scala.js

What it gives you

Quickstart

import io.github.scala_tessella.dcel.TilingDCEL
import io.github.scala_tessella.dcel.geometry.RegularPolygon
import io.github.scala_tessella.dcel.structure.VertexId

// start from a single hexagon
val base = TilingDCEL.createRegularPolygon(RegularPolygon(6))

// attach a triangle to one of its edges (returns Either[TilingError, TilingDCEL])
val grownEither =
  base.maybeAddRegularPolygonToBoundary(
    onEdgeStartingWith = VertexId(1),
    polygon            = RegularPolygon(3)
  )

// render to SVG
val svgEither = grownEither.map(_.toSVG(scale = 80.0))

Every mutating public API returns an Either[TilingError, TilingDCEL] and operates on an internal deep copy, so the input value is never modified. Methods ending in Unsafe skip defensive checks for hot paths; prefer the non-Unsafe counterparts from client code.

API shape

Errors are surfaced through a sealed TilingError ADT — ValidationError, IncompleteError, TopologyError, GeometryError, SpatialError, NotFoundError — plus a TilingError.combineErrors helper.

IDs are opaque types (VertexId, FaceId) and format themselves through the Prefixable trait (e.g. v1, f7), so log output and error messages stay readable.

The library is split into four packages:

PackageRole
io.github.scala_tessella.dcelCore: TilingDCEL, builders, operations, validation, errors
io.github.scala_tessella.dcel.geometryDeterministic BigDecimal / Spire primitives: BigPoint, BigLineSegment, RegularPolygon, SimplePolygon, SpatialGrid, …
io.github.scala_tessella.dcel.structureVertex, HalfEdge, Face, plus opaque VertexId / FaceId
io.github.scala_tessella.dcel.conversionTilingSVG (with SvgOptions), TilingDOT, SVG-metadata round-trip

Only the root package depends on the other three; conversion depends on everything, structure depends on geometry, geometry has no internal deps.

Where it’s used

If you adopt it in a project, open an issue and we will add it to the list.

Install, docs and source

ResourceLink
Maven Centralio.github.scala-tessella :: dcel
API docsScaladoc
SourceGitHub
LicenseApache-2.0 OR MIT