Class PolyLineConstraintAdapter
- java.lang.Object
-
- org.tinfour.common.PolyLineConstraintAdapter
-
- All Implemented Interfaces:
Iterable<Vertex>,IConstraint,IPolyline
- Direct Known Subclasses:
LinearConstraint,PolygonConstraint
public abstract class PolyLineConstraintAdapter extends Object implements IConstraint, Iterable<Vertex>
An implementation of the IConstraint interface intended to store constraints comprised of a chain of connected line segments. Constraint chains must be non-self-intersecting (except at segment endpoints). The chain must never "fold back" on itself. All segments in the chain must be non-zero-length. Do not use this class for closed polygons.
-
-
Field Summary
Fields Modifier and Type Field Description protected ObjectapplicationDataIndicates an object registered to the constraint for use by application code.protected intconstraintIndexAn integer index for the constraintprotected IQuadEdgeconstraintLinkingEdgeDefines an edge that links the constraint to the Delaunay triangulation (may be null).protected booleanisCompleteIndicates that the constraint is complete (application-dependent, for example, if the constraint defines a closed polygon, this value would indicate that the area has been computed).protected doublelengthIndicates the overall length of the polyline.protected List<Vertex>listThe list of vertices that define the constraint geometryprotected IIncrementalTinmaintainingTinThe Delaunay triangulation associated with the constraint (if any)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Vertex v)Adds a vertex to the polyline feature.voiddensify(double threshold)Insert synthetic vertices into the constraint so that the spacing between vertices does not exceed the specified threshold.ObjectgetApplicationData()Gets the application data (if any) stored in the constraint.Rectangle2DgetBounds()Gets the bounds of the feature.intgetConstraintIndex()Gets an index value used for internal bookkeeping by Tinfour code.IQuadEdgegetConstraintLinkingEdge()Gets a reference to an arbitrarily selected edge that was produced when the constraint was added to a TIN.doublegetLength()Gets the total length of the feature.IIncrementalTingetManagingTin()Gets the instance of the incremental TIN interface that is managing this constraint, if any.List<Vertex>getVertices()Gets the vertices for this feature.booleanisPointInsideConstraint(double x, double y)Indicates if a point at the specified coordinates is unambiguously inside the constraint.Iterator<Vertex>iterator()voidsetApplicationData(Object applicationData)Permits an application to add data elements to the constraint for its own uses.voidsetConstraintIndex(IIncrementalTin tin, int index)Sets an index value used for internal bookkeeping by Tinfour code; not intended for use by application code.voidsetConstraintLinkingEdge(IQuadEdge edge)Sets a reference to an arbitrarily selected edge that was produced when the constraint was added to a TIN.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.tinfour.common.IConstraint
definesConstrainedRegion, getConstraintWithNewGeometry, getPath2D
-
Methods inherited from interface org.tinfour.common.IPolyline
complete, getNominalPointSpacing, isPolygon, isValid, refactor
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
applicationData
protected Object applicationData
Indicates an object registered to the constraint for use by application code.
-
constraintIndex
protected int constraintIndex
An integer index for the constraint
-
constraintLinkingEdge
protected IQuadEdge constraintLinkingEdge
Defines an edge that links the constraint to the Delaunay triangulation (may be null).
-
maintainingTin
protected IIncrementalTin maintainingTin
The Delaunay triangulation associated with the constraint (if any)
-
isComplete
protected boolean isComplete
Indicates that the constraint is complete (application-dependent, for example, if the constraint defines a closed polygon, this value would indicate that the area has been computed).
-
length
protected double length
Indicates the overall length of the polyline.
-
-
Method Detail
-
getVertices
public List<Vertex> getVertices()
Description copied from interface:IPolylineGets the vertices for this feature. The vertices define a non-self-intersecting chain of line segments (that is, no line segments intersect except at their endpoints). The vertices are assumed to be unique and far enough apart that they are stable in numeric operations.- Specified by:
getVerticesin interfaceIPolyline- Returns:
- a valid list of two or more unique vertices.
-
add
public final void add(Vertex v)
Description copied from interface:IPolylineAdds a vertex to the polyline feature. Implementations of this interface are expected to ensure that all vertices are unique and that no vertices are repeated.
-
getBounds
public Rectangle2D getBounds()
Description copied from interface:IPolylineGets the bounds of the feature.Caution: Implementations of this method expose the Rectangle2D object used by the feature instance. Although this approach supports efficiency for the potentially intense processing conducted by the Tinfour classes, it does not provide a safe implementation for careless developers. Therefore, applications should not manipulate or modify the rectangle instance returned by this routine at any time.
-
setApplicationData
public void setApplicationData(Object applicationData)
Description copied from interface:IConstraintPermits an application to add data elements to the constraint for its own uses. The reference stored in this instance is not accessed by the Tinfour classes.- Specified by:
setApplicationDatain interfaceIConstraint- Parameters:
applicationData- an object or null according to the needs of the calling application.
-
getApplicationData
public Object getApplicationData()
Description copied from interface:IConstraintGets the application data (if any) stored in the constraint. The reference stored in this instance is not accessed by the Tinfour classes.- Specified by:
getApplicationDatain interfaceIConstraint- Returns:
- an object or null according to the needs of the calling application.
-
setConstraintIndex
public void setConstraintIndex(IIncrementalTin tin, int index)
Description copied from interface:IConstraintSets an index value used for internal bookkeeping by Tinfour code; not intended for use by application code. Application code that sets a constraint index runs the risk of damaging the internal data relations maintained by Tinfour.- Specified by:
setConstraintIndexin interfaceIConstraint- Parameters:
tin- the IIncrementalTin instance to while this constraint has been added (or null if not applicable).index- a positive integer.
-
getConstraintIndex
public int getConstraintIndex()
Description copied from interface:IConstraintGets an index value used for internal bookkeeping by Tinfour code. The index value is assigned to a constraint when it is inserted into a Tinfour IIncrementalTin implementation. If an application used a getConstraints() call to get a list of the constraints stored in an IIncrementalTin, the constraint index can be used to get the constraint from that list.- Specified by:
getConstraintIndexin interfaceIConstraint- Returns:
- the index of the constraint associated with the edge; undefined if the edge is not constrained or an interior member of a constrained region.
-
getLength
public double getLength()
Description copied from interface:IPolylineGets the total length of the feature. The length is the accumulated sum of the lengths of the line segments that comprise the feature. In the case of a closed polygon feature, the length is the perimeter of the polygon.
-
getConstraintLinkingEdge
public IQuadEdge getConstraintLinkingEdge()
Description copied from interface:IConstraintGets a reference to an arbitrarily selected edge that was produced when the constraint was added to a TIN.- Specified by:
getConstraintLinkingEdgein interfaceIConstraint- Returns:
- if the constraint is tied to a TIN, a valid edge; otherwise, a null.
-
setConstraintLinkingEdge
public void setConstraintLinkingEdge(IQuadEdge edge)
Description copied from interface:IConstraintSets a reference to an arbitrarily selected edge that was produced when the constraint was added to a TIN. In effect, this reference links the constraint to the TIN. In the case of constraints that define a constrained region, the edge will be the interior side of the edge.This method is not intended for use by application code. Application code that sets a constraint index runs the risk of damaging the internal data relations maintained by Tinfour.
- Specified by:
setConstraintLinkingEdgein interfaceIConstraint- Parameters:
edge- a valid edge reference
-
getManagingTin
public IIncrementalTin getManagingTin()
Description copied from interface:IConstraintGets the instance of the incremental TIN interface that is managing this constraint, if any.- Specified by:
getManagingTinin interfaceIConstraint- Returns:
- if under management, a valid instance; otherwise, a null.
-
isPointInsideConstraint
public boolean isPointInsideConstraint(double x, double y)Description copied from interface:IConstraintIndicates if a point at the specified coordinates is unambiguously inside the constraint. Points on the constraint border are not treated as inside the constraint.This method will only return true for polygon constraints. For all other constraint implementations, it will return a value of false.
- Specified by:
isPointInsideConstraintin interfaceIConstraint- Parameters:
x- the Cartesian coordinate for the pointy- the Cartesian coordinate for the point- Returns:
- true if the point is in the interior of the constraint.
-
densify
public void densify(double threshold)
Description copied from interface:IConstraintInsert synthetic vertices into the constraint so that the spacing between vertices does not exceed the specified threshold. Z values for the inserted vertices are computed using a linear interpolation.This method is intended to aid in analysis and computation. The vertices that are inserted are to be marked as synthetic to indicate that they are not source data.
- Specified by:
densifyin interfaceIConstraint- Parameters:
threshold- the spacing threshold.
-
-