|
class Vertex extends cVector implements java.io.Serializable, java.lang.Comparable
|
{
|
static int sortaxis = 0;
|
|
public int compareTo(Object o)
|
{
|
Vertex b = (Vertex) o;
|
|
switch (sortaxis)
|
{
|
case 0: return x < b.x?-1:1;
|
case 1: return y < b.y?-1:1;
|
case 2: return z < b.z?-1:1;
|
}
|
|
return 0;
|
}
|
|
static final long serialVersionUID = -367349739426346764L;
|
|
Vertex()
|
{
|
this(false);
|
}
|
|
Vertex(boolean withnorm)
|
{
|
//pos = new cVector();
|
if (withnorm)
|
{
|
norm = new cVector();
|
}
|
}
|
|
Vertex(cVector v)
|
{
|
//pos = new cVector(v);
|
super(v);
|
}
|
|
Vertex(Vertex v)
|
{
|
//pos = new cVector(v/*.pos*/);
|
super(v);
|
if (v.norm != null)
|
{
|
norm = new cVector(v.norm);
|
assert(norm.normalized());
|
}
|
index = v.index;
|
s = v.s;
|
t = v.t;
|
}
|
|
Vertex(double x, double y, double z)
|
{
|
//pos = new cVector(x,y,z);
|
super(x, y, z);
|
}
|
|
void set(Vertex v)
|
{
|
super.set(v);
|
|
if (norm != null && v.norm != null)
|
{
|
assert(norm.normalized());
|
|
norm.set(v.norm);
|
|
assert(norm.normalized());
|
}
|
}
|
|
boolean ContainsFace(int index)
|
{
|
assert(norm.normalized());
|
for (int i=0; i<faceindices.length; i++)
|
{
|
if (faceindices[i] == -1)
|
return false;
|
|
if (faceindices[i] == index)
|
return true;
|
}
|
|
// assert(false);
|
|
return false;
|
}
|
|
void AddFace(int index)
|
{
|
assert(norm.normalized());
|
for (int i=0; i<faceindices.length; i++)
|
{
|
if (faceindices[i] == -1)
|
{
|
faceindices[i] = index;
|
return;
|
}
|
}
|
|
// assert(false);
|
}
|
|
// Don't consider normal into hashcode for uniqueness
|
static boolean normalmode = false;
|
|
public int hashCode()
|
{
|
//if (normalmode) // pos == null)
|
// return 0;
|
if (norm == null || !normalmode)
|
{
|
return /*pos.*/ super.hashCode();
|
}
|
|
return /*pos.*/ super.hashCode() + norm.hashCode();
|
}
|
|
public boolean equals(Object o)
|
{
|
// JUNE 2019. norm can be null (e.g. Box) Grafreed.Assert(norm.normalized());
|
//if (true) return false;
|
|
Vertex vert = (Vertex) o;
|
|
//System.out.println("pos = " + pos + "; vert.pos = " + vert/*.pos*/);
|
|
double tolerance = 0.00001;
|
|
if (!Grafreed.epsequal)
|
tolerance = 0;
|
|
boolean samepos = Math.abs(/*pos.*/x - vert./*pos.*/x) +
|
Math.abs(/*pos.*/y - vert./*pos.*/y) +
|
Math.abs(/*pos.*/z - vert./*pos.*/z) <= tolerance && // GrafreeD.epsvertex2 && // WARNING: USE 0.0001 for serial issues
|
(Grafreed.linkUV || Math.abs(s - vert.s) + Math.abs(t - vert.t) <= tolerance)
|
; // GrafreeD.epsvertex2;
|
|
if (samepos && Grafreed.smoothmode)
|
{
|
norm.add(vert.norm);
|
norm.normalize();
|
vert.norm.set(norm);
|
}
|
|
return samepos;
|
}
|
/*
|
public boolean isSame(Object o)
|
{
|
Vertex vert = (Vertex) o;
|
return x == vert.x && y == vert.y && z == vert.z;
|
}
|
*/
|
//cVector pos; // Base class
|
cVector norm;
|
cVector speed;
|
int index = -1;
|
double s, t;
|
int vertexlink = -1;
|
int vertexlink2 = -1; // second point to block the rotation
|
float tx; // coordinates in tangent plane (closest point)
|
float ty;
|
float tz;
|
float nx; // normals in tangent plane (closest point)
|
float ny;
|
float nz;
|
|
int[] vertexlinks = null; // multiple support points (N)
|
int[] vertexlinks2 = null; // second point to block the rotation
|
float[] weights;
|
float totalweight;
|
float[] tplane; // coordinates in tangent plane (xyz*N)
|
float[] nplane; // normals
|
int closestsupport;
|
|
// june 2013
|
transient int[] faceindices;
|
|
int supportindex; // actually subgeometry
|
|
//short flags;
|
//boolean touched;
|
transient int /*byte*/ valid = -1;
|
transient int boundary = -1;
|
transient int valence = 0;
|
//transient
|
float AO = 1;
|
}
|