Class 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 Detail

      • list

        protected final List<Vertex> list
        The list of vertices that define the constraint geometry
      • 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: IPolyline
        Gets 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:
        getVertices in interface IPolyline
        Returns:
        a valid list of two or more unique vertices.
      • add

        public final void add​(Vertex v)
        Description copied from interface: IPolyline
        Adds 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.
        Specified by:
        add in interface IPolyline
        Parameters:
        v - a valid instance
      • getBounds

        public Rectangle2D getBounds()
        Description copied from interface: IPolyline
        Gets 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.

        Specified by:
        getBounds in interface IPolyline
        Returns:
        a valid, potentially empty rectangle instance.
      • setApplicationData

        public void setApplicationData​(Object applicationData)
        Description copied from interface: IConstraint
        Permits 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:
        setApplicationData in interface IConstraint
        Parameters:
        applicationData - an object or null according to the needs of the calling application.
      • getApplicationData

        public Object getApplicationData()
        Description copied from interface: IConstraint
        Gets the application data (if any) stored in the constraint. The reference stored in this instance is not accessed by the Tinfour classes.
        Specified by:
        getApplicationData in interface IConstraint
        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: IConstraint
        Sets 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:
        setConstraintIndex in interface IConstraint
        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: IConstraint
        Gets 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:
        getConstraintIndex in interface IConstraint
        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: IPolyline
        Gets 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.
        Specified by:
        getLength in interface IPolyline
        Returns:
        if the feature geometry is defined, a positive floating point value, otherwise a zero.
      • getConstraintLinkingEdge

        public IQuadEdge getConstraintLinkingEdge()
        Description copied from interface: IConstraint
        Gets a reference to an arbitrarily selected edge that was produced when the constraint was added to a TIN.
        Specified by:
        getConstraintLinkingEdge in interface IConstraint
        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: IConstraint
        Sets 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:
        setConstraintLinkingEdge in interface IConstraint
        Parameters:
        edge - a valid edge reference
      • getManagingTin

        public IIncrementalTin getManagingTin()
        Description copied from interface: IConstraint
        Gets the instance of the incremental TIN interface that is managing this constraint, if any.
        Specified by:
        getManagingTin in interface IConstraint
        Returns:
        if under management, a valid instance; otherwise, a null.
      • isPointInsideConstraint

        public boolean isPointInsideConstraint​(double x,
                                               double y)
        Description copied from interface: IConstraint
        Indicates 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:
        isPointInsideConstraint in interface IConstraint
        Parameters:
        x - the Cartesian coordinate for the point
        y - 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: IConstraint
        Insert 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:
        densify in interface IConstraint
        Parameters:
        threshold - the spacing threshold.