Normand Briere
2019-09-24 767be784dc7fe293bf5c5ee6507df242526be3ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
 
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;
}