Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
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,9 @@
19661997 if (v.vertexlinks == null)
19671998 continue;
19681999
1969
- if (v.weights != null && v.weights[j] == 0) // < 0.01 * v.totalweight) // == 0)
2000
+ // Warning: a bit faster but dangerous
2001
+ if (v.weights != null && v.weights[j] == 0)
2002
+ // < 0.001 * v.totalweight)
19702003 {
19712004 //testweight += v.weights[j-1];
19722005 continue;
....@@ -2247,6 +2280,8 @@
22472280
22482281 transient int lastsoundtime;
22492282
2283
+ transient boolean once = false;
2284
+
22502285 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked)
22512286 {
22522287 if (LA.isIdentity(toRoot))
....@@ -2302,7 +2337,11 @@
23022337
23032338 if (v.totalweight == 0)
23042339 {
2305
- System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2340
+ if (!once)
2341
+ {
2342
+ System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2343
+ once = true;
2344
+ }
23062345 continue;
23072346 }
23082347
....@@ -3098,6 +3137,7 @@
30983137 //
30993138 // transient VertexCompare[] vertexcompare = null;
31003139
3140
+ // Check if v0 is close enough from any vertex of the given subobject of this.
31013141 boolean Contains(Vertex v0, int object)
31023142 {
31033143 int start = startvertices[object-1];
....@@ -3696,6 +3736,111 @@
36963736 */
36973737 }
36983738
3739
+ void GenerateNormals2(boolean crease)
3740
+ {
3741
+ cVector tempVector = new cVector();
3742
+
3743
+// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();
3744
+//
3745
+//
3746
+// for (int i=0; i<this.VertexCount(); i++)
3747
+// {
3748
+// Vertex v = this.GetVertex(i);
3749
+//
3750
+// tempVector.set(v);
3751
+//
3752
+// cVector n = tableBase.get(tempVector.ToFloat());
3753
+//
3754
+// if (n != null)
3755
+// {
3756
+// continue;
3757
+// }
3758
+//
3759
+// tableBase.put(new cVector(tempVector), new cVector(v.norm));
3760
+// }
3761
+
3762
+ BoundaryRep tempSupport = this.support;
3763
+
3764
+ this.support = null;
3765
+
3766
+ BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);
3767
+
3768
+ this.support = tempSupport;
3769
+
3770
+ //tempRep.Unstripify();
3771
+
3772
+ tempRep.GenerateNormals2(crease);
3773
+
3774
+ boolean keepnormal = Vertex.normalmode;
3775
+ boolean epsequal = Grafreed.epsequal;
3776
+
3777
+ Vertex.normalmode = false;
3778
+ Grafreed.epsequal = false; // A bit strange
3779
+
3780
+ // No need to have a match for vertex counts.
3781
+
3782
+ java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();
3783
+
3784
+ for (int i=0; i<tempRep.VertexCount(); i++)
3785
+ {
3786
+ Vertex v = tempRep.GetVertex(i);
3787
+
3788
+ cVector n = table.get(tempVector.ToFloat());
3789
+
3790
+ if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)
3791
+ {
3792
+ //continue;
3793
+ }
3794
+
3795
+ tempVector.set(v);
3796
+
3797
+ //cVector nBase = tableBase.get(tempVector);
3798
+
3799
+ //if (v.norm.dot(nBase) < 0.9)
3800
+ //{
3801
+ // continue;
3802
+ //}
3803
+
3804
+ if (n != null && n.x == 1 && n.y == 0 && n.z == 0)
3805
+ {
3806
+ //continue;
3807
+ }
3808
+
3809
+ if (n != null)
3810
+ {
3811
+// if (n.dot(v.norm) < 0)
3812
+// n.sub(v.norm);
3813
+// else
3814
+// n.add(v.norm);
3815
+//
3816
+// n.normalize();
3817
+ continue;
3818
+ }
3819
+
3820
+ table.put(new cVector(tempVector), new cVector(v.norm));
3821
+ }
3822
+
3823
+ for (int i=0; i<this.VertexCount(); i++)
3824
+ {
3825
+ Vertex v = this.GetVertex(i);
3826
+
3827
+ tempVector.set(v);
3828
+
3829
+ cVector n = table.get(tempVector.ToFloat());
3830
+
3831
+ //if (n.dot(v.norm) < 0)
3832
+ if (n == null)
3833
+ continue;
3834
+
3835
+ LA.vecCopy(n, v.norm);
3836
+
3837
+ this.SetVertex(v, i);
3838
+ }
3839
+
3840
+ Grafreed.epsequal = epsequal;
3841
+ Vertex.normalmode = keepnormal;
3842
+ }
3843
+
36993844 void GenerateNormals(boolean crease)
37003845 {
37013846 boolean wastrim = trimmed;
....@@ -3712,6 +3857,28 @@
37123857 }
37133858
37143859 Trim(true/*wastrim*/,true,crease,wasstrip,false);
3860
+ }
3861
+
3862
+ void GenerateNormalsMesh()
3863
+ {
3864
+ if (stripified)
3865
+ {
3866
+ Unstripify();
3867
+ }
3868
+
3869
+ if (trimmed)
3870
+ {
3871
+ normals = null;
3872
+ }
3873
+ else
3874
+ {
3875
+ for (int i=VertexCount(); --i>=0;)
3876
+ {
3877
+ Vertex v = GetVertex(i);
3878
+
3879
+ v.norm = null;
3880
+ }
3881
+ }
37153882 }
37163883
37173884 void GenNormalsJME()
....@@ -3836,7 +4003,7 @@
38364003 NormalGenerator ng;
38374004
38384005 if (crease)
3839
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4006
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
38404007 else
38414008 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
38424009
....@@ -3869,6 +4036,10 @@
38694036 {
38704037 triangles[i] = i;
38714038 }
4039
+
4040
+// Untrim();
4041
+ if (!trimmed)
4042
+ MergeNormals();
38724043 }
38734044 }
38744045
....@@ -3929,6 +4100,10 @@
39294100 triangles = new int[1];
39304101 triangles[0] = 3;
39314102 }
4103
+
4104
+ //Untrim();
4105
+ if (!trimmed)
4106
+ MergeNormals();
39324107 }
39334108
39344109 /*
....@@ -3978,6 +4153,42 @@
39784153 }
39794154
39804155 Vertex.normalmode = false;
4156
+ }
4157
+
4158
+ void MergeNormals()
4159
+ {
4160
+ assert(!trimmed);
4161
+
4162
+ boolean smooth = Grafreed.smoothmode;
4163
+ boolean link = Grafreed.linkUV;
4164
+ Grafreed.smoothmode = true;
4165
+ Grafreed.linkUV = true;
4166
+
4167
+ System.out.println("#Vertex = " + VertexCount());
4168
+ System.out.println("#Face = " + FaceCount());
4169
+
4170
+ java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();
4171
+
4172
+ for (int i = 0; i < VertexCount(); i++)
4173
+ {
4174
+ Vertex v = GetVertex(i);
4175
+
4176
+ if (!table.contains(v))
4177
+ {
4178
+ table.add(v);
4179
+ }
4180
+ }
4181
+
4182
+ Grafreed.smoothmode = smooth;
4183
+ Grafreed.linkUV = link;
4184
+
4185
+// for (int i = 0; i < VertexCount(); i++)
4186
+// {
4187
+// Vertex v = GetVertex(i);
4188
+//
4189
+// table.add(v);
4190
+// }
4191
+
39814192 }
39824193
39834194 static cVector temp1 = new cVector();
....@@ -4752,16 +4963,25 @@
47524963 {
47534964 i3 = positions.length-3;
47544965 i2 = uvmap.length - 2;
4755
- new Exception().printStackTrace();
4966
+ //new Exception().printStackTrace();
47564967 }
47574968
47584969 v./*pos.*/x = positions[i3];
47594970 v./*pos.*/y = positions[i3 + 1];
47604971 v./*pos.*/z = positions[i3 + 2];
47614972
4762
- v.norm.x = normals[i3];
4763
- v.norm.y = normals[i3 + 1];
4764
- v.norm.z = normals[i3 + 2];
4973
+ if (normals == null)
4974
+ {
4975
+ v.norm.x = 0;
4976
+ v.norm.y = 0;
4977
+ v.norm.z = 0;
4978
+ }
4979
+ else
4980
+ {
4981
+ v.norm.x = normals[i3];
4982
+ v.norm.y = normals[i3 + 1];
4983
+ v.norm.z = normals[i3 + 2];
4984
+ }
47654985
47664986 v.s = uvmap[i2];
47674987 v.t = uvmap[i2 + 1];
....@@ -5476,17 +5696,27 @@
54765696
54775697 transient int nbbadfaces; // ?? = 1000000;
54785698
5479
- int ChooseTriangle()
5699
+ /*
5700
+ */
5701
+ int ChooseTriangle(boolean firstEquilateral)
54805702 {
54815703 int chosen = -1;
54825704
54835705 double minweight = 1E10;
54845706
5707
+ int step = 8; // ?
5708
+
5709
+ if (firstEquilateral)
5710
+ step = 1;
5711
+
54855712 nbbadfaces = 0;
5486
- for (int i=0; i<faces.size(); i+=8)
5713
+ for (int i=0; i<faces.size(); i+=step)
54875714 // for (int i=faces.size(); (i-=8)>=0;)
54885715 {
54895716 Face face = (Face) faces.get(i);
5717
+
5718
+ if (face.used)
5719
+ continue;
54905720
54915721 if (!Valid(face))
54925722 {
....@@ -5496,6 +5726,15 @@
54965726
54975727 if (Boundary(face))
54985728 continue;
5729
+
5730
+// if (Boundary(face.p))
5731
+// continue;
5732
+//
5733
+// if (Boundary(face.q))
5734
+// continue;
5735
+//
5736
+// if (Boundary(face.r))
5737
+// continue;
54995738
55005739 if (!ValidValence(face))
55015740 continue;
....@@ -5508,22 +5747,55 @@
55085747 //?? if (face.weight < 0)
55095748 // continue;
55105749
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)
5750
+ if (firstEquilateral)
55185751 {
5519
- minweight = weight;
5752
+ if (OneFaceUsed(links.get(face.p)))
5753
+ continue;
5754
+
5755
+ if (OneFaceUsed(links.get(face.q)))
5756
+ continue;
5757
+
5758
+ if (OneFaceUsed(links.get(face.r)))
5759
+ continue;
5760
+
55205761 chosen = i;
5521
- if (minweight == 0)
5522
- break;
5762
+ break;
5763
+ }
5764
+ else
5765
+ {
5766
+ double K = 1; // 0.01; // .25;
5767
+
5768
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5769
+
5770
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5771
+
5772
+ if (minweight > weight)
5773
+ {
5774
+ minweight = weight;
5775
+ chosen = i;
5776
+ if (minweight == 0)
5777
+ break;
5778
+ }
55235779 }
55245780 }
55255781
55265782 return chosen;
5783
+ }
5784
+
5785
+ private boolean OneFaceUsed(Vector<Face> faces)
5786
+ {
5787
+ if (faces.size() != 6)
5788
+ return true;
5789
+
5790
+ for (int i=0; i<6; i+=1)
5791
+ {
5792
+ if (faces.get(i).used)
5793
+ {
5794
+ return true;
5795
+ }
5796
+ }
5797
+
5798
+ return false;
55275799 }
55285800
55295801 static boolean remove3valence = true;
....@@ -5559,7 +5831,7 @@
55595831 }
55605832 else
55615833 {
5562
- assert(links.size() == vertices.size());
5834
+ // TODO Grafreed.Assert(links.size() == vertices.size());
55635835
55645836 links.setSize(vertices.size());
55655837 for (int i=vertices.size(); --i>=0;)
....@@ -5567,6 +5839,7 @@
55675839 // linkstouched[i] = false;
55685840 if (links.get(i) == null) // ??
55695841 {
5842
+ new Exception().printStackTrace();
55705843 links.set(i, new Vector(8));
55715844 // linkstouched[i] = true;
55725845 }
....@@ -5577,6 +5850,8 @@
55775850 }
55785851 }
55795852
5853
+ boolean once = false;
5854
+
55805855 for (int i=faces.size(); --i>=0;)
55815856 {
55825857 Face face = (Face) faces.get(i);
....@@ -5588,6 +5863,9 @@
55885863 //if (linkstouched[face.r])
55895864 links.get(face.r).add(face);
55905865
5866
+ if (face.used)
5867
+ once = true;
5868
+
55915869 face.good = 1;
55925870 face.boundary = -1;
55935871 }
....@@ -6953,6 +7231,10 @@
69537231 return (face.boundary = 1) == 1;
69547232 }
69557233
7234
+ // June 2019
7235
+ if (true)
7236
+ return (face.boundary = 0) == 1;
7237
+
69567238 // reverse triangle test
69577239 q1.set(p);
69587240 q2.set(q);
....@@ -7402,7 +7684,7 @@
74027684 //InitWeights();
74037685 }
74047686
7405
- int chosen = ChooseTriangle(); // Best is slow and not really better
7687
+ int chosen = ChooseTriangle(true); // Best is slow and not really better
74067688
74077689 if (chosen == -1)
74087690 {
....@@ -7416,7 +7698,7 @@
74167698 //remove3valence = false;
74177699 // InitWeights();
74187700
7419
- chosen = ChooseTriangle();
7701
+ chosen = ChooseTriangle(true);
74207702 }
74217703 }
74227704
....@@ -7692,7 +7974,7 @@
76927974
76937975 // boolean lock;
76947976
7695
- void SplitInTwo(boolean reduction34, boolean onlyone)
7977
+ boolean SplitInTwo(boolean reduction34, boolean onlyone)
76967978 {
76977979 if (stripified)
76987980 {
....@@ -7729,12 +8011,12 @@
77298011 {
77308012 System.err.println("EXCEPTION CAUGHT");
77318013 e.printStackTrace();
7732
- return;
8014
+ return false;
77338015 } catch (Error e)
77348016 {
77358017 System.err.println("ERROR CAUGHT");
77368018 e.printStackTrace();
7737
- return;
8019
+ return false;
77388020 }
77398021
77408022 System.out.println("# faces = " + faces.size());
....@@ -7744,6 +8026,7 @@
77448026 {
77458027 Face face = (Face) faces.get(i);
77468028
8029
+ face.used = false;
77478030 face.nbiterations = 1;
77488031 face.weight = -1;
77498032 face.boundary = -1;
....@@ -7795,6 +8078,11 @@
77958078 nbbadfaces = faces.size();
77968079 //remove3valence = true;
77978080
8081
+ int count = 2;
8082
+
8083
+ if (onlyone)
8084
+ count = 1;
8085
+
77988086 firstpass = true;
77998087
78008088 int n = faces.size();
....@@ -7810,8 +8098,9 @@
78108098 System.out.print('.');
78118099 }
78128100 System.out.println();
8101
+ boolean atleastone = false;
78138102 int i = 0;
7814
- while (reduction34 || faces.size() > n/2)
8103
+ while (true) // reduction34 || faces.size() > n/2)
78158104 {
78168105 if (i++%100 == 0)
78178106 {
....@@ -7833,6 +8122,8 @@
78338122 {
78348123 if (!RemoveOneTriangle())
78358124 break;
8125
+
8126
+ atleastone = true;
78368127 }
78378128 // if (iterationcount == 0)
78388129 // break;
....@@ -7843,8 +8134,8 @@
78438134 break;
78448135 }
78458136 firstpass = false;
7846
- if (onlyone)
7847
- break; // one triangle only
8137
+// if (--count<0 && !reduction34)
8138
+// break; // one triangle only
78488139 }
78498140
78508141 InitLinks(false); // for further display
....@@ -7860,6 +8151,8 @@
78608151 Trim(true,false,false,false,false);
78618152
78628153 Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8154
+
8155
+ return atleastone;
78638156 }
78648157
78658158 void UpdateIndices(Face face, Face minface)
....@@ -7872,18 +8165,21 @@
78728165 face.p = minface.p;
78738166 //if (leafweights)
78748167 face.good = 0; // false;
8168
+ face.used = true;
78758169 }
78768170 if (face.q == minface.p || face.q == minface.q || face.q == minface.r)
78778171 {
78788172 face.q = minface.p;
78798173 //if (leafweights)
78808174 face.good = 0; // false;
8175
+ face.used = true;
78818176 }
78828177 if (face.r == minface.p || face.r == minface.q || face.r == minface.r)
78838178 {
78848179 face.r = minface.p;
78858180 //if (leafweights)
78868181 face.good = 0; // false;
8182
+ face.used = true;
78878183 }
78888184
78898185 if (face.p >/*=*/ minface.q && face.p < minface.r)
....@@ -7943,50 +8239,50 @@
79438239 if (v == 2)
79448240 vert = minface.r;
79458241 // 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)
8242
+ Vector<Face> vertfaces = links.get(vert);
8243
+ for (int i=vertfaces.size(); --i>=0;)
79578244 {
7958
- if (!leafweights)
8245
+ Face face = (Face) vertfaces.get(i);
8246
+
8247
+ // if (face.weight == 10000)
8248
+ // continue;
8249
+
8250
+ if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
8251
+ face.p == minface.q || face.q == minface.q || face.r == minface.q ||
8252
+ face.p == minface.r || face.q == minface.r || face.r == minface.r)
79598253 {
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);
8254
+ if (!leafweights)
8255
+ {
8256
+ // if(minfaceweight <= 0)
8257
+ // assert(minfaceweight > 0);
8258
+ //
8259
+ // //FaceWeight(face);
8260
+ // if(face.weight < 0)
8261
+ // assert(face.weight >= 0);
8262
+
8263
+ face.weight += minfaceweight;
8264
+
8265
+ // if (face.weight >= 10000)
8266
+ // assert(face.weight < 10000);
8267
+ }
8268
+ else
8269
+ face.weight = -1;
8270
+
8271
+ face.nbiterations += 1;
8272
+ face.boundary = -1;
8273
+
8274
+ Vertex p = (Vertex)vertices.get(face.p);
8275
+ Vertex q = (Vertex)vertices.get(face.q);
8276
+ Vertex r = (Vertex)vertices.get(face.r);
8277
+
8278
+ p.boundary = -1;
8279
+ q.boundary = -1;
8280
+ r.boundary = -1;
79718281 }
79728282 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;
8283
+ assert(false);
79858284 }
7986
- else
7987
- assert(false);
79888285 }
7989
- }
79908286
79918287 // TouchVertex(minface.p);
79928288 // TouchVertex(minface.q);
....@@ -8187,6 +8483,7 @@
81878483 for (int i=vertfaces.size(); --i>=0;)
81888484 {
81898485 Face face = (Face) vertfaces.get(i);
8486
+ face.used = true;
81908487 face.good = 0; // false;
81918488 if (leafweights)
81928489 face.weight = -1;
....@@ -8465,7 +8762,8 @@
84658762 int[] startvertices;
84668763 float[] averagepoints;
84678764 float[] extremepoints;
8468
- float[] supportsizes; // distance of closest point
8765
+ float[] supportminsize; // distance of closest point
8766
+ float[] supportmaxsize; // distance of fartest point
84698767
84708768 transient Hashtable vertextable;
84718769 /*transient*/ private Vertex[] verticesCopy;