public class EdgePool extends Object implements Iterable<IQuadEdge>
This class is written using a very old-school approach as a way of minimizing the frequency with which objects are garbage collected. Edges are extensively allocated and freed as the TIN is built. Were they simply constructed and put out-of-scope, the resulting garbage collection could degrade performance.
Note that this class is not thread safe.
For performance reasons, many of the methods in this class make the assumption that any edges passed into the method are under the management of the current instance. If this assumption is violated, serious errors could occur. For example, if an application uses one edge pool to allocate an edge and then passes it to the deallocEdge method another edge pool instance, both instances could become seriously corrupted.
Constructor and Description |
---|
EdgePool()
Construct a QuadEdge manager allocating a small number
of initial edges.
|
Modifier and Type | Method and Description |
---|---|
void |
addBorderConstraintToMap(IQuadEdge edge,
IConstraint constraint)
Adds the specified constraint to the border constraint map, thus recording
which region constraint lies to the left side of the edge (e.g.
|
void |
addLinearConstraintToMap(IQuadEdge edge,
IConstraint constraint)
Adds the specified constraint to the linear constraint map, thus recording
which constraint lies to the left side of the edge.
|
QuadEdge |
allocateEdge(Vertex a,
Vertex b) |
void |
clear()
Deallocates all Edges, returning them to the free
list.
|
void |
deallocateEdge(QuadEdge e)
Deallocates the QuadEdge returning it to the QuadEdge pool.
|
void |
dispose()
Puts all references used in the collection out-of-scope as a way of
simplifying and expediting garbage collection.
|
IConstraint |
getBorderConstraint(IQuadEdge edge)
Gets the border constraint associated with the edge.
|
int |
getEdgeCount() |
List<IQuadEdge> |
getEdges()
Get a list of the Edges currently stored in the collection
|
Iterator<IQuadEdge> |
getIterator(boolean includeGhostEdges)
Constructs an iterator that will optionally skip
ghost edges.
|
IConstraint |
getLinearConstraint(IQuadEdge edge)
Gets the linear constraint associated with the edge, if any.
|
int |
getMaximumAllocationIndex()
Gets the maximum value of an edge index that is currently allocated
within the edge pool.
|
QuadEdge |
getStartingEdge()
Get first valid, non-ghost QuadEdge in collection
|
QuadEdge |
getStartingGhostEdge() |
Iterator<IQuadEdge> |
iterator() |
void |
preAllocateEdges(int n)
Pre-allocates the specified number of edges.
|
void |
printDiagnostics(PrintStream ps)
Prints diagnostic information about the manager to the specified print
stream.
|
void |
removeBorderConstraintFromMap(IQuadEdge edge)
Removes any existing border constraint from the constraint map.
|
int |
size()
Get the number of Edges currently stored in the collection
|
QuadEdge |
splitEdge(QuadEdge e,
Vertex m)
Split the edge e into two by inserting a new vertex m into
the edge.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public EdgePool()
public void preAllocateEdges(int n)
n
- the number of edge (not vertices) to be allocated.public void deallocateEdge(QuadEdge e)
e
- a valid QuadEdgepublic int size()
public QuadEdge getStartingEdge()
public QuadEdge getStartingGhostEdge()
public List<IQuadEdge> getEdges()
public int getEdgeCount()
public void dispose()
public void clear()
public void printDiagnostics(PrintStream ps)
ps
- a valid print stream.public Iterator<IQuadEdge> getIterator(boolean includeGhostEdges)
includeGhostEdges
- indicates that ghost edges are
to be included in the iterator production.public int getMaximumAllocationIndex()
public QuadEdge splitEdge(QuadEdge e, Vertex m)
The split edge method preserves constraint flags and other attributes associated with the edge.
e
- the input segmentm
- the insertion vertexpublic void addBorderConstraintToMap(IQuadEdge edge, IConstraint constraint)
edge
- a valid edge instanceconstraint
- a valid constraint instancepublic void addLinearConstraintToMap(IQuadEdge edge, IConstraint constraint)
edge
- a valid edge instanceconstraint
- a valid constraint instancepublic void removeBorderConstraintFromMap(IQuadEdge edge)
edge
- a valid edge instancepublic IConstraint getBorderConstraint(IQuadEdge edge)
edge
- a valid edge instance.public IConstraint getLinearConstraint(IQuadEdge edge)
edge
- a valid edge instance.Copyright © 2021. All rights reserved.