public class MedialAxis
extends java.lang.Object
Produces a directed acyclic graph of the MD / more specifically rooted tree
Medial Axis library models medial axes of shapes as a (rooted) tree of medial disks. Medial disks reference a parent and have upto 3 children (the medial axis bifurcates/forks at disks with 2 children). The root is the disk with the largest circumcirle, also the single disk that trifurcates. All disks have an indegree of 1.
For geometries of genus zero, the graph is naturally a tree. For objects with holes, we break each cycle by imposing an appropriate breakpoint in the loop. This is only for the purposes of traversing the graph without running into infinite loops. In order to preserve the topology of the original object, cycles are never pruned
Decompose the disk coordinates into curves.
If angle of successive line branches is the same, merge them
* One way to get a smoother initial axis (i.e. without pruning) is to apply on a smoothed version of the shape.
Modifier and Type | Class and Description |
---|---|
class |
MedialAxis.Branch
Branches are series of successive disks found in between.
|
class |
MedialAxis.Edge
Edges are straight-line segments that connect two adjacent disks.
|
class |
MedialAxis.MedialDisk
Voronoi Disk. medial disk?
|
Modifier and Type | Field and Description |
---|---|
boolean |
debug |
MedialAxis.MedialDisk |
furthestNode |
MedialAxis.MedialDisk |
rootNode |
Constructor and Description |
---|
MedialAxis(Coordinate[] coordinates) |
MedialAxis(Geometry g)
The medial axis is computed for the geometry during construction.
|
Modifier and Type | Method and Description |
---|---|
void |
calcFeatureArea() |
java.util.List<MedialAxis.MedialDisk> |
getAncestors(MedialAxis.MedialDisk child)
The ancestors of a node d are the nodes on the path from d to the root.
|
java.util.List<MedialAxis.MedialDisk> |
getBifurcations()
Nodes/medial disks with two descendent lineages (two children disks).
|
java.util.List<MedialAxis.Branch> |
getBranches()
Aka features, aka branches Segment is a linear portion of medial disks.
|
java.util.List<MedialAxis.MedialDisk> |
getDescendants(MedialAxis.MedialDisk parent)
Returns the children of a disk into a linear array
|
java.util.List<MedialAxis.MedialDisk> |
getDescendants(MedialAxis.MedialDisk parent,
int maxDepth) |
java.util.List<MedialAxis.MedialDisk> |
getDisks() |
Geometry |
getDissolvedGeometry()
Returns a JTS geometry where medial axis edges are dissolved into a set of
maximal-length Linestrings.
|
java.util.Collection<MedialAxis.Edge> |
getEdges() |
java.util.List<MedialAxis.MedialDisk> |
getLeaves()
End nodes / A VDs of degree 1/no children
|
LineMergeGraph |
getLineMergeGraph()
Get the medial axis in the form of an undirected planar graph.
|
java.util.List<MedialAxis.Edge> |
getPrunedEdges(double threshold)
Returns a subset of the axis' edges; in this method edges are pruned by their
axial gradient value.
|
java.util.List<MedialAxis.Edge> |
getPrunedEdges(double axialThreshold,
double distanceThreshold)
Returns a subset of the axis' edges; in this method edges are pruned by their
axial gradient value and axis distance from the root node.
|
java.util.List<MedialAxis.Edge> |
getPrunedEdges(double axialThreshold,
double distanceThreshold,
double areaThreshold) |
static void |
main(java.lang.String[] args) |
MedialAxis.MedialDisk |
nearestDisk(Coordinate coordinate) |
MedialAxis.MedialDisk |
nearestDisk(double x,
double y) |
public MedialAxis.MedialDisk rootNode
public MedialAxis.MedialDisk furthestNode
public boolean debug
public MedialAxis(Coordinate[] coordinates)
public MedialAxis(Geometry g)
g
- Geometry whose medial axis to compute. Can contain holes. Must not
be a multigeometrypublic java.util.List<MedialAxis.MedialDisk> getDisks()
public MedialAxis.MedialDisk nearestDisk(double x, double y)
public MedialAxis.MedialDisk nearestDisk(Coordinate coordinate)
public java.util.List<MedialAxis.MedialDisk> getDescendants(MedialAxis.MedialDisk parent)
parent
- contains chil out: contains children and the parent (at
position 0)public java.util.List<MedialAxis.MedialDisk> getDescendants(MedialAxis.MedialDisk parent, int maxDepth)
public java.util.List<MedialAxis.MedialDisk> getAncestors(MedialAxis.MedialDisk child)
TODO another method that returns paths from fork VDs in the ancestors (Except rootnode)
child
- public Geometry getDissolvedGeometry()
public LineMergeGraph getLineMergeGraph()
public java.util.List<MedialAxis.MedialDisk> getLeaves()
public java.util.List<MedialAxis.MedialDisk> getBifurcations()
public java.util.Collection<MedialAxis.Edge> getEdges()
public java.util.List<MedialAxis.Branch> getBranches()
branches
public java.util.List<MedialAxis.Edge> getPrunedEdges(double threshold)
Presently this method prunes based on global min and max axial values (rather than per branch).
threshold
- between 0...1, where 0 is no pruning and 1 is maximal
pruning. the shape may be fully pruned before threshold = 1public java.util.List<MedialAxis.Edge> getPrunedEdges(double axialThreshold, double distanceThreshold)
axialThreshold
- between 0...1, where 0 is no pruning and 1 is
maximal pruningdistanceThreshold
- between 0...1, where 0 is no pruning and 1 is
maximal pruningpublic java.util.List<MedialAxis.Edge> getPrunedEdges(double axialThreshold, double distanceThreshold, double areaThreshold)
axialThreshold
- distanceThreshold
- areaThreshold
- between 0...1, where 0 is no pruning and 1 is
maximal pruning for this featurepublic void calcFeatureArea()
public static void main(java.lang.String[] args) throws ParseException
ParseException