| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
package org.locationtech.jts.triangulate; |
| 13 |
|
| 14 |
|
| 15 |
import org.locationtech.jts.geom.Coordinate; |
| 16 |
import org.locationtech.jts.triangulate.quadedge.Vertex; |
| 17 |
|
| 18 |
/** |
| 19 |
* A vertex in a Constrained Delaunay Triangulation. |
| 20 |
* The vertex may or may not lie on a constraint. |
| 21 |
* If it does it may carry extra information about the original constraint. |
| 22 |
* |
| 23 |
* @author Martin Davis |
| 24 |
*/ |
| 25 |
public class ConstraintVertex extends Vertex { |
| 26 |
private boolean isOnConstraint; |
| 27 |
private Object constraint = null; |
| 28 |
|
| 29 |
/** |
| 30 |
* Creates a new constraint vertex |
| 31 |
* |
| 32 |
* @param p the location of the vertex |
| 33 |
*/ |
| 34 |
public ConstraintVertex(Coordinate p) { |
| 35 |
super(p); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Sets whether this vertex lies on a constraint. |
| 40 |
* |
| 41 |
* @param isOnConstraint true if this vertex lies on a constraint |
| 42 |
*/ |
| 43 |
public void setOnConstraint(boolean isOnConstraint) { |
| 44 |
this.isOnConstraint = isOnConstraint; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Tests whether this vertex lies on a constraint. |
| 49 |
* |
| 50 |
* @return true if the vertex lies on a constraint |
| 51 |
*/ |
| 52 |
public boolean isOnConstraint() { |
| 53 |
return isOnConstraint; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Sets the external constraint information |
| 58 |
* |
| 59 |
* @param constraint an object which carries information about the constraint this vertex lies on |
| 60 |
*/ |
| 61 |
public void setConstraint(Object constraint) { |
| 62 |
isOnConstraint = true; |
| 63 |
this.constraint = constraint; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Gets the external constraint object |
| 68 |
* |
| 69 |
* @return the external constraint object |
| 70 |
*/ |
| 71 |
public Object getConstraint() { |
| 72 |
return constraint; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Merges the constraint data in the vertex <tt>other</tt> into this vertex. |
| 77 |
* This method is called when an inserted vertex is |
| 78 |
* very close to an existing vertex in the triangulation. |
| 79 |
* |
| 80 |
* @param other the constraint vertex to merge |
| 81 |
*/ |
| 82 |
protected void merge(ConstraintVertex other) { |
| 83 |
if (other.isOnConstraint) { |
| 84 |
isOnConstraint = true; |
| 85 |
constraint = other.constraint; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|