- Object
-
- AbstractSimplifier
-
- All Implemented Interfaces:
Simplifier
- Direct Known Subclasses:
VertexClusterReduction
public abstract class AbstractSimplifier extends Object implements Simplifier
Abstract simplifier providing some shared logic for all simplifiers.- Since:
- 4.2.0
- Version:
- 4.2.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description AbstractSimplifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Vector2>
buildResult(SimplePolygonVertex start)
Builds a polygon from the remaining vertices in the queue.protected SegmentTree
buildSegmentTree(SimplePolygonVertex start)
Builds aSegmentTree
used to prevent self-intersection during simplification.protected boolean
intersects(Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2)
Returns true if the given segments intersect each other.protected boolean
isSelfIntersectionProduced(SimplePolygonVertex vertex, SegmentTree tree)
Returns true if removing the given vertex will generate a line segment that causes self intersection.protected boolean
isSelfIntersectionProduced(SimplePolygonVertex vertex1, SimplePolygonVertex vertex2, SegmentTree tree)
Returns true if the given segment will generate a self-intersection assuming all vertices between the two given vertices are removed.Vector2[]
simplify(Vector2... vertices)
Simplifies the given simple polygon and returns a new simplified simple polygon.-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface Simplifier
simplify
-
-
-
-
Method Detail
-
simplify
public Vector2[] simplify(Vector2... vertices)
Description copied from interface:Simplifier
Simplifies the given simple polygon and returns a new simplified simple polygon.- Specified by:
simplify
in interfaceSimplifier
- Parameters:
vertices
- the simple polygon's vertices- Returns:
Vector2
[]
-
buildSegmentTree
protected final SegmentTree buildSegmentTree(SimplePolygonVertex start)
Builds aSegmentTree
used to prevent self-intersection during simplification.- Parameters:
start
- the start vertex- Returns:
SegmentTree
-
buildResult
protected final List<Vector2> buildResult(SimplePolygonVertex start)
Builds a polygon from the remaining vertices in the queue.- Parameters:
start
- the vertex to begin building the result from- Returns:
- List<
Vector2
>
-
isSelfIntersectionProduced
protected final boolean isSelfIntersectionProduced(SimplePolygonVertex vertex, SegmentTree tree)
Returns true if removing the given vertex will generate a line segment that causes self intersection.- Parameters:
vertex
- the vertex that will be removedtree
- the segment tree for accelerated detection- Returns:
- boolean
-
isSelfIntersectionProduced
protected final boolean isSelfIntersectionProduced(SimplePolygonVertex vertex1, SimplePolygonVertex vertex2, SegmentTree tree)
Returns true if the given segment will generate a self-intersection assuming all vertices between the two given vertices are removed.- Parameters:
vertex1
- the first vertex of the segment to be createdvertex2
- the second vertex of the segment to be createdtree
- the segment tree for accelerated detection- Returns:
- boolean
-
intersects
protected final boolean intersects(Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2)
Returns true if the given segments intersect each other.- Parameters:
a1
- the first point of the first segmenta2
- the second point of the first segmentb1
- the first point of the second segmentb2
- the second point of the second segment- Returns:
- boolean
-
-