/* 199 */ int flag = -1; int numContours = 0; int numPoints = 0; int num = 0;
/* 200 */ UnorderList coords = new UnorderList(100, Point3f.class);
/* 201 */ float[] tmpCoords = new float[6];
/* 202 */ float lastX = 0.0F; float lastY = 0.0F;
/* 203 */ float firstPntx = 3.4028235E+38F; float firstPnty = 3.4028235E+38F;
/* 204 */ GeometryInfo gi = null;
/* 205 */ NormalGenerator ng = new NormalGenerator();
/* 206 */ FastVector contours = new FastVector(10);
/* 207 */ float maxY = -3.402824E+038F;
/* 208 */ int maxYIndex = 0; int beginIdx = 0; int endIdx = 0; int start = 0;
/* */
/* 210 */ boolean setMaxY = false;
/* */
/* 213 */ while (!pIt.isDone()) {
/* 214 */ Point3f vertex = new Point3f();
/* 215 */ flag = pIt.currentSegment(tmpCoords);
/* 216 */ if (flag == 4) {
/* 217 */ if (num > 0) {
/* 218 */ if (setMaxY)
/* */ {
/* 220 */ beginIdx = start;
/* 221 */ endIdx = numPoints - 1;
/* */ }
/* 223 */ contours.addElement(num);
/* 224 */ num = 0;
/* 225 */ numContours++;
/* */ }
/* */ } else { if (flag == 0) {
/* 228 */ vertex.x = tmpCoords[0];
/* 229 */ vertex.y = tmpCoords[1];
/* 230 */ lastX = vertex.x;
/* 231 */ lastY = vertex.y;
/* */
/* 233 */ if ((lastX == firstPntx) && (lastY == firstPnty)) {
/* 234 */ pIt.next();
/* 235 */ continue;
/* */ }
/* 237 */ setMaxY = false;
/* 238 */ coords.add(vertex);
/* 239 */ firstPntx = lastX;
/* 240 */ firstPnty = lastY;
/* 241 */ if (num > 0) {
/* 242 */ contours.addElement(num);
/* 243 */ num = 0;
/* 244 */ numContours++;
/* */ }
/* 246 */ num++;
/* 247 */ numPoints++;
/* */
/* 250 */ start = numPoints; break label525;
/* 251 */ }if (flag == 1) {
/* 252 */ vertex.x = tmpCoords[0];
/* 253 */ vertex.y = tmpCoords[1];
/* */
/* 258 */ if ((vertex.x == lastX) && (vertex.y == lastY)) {
/* 259 */ pIt.next();
/* 260 */ continue;
/* */ }
/* 262 */ if (vertex.y > maxY) {
/* 263 */ maxY = vertex.y;
/* 264 */ maxYIndex = numPoints;
/* 265 */ setMaxY = true;
/* */ }
/* 267 */ lastX = vertex.x;
/* 268 */ lastY = vertex.y;
/* 269 */ coords.add(vertex);
/* 270 */ num++;
/* 271 */ numPoints++;
/* */ } }
/* 273 */ label525: pIt.next();
/* */ }
/* */
/* 278 */ if (numPoints == 0) {
/* 279 */ return null;
/* */ }
/* */
/* 285 */ Point3f p1 = new Point3f(); Point3f p2 = new Point3f(); Point3f p3 = new Point3f();
/* 286 */ boolean flip_side_orient = true;
/* 287 */ Point3f[] vertices = (Point3f[])coords.toArray(false);
/* */
/* 289 */ if (endIdx - beginIdx > 0)
/* */ {
/* 294 */ if (maxYIndex == beginIdx)
/* 295 */ p1.set(vertices[endIdx]);
/* */ else {
/* 297 */ p1.set(vertices[(maxYIndex - 1)]);
/* */ }
/* 299 */ p2.set(vertices[maxYIndex]);
/* 300 */ if (maxYIndex == endIdx)
/* 301 */ p3.set(vertices[beginIdx]);
/* */ else {
/* 303 */ p3.set(vertices[(maxYIndex + 1)]);
/* */ }
/* */
/* 306 */ if (p3.x != p2.x) {
/* 307 */ if (p1.x != p2.x)
/* */ {
/* 309 */ if (Math.abs((p2.y - p1.y) / (p2.x - p1.x)) > Math.abs((p3.y - p2.y) / (p3.x - p2.x)))
/* */ {
/* 311 */ flip_side_orient = p3.x > p2.x;
/* */ }
/* 313 */ else flip_side_orient = p2.x > p1.x;
/* */ }
/* */ else {
/* 316 */ flip_side_orient = p3.x > p2.x;
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 323 */ flip_side_orient = p2.x > p1.x;
/* */ }
/* */
/* */ }
/* */
/* 328 */ int startIdx = 0;
/* 329 */ IslandsNode islandsTree = new IslandsNode(-1, -1);
/* 330 */ int[] contourCounts = contours.getData();
/* */
/* 333 */ for (int i = 0; i < contours.getSize(); i++) {
/* 334 */ endIdx = startIdx + contourCounts[i];
/* 335 */ islandsTree.insert(new IslandsNode(startIdx, endIdx), vertices);
/* 336 */ startIdx = endIdx;
/* */ }
/* */
/* 339 */ coords = null;
/* 340 */ contours = null;
/* 341 */ contourCounts = null;
/* */
/* 344 */ UnorderList islandsList = new UnorderList(10, IslandsNode.class);
/* 345 */ islandsTree.collectOddLevelNode(islandsList, 0);
/* 346 */ IslandsNode[] nodes = (IslandsNode[])islandsList.toArray(false);
/* 347 */ int[][] islandCounts = new int[islandsList.arraySize()][];
/* 348 */ Point3f[][] outVerts = new Point3f[islandCounts.length][];
/* */
/* 352 */ for (i = 0; i < islandCounts.length; i++) {
/* 353 */ IslandsNode node = nodes[i];
/* 354 */ int nchild = node.numChild();
/* 355 */ islandCounts[i] = new int[nchild + 1];
/* 356 */ islandCounts[i][0] = node.numVertices();
/* 357 */ int sum = 0;
/* 358 */ sum += islandCounts[i][0];
/* 359 */ for (int j = 0; j < nchild; j++) {
/* 360 */ islandCounts[i][(j + 1)] = node.getChild(j).numVertices();
/* 361 */ sum += islandCounts[i][(j + 1)];
/* */ }
/* 363 */ outVerts[i] = new Point3f[sum];
/* 364 */ startIdx = 0;
/* 365 */ for (int k = node.startIdx; k < node.endIdx; k++) {
/* 366 */ outVerts[i][(startIdx++)] = vertices[k];
/* */ }
/* */
/* 369 */ for (j = 0; j < nchild; j++) {
/* 370 */ endIdx = node.getChild(j).endIdx;
/* 371 */ for (k = node.getChild(j).startIdx; k < endIdx; k++) {
/* 372 */ outVerts[i][(startIdx++)] = vertices[k];
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */
/* 379 */ islandsTree = null;
/* 380 */ islandsList = null;
/* 381 */ vertices = null;
/* */
/* 383 */ contourCounts = new int[1];
/* 384 */ int currCoordIndex = 0; int vertOffset = 0;
/* 385 */ ArrayList triangData = new ArrayList();
/* */
/* 387 */ Point3f q1 = new Point3f(); Point3f q2 = new Point3f(); Point3f q3 = new Point3f();
/* 388 */ Vector3f n1 = new Vector3f(); Vector3f n2 = new Vector3f();
/* 389 */ numPoints = 0;
/* */
/* 392 */ for (i = 0; i < islandCounts.length; i++)
/* */ {
/* 394 */ contourCounts[0] = islandCounts[i].length;
/* 395 */ numPoints += outVerts[i].length;
/* 396 */ gi = new GeometryInfo(5);
/* 397 */ gi.setCoordinates(outVerts[i]);
/* 398 */ gi.setStripCounts(islandCounts[i]);
/* 399 */ gi.setContourCounts(contourCounts);
/* 400 */ ng.generateNormals(gi);
/* */
/* 402 */ GeometryArray ga = gi.getGeometryArray(false, false, false);
/* 403 */ vertOffset += ga.getVertexCount();
/* */
/* 405 */ triangData.add(ga);
/* */ }
/* */ int vertCnt;