Class SemiVirtualEdge

  • All Implemented Interfaces:
    IQuadEdge

    public final class SemiVirtualEdge
    extends Object
    implements IQuadEdge
    Provides methods and elements implementing the QuadEdge data structure using a virtual representation of the links based on integer arrays rather than direct class instances.
    • Method Detail

      • loadForwardFromEdge

        public void loadForwardFromEdge​(SemiVirtualEdge e)
        Load the content of the forward of the specified edge
        Parameters:
        e - a valid instance
      • loadReverseFromEdge

        public void loadReverseFromEdge​(SemiVirtualEdge e)
        Load the content of the reverse of the specified edge
        Parameters:
        e - a valid instance
      • getA

        public Vertex getA()
        Description copied from interface: IQuadEdge
        Gets the initial vertex for this edge.
        Specified by:
        getA in interface IQuadEdge
        Returns:
        a valid reference.
      • getB

        public Vertex getB()
        Description copied from interface: IQuadEdge
        Gets the second vertex for this edge.
        Specified by:
        getB in interface IQuadEdge
        Returns:
        a valid reference or a null for a ghost edge.
      • getTriangleApex

        public Vertex getTriangleApex()
        When the edge exists within a TIN, this method gets the apex of a triangle formed with the edge as the base.
        Returns:
        if defined, a valid instance; otherwise, a null.
      • isExterior

        public boolean isExterior()
        Indicates if the edge is exterior to a TIN.
        Returns:
        true if the edge is exterior; otherwise, false.
      • getReverse

        public SemiVirtualEdge getReverse()
        Constructs a new instance of the virtual edge class referencing the forward of the current edge.
        Specified by:
        getReverse in interface IQuadEdge
        Returns:
        a new instances
      • getDualFromReverse

        public SemiVirtualEdge getDualFromReverse()
        Constructs a new instance of the virtual edge class referencing the dual of the current edge's reverse.
        Specified by:
        getDualFromReverse in interface IQuadEdge
        Returns:
        a new instances
      • getDual

        public SemiVirtualEdge getDual()
        Constructs a new instance of the virtual edge class referencing the dual of the current edge.
        Specified by:
        getDual in interface IQuadEdge
        Returns:
        a new instances
      • clear

        public void clear()
        Clear all reference in the virtual edge.
      • getBaseReference

        public SemiVirtualEdge getBaseReference()
        Constructs a new instance of the virtual edge class referencing the base of the current edge (may be a copy of the current edge if it is a base).
        Specified by:
        getBaseReference in interface IQuadEdge
        Returns:
        a new instances
      • getBaseIndex

        public int getBaseIndex()
        Description copied from interface: IQuadEdge
        Gets the index of the "base" side of a bi-directional edge. In Tinfour implementations, edges are bi-directional. In effect, the edge is implemented as a pair of unidirectional elements. Each element is assigned a separate index. The first element in the pair is designated as the "base" and is assigned an even-valued index. Its dual is assigned a value one greater than the base index. This method always returns an even value.

        This method can be useful in cases where an application needs to track a complete edge without regard to which side of the edge is being considered.

        Specified by:
        getBaseIndex in interface IQuadEdge
        Returns:
        a positive, even value.
      • getForwardFromDual

        public SemiVirtualEdge getForwardFromDual()
        Constructs a new instance of the virtual edge class referencing the forward of the dual of the current edge
        Specified by:
        getForwardFromDual in interface IQuadEdge
        Returns:
        a new instances
      • getDualFromForward

        public SemiVirtualEdge getDualFromForward()
        Constructs a new instance of the virtual edge class referencing the dual of the forward of the current edge
        Returns:
        a new instances
      • getReverseFromDual

        public SemiVirtualEdge getReverseFromDual()
        Constructs a new instance of the virtual edge class referencing the reverse of the dual of the current edge
        Specified by:
        getReverseFromDual in interface IQuadEdge
        Returns:
        a new instances
      • getIndex

        public int getIndex()
        Description copied from interface: IQuadEdge
        Gets the index value for this edge. In general, the index value is intended for memory management and edge pools. So while application code may read index values, it is not generally enabled to set them.

        In Tinfour implementations, edges are bi-directional. In effect, the edge is implemented as a pair of unidirectional elements. Each element is assigned a separate index.

        One common use for the index code by applications is to main a record of processing performed using edge-traversal operations. For example, some applications use the index to maintain a bitmap of visited edges when performing surface analysis.

        When an edge is allocated, it is set with an arbitrary index value. This value will not change while the edge remains allocated by and edge-pool instance. As soon as the edge is released, it is likely to have its index value reassigned.

        Specified by:
        getIndex in interface IQuadEdge
        Returns:
        a positive integer value
      • getLength

        public double getLength()
        Description copied from interface: IQuadEdge
        Gets the length of the edge.
        Specified by:
        getLength in interface IQuadEdge
        Returns:
        a positive floating point value
      • getLengthSq

        public double getLengthSq()
        Description copied from interface: IQuadEdge
        Gets the squared length of the edge.
        Specified by:
        getLengthSq in interface IQuadEdge
        Returns:
        a positive floating point value
      • getSide

        public int getSide()
        Gets the low-order bit of the index of the current edge
        Specified by:
        getSide in interface IQuadEdge
        Returns:
        a zero or a one.
      • setA

        public void setA​(Vertex a)
        Sets the initial vertex of the current edge (and final vertex of its dual)
        Parameters:
        a - a valid reference or a null.
      • setB

        public void setB​(Vertex b)
        Sets the final vertex of the current edge (and initial vertex of its dual)
        Parameters:
        b - a valid reference or a null.
      • setDualForward

        public void setDualForward​(SemiVirtualEdge forward)
        Sets the forward link for the dual of the current edge.
        Parameters:
        forward - the forward reference/
      • setDualReverse

        public void setDualReverse​(SemiVirtualEdge reverse)
        Sets the reverse link for the dual of the current edge.
        Parameters:
        reverse - the forward reference/
      • setForward

        public void setForward​(SemiVirtualEdge e)
        Sets the forward link for the current edge.
        Parameters:
        e - the forward reference/
      • setReverse

        public void setReverse​(SemiVirtualEdge e)
        Sets the reverse link for the current edge.
        Parameters:
        e - the forward reference/
      • setVertices

        public void setVertices​(Vertex a,
                                Vertex b)
        Sets both vertices for the current edge (and the opposite vertices of its dual).
        Parameters:
        a - the initial vertex
        b - the final vertex
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getConstraintIndex

        public int getConstraintIndex()
        Description copied from interface: IQuadEdge
        Gets the index of the constraint associated with this edge.
        Specified by:
        getConstraintIndex in interface IQuadEdge
        Returns:
        a positive value; may be zero if not specified.
      • setConstraintIndex

        public void setConstraintIndex​(int constraintIndex)
        Description copied from interface: IQuadEdge
        Sets the constraint index for this edge. This method does not necessarily set an edge to a constrained status. In some implementations the constraint index may be used as a way of associating ordinary edges with a neighboring constraint. Constraint index values must be positive integers. The range of supported values will depend on the specific class that implements this interface. Please refer to the class documentation for specific values.
        Specified by:
        setConstraintIndex in interface IQuadEdge
        Parameters:
        constraintIndex - a positive number indicating which constraint a particular edge is associated with.
      • isConstrained

        public boolean isConstrained()
        Description copied from interface: IQuadEdge
        Indicates whether an edge is constrained.
        Specified by:
        isConstrained in interface IQuadEdge
        Returns:
        true if the edge is constrained; otherwise, false.
      • isConstraintRegionBorder

        public boolean isConstraintRegionBorder()
        Description copied from interface: IQuadEdge
        Indicates whether an edge represents the border of a constrained region. Border edges will always be constrained. Border edges are also classified as "member" edges of a constrained region.
        Specified by:
        isConstraintRegionBorder in interface IQuadEdge
        Returns:
        true if the edge is the border of the constrained region; otherwise, false.
      • isConstraintRegionInterior

        public boolean isConstraintRegionInterior()
        Description copied from interface: IQuadEdge
        Indicates whether the edge is in the interior of a constrained region. Both sides of the edge lie within the interior of the region. All points along the edge will lie within the interior of the region with the possible exception of the endpoints. The endpoints may lie on the border of the region. An interior edge for a constrained region is not a constrained edge. Interior edges are also classified as "member" edges of a constrained region.
        Specified by:
        isConstraintRegionInterior in interface IQuadEdge
        Returns:
        true if the edge is in the interior of an region; otherwise false.
      • isConstraintRegionMember

        public boolean isConstraintRegionMember()
        Description copied from interface: IQuadEdge
        Indicates whether the edge is a member of a constrained region (is in the interior or serves as the border of a polygon-based constraint). A constrained region member is not necessarily a constrained edge.
        Specified by:
        isConstraintRegionMember in interface IQuadEdge
        Returns:
        true if the edge is a member of an region; otherwise false.
      • setConstraintRegionBorderFlag

        public void setConstraintRegionBorderFlag()
        Description copied from interface: IQuadEdge
        Sets a flag indicating that the edge is an edge of a constrained region.
        Specified by:
        setConstraintRegionBorderFlag in interface IQuadEdge
      • isConstraintLineMember

        public boolean isConstraintLineMember()
        Description copied from interface: IQuadEdge
        Indicates whether the edge is a member of a constraint line, In some cases, a constraint line member edge may lie within a constrained region but will not lie on one of its borders.
        Specified by:
        isConstraintLineMember in interface IQuadEdge
        Returns:
        true if the edge is a member of an region; otherwise false.
      • setConstraintLineMemberFlag

        public void setConstraintLineMemberFlag()
        Description copied from interface: IQuadEdge
        Sets the constraint-line member flag for the edge to true.
        Specified by:
        setConstraintLineMemberFlag in interface IQuadEdge
      • pinwheel

        public Iterable<IQuadEdge> pinwheel()
        Description copied from interface: IQuadEdge
        Gets an instance of an iterable that performs a pinwheel operation. This instance may be used in a Java for statement
            for(IQuadEdge e: startingEdge.pinwheel()){
            }
         

        About the pinwheel operation: In the Tinfour library, a pinwheel operation interates over the set of edges that connect to the initial vertex of the current edge. The initial vertex is the one returned from a call to getA(). Connected vertices may be obtained through a call to getB().

        Null references for vertex:If vertex A lies on the perimeter of the Delaunay mesh, one or more of the connected edges may terminate on the "ghost vertex" which is used by Tinfour to complete the triangulation. The ghost vertex is represented by a null reference. So applications performing a pinwheel on an arbitrary edge should include logic to handle a null return from the getB() method.

            for(IQuadEdge e: startingEdge.pinwheel()){
                Vertex B = e.getB();
                if(B == null){
                     // skip processing
                }else {
                     // perform processing using B
                }
            }
         
        Specified by:
        pinwheel in interface IQuadEdge
        Returns:
        a valid Iterable.
      • setSynthetic

        public void setSynthetic​(boolean status)
        Description copied from interface: IQuadEdge
        Sets the synthetic flag for the edge. Synthetic edges are those that do not arise naturally from the TIN-building logic but are created by special operations.
        Specified by:
        setSynthetic in interface IQuadEdge
        Parameters:
        status - true if the edge is synthetic; otherwise, false.
      • isSynthetic

        public boolean isSynthetic()
        Description copied from interface: IQuadEdge
        Indicates whether the synthetic flag is set for the edge.
        Specified by:
        isSynthetic in interface IQuadEdge
        Returns:
        true if the edge is synthetic; otherwise, false.
      • setLine2D

        public void setLine2D​(AffineTransform transform,
                              Line2D l2d)
        Description copied from interface: IQuadEdge
        A deprecated method replaced by the equivalent transcribeToLine2D().
        Specified by:
        setLine2D in interface IQuadEdge
        Parameters:
        transform - a valid affine transform
        l2d - a valid Line2D instance to receive the geometry data from the edge.
      • transcribeToLine2D

        public void transcribeToLine2D​(AffineTransform transform,
                                       Line2D l2d)
        Description copied from interface: IQuadEdge
        Provides a convenience method for rendering edges by setting the Line2D argument with the transformed coordinates of the edge. The affine transform is used to map vertex A and B of the edge to the specified coordinate system. The transformed coordinates are then stored in the application-supplied Line2D object. If a null reference is supplied for the transform, this method treats it as the identity transform.

        This method is intended to support rendering operations that may render a large number of edges using Java's Line2D class. In such cases, this method avoids the overhead involved in creating multiple Line2D instances by allowing an application to reuse a single instance multiple times.

        Specified by:
        transcribeToLine2D in interface IQuadEdge
        Parameters:
        transform - a valid affine transform
        l2d - a valid Line2D instance to receive the geometry data from the edge.
      • setConstraintBorderIndex

        public void setConstraintBorderIndex​(int constraintIndex)
        Description copied from interface: IQuadEdge
        Sets a flag identifying the edge as the border of a region-based constraint and stores the index for that constraint.
        Specified by:
        setConstraintBorderIndex in interface IQuadEdge
        Parameters:
        constraintIndex - a positive integer in the range zero to 8190, or -1 for a null constraint.
      • getConstraintBorderIndex

        public int getConstraintBorderIndex()
        Description copied from interface: IQuadEdge
        Gets the index of the region-based constraint associated with an edge that serves as part of the polygon bounding that region.
        Specified by:
        getConstraintBorderIndex in interface IQuadEdge
        Returns:
        a positive integer or -1 if no constraint is specified.
      • setConstraintLineIndex

        public void setConstraintLineIndex​(int constraintIndex)
        Description copied from interface: IQuadEdge
        Sets a flag identifying the edge as the border of a line-based constraint and stores the index for that constraint.
        Specified by:
        setConstraintLineIndex in interface IQuadEdge
        Parameters:
        constraintIndex - a positive integer in range zero to 8190
      • setConstraintRegionInteriorIndex

        public void setConstraintRegionInteriorIndex​(int constraintIndex)
        Description copied from interface: IQuadEdge
        Sets a flag identifying the edge as an interior member of a region-based constraint and stores the index for that constraint.
        Specified by:
        setConstraintRegionInteriorIndex in interface IQuadEdge
        Parameters:
        constraintIndex - a positive integer in the range 0 to 8190, or -1 for a null value
      • getConstraintRegionInteriorIndex

        public int getConstraintRegionInteriorIndex()
        Description copied from interface: IQuadEdge
        Gets the index of the region-based constraint associated with an edge contained in the interior of a constraint polygon. The edge itself is not necessarily constrained and is not part of the definition for the polygon.
        Specified by:
        getConstraintRegionInteriorIndex in interface IQuadEdge
        Returns:
        a positive integer or -1 if no constraint is specified.
      • getConstraintLineIndex

        public int getConstraintLineIndex()
        Description copied from interface: IQuadEdge
        Gets the index of a line-based constraint associated with an edge. The edge is constrained. Due to limitations of memory, the Tinfour implementation cannot support an index for an edge that happens to be a member of multiple constraints (as in the case of an edge that is also part of a border constraint).
        Specified by:
        getConstraintLineIndex in interface IQuadEdge
        Returns:
        a positive integer or -1 is no constraint index is available.