Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 package edu.tum.cs.vis.model.util;
00010
00011 import java.awt.Color;
00012 import java.util.Collection;
00013 import java.util.HashSet;
00014 import java.util.Set;
00015
00016 import javax.vecmath.Point3f;
00017 import javax.vecmath.Tuple3f;
00018 import javax.vecmath.Vector3f;
00019
00027 public class Vertex extends Point3f {
00028
00032 private static final long serialVersionUID = 4454667509075960402L;
00033
00037 private Vector3f normalVector = new Vector3f();
00038
00042 private float pointarea = 0f;
00043
00047 public Color color;
00048
00052 public Color overrideColor = null;
00053
00057 private int clusterLabel = -1;
00058
00063 private final float[] clusterCurvatureVal = { 0.0f, 0.0f, 0.0f };
00064
00068 private boolean isSharpVertex = false;
00069
00073 private final Set<Vertex> neighbors = new HashSet<Vertex>();
00074
00085 public Vertex(float x, float y, float z) {
00086 super(x, y, z);
00087 }
00088
00095 public Vertex(Tuple3f p) {
00096 super(p);
00097 }
00098
00107 public Vertex(Tuple3f p, Vector3f norm) {
00108 super(p);
00109 this.normalVector = (Vector3f) norm.clone();
00110 }
00111
00112
00113
00114
00115
00116 @Override
00117 public Object clone() {
00118 Vertex v = new Vertex(this);
00119 v.normalVector = (Vector3f) normalVector.clone();
00120 v.color = color == null ? null : new Color(color.getRed(), color.getGreen(),
00121 color.getBlue(), color.getAlpha());
00122 v.overrideColor = overrideColor == null ? null : new Color(overrideColor.getRed(),
00123 overrideColor.getGreen(), overrideColor.getBlue(), overrideColor.getAlpha());
00124 return v;
00125 }
00126
00127
00128
00129
00130
00131 @Override
00132 public boolean equals(Object o) {
00133 if (o == this) {
00134 return true;
00135 }
00136
00137 return false;
00138 }
00139
00147 public boolean sameCoordinates(Point3f p) {
00148
00149 if (p.x == x && p.y == y && p.z == z) {
00150 return true;
00151 }
00152
00153
00154 float distanceTolerance = Thresholds.DISTANCE_TOLERANCE;
00155 Vector3f diff = new Vector3f(x, y, z);
00156 diff.sub(p);
00157 return (diff.length() <= distanceTolerance);
00158 }
00159
00165 public Vector3f getNormalVector() {
00166 return normalVector;
00167 }
00168
00174 public float getPointarea() {
00175 return pointarea;
00176 }
00177
00178
00179
00180
00181
00182 @Override
00183 public int hashCode() {
00184 return Float.valueOf(x).hashCode() ^ Float.valueOf(y).hashCode()
00185 ^ Float.valueOf(z).hashCode() ^ Double.valueOf(pointarea).hashCode()
00186 ^ normalVector.hashCode();
00187 }
00188
00195 public void setNormalVector(Vector3f normalVector) {
00196 this.normalVector = normalVector;
00197 }
00198
00205 public void setPointarea(float pointarea) {
00206
00207 this.pointarea = pointarea;
00208 }
00209
00216 public void transform(float[][] matrix) {
00217
00218 float[] newPos = new float[4];
00219 for (int row = 0; row < 4; row++) {
00220 newPos[row] = x * matrix[row][0] + y * matrix[row][1] + z * matrix[row][2]
00221 + matrix[row][3];
00222 }
00223 x = newPos[0] / newPos[3];
00224 y = newPos[1] / newPos[3];
00225 z = newPos[2] / newPos[3];
00226 }
00227
00233 public Set<Vertex> getNeighbors() {
00234 return neighbors;
00235 }
00236
00244 public void addNeighbor(Vertex v) {
00245 if (v == this)
00246 return;
00247 synchronized (neighbors) {
00248 neighbors.add(v);
00249 }
00250 }
00251
00259 public void addNeighbor(Collection<Vertex> neig) {
00260 synchronized (neighbors) {
00261 synchronized (neig) {
00262 neighbors.addAll(neig);
00263 }
00264
00265 if (neighbors.contains(this))
00266 neighbors.remove(this);
00267 }
00268 }
00269
00277 public void addNeighbor(Vertex[] neig) {
00278 synchronized (neighbors) {
00279 synchronized (neig) {
00280 for (Vertex v : neig) {
00281 if (v == this)
00282 continue;
00283 neighbors.add(v);
00284 }
00285 }
00286 }
00287 }
00288
00292 public boolean isSharpVertex() {
00293 return isSharpVertex;
00294 }
00295
00302 public void isSharpVertex(final boolean value) {
00303 this.isSharpVertex = value;
00304 }
00305
00309 public int getClusterLabel() {
00310 return clusterLabel;
00311 }
00312
00319 public void setClusterLabel(final int newLabel) {
00320 this.clusterLabel = newLabel;
00321 }
00322
00326 public float[] getClusterCurvatureVal() {
00327 return clusterCurvatureVal;
00328 }
00329
00340 public void setClusterCurvatureVal(final float newKMin, final float newKMax,
00341 final float newKMinKMax) {
00342 this.clusterCurvatureVal[0] = newKMin;
00343 this.clusterCurvatureVal[1] = newKMax;
00344 this.clusterCurvatureVal[2] = newKMinKMax;
00345 }
00346 }