Normand Briere
2019-07-25 f2b6a33fdf84a06b958f9cb9d667a2eff3063d8b
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;
....@@ -172,16 +173,16 @@
172173 bufV = other.bufV;
173174 bufF = other.bufF;
174175
175
- positions = (float[]) GrafreeD.clone(other.positions);
176
- normals = (float[]) GrafreeD.clone(other.normals);
177
- colors = (float[]) GrafreeD.clone(other.colors);
178
- uvmap = (float[]) GrafreeD.clone(other.uvmap);
179
- triangles = (int[]) GrafreeD.clone(other.triangles);
176
+ positions = (float[]) Grafreed.clone(other.positions);
177
+ normals = (float[]) Grafreed.clone(other.normals);
178
+ colors = (float[]) Grafreed.clone(other.colors);
179
+ uvmap = (float[]) Grafreed.clone(other.uvmap);
180
+ triangles = (int[]) Grafreed.clone(other.triangles);
180181
181
- indices = (int[]) GrafreeD.clone(other.indices);
182
+ indices = (int[]) Grafreed.clone(other.indices);
182183
183
- vertices = (Vector<Vertex>) GrafreeD.clone(other.vertices);
184
- faces = (Vector<Face>) GrafreeD.clone(other.faces);
184
+ vertices = (Vector<Vertex>) Grafreed.clone(other.vertices);
185
+ faces = (Vector<Face>) Grafreed.clone(other.faces);
185186 }
186187 else
187188 {
....@@ -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
....@@ -1518,7 +1549,7 @@
15181549 InitFaceIndices();
15191550 }
15201551
1521
- BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this);
1552
+ BoundaryRep rep = (BoundaryRep) Grafreed.clone(this);
15221553 //float[] v = new float[100];
15231554
15241555 for (int loops=1; --loops>=0;)
....@@ -1548,7 +1579,7 @@
15481579 InitFaceIndices();
15491580 }
15501581
1551
- BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this);
1582
+ BoundaryRep rep = (BoundaryRep) Grafreed.clone(this);
15521583 //float[] v = new float[100];
15531584
15541585 for (int loops=10; --loops>=0;)
....@@ -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,8 @@
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] == 0) // < 0.001 * v.totalweight)
19702002 {
19712003 //testweight += v.weights[j-1];
19722004 continue;
....@@ -2247,6 +2279,8 @@
22472279
22482280 transient int lastsoundtime;
22492281
2282
+ transient boolean once = false;
2283
+
22502284 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked)
22512285 {
22522286 if (LA.isIdentity(toRoot))
....@@ -2302,7 +2336,11 @@
23022336
23032337 if (v.totalweight == 0)
23042338 {
2305
- System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2339
+ if (!once)
2340
+ {
2341
+ System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2342
+ once = true;
2343
+ }
23062344 continue;
23072345 }
23082346
....@@ -2670,7 +2708,7 @@
26702708
26712709 if (Globals.framecount - lastsoundtime > 30) // 0.25 secs
26722710 {
2673
- GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1);
2711
+ Grafreed.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1);
26742712
26752713 lastsoundtime = Globals.framecount;
26762714 }
....@@ -3098,6 +3136,7 @@
30983136 //
30993137 // transient VertexCompare[] vertexcompare = null;
31003138
3139
+ // Check if v0 is close enough from any vertex of the given subobject of this.
31013140 boolean Contains(Vertex v0, int object)
31023141 {
31033142 int start = startvertices[object-1];
....@@ -3403,7 +3442,7 @@
34033442 k /= x*x + y*y;
34043443 }
34053444 else
3406
- GrafreeD.Assert(z == 1);
3445
+ Grafreed.Assert(z == 1);
34073446
34083447 if (k < 0)
34093448 k = 0;
....@@ -3696,6 +3735,111 @@
36963735 */
36973736 }
36983737
3738
+ void GenerateNormals2(boolean crease)
3739
+ {
3740
+ cVector tempVector = new cVector();
3741
+
3742
+// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();
3743
+//
3744
+//
3745
+// for (int i=0; i<this.VertexCount(); i++)
3746
+// {
3747
+// Vertex v = this.GetVertex(i);
3748
+//
3749
+// tempVector.set(v);
3750
+//
3751
+// cVector n = tableBase.get(tempVector.ToFloat());
3752
+//
3753
+// if (n != null)
3754
+// {
3755
+// continue;
3756
+// }
3757
+//
3758
+// tableBase.put(new cVector(tempVector), new cVector(v.norm));
3759
+// }
3760
+
3761
+ BoundaryRep tempSupport = this.support;
3762
+
3763
+ this.support = null;
3764
+
3765
+ BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);
3766
+
3767
+ this.support = tempSupport;
3768
+
3769
+ //tempRep.Unstripify();
3770
+
3771
+ tempRep.GenerateNormals2(crease);
3772
+
3773
+ boolean keepnormal = Vertex.normalmode;
3774
+ boolean epsequal = Grafreed.epsequal;
3775
+
3776
+ Vertex.normalmode = false;
3777
+ Grafreed.epsequal = false; // A bit strange
3778
+
3779
+ // No need to have a match for vertex counts.
3780
+
3781
+ java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();
3782
+
3783
+ for (int i=0; i<tempRep.VertexCount(); i++)
3784
+ {
3785
+ Vertex v = tempRep.GetVertex(i);
3786
+
3787
+ cVector n = table.get(tempVector.ToFloat());
3788
+
3789
+ if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)
3790
+ {
3791
+ //continue;
3792
+ }
3793
+
3794
+ tempVector.set(v);
3795
+
3796
+ //cVector nBase = tableBase.get(tempVector);
3797
+
3798
+ //if (v.norm.dot(nBase) < 0.9)
3799
+ //{
3800
+ // continue;
3801
+ //}
3802
+
3803
+ if (n != null && n.x == 1 && n.y == 0 && n.z == 0)
3804
+ {
3805
+ //continue;
3806
+ }
3807
+
3808
+ if (n != null)
3809
+ {
3810
+// if (n.dot(v.norm) < 0)
3811
+// n.sub(v.norm);
3812
+// else
3813
+// n.add(v.norm);
3814
+//
3815
+// n.normalize();
3816
+ continue;
3817
+ }
3818
+
3819
+ table.put(new cVector(tempVector), new cVector(v.norm));
3820
+ }
3821
+
3822
+ for (int i=0; i<this.VertexCount(); i++)
3823
+ {
3824
+ Vertex v = this.GetVertex(i);
3825
+
3826
+ tempVector.set(v);
3827
+
3828
+ cVector n = table.get(tempVector.ToFloat());
3829
+
3830
+ //if (n.dot(v.norm) < 0)
3831
+ if (n == null)
3832
+ continue;
3833
+
3834
+ LA.vecCopy(n, v.norm);
3835
+
3836
+ this.SetVertex(v, i);
3837
+ }
3838
+
3839
+ Grafreed.epsequal = epsequal;
3840
+ Vertex.normalmode = keepnormal;
3841
+ }
3842
+
36993843 void GenerateNormals(boolean crease)
37003844 {
37013845 boolean wastrim = trimmed;
....@@ -3712,6 +3856,28 @@
37123856 }
37133857
37143858 Trim(true/*wastrim*/,true,crease,wasstrip,false);
3859
+ }
3860
+
3861
+ void GenerateNormalsMesh()
3862
+ {
3863
+ if (stripified)
3864
+ {
3865
+ Unstripify();
3866
+ }
3867
+
3868
+ if (trimmed)
3869
+ {
3870
+ normals = null;
3871
+ }
3872
+ else
3873
+ {
3874
+ for (int i=VertexCount(); --i>=0;)
3875
+ {
3876
+ Vertex v = GetVertex(i);
3877
+
3878
+ v.norm = null;
3879
+ }
3880
+ }
37153881 }
37163882
37173883 void GenNormalsJME()
....@@ -3836,7 +4002,7 @@
38364002 NormalGenerator ng;
38374003
38384004 if (crease)
3839
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4005
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
38404006 else
38414007 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
38424008
....@@ -3869,6 +4035,10 @@
38694035 {
38704036 triangles[i] = i;
38714037 }
4038
+
4039
+// Untrim();
4040
+ if (!trimmed)
4041
+ MergeNormals();
38724042 }
38734043 }
38744044
....@@ -3929,6 +4099,10 @@
39294099 triangles = new int[1];
39304100 triangles[0] = 3;
39314101 }
4102
+
4103
+ //Untrim();
4104
+ if (!trimmed)
4105
+ MergeNormals();
39324106 }
39334107
39344108 /*
....@@ -3978,6 +4152,42 @@
39784152 }
39794153
39804154 Vertex.normalmode = false;
4155
+ }
4156
+
4157
+ void MergeNormals()
4158
+ {
4159
+ assert(!trimmed);
4160
+
4161
+ boolean smooth = Grafreed.smoothmode;
4162
+ boolean link = Grafreed.linkUV;
4163
+ Grafreed.smoothmode = true;
4164
+ Grafreed.linkUV = true;
4165
+
4166
+ System.out.println("#Vertex = " + VertexCount());
4167
+ System.out.println("#Face = " + FaceCount());
4168
+
4169
+ java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();
4170
+
4171
+ for (int i = 0; i < VertexCount(); i++)
4172
+ {
4173
+ Vertex v = GetVertex(i);
4174
+
4175
+ if (!table.contains(v))
4176
+ {
4177
+ table.add(v);
4178
+ }
4179
+ }
4180
+
4181
+ Grafreed.smoothmode = smooth;
4182
+ Grafreed.linkUV = link;
4183
+
4184
+// for (int i = 0; i < VertexCount(); i++)
4185
+// {
4186
+// Vertex v = GetVertex(i);
4187
+//
4188
+// table.add(v);
4189
+// }
4190
+
39814191 }
39824192
39834193 static cVector temp1 = new cVector();
....@@ -4752,16 +4962,25 @@
47524962 {
47534963 i3 = positions.length-3;
47544964 i2 = uvmap.length - 2;
4755
- new Exception().printStackTrace();
4965
+ //new Exception().printStackTrace();
47564966 }
47574967
47584968 v./*pos.*/x = positions[i3];
47594969 v./*pos.*/y = positions[i3 + 1];
47604970 v./*pos.*/z = positions[i3 + 2];
47614971
4762
- v.norm.x = normals[i3];
4763
- v.norm.y = normals[i3 + 1];
4764
- v.norm.z = normals[i3 + 2];
4972
+ if (normals == null)
4973
+ {
4974
+ v.norm.x = 0;
4975
+ v.norm.y = 0;
4976
+ v.norm.z = 0;
4977
+ }
4978
+ else
4979
+ {
4980
+ v.norm.x = normals[i3];
4981
+ v.norm.y = normals[i3 + 1];
4982
+ v.norm.z = normals[i3 + 2];
4983
+ }
47654984
47664985 v.s = uvmap[i2];
47674986 v.t = uvmap[i2 + 1];
....@@ -5476,17 +5695,27 @@
54765695
54775696 transient int nbbadfaces; // ?? = 1000000;
54785697
5479
- int ChooseTriangle()
5698
+ /*
5699
+ */
5700
+ int ChooseTriangle(boolean firstEquilateral)
54805701 {
54815702 int chosen = -1;
54825703
54835704 double minweight = 1E10;
54845705
5706
+ int step = 8; // ?
5707
+
5708
+ if (firstEquilateral)
5709
+ step = 1;
5710
+
54855711 nbbadfaces = 0;
5486
- for (int i=0; i<faces.size(); i+=8)
5712
+ for (int i=0; i<faces.size(); i+=step)
54875713 // for (int i=faces.size(); (i-=8)>=0;)
54885714 {
54895715 Face face = (Face) faces.get(i);
5716
+
5717
+ if (face.used)
5718
+ continue;
54905719
54915720 if (!Valid(face))
54925721 {
....@@ -5496,6 +5725,15 @@
54965725
54975726 if (Boundary(face))
54985727 continue;
5728
+
5729
+// if (Boundary(face.p))
5730
+// continue;
5731
+//
5732
+// if (Boundary(face.q))
5733
+// continue;
5734
+//
5735
+// if (Boundary(face.r))
5736
+// continue;
54995737
55005738 if (!ValidValence(face))
55015739 continue;
....@@ -5508,22 +5746,55 @@
55085746 //?? if (face.weight < 0)
55095747 // continue;
55105748
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)
5749
+ if (firstEquilateral)
55185750 {
5519
- minweight = weight;
5751
+ if (OneFaceUsed(links.get(face.p)))
5752
+ continue;
5753
+
5754
+ if (OneFaceUsed(links.get(face.q)))
5755
+ continue;
5756
+
5757
+ if (OneFaceUsed(links.get(face.r)))
5758
+ continue;
5759
+
55205760 chosen = i;
5521
- if (minweight == 0)
5522
- break;
5761
+ break;
5762
+ }
5763
+ else
5764
+ {
5765
+ double K = 1; // 0.01; // .25;
5766
+
5767
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5768
+
5769
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5770
+
5771
+ if (minweight > weight)
5772
+ {
5773
+ minweight = weight;
5774
+ chosen = i;
5775
+ if (minweight == 0)
5776
+ break;
5777
+ }
55235778 }
55245779 }
55255780
55265781 return chosen;
5782
+ }
5783
+
5784
+ private boolean OneFaceUsed(Vector<Face> faces)
5785
+ {
5786
+ if (faces.size() != 6)
5787
+ return true;
5788
+
5789
+ for (int i=0; i<6; i+=1)
5790
+ {
5791
+ if (faces.get(i).used)
5792
+ {
5793
+ return true;
5794
+ }
5795
+ }
5796
+
5797
+ return false;
55275798 }
55285799
55295800 static boolean remove3valence = true;
....@@ -5559,7 +5830,7 @@
55595830 }
55605831 else
55615832 {
5562
- assert(links.size() == vertices.size());
5833
+ // TODO Grafreed.Assert(links.size() == vertices.size());
55635834
55645835 links.setSize(vertices.size());
55655836 for (int i=vertices.size(); --i>=0;)
....@@ -5567,6 +5838,7 @@
55675838 // linkstouched[i] = false;
55685839 if (links.get(i) == null) // ??
55695840 {
5841
+ new Exception().printStackTrace();
55705842 links.set(i, new Vector(8));
55715843 // linkstouched[i] = true;
55725844 }
....@@ -5577,6 +5849,8 @@
55775849 }
55785850 }
55795851
5852
+ boolean once = false;
5853
+
55805854 for (int i=faces.size(); --i>=0;)
55815855 {
55825856 Face face = (Face) faces.get(i);
....@@ -5588,6 +5862,9 @@
55885862 //if (linkstouched[face.r])
55895863 links.get(face.r).add(face);
55905864
5865
+ if (face.used)
5866
+ once = true;
5867
+
55915868 face.good = 1;
55925869 face.boundary = -1;
55935870 }
....@@ -6953,6 +7230,10 @@
69537230 return (face.boundary = 1) == 1;
69547231 }
69557232
7233
+ // June 2019
7234
+ if (true)
7235
+ return (face.boundary = 0) == 1;
7236
+
69567237 // reverse triangle test
69577238 q1.set(p);
69587239 q2.set(q);
....@@ -7402,7 +7683,7 @@
74027683 //InitWeights();
74037684 }
74047685
7405
- int chosen = ChooseTriangle(); // Best is slow and not really better
7686
+ int chosen = ChooseTriangle(true); // Best is slow and not really better
74067687
74077688 if (chosen == -1)
74087689 {
....@@ -7416,7 +7697,7 @@
74167697 //remove3valence = false;
74177698 // InitWeights();
74187699
7419
- chosen = ChooseTriangle();
7700
+ chosen = ChooseTriangle(true);
74207701 }
74217702 }
74227703
....@@ -7692,7 +7973,7 @@
76927973
76937974 // boolean lock;
76947975
7695
- void SplitInTwo(boolean reduction34, boolean onlyone)
7976
+ boolean SplitInTwo(boolean reduction34, boolean onlyone)
76967977 {
76977978 if (stripified)
76987979 {
....@@ -7729,12 +8010,12 @@
77298010 {
77308011 System.err.println("EXCEPTION CAUGHT");
77318012 e.printStackTrace();
7732
- return;
8013
+ return false;
77338014 } catch (Error e)
77348015 {
77358016 System.err.println("ERROR CAUGHT");
77368017 e.printStackTrace();
7737
- return;
8018
+ return false;
77388019 }
77398020
77408021 System.out.println("# faces = " + faces.size());
....@@ -7744,6 +8025,7 @@
77448025 {
77458026 Face face = (Face) faces.get(i);
77468027
8028
+ face.used = false;
77478029 face.nbiterations = 1;
77488030 face.weight = -1;
77498031 face.boundary = -1;
....@@ -7795,6 +8077,11 @@
77958077 nbbadfaces = faces.size();
77968078 //remove3valence = true;
77978079
8080
+ int count = 2;
8081
+
8082
+ if (onlyone)
8083
+ count = 1;
8084
+
77988085 firstpass = true;
77998086
78008087 int n = faces.size();
....@@ -7810,8 +8097,9 @@
78108097 System.out.print('.');
78118098 }
78128099 System.out.println();
8100
+ boolean atleastone = false;
78138101 int i = 0;
7814
- while (reduction34 || faces.size() > n/2)
8102
+ while (true) // reduction34 || faces.size() > n/2)
78158103 {
78168104 if (i++%100 == 0)
78178105 {
....@@ -7833,6 +8121,8 @@
78338121 {
78348122 if (!RemoveOneTriangle())
78358123 break;
8124
+
8125
+ atleastone = true;
78368126 }
78378127 // if (iterationcount == 0)
78388128 // break;
....@@ -7843,8 +8133,8 @@
78438133 break;
78448134 }
78458135 firstpass = false;
7846
- if (onlyone)
7847
- break; // one triangle only
8136
+// if (--count<0 && !reduction34)
8137
+// break; // one triangle only
78488138 }
78498139
78508140 InitLinks(false); // for further display
....@@ -7860,6 +8150,8 @@
78608150 Trim(true,false,false,false,false);
78618151
78628152 Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8153
+
8154
+ return atleastone;
78638155 }
78648156
78658157 void UpdateIndices(Face face, Face minface)
....@@ -7872,18 +8164,21 @@
78728164 face.p = minface.p;
78738165 //if (leafweights)
78748166 face.good = 0; // false;
8167
+ face.used = true;
78758168 }
78768169 if (face.q == minface.p || face.q == minface.q || face.q == minface.r)
78778170 {
78788171 face.q = minface.p;
78798172 //if (leafweights)
78808173 face.good = 0; // false;
8174
+ face.used = true;
78818175 }
78828176 if (face.r == minface.p || face.r == minface.q || face.r == minface.r)
78838177 {
78848178 face.r = minface.p;
78858179 //if (leafweights)
78868180 face.good = 0; // false;
8181
+ face.used = true;
78878182 }
78888183
78898184 if (face.p >/*=*/ minface.q && face.p < minface.r)
....@@ -7943,50 +8238,50 @@
79438238 if (v == 2)
79448239 vert = minface.r;
79458240 // 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)
8241
+ Vector<Face> vertfaces = links.get(vert);
8242
+ for (int i=vertfaces.size(); --i>=0;)
79578243 {
7958
- if (!leafweights)
8244
+ Face face = (Face) vertfaces.get(i);
8245
+
8246
+ // if (face.weight == 10000)
8247
+ // continue;
8248
+
8249
+ if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
8250
+ face.p == minface.q || face.q == minface.q || face.r == minface.q ||
8251
+ face.p == minface.r || face.q == minface.r || face.r == minface.r)
79598252 {
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);
8253
+ if (!leafweights)
8254
+ {
8255
+ // if(minfaceweight <= 0)
8256
+ // assert(minfaceweight > 0);
8257
+ //
8258
+ // //FaceWeight(face);
8259
+ // if(face.weight < 0)
8260
+ // assert(face.weight >= 0);
8261
+
8262
+ face.weight += minfaceweight;
8263
+
8264
+ // if (face.weight >= 10000)
8265
+ // assert(face.weight < 10000);
8266
+ }
8267
+ else
8268
+ face.weight = -1;
8269
+
8270
+ face.nbiterations += 1;
8271
+ face.boundary = -1;
8272
+
8273
+ Vertex p = (Vertex)vertices.get(face.p);
8274
+ Vertex q = (Vertex)vertices.get(face.q);
8275
+ Vertex r = (Vertex)vertices.get(face.r);
8276
+
8277
+ p.boundary = -1;
8278
+ q.boundary = -1;
8279
+ r.boundary = -1;
79718280 }
79728281 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;
8282
+ assert(false);
79858283 }
7986
- else
7987
- assert(false);
79888284 }
7989
- }
79908285
79918286 // TouchVertex(minface.p);
79928287 // TouchVertex(minface.q);
....@@ -8187,6 +8482,7 @@
81878482 for (int i=vertfaces.size(); --i>=0;)
81888483 {
81898484 Face face = (Face) vertfaces.get(i);
8485
+ face.used = true;
81908486 face.good = 0; // false;
81918487 if (leafweights)
81928488 face.weight = -1;
....@@ -8233,7 +8529,7 @@
82338529 if (!trimmed)
82348530 return;
82358531
8236
- GrafreeD.linkUV = false;
8532
+ Grafreed.linkUV = false;
82378533
82388534 try
82398535 {
....@@ -8465,7 +8761,8 @@
84658761 int[] startvertices;
84668762 float[] averagepoints;
84678763 float[] extremepoints;
8468
- float[] supportsizes; // distance of closest point
8764
+ float[] supportminsize; // distance of closest point
8765
+ float[] supportmaxsize; // distance of fartest point
84698766
84708767 transient Hashtable vertextable;
84718768 /*transient*/ private Vertex[] verticesCopy;