public class SimpleSnapRounder extends java.lang.Object implements Noder
SegmentString
s.
Implements the Snap Rounding technique described in
the papers by Hobby, Guibas & Marimont, and Goodrich et al.
Snap Rounding assumes that all vertices lie on a uniform grid;
hence the precision model of the input must be fixed precision,
and all the input vertices must be rounded to that precision.
This implementation uses simple iteration over the line segments. This is not the most efficient approach for large sets of segments.
This implementation appears to be fully robust using an integer precision model. It will function with non-integer precision models, but the results are not 100% guaranteed to be correctly noded.
Modifier and Type | Field and Description |
---|---|
private LineIntersector |
li |
private java.util.Collection |
nodedSegStrings |
private PrecisionModel |
pm |
private double |
scaleFactor |
Constructor and Description |
---|
SimpleSnapRounder(PrecisionModel pm) |
Modifier and Type | Method and Description |
---|---|
private void |
checkCorrectness(java.util.Collection inputSegmentStrings) |
void |
computeNodes(java.util.Collection inputSegmentStrings)
Computes the noding for a collection of
SegmentString s. |
private void |
computeSnaps(java.util.Collection segStrings,
java.util.Collection snapPts)
Computes nodes introduced as a result of snapping segments to snap points (hot pixels)
|
private void |
computeSnaps(NodedSegmentString ss,
java.util.Collection snapPts) |
void |
computeVertexSnaps(java.util.Collection edges)
Computes nodes introduced as a result of
snapping segments to vertices of other segments
|
private void |
computeVertexSnaps(NodedSegmentString e0,
NodedSegmentString e1)
Performs a brute-force comparison of every segment in each
SegmentString . |
private java.util.List |
findInteriorIntersections(java.util.Collection segStrings,
LineIntersector li)
Computes all interior intersections in the collection of
SegmentString s,
and returns their Coordinate s. |
java.util.Collection |
getNodedSubstrings()
Returns a
Collection of fully noded SegmentString s. |
private void |
snapRound(java.util.Collection segStrings,
LineIntersector li) |
private final PrecisionModel pm
private LineIntersector li
private final double scaleFactor
private java.util.Collection nodedSegStrings
public SimpleSnapRounder(PrecisionModel pm)
public java.util.Collection getNodedSubstrings()
Noder
Collection
of fully noded SegmentString
s.
The SegmentStrings have the same context as their parent.getNodedSubstrings
in interface Noder
public void computeNodes(java.util.Collection inputSegmentStrings)
Noder
SegmentString
s.
Some Noders may add all these nodes to the input SegmentStrings;
others may only add some or none at all.computeNodes
in interface Noder
inputSegmentStrings
- a Collection of NodedSegmentStringsprivate void checkCorrectness(java.util.Collection inputSegmentStrings)
private void snapRound(java.util.Collection segStrings, LineIntersector li)
private java.util.List findInteriorIntersections(java.util.Collection segStrings, LineIntersector li)
SegmentString
s,
and returns their Coordinate
s.
Does NOT node the segStrings.private void computeSnaps(java.util.Collection segStrings, java.util.Collection snapPts)
li
- private void computeSnaps(NodedSegmentString ss, java.util.Collection snapPts)
public void computeVertexSnaps(java.util.Collection edges)
edges
- the list of segment strings to snap togetherprivate void computeVertexSnaps(NodedSegmentString e0, NodedSegmentString e1)
SegmentString
.
This has n^2 performance.