org.jdelaunay.delaunay.geometries
Class DEdge

java.lang.Object
  extended by org.jdelaunay.delaunay.geometries.Element
      extended by org.jdelaunay.delaunay.geometries.DEdge
All Implemented Interfaces:
Comparable<DEdge>

public class DEdge
extends Element
implements Comparable<DEdge>

An edge in the tringulation. A DEdge is formed with two DPoint instances. A DEdge is linked to up to two DTriangle : one on its left, and one on its right. This DEdge is an edge of these DTriangle. The left and right sides are relative to the orientation of the edge. Indeed, a DEdge has a start and an end. If you want to know the leftmost point, you can use getPointLeft (resp getPointRight for the rightmost point). The leftmost point is not necessarily the start point. To swap the start and the end, you can use the swap() method.

Author:
Adelin Piau, Jean-Yves Martin, Erwan Bocher

Field Summary
static int COLINEAR
          Value returned by the intersects method when the two edges are colinear and don't intersect
static int DOWNSLOPE
           
static int FLATSLOPE
           
static int INTERSECT
          Value returned by the intersects method when the two edges intersect in one point
static int NO_INTERSECTION
          Value returned by the intersects method when the two edges don't intersect
static int SHARE_EDGE_PART
          Value returned by the intersects method when the two edges intersect in more than one point (ie they are colinear and do not just share their extremities).
static int SHARE_EXTREMITY
          Value returned by the intersects method when the two edges intersect in one point that is an extremity for both of them.
static int UPSLOPE
           
 
Fields inherited from class org.jdelaunay.delaunay.geometries.Element
WEIGHTED_PROPERTIES
 
Constructor Summary
DEdge()
          Generate a new edge.
DEdge(DEdge ed)
          Generate an edge from another edge.
DEdge(double x, double y, double z, double u, double v, double w)
          Create a new edge given the coordinates of its two extremities
DEdge(DPoint start, DPoint end)
          Generate an edge from two points.
 
Method Summary
 void addProperty(int prop)
          Overrides the default method.
 int compareTo(DEdge edge)
          Realization of Compare.
 boolean contains(com.vividsolutions.jts.geom.Coordinate c)
          Check if the coordinate is inside the element
 boolean contains(DPoint aPoint)
          Check if the point is inside the element
 void deepSwap()
          Perform a "deep swap" on this edge.
 void displayObject(Graphics g, int decalageX, int decalageY, double minX, double minY, double scaleX, double scaleY)
          Display the edge in a JPanel
 boolean equals(Object other)
          Two edges are supposed to be equals if the points they are defined by are the same.
 void forceTopographicOrientation()
          This method wil force the point marked as the end of the edge to be the point with the lower altitude.
 void forceTriangleSide()
          This method takes care to ensure that the left and right triangles are actually on the left and on the right, and not on the right and on the left.
 double get2DLength()
          get 2D length
 double get3DLength()
          get 3D length
 DPoint getBarycenter()
          Get the barycenter of the DEdge.
 BoundaryBox getBoundingBox()
          Computed bounding box
 DPoint getDirectionVector()
          Get the direction vector of the associated line.
 double getDistance2D(DPoint p)
          Get the euclidean distance between p and the line defined by this edge.
 DPoint getEndPoint()
           
 int getGradient()
           
 Element getIntersection(DEdge ed)
          intersects two edges returns null if there is no intersection
 Element getIntersection(DEdge ed, Map<Integer,Integer> weights)
          Get the intersection, using the weights given in argument to compute the z : we will use the z from the edge with the highest weight.
 Element getIntersection(DPoint p1, DPoint p2)
          intersects two edges returns null if there is no intersection
 Element getIntersection(DPoint point1, DPoint point2, boolean useCoordZOfp1p2)
          intersects two edges returns null if there is no intersection if the two edgse are colinear, returns the minimum intersection point, if such a point exists.
 DTriangle getLeft()
           
 DPoint getMiddle()
          Get the middle of the segment, in 3 dimensions.
 DTriangle getOtherTriangle(DTriangle tri)
          Return the left triangle if tri is the right one, the right triangle if tri is the left one, and null otherwise.
 DPoint getPointFromItsX(double abs)
          This method retrieves the point that would stand on the line defined by this edge, and whose absciss is abs.
 DPoint getPointLeft()
          Get the point of this edge that is on the left from the other.
 DPoint getPointRight()
          Get the point of this edge that is on the left from the other.
 DTriangle getRight()
           
 double getSlope()
          Get the slope of the edge
 double getSlopeAspect()
          Compute the aspect of an edge.
 double getSlopeInDegree()
          Get the slope of the edge in degree.
 double getSquared2DLength()
          get squared 2D length
protected  double getSquared3DLength()
          get squared 3D length
 DPoint getStartPoint()
           
 DPoint getUpperPoint()
          return the point of the edge that have the greatest Z coordinate.
 double getZOnEdge(DPoint p)
          Make a linear interpolation for the points that lie on the edge.
 int hashCode()
          Get edge hashCode as min hashCode of its points
 boolean haveSamePoint(DEdge anEdge)
          Check if two edges have the same points.
 int intersects(DEdge other)
          Check if this and other intersect.
 int intersects(DPoint p1, DPoint p2)
          check if two edges intersect
 boolean isColinear(DPoint p)
          check if the point is colinear to the edge
 boolean isColinear2D(DPoint p)
          check if the point is colinear to the edge in the XY plane, ie if it lies on the line defined by this edge.
 boolean isDegenerated()
          Checks if this edge is "degenerated" or not.
 boolean isEncroached()
          An edge is said to be encroached in a mesh if :
(The edge is a constraint OR an edge of the mesh' boundary)
AND there is a point lying in the circle it is the diameter of.
 boolean isEncroachedBy(DPoint pt)
          Test if this edge is encroached by the given point.
 boolean isExtremity(DPoint p)
          check if the point is one of the extremities of the edge (on the xy-plane)
 boolean isFlatSlope()
          Check if the edge is flat or not
 boolean isInside(DPoint p)
          check if the point is between the extremities of the edge (on the xy-plane)
 boolean isLeft(DPoint p)
          Check if the point p is on the left
 boolean isLeftTriangleGoToEdge()
          Returns true if the triangle connected to the left of the edge is pouring into it.
 boolean isLocked()
          get the mark of the edge
 boolean isOnEdge(DPoint p)
          Check if the point p is on edge.
 boolean isRight(DPoint p)
          Check if the point p is on the right
 boolean isRightTriangleGoToEdge()
          Returns true if the triangle connected to the right of the edge is pouring into it.
 boolean isShared()
          An edge is shared when in use by two boundary parts.
 boolean isVertical()
          Returns true if the two points of this edge have the same x coordinate.
protected  void setColor(Graphics g)
          Set the edge color for the JFrame panel
 void setDegenerated(boolean degen)
          Determines if this edge must be considered as degenerated or not.
 void setEndPoint(DPoint p)
          Set edge end point.
 void setLeft(DTriangle aTriangle)
          Set DTriangle at left of edge.
 void setLocked(boolean locked)
          set the mark of the edge
 void setRight(DTriangle aTriangle)
          Set DTriangle at right of edge.
 void setShared(boolean share)
          set the shared status of this DEdge.
 void setStartPoint(DPoint p)
          Set edge start point.
 int sortLeftRight(DEdge edge)
          This method will be used to sort the edges using the following strategy.
 void swap()
          Swap the 2 points of the edge also swap connected triangles
 String toString()
          Gives a string representation of this object.
 int verticalSort(DEdge edge, double abs)
          Sort two edges (this and edge, indeed), and sort them according to their intersection point with the line l of equation x=abs.
 
Methods inherited from class org.jdelaunay.delaunay.geometries.Element
getExternalGID, getGID, getHeight, getMaxWeight, getProperty, hasProperty, removeProperties, setExternalGID, setGID, setHeight, setProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UPSLOPE

public static final int UPSLOPE
See Also:
Constant Field Values

DOWNSLOPE

public static final int DOWNSLOPE
See Also:
Constant Field Values

FLATSLOPE

public static final int FLATSLOPE
See Also:
Constant Field Values

NO_INTERSECTION

public static final int NO_INTERSECTION
Value returned by the intersects method when the two edges don't intersect

See Also:
Constant Field Values

INTERSECT

public static final int INTERSECT
Value returned by the intersects method when the two edges intersect in one point

See Also:
Constant Field Values

COLINEAR

public static final int COLINEAR
Value returned by the intersects method when the two edges are colinear and don't intersect

See Also:
Constant Field Values

SHARE_EXTREMITY

public static final int SHARE_EXTREMITY
Value returned by the intersects method when the two edges intersect in one point that is an extremity for both of them.

See Also:
Constant Field Values

SHARE_EDGE_PART

public static final int SHARE_EDGE_PART
Value returned by the intersects method when the two edges intersect in more than one point (ie they are colinear and do not just share their extremities).

See Also:
Constant Field Values
Constructor Detail

DEdge

public DEdge()
Generate a new edge. The two points that define the DEdge are set to null, it's up to you to use another constructor or to fill the extremities with actual values.


DEdge

public DEdge(DPoint start,
             DPoint end)
Generate an edge from two points.

Parameters:
start -
end -

DEdge

public DEdge(DEdge ed)
Generate an edge from another edge.

Parameters:
ed -

DEdge

public DEdge(double x,
             double y,
             double z,
             double u,
             double v,
             double w)
      throws DelaunayError
Create a new edge given the coordinates of its two extremities

Parameters:
x -
y -
z -
u -
v -
w -
Throws:
DelaunayError
Method Detail

addProperty

public final void addProperty(int prop)
Overrides the default method. The properties will be added to the points that define this edge.

Overrides:
addProperty in class Element
Parameters:
prop -

getLeft

public final DTriangle getLeft()
Returns:
DTriangle at the left of edge.

getRight

public final DTriangle getRight()
Returns:
DTriangle at the right of edge.

getOtherTriangle

public final DTriangle getOtherTriangle(DTriangle tri)
Return the left triangle if tri is the right one, the right triangle if tri is the left one, and null otherwise.

Parameters:
tri -
Returns:
The left (resp. right) triangle of this edge if tri is its right (resp. left) triangle, null otherwise.

setLeft

public final void setLeft(DTriangle aTriangle)
Set DTriangle at left of edge.

Parameters:
aTriangle - A triangle at left of edge.

setRight

public final void setRight(DTriangle aTriangle)
Set DTriangle at right of edge.

Parameters:
aTriangle - A triangle at right of edge.

getStartPoint

public final DPoint getStartPoint()
Returns:
start point of edge.

getEndPoint

public final DPoint getEndPoint()
Returns:
end point of edge.

isDegenerated

public final boolean isDegenerated()
Checks if this edge is "degenerated" or not. An edge is marked as degenerated when connecting to the mesh, but not implied in the building of any triangle.

Returns:
true if this is marked as degenerated.

setDegenerated

public final void setDegenerated(boolean degen)
Determines if this edge must be considered as degenerated or not.

Parameters:
degen -

isShared

public final boolean isShared()
An edge is shared when in use by two boundary parts.

Returns:
true if this is shared between two boundary parts.

setShared

public final void setShared(boolean share)
set the shared status of this DEdge.

Parameters:
share -

setStartPoint

public final void setStartPoint(DPoint p)
Set edge start point.

Parameters:
p - Start point.

setEndPoint

public final void setEndPoint(DPoint p)
Set edge end point.

Parameters:
p - End point.

getPointLeft

public final DPoint getPointLeft()
Get the point of this edge that is on the left from the other. We use the order relation defined in DPoint. Consequently, with a vertical edge, this method return the minimum point, (so the one with the lowest y).

Returns:
the leftmost point of this edge.

getPointRight

public final DPoint getPointRight()
Get the point of this edge that is on the left from the other. We use the order relation defined in DPoint.

Returns:
Rhe rightmost point of this edge.

getSquared2DLength

public final double getSquared2DLength()
get squared 2D length

Returns:
the square of the 2D-length of this edge.

get2DLength

public final double get2DLength()
get 2D length

Returns:
The length of this edge in two dimensions.

getSquared3DLength

protected final double getSquared3DLength()
get squared 3D length

Returns:
the square of the 3D-length of this edge.

get3DLength

public final double get3DLength()
get 3D length

Returns:
The length of this edge in three dimensions.

isLocked

public final boolean isLocked()
get the mark of the edge

Returns:
true if this edge is locked.

setLocked

public final void setLocked(boolean locked)
set the mark of the edge

Parameters:
locked -

getBoundingBox

public final BoundaryBox getBoundingBox()
Description copied from class: Element
Computed bounding box

Specified by:
getBoundingBox in class Element
Returns:
The boundary box of this element.

contains

public final boolean contains(DPoint aPoint)
Description copied from class: Element
Check if the point is inside the element

Specified by:
contains in class Element
Returns:
bool

contains

public final boolean contains(com.vividsolutions.jts.geom.Coordinate c)
Description copied from class: Element
Check if the coordinate is inside the element

Specified by:
contains in class Element
Returns:
bool

getDistance2D

public final double getDistance2D(DPoint p)
Get the euclidean distance between p and the line defined by this edge.

Parameters:
p -
Returns:
the minimal distance between this edge and p.

intersects

public final int intersects(DEdge other)
                     throws DelaunayError
Check if this and other intersect.

Parameters:
other -
Returns:
intersection :
0 = no intersection
1 = intersects
2 = co-linear
3 = intersects at the extremity
4 = intersect in more than one point
note that if on extremity of an edge lies inside the other edge, but is not one of the extremities of the other edge, this method returns 1
Throws:
DelaunayError

intersects

public final int intersects(DPoint p1,
                            DPoint p2)
                     throws DelaunayError
check if two edges intersect

Parameters:
p1 - the start point of the other edge
p2 - the end point of the other edge
Returns:
intersection :
NO_INTERSECTION = no intersection
INTERSECT = intersect
COLINEAR = co-linear and don't intersect
SHARE_EXTREMITY = intersects at the extremity
SHARE_EDGE_PART = intersect in more than one point
note that if on extremity of an edge lies inside the other edge, but is not one of the extremities of the other edge, this method returns 1
Throws:
DelaunayError

getIntersection

public final Element getIntersection(DPoint p1,
                                     DPoint p2)
                              throws DelaunayError
intersects two edges returns null if there is no intersection

Parameters:
p1 -
p2 -
Returns:
the intersection, as an element instance. it can be an DEdge, a DPoint or null.
Throws:
DelaunayError

getIntersection

public final Element getIntersection(DPoint point1,
                                     DPoint point2,
                                     boolean useCoordZOfp1p2)
                              throws DelaunayError
intersects two edges returns null if there is no intersection if the two edgse are colinear, returns the minimum intersection point, if such a point exists.

Parameters:
point1 -
point2 -
useCoordZOfp1p2 - If true, the coordinate of intersection get in Z the average of p1 and p2 Z. Don't care of p3 and, p4 Z. Else if false, the coordinate of intersection get in Z the average of p1, p2, p3 and p4 Z.
Returns:
the intersection, as an element instance. it can be an DEdge, a DPoint or null.
Throws:
DelaunayError

getIntersection

public final Element getIntersection(DEdge ed)
                              throws DelaunayError
intersects two edges returns null if there is no intersection

Parameters:
ed -
Returns:
intersection
Throws:
DelaunayError

getIntersection

public final Element getIntersection(DEdge ed,
                                     Map<Integer,Integer> weights)
                              throws DelaunayError
Get the intersection, using the weights given in argument to compute the z : we will use the z from the edge with the highest weight.

Parameters:
ed -
weights -
Returns:
The intersection, as an element instance. It can be a DPoint, a DEdge, or null.
Throws:
DelaunayError

getZOnEdge

public final double getZOnEdge(DPoint p)
Make a linear interpolation for the points that lie on the edge.

Parameters:
p -
Returns:
Z coordinate of the point p, if it is on the edge. It it is outside the edge, Double.NaN is returned instead.

getSlope

public final double getSlope()
Get the slope of the edge

Returns:
The slope of the edge, in radians.

getSlopeInDegree

public final double getSlopeInDegree()
Get the slope of the edge in degree.

Returns:
The slope of the edge, in degrees.

getDirectionVector

public final DPoint getDirectionVector()
                                throws DelaunayError
Get the direction vector of the associated line.

Returns:
a DPoint that represents the direction vector of the associated line.
Throws:
DelaunayError

isInside

public final boolean isInside(DPoint p)
check if the point is between the extremities of the edge (on the xy-plane)

Parameters:
p -
Returns:
isInside

isColinear2D

public final boolean isColinear2D(DPoint p)
check if the point is colinear to the edge in the XY plane, ie if it lies on the line defined by this edge.

Parameters:
p -
Returns:
isColinear2D

isColinear

public final boolean isColinear(DPoint p)
check if the point is colinear to the edge

Parameters:
p -
Returns:
isColinear2D

haveSamePoint

public final boolean haveSamePoint(DEdge anEdge)
Check if two edges have the same points.

Parameters:
anEdge -
Returns:
True if points are the same.

isExtremity

public final boolean isExtremity(DPoint p)
check if the point is one of the extremities of the edge (on the xy-plane)

Parameters:
p -
Returns:
isInside

isLeft

public final boolean isLeft(DPoint p)
Check if the point p is on the left

Parameters:
p -
Returns:
true if p is on the left (strictly) of this point.

isRight

public final boolean isRight(DPoint p)
Check if the point p is on the right

Parameters:
p -
Returns:
true if p is on the right (strictly) of this point.

isOnEdge

public final boolean isOnEdge(DPoint p)
Check if the point p is on edge. Computation is made in two dimensions.

Parameters:
p -
Returns:
True if the point is on edge.

isVertical

public final boolean isVertical()
Returns true if the two points of this edge have the same x coordinate.

Returns:
True if this is vertical

getPointFromItsX

public final DPoint getPointFromItsX(double abs)
                              throws DelaunayError
This method retrieves the point that would stand on the line defined by this edge, and whose absciss is abs. if this is a vertical edge, the method returns : the minimum point if this edge stand on the line x=abs null otherwise

Parameters:
abs -
Returns:
The intersection of this with the line of absciss abs.
Throws:
DelaunayError - If this is vertical and this.x != abs.

getUpperPoint

public final DPoint getUpperPoint()
return the point of the edge that have the greatest Z coordinate.

Returns:
The uppest extremiety of this edge.

getMiddle

public final DPoint getMiddle()
                       throws DelaunayError
Get the middle of the segment, in 3 dimensions.

Returns:
The middle of the edge, as a DPoint.
Throws:
DelaunayError

isEncroached

public final boolean isEncroached()
                           throws DelaunayError
An edge is said to be encroached in a mesh if :
(The edge is a constraint OR an edge of the mesh' boundary)
AND there is a point lying in the circle it is the diameter of.

Returns:
true if there is such a point.
Throws:
DelaunayError

isEncroachedBy

public final boolean isEncroachedBy(DPoint pt)
                             throws DelaunayError
Test if this edge is encroached by the given point.

Parameters:
pt -
Returns:
true if pt encroaches this.
Throws:
DelaunayError

swap

public final void swap()
Swap the 2 points of the edge also swap connected triangles


isFlatSlope

public final boolean isFlatSlope()
Check if the edge is flat or not

Returns:
isFlat

getBarycenter

public final DPoint getBarycenter()
                           throws DelaunayError
Get the barycenter of the DEdge.

Returns:
barycenter point.
Throws:
DelaunayError

equals

public final boolean equals(Object other)
Two edges are supposed to be equals if the points they are defined by are the same.

Overrides:
equals in class Object
Parameters:
other -
Returns:
true if this and other are equal.

hashCode

public final int hashCode()
Get edge hashCode as min hashCode of its points

Overrides:
hashCode in class Object
Returns:
a hashcode.

setColor

protected final void setColor(Graphics g)
Set the edge color for the JFrame panel

Parameters:
g -

displayObject

public final void displayObject(Graphics g,
                                int decalageX,
                                int decalageY,
                                double minX,
                                double minY,
                                double scaleX,
                                double scaleY)
Display the edge in a JPanel

Parameters:
g -
decalageX -
decalageY -
minX -
minY -
scaleX -
scaleY -

sortLeftRight

public final int sortLeftRight(DEdge edge)
This method will be used to sort the edges using the following strategy. If we note leftP and rightP the leftmost and rightmost point of this this < edge if this.leftP < edge.leftP or (this.leftP == edge.leftP and this.rightP < edge.rightP) this == edge if this.leftP == edge.leftP and this.rightP == edge.rightP this > edge otherwise.

Parameters:
edge -
Returns:
-1 if this is inferior to edge, 0 if they are equal, 1 otherwise.

forceTopographicOrientation

public final void forceTopographicOrientation()
This method wil force the point marked as the end of the edge to be the point with the lower altitude.


compareTo

public final int compareTo(DEdge edge)
Realization of Compare. We use sortLeftRight here to sort our edges, not a vertical sort or something else...

Specified by:
compareTo in interface Comparable<DEdge>
Parameters:
edge -
Returns:
-1 if this is inferior to edge, 0 if they are equal, 1 otherwise.

verticalSort

public final int verticalSort(DEdge edge,
                              double abs)
                       throws DelaunayError
Sort two edges (this and edge, indeed), and sort them according to their intersection point with the line l of equation x=abs. if p1 (p2) is the intersection between l and the line defined by this (edge), this method returns : * -1 if p1 < p2 or ( p1 == p2 and this is "under" edge)
* 0 if p1 == p2 and (this and edge are colinear)
* 1 if p1 > p2 or (p1 == p2 and edge is under this)

Parameters:
edge -
Returns:
* -1 if p1 < p2 or ( p1 == p2 and this is "under" edge)
* 0 if p1 == p2 and (this and edge are colinear)
* 1 if p1 > p2 or (p1 == p2 and edge is under this)
Throws:
DelaunayError

getGradient

public final int getGradient()
Returns:
gradient

getSlopeAspect

public final double getSlopeAspect()
Compute the aspect of an edge. Aspect is measured clockwise in degrees from 0, due north, to 360, again due north, coming full circle.

Returns:
The aspect of this edge.

isLeftTriangleGoToEdge

public final boolean isLeftTriangleGoToEdge()
                                     throws DelaunayError
Returns true if the triangle connected to the left of the edge is pouring into it.

Returns:
True if the left triangle is pouring to this.
Throws:
DelaunayError

isRightTriangleGoToEdge

public final boolean isRightTriangleGoToEdge()
                                      throws DelaunayError
Returns true if the triangle connected to the right of the edge is pouring into it.

Returns:
True if the right triangle is pouring to this.
Throws:
DelaunayError

toString

public final String toString()
Gives a string representation of this object.

Overrides:
toString in class Object
Returns:
"DEdge GID [Start : startPoint, End : endPoint]

deepSwap

public final void deepSwap()
Perform a "deep swap" on this edge. The content of the left and right triangles are inverted, then the references to the triangles are inverted too.
It can be useful when needing to invert two elements in a list without knowing the indices of the elements, or in a non random access list.
This method is useful only when both the right and left triangles associated to this edge are not null.


forceTriangleSide

public final void forceTriangleSide()
This method takes care to ensure that the left and right triangles are actually on the left and on the right, and not on the right and on the left.



Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.