Normand Briere
2019-08-14 0c1f740dd6ddd6432dc29266e42ef851e26027bb
BoundaryRep.java
....@@ -161,6 +161,7 @@
161161 || FaceCount() != other.FaceCount()
162162 || !(indices == null ^ other.indices != null)) // july 2014
163163 {
164
+ // The meshes have different structures.
164165 //new Exception().printStackTrace();
165166 trimmed = other.trimmed;
166167 stripified = other.stripified;
....@@ -239,9 +240,16 @@
239240 }
240241 }
241242
242
- Support[] InitConnections(BoundaryRep other)
243
+ transient Support[] cachesupports = null;
244
+
245
+ Support[] InitConnections()
243246 {
244
- int n = other.startvertices.length-1;
247
+ if (cachesupports != null)
248
+ {
249
+ return cachesupports;
250
+ }
251
+
252
+ int n = this.startvertices.length-1;
245253
246254 Support[] supports = new Support[n];
247255
....@@ -253,38 +261,60 @@
253261
254262 for (int object=1; object<=n; object++)
255263 {
256
- int start = other.startvertices[object-1];
257
- int end = other.startvertices[object];
264
+ int start = this.startvertices[object-1];
265
+ int end = this.startvertices[object];
258266
259267 if (start == end)
260268 continue; // ??
261269
270
+ /**
271
+ Vertex v2 = vertextemp;
272
+ v2.x = averagepoints[object*3];
273
+ v2.y = averagepoints[object*3+1];
274
+ v2.z = averagepoints[object*3+2];
275
+
276
+ //v2.set(GetVertex(this.startvertices[subsupport]));
277
+
278
+ // projected point
279
+ Vertex v3 = vertextemp2;
280
+ //GetVertex(this.startvertices[subsupport]);
281
+ v3.x = extremepoints[object*3];
282
+ v3.y = extremepoints[object*3+1];
283
+ v3.z = extremepoints[object*3+2];
284
+
285
+ vect3.set(v3); // "X" axis apex
286
+ vect3.sub(v2); // origin (center)
287
+ vect3.normalize();
288
+ /**/
289
+
262290 int linkcount = 0;
263291
264292 int objectinlist = -1;
293
+
294
+ Support subsupport = supports[object-1];
265295
266296 for (int object2=1; object2<=n; object2++)
267297 {
268298 for (int i = start; i < end; i++)
269299 {
270
- Vertex v = other.GetVertex(i);
300
+ Vertex v = this.GetVertex(i);
271301
272
- //
273
- if (other.Contains(v, object2))
302
+ // Check if v is close enough from any vertex of the given subobject.
303
+ if (this.Contains(v, object2))
274304 {
275
- if (linkcount == supports[object-1].links.length)
305
+ if (linkcount == subsupport.links.length)
276306 break;
277307
278308 if (object2 == object)
279309 objectinlist = linkcount;
280310
281
- supports[object-1].links[linkcount++] = object2;
311
+ subsupport.links[linkcount++] = object2;
282312 break;
283313 }
284314 }
285315 }
286316
287
- supports[object-1].links[linkcount] = -1;
317
+ subsupport.links[linkcount] = -1;
288318
289319 if (objectinlist == -1)
290320 assert(objectinlist != -1);
....@@ -293,9 +323,9 @@
293323 // assert(linkcount > 1);
294324
295325 // show main support as blue
296
- int first = supports[object-1].links[0];
297
- supports[object-1].links[0] = supports[object-1].links[objectinlist];
298
- supports[object-1].links[objectinlist] = first;
326
+ int first = subsupport.links[0];
327
+ subsupport.links[0] = subsupport.links[objectinlist];
328
+ subsupport.links[objectinlist] = first;
299329 }
300330
301331 for (int loop = 0; --loop>=0;)
....@@ -353,7 +383,7 @@
353383 supports = supports2;
354384 }
355385
356
- return supports;
386
+ return cachesupports = supports;
357387 }
358388
359389 double Distance2(Vertex v, Vertex v2, double dist2beat, double[][] toRoot, int k)
....@@ -500,7 +530,7 @@
500530 static Vertex vertextemp = new Vertex(true);
501531 static Vertex vertextemp2 = new Vertex(true);
502532
503
- static double SEUIL = 0.1f; // 0.1 for rag doll; 0.07;
533
+ static double SEUIL = 0.05f; // 0.1 for rag doll; 0.07;
504534
505535 // Compute weight of point w/r to this
506536 float ComputeWeight(Vertex v, double[][] toRoot, int k)
....@@ -598,7 +628,7 @@
598628 // ;
599629 //
600630
601
- supportsize = supportsizes[subsupport];
631
+ supportsize = supportminsize[subsupport];
602632
603633 double K = supportsize / distmax;
604634
....@@ -650,7 +680,8 @@
650680 // if (supportsize * fadefactor > 1)
651681 // return 1;
652682
653
- return supportsize * fadefactor;
683
+ return //supportsize *
684
+ supportsize * fadefactor;
654685 }
655686
656687 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
....@@ -952,7 +983,7 @@
952983
953984 // sept 2017 SEUIL = 0.1; // aout 2013
954985
955
- supports = InitConnections(other);
986
+ supports = other.InitConnections();
956987
957988 other.supports = supports; // should be the other way around...
958989
....@@ -1895,7 +1926,7 @@
18951926 return;
18961927 }
18971928
1898
- // System.exit(0);
1929
+ // System.exit(0);
18991930
19001931 cVector vect = new cVector();
19011932 cVector normal = new cVector();
....@@ -1966,7 +1997,10 @@
19661997 if (v.vertexlinks == null)
19671998 continue;
19681999
1969
- if (v.weights != null && v.weights[j] == 0) // < 0.01 * v.totalweight) // == 0)
2000
+ // Warning: faster but dangerous
2001
+ if (v.weights != null && v.weights[j]
2002
+ // == 0)
2003
+ < 0.001 * v.totalweight)
19702004 {
19712005 //testweight += v.weights[j-1];
19722006 continue;
....@@ -2247,6 +2281,8 @@
22472281
22482282 transient int lastsoundtime;
22492283
2284
+ transient boolean once = false;
2285
+
22502286 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked)
22512287 {
22522288 if (LA.isIdentity(toRoot))
....@@ -2302,7 +2338,11 @@
23022338
23032339 if (v.totalweight == 0)
23042340 {
2305
- System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2341
+ if (!once)
2342
+ {
2343
+ System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2344
+ once = true;
2345
+ }
23062346 continue;
23072347 }
23082348
....@@ -3098,6 +3138,7 @@
30983138 //
30993139 // transient VertexCompare[] vertexcompare = null;
31003140
3141
+ // Check if v0 is close enough from any vertex of the given subobject of this.
31013142 boolean Contains(Vertex v0, int object)
31023143 {
31033144 int start = startvertices[object-1];
....@@ -3696,6 +3737,111 @@
36963737 */
36973738 }
36983739
3740
+ void GenerateNormals2(boolean crease)
3741
+ {
3742
+ cVector tempVector = new cVector();
3743
+
3744
+// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();
3745
+//
3746
+//
3747
+// for (int i=0; i<this.VertexCount(); i++)
3748
+// {
3749
+// Vertex v = this.GetVertex(i);
3750
+//
3751
+// tempVector.set(v);
3752
+//
3753
+// cVector n = tableBase.get(tempVector.ToFloat());
3754
+//
3755
+// if (n != null)
3756
+// {
3757
+// continue;
3758
+// }
3759
+//
3760
+// tableBase.put(new cVector(tempVector), new cVector(v.norm));
3761
+// }
3762
+
3763
+ BoundaryRep tempSupport = this.support;
3764
+
3765
+ this.support = null;
3766
+
3767
+ BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);
3768
+
3769
+ this.support = tempSupport;
3770
+
3771
+ //tempRep.Unstripify();
3772
+
3773
+ tempRep.GenerateNormals2(crease);
3774
+
3775
+ boolean keepnormal = Vertex.normalmode;
3776
+ boolean epsequal = Grafreed.epsequal;
3777
+
3778
+ Vertex.normalmode = false;
3779
+ Grafreed.epsequal = false; // A bit strange
3780
+
3781
+ // No need to have a match for vertex counts.
3782
+
3783
+ java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();
3784
+
3785
+ for (int i=0; i<tempRep.VertexCount(); i++)
3786
+ {
3787
+ Vertex v = tempRep.GetVertex(i);
3788
+
3789
+ cVector n = table.get(tempVector.ToFloat());
3790
+
3791
+ if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)
3792
+ {
3793
+ //continue;
3794
+ }
3795
+
3796
+ tempVector.set(v);
3797
+
3798
+ //cVector nBase = tableBase.get(tempVector);
3799
+
3800
+ //if (v.norm.dot(nBase) < 0.9)
3801
+ //{
3802
+ // continue;
3803
+ //}
3804
+
3805
+ if (n != null && n.x == 1 && n.y == 0 && n.z == 0)
3806
+ {
3807
+ //continue;
3808
+ }
3809
+
3810
+ if (n != null)
3811
+ {
3812
+// if (n.dot(v.norm) < 0)
3813
+// n.sub(v.norm);
3814
+// else
3815
+// n.add(v.norm);
3816
+//
3817
+// n.normalize();
3818
+ continue;
3819
+ }
3820
+
3821
+ table.put(new cVector(tempVector), new cVector(v.norm));
3822
+ }
3823
+
3824
+ for (int i=0; i<this.VertexCount(); i++)
3825
+ {
3826
+ Vertex v = this.GetVertex(i);
3827
+
3828
+ tempVector.set(v);
3829
+
3830
+ cVector n = table.get(tempVector.ToFloat());
3831
+
3832
+ //if (n.dot(v.norm) < 0)
3833
+ if (n == null)
3834
+ continue;
3835
+
3836
+ LA.vecCopy(n, v.norm);
3837
+
3838
+ this.SetVertex(v, i);
3839
+ }
3840
+
3841
+ Grafreed.epsequal = epsequal;
3842
+ Vertex.normalmode = keepnormal;
3843
+ }
3844
+
36993845 void GenerateNormals(boolean crease)
37003846 {
37013847 boolean wastrim = trimmed;
....@@ -3712,6 +3858,28 @@
37123858 }
37133859
37143860 Trim(true/*wastrim*/,true,crease,wasstrip,false);
3861
+ }
3862
+
3863
+ void GenerateNormalsMesh()
3864
+ {
3865
+ if (stripified)
3866
+ {
3867
+ Unstripify();
3868
+ }
3869
+
3870
+ if (trimmed)
3871
+ {
3872
+ normals = null;
3873
+ }
3874
+ else
3875
+ {
3876
+ for (int i=VertexCount(); --i>=0;)
3877
+ {
3878
+ Vertex v = GetVertex(i);
3879
+
3880
+ v.norm = null;
3881
+ }
3882
+ }
37153883 }
37163884
37173885 void GenNormalsJME()
....@@ -3836,7 +4004,7 @@
38364004 NormalGenerator ng;
38374005
38384006 if (crease)
3839
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4007
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
38404008 else
38414009 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
38424010
....@@ -3854,8 +4022,6 @@
38544022 //System.out.println("NEW = " + positions.length);
38554023 uvmap = new float[ta.getVertexCount() * 2];
38564024
3857
- colors = new float[ta.getVertexCount()]; // * 3];
3858
-
38594025 ta.getCoordinates(0, positions);
38604026 ta.getNormals(0, normals);
38614027 // ta.getColors(0, colors);
....@@ -3863,12 +4029,24 @@
38634029
38644030 System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";");
38654031
4032
+ colors = null;
4033
+// colors = new float[ta.getVertexCount()]; // * 3];
4034
+//
4035
+// for (int i=colors.length; --i>=0;)
4036
+// {
4037
+// colors[i] = 1;
4038
+// }
4039
+
38664040 triangles = new int[ta.getVertexCount()];
38674041
38684042 for (int i = 0; i < triangles.length; i++)
38694043 {
38704044 triangles[i] = i;
38714045 }
4046
+
4047
+// Untrim();
4048
+ if (!trimmed)
4049
+ MergeNormals();
38724050 }
38734051 }
38744052
....@@ -3896,17 +4074,18 @@
38964074 positions = new float[3 * ga.getVertexCount()];
38974075 normals = new float[3 * ga.getVertexCount()];
38984076 uvmap = new float[2 * ga.getVertexCount()];
3899
- colors = new float[1 * ga.getVertexCount()];
39004077
39014078 tsa.getCoordinates(0, positions);
39024079 tsa.getNormals(0, normals);
39034080 tsa.getTextureCoordinates(0, 0, uvmap);
39044081 // tsa.getColors(0, colors);
3905
-
3906
- for (int i=colors.length; --i>=0;)
3907
- {
3908
- colors[i] = 1;
3909
- }
4082
+
4083
+ colors = null;
4084
+// colors = new float[1 * ga.getVertexCount()];
4085
+// for (int i=colors.length; --i>=0;)
4086
+// {
4087
+// colors[i] = 1;
4088
+// }
39104089
39114090 int stripcount = tsa.getNumStrips();
39124091 triangles = new int[stripcount];
....@@ -3915,6 +4094,7 @@
39154094 stripified = true;
39164095 } catch (ClassCastException e)
39174096 {
4097
+ // ??? aug 2019
39184098 TriangleArray ta = (TriangleArray) ga;
39194099
39204100 positions = new float[3 * ga.getVertexCount()];
....@@ -3929,6 +4109,10 @@
39294109 triangles = new int[1];
39304110 triangles[0] = 3;
39314111 }
4112
+
4113
+ //Untrim();
4114
+ if (!trimmed)
4115
+ MergeNormals();
39324116 }
39334117
39344118 /*
....@@ -3978,6 +4162,42 @@
39784162 }
39794163
39804164 Vertex.normalmode = false;
4165
+ }
4166
+
4167
+ void MergeNormals()
4168
+ {
4169
+ assert(!trimmed);
4170
+
4171
+ boolean smooth = Grafreed.smoothmode;
4172
+ boolean link = Grafreed.linkUV;
4173
+ Grafreed.smoothmode = true;
4174
+ Grafreed.linkUV = true;
4175
+
4176
+ System.out.println("#Vertex = " + VertexCount());
4177
+ System.out.println("#Face = " + FaceCount());
4178
+
4179
+ java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();
4180
+
4181
+ for (int i = 0; i < VertexCount(); i++)
4182
+ {
4183
+ Vertex v = GetVertex(i);
4184
+
4185
+ if (!table.contains(v))
4186
+ {
4187
+ table.add(v);
4188
+ }
4189
+ }
4190
+
4191
+ Grafreed.smoothmode = smooth;
4192
+ Grafreed.linkUV = link;
4193
+
4194
+// for (int i = 0; i < VertexCount(); i++)
4195
+// {
4196
+// Vertex v = GetVertex(i);
4197
+//
4198
+// table.add(v);
4199
+// }
4200
+
39814201 }
39824202
39834203 static cVector temp1 = new cVector();
....@@ -4752,16 +4972,25 @@
47524972 {
47534973 i3 = positions.length-3;
47544974 i2 = uvmap.length - 2;
4755
- new Exception().printStackTrace();
4975
+ //new Exception().printStackTrace();
47564976 }
47574977
47584978 v./*pos.*/x = positions[i3];
47594979 v./*pos.*/y = positions[i3 + 1];
47604980 v./*pos.*/z = positions[i3 + 2];
47614981
4762
- v.norm.x = normals[i3];
4763
- v.norm.y = normals[i3 + 1];
4764
- v.norm.z = normals[i3 + 2];
4982
+ if (normals == null)
4983
+ {
4984
+ v.norm.x = 0;
4985
+ v.norm.y = 0;
4986
+ v.norm.z = 0;
4987
+ }
4988
+ else
4989
+ {
4990
+ v.norm.x = normals[i3];
4991
+ v.norm.y = normals[i3 + 1];
4992
+ v.norm.z = normals[i3 + 2];
4993
+ }
47654994
47664995 v.s = uvmap[i2];
47674996 v.t = uvmap[i2 + 1];
....@@ -5476,17 +5705,27 @@
54765705
54775706 transient int nbbadfaces; // ?? = 1000000;
54785707
5479
- int ChooseTriangle()
5708
+ /*
5709
+ */
5710
+ int ChooseTriangle(boolean firstEquilateral)
54805711 {
54815712 int chosen = -1;
54825713
54835714 double minweight = 1E10;
54845715
5716
+ int step = 8; // ?
5717
+
5718
+ if (firstEquilateral)
5719
+ step = 1;
5720
+
54855721 nbbadfaces = 0;
5486
- for (int i=0; i<faces.size(); i+=8)
5722
+ for (int i=0; i<faces.size(); i+=step)
54875723 // for (int i=faces.size(); (i-=8)>=0;)
54885724 {
54895725 Face face = (Face) faces.get(i);
5726
+
5727
+ if (face.used)
5728
+ continue;
54905729
54915730 if (!Valid(face))
54925731 {
....@@ -5496,6 +5735,15 @@
54965735
54975736 if (Boundary(face))
54985737 continue;
5738
+
5739
+// if (Boundary(face.p))
5740
+// continue;
5741
+//
5742
+// if (Boundary(face.q))
5743
+// continue;
5744
+//
5745
+// if (Boundary(face.r))
5746
+// continue;
54995747
55005748 if (!ValidValence(face))
55015749 continue;
....@@ -5508,22 +5756,55 @@
55085756 //?? if (face.weight < 0)
55095757 // continue;
55105758
5511
- double K = 1; // 0.01; // .25;
5512
-
5513
- double factor = (1-K)*face.nbiterations + K; //*face.weight;
5514
-
5515
- double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5516
-
5517
- if (minweight > weight)
5759
+ if (firstEquilateral)
55185760 {
5519
- minweight = weight;
5761
+ if (OneFaceUsed(links.get(face.p)))
5762
+ continue;
5763
+
5764
+ if (OneFaceUsed(links.get(face.q)))
5765
+ continue;
5766
+
5767
+ if (OneFaceUsed(links.get(face.r)))
5768
+ continue;
5769
+
55205770 chosen = i;
5521
- if (minweight == 0)
5522
- break;
5771
+ break;
5772
+ }
5773
+ else
5774
+ {
5775
+ double K = 1; // 0.01; // .25;
5776
+
5777
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5778
+
5779
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5780
+
5781
+ if (minweight > weight)
5782
+ {
5783
+ minweight = weight;
5784
+ chosen = i;
5785
+ if (minweight == 0)
5786
+ break;
5787
+ }
55235788 }
55245789 }
55255790
55265791 return chosen;
5792
+ }
5793
+
5794
+ private boolean OneFaceUsed(Vector<Face> faces)
5795
+ {
5796
+ if (faces.size() != 6)
5797
+ return true;
5798
+
5799
+ for (int i=0; i<6; i+=1)
5800
+ {
5801
+ if (faces.get(i).used)
5802
+ {
5803
+ return true;
5804
+ }
5805
+ }
5806
+
5807
+ return false;
55275808 }
55285809
55295810 static boolean remove3valence = true;
....@@ -5559,7 +5840,7 @@
55595840 }
55605841 else
55615842 {
5562
- assert(links.size() == vertices.size());
5843
+ // TODO Grafreed.Assert(links.size() == vertices.size());
55635844
55645845 links.setSize(vertices.size());
55655846 for (int i=vertices.size(); --i>=0;)
....@@ -5567,6 +5848,7 @@
55675848 // linkstouched[i] = false;
55685849 if (links.get(i) == null) // ??
55695850 {
5851
+ new Exception().printStackTrace();
55705852 links.set(i, new Vector(8));
55715853 // linkstouched[i] = true;
55725854 }
....@@ -5577,6 +5859,8 @@
55775859 }
55785860 }
55795861
5862
+ boolean once = false;
5863
+
55805864 for (int i=faces.size(); --i>=0;)
55815865 {
55825866 Face face = (Face) faces.get(i);
....@@ -5588,6 +5872,9 @@
55885872 //if (linkstouched[face.r])
55895873 links.get(face.r).add(face);
55905874
5875
+ if (face.used)
5876
+ once = true;
5877
+
55915878 face.good = 1;
55925879 face.boundary = -1;
55935880 }
....@@ -6953,6 +7240,10 @@
69537240 return (face.boundary = 1) == 1;
69547241 }
69557242
7243
+ // June 2019
7244
+ if (true)
7245
+ return (face.boundary = 0) == 1;
7246
+
69567247 // reverse triangle test
69577248 q1.set(p);
69587249 q2.set(q);
....@@ -7402,7 +7693,7 @@
74027693 //InitWeights();
74037694 }
74047695
7405
- int chosen = ChooseTriangle(); // Best is slow and not really better
7696
+ int chosen = ChooseTriangle(true); // Best is slow and not really better
74067697
74077698 if (chosen == -1)
74087699 {
....@@ -7416,7 +7707,7 @@
74167707 //remove3valence = false;
74177708 // InitWeights();
74187709
7419
- chosen = ChooseTriangle();
7710
+ chosen = ChooseTriangle(true);
74207711 }
74217712 }
74227713
....@@ -7692,7 +7983,7 @@
76927983
76937984 // boolean lock;
76947985
7695
- void SplitInTwo(boolean reduction34, boolean onlyone)
7986
+ boolean SplitInTwo(boolean reduction34, boolean onlyone)
76967987 {
76977988 if (stripified)
76987989 {
....@@ -7729,12 +8020,12 @@
77298020 {
77308021 System.err.println("EXCEPTION CAUGHT");
77318022 e.printStackTrace();
7732
- return;
8023
+ return false;
77338024 } catch (Error e)
77348025 {
77358026 System.err.println("ERROR CAUGHT");
77368027 e.printStackTrace();
7737
- return;
8028
+ return false;
77388029 }
77398030
77408031 System.out.println("# faces = " + faces.size());
....@@ -7744,6 +8035,7 @@
77448035 {
77458036 Face face = (Face) faces.get(i);
77468037
8038
+ face.used = false;
77478039 face.nbiterations = 1;
77488040 face.weight = -1;
77498041 face.boundary = -1;
....@@ -7795,6 +8087,11 @@
77958087 nbbadfaces = faces.size();
77968088 //remove3valence = true;
77978089
8090
+ int count = 2;
8091
+
8092
+ if (onlyone)
8093
+ count = 1;
8094
+
77988095 firstpass = true;
77998096
78008097 int n = faces.size();
....@@ -7810,8 +8107,9 @@
78108107 System.out.print('.');
78118108 }
78128109 System.out.println();
8110
+ boolean atleastone = false;
78138111 int i = 0;
7814
- while (reduction34 || faces.size() > n/2)
8112
+ while (true) // reduction34 || faces.size() > n/2)
78158113 {
78168114 if (i++%100 == 0)
78178115 {
....@@ -7833,6 +8131,8 @@
78338131 {
78348132 if (!RemoveOneTriangle())
78358133 break;
8134
+
8135
+ atleastone = true;
78368136 }
78378137 // if (iterationcount == 0)
78388138 // break;
....@@ -7843,8 +8143,8 @@
78438143 break;
78448144 }
78458145 firstpass = false;
7846
- if (onlyone)
7847
- break; // one triangle only
8146
+// if (--count<0 && !reduction34)
8147
+// break; // one triangle only
78488148 }
78498149
78508150 InitLinks(false); // for further display
....@@ -7860,6 +8160,8 @@
78608160 Trim(true,false,false,false,false);
78618161
78628162 Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8163
+
8164
+ return atleastone;
78638165 }
78648166
78658167 void UpdateIndices(Face face, Face minface)
....@@ -7872,18 +8174,21 @@
78728174 face.p = minface.p;
78738175 //if (leafweights)
78748176 face.good = 0; // false;
8177
+ face.used = true;
78758178 }
78768179 if (face.q == minface.p || face.q == minface.q || face.q == minface.r)
78778180 {
78788181 face.q = minface.p;
78798182 //if (leafweights)
78808183 face.good = 0; // false;
8184
+ face.used = true;
78818185 }
78828186 if (face.r == minface.p || face.r == minface.q || face.r == minface.r)
78838187 {
78848188 face.r = minface.p;
78858189 //if (leafweights)
78868190 face.good = 0; // false;
8191
+ face.used = true;
78878192 }
78888193
78898194 if (face.p >/*=*/ minface.q && face.p < minface.r)
....@@ -7943,50 +8248,50 @@
79438248 if (v == 2)
79448249 vert = minface.r;
79458250 // Face face = (Face) faces.get(i);
7946
- Vector<Face> vertfaces = links.get(vert);
7947
- for (int i=vertfaces.size(); --i>=0;)
7948
- {
7949
- Face face = (Face) vertfaces.get(i);
7950
-
7951
- // if (face.weight == 10000)
7952
- // continue;
7953
-
7954
- if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
7955
- face.p == minface.q || face.q == minface.q || face.r == minface.q ||
7956
- face.p == minface.r || face.q == minface.r || face.r == minface.r)
8251
+ Vector<Face> vertfaces = links.get(vert);
8252
+ for (int i=vertfaces.size(); --i>=0;)
79578253 {
7958
- if (!leafweights)
8254
+ Face face = (Face) vertfaces.get(i);
8255
+
8256
+ // if (face.weight == 10000)
8257
+ // continue;
8258
+
8259
+ if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
8260
+ face.p == minface.q || face.q == minface.q || face.r == minface.q ||
8261
+ face.p == minface.r || face.q == minface.r || face.r == minface.r)
79598262 {
7960
-// if(minfaceweight <= 0)
7961
-// assert(minfaceweight > 0);
7962
-//
7963
-// //FaceWeight(face);
7964
-// if(face.weight < 0)
7965
-// assert(face.weight >= 0);
7966
-
7967
- face.weight += minfaceweight;
7968
-
7969
-// if (face.weight >= 10000)
7970
-// assert(face.weight < 10000);
8263
+ if (!leafweights)
8264
+ {
8265
+ // if(minfaceweight <= 0)
8266
+ // assert(minfaceweight > 0);
8267
+ //
8268
+ // //FaceWeight(face);
8269
+ // if(face.weight < 0)
8270
+ // assert(face.weight >= 0);
8271
+
8272
+ face.weight += minfaceweight;
8273
+
8274
+ // if (face.weight >= 10000)
8275
+ // assert(face.weight < 10000);
8276
+ }
8277
+ else
8278
+ face.weight = -1;
8279
+
8280
+ face.nbiterations += 1;
8281
+ face.boundary = -1;
8282
+
8283
+ Vertex p = (Vertex)vertices.get(face.p);
8284
+ Vertex q = (Vertex)vertices.get(face.q);
8285
+ Vertex r = (Vertex)vertices.get(face.r);
8286
+
8287
+ p.boundary = -1;
8288
+ q.boundary = -1;
8289
+ r.boundary = -1;
79718290 }
79728291 else
7973
- face.weight = -1;
7974
-
7975
- face.nbiterations += 1;
7976
- face.boundary = -1;
7977
-
7978
- Vertex p = (Vertex)vertices.get(face.p);
7979
- Vertex q = (Vertex)vertices.get(face.q);
7980
- Vertex r = (Vertex)vertices.get(face.r);
7981
-
7982
- p.boundary = -1;
7983
- q.boundary = -1;
7984
- r.boundary = -1;
8292
+ assert(false);
79858293 }
7986
- else
7987
- assert(false);
79888294 }
7989
- }
79908295
79918296 // TouchVertex(minface.p);
79928297 // TouchVertex(minface.q);
....@@ -8187,6 +8492,7 @@
81878492 for (int i=vertfaces.size(); --i>=0;)
81888493 {
81898494 Face face = (Face) vertfaces.get(i);
8495
+ face.used = true;
81908496 face.good = 0; // false;
81918497 if (leafweights)
81928498 face.weight = -1;
....@@ -8465,7 +8771,8 @@
84658771 int[] startvertices;
84668772 float[] averagepoints;
84678773 float[] extremepoints;
8468
- float[] supportsizes; // distance of closest point
8774
+ float[] supportminsize; // distance of closest point
8775
+ float[] supportmaxsize; // distance of fartest point
84698776
84708777 transient Hashtable vertextable;
84718778 /*transient*/ private Vertex[] verticesCopy;