/* */ package com.sun.j3d.utils.geometry;
/* */
/* */ import javax.vecmath.Point2f;
/* */
/* */ class Clean
/* */ {
/* */ static void initPUnsorted(Triangulator triRef, int number)
/* */ {
/* 23 */ if (number > triRef.maxNumPUnsorted) {
/* 24 */ triRef.maxNumPUnsorted = number;
/* 25 */ triRef.pUnsorted = new Point2f[triRef.maxNumPUnsorted];
/* 26 */ for (int i = 0; i < triRef.maxNumPUnsorted; i++)
/* 27 */ triRef.pUnsorted[i] = new Point2f();
/* */ }
/* */ }
/* */
/* */ static int cleanPolyhedralFace(Triangulator triRef, int i1, int i2)
/* */ {
/* 38 */ initPUnsorted(triRef, triRef.numPoints);
/* */
/* 40 */ for (int i = 0; i < triRef.numPoints; i++) {
/* 41 */ triRef.pUnsorted[i].set(triRef.points[i]);
/* */ }
/* */
/* 55 */ sort(triRef.points, triRef.numPoints);
/* */
/* 66 */ i = 0;
/* 67 */ for (int j = 1; j < triRef.numPoints; j++) {
/* 68 */ if (pComp(triRef.points[i], triRef.points[j]) != 0) {
/* 69 */ i++;
/* 70 */ triRef.points[i] = triRef.points[j];
/* */ }
/* */ }
/* 73 */ int numSorted = i + 1;
/* 74 */ int removed = triRef.numPoints - numSorted;
/* */
/* 86 */ for (i = i1; i < i2; i++) {
/* 87 */ int ind1 = triRef.loops[i];
/* 88 */ int ind2 = triRef.fetchNextData(ind1);
/* 89 */ int index = triRef.fetchData(ind2);
/* 90 */ while (ind2 != ind1) {
/* 91 */ j = findPInd(triRef.points, numSorted, triRef.pUnsorted[index]);
/* 92 */ triRef.updateIndex(ind2, j);
/* 93 */ ind2 = triRef.fetchNextData(ind2);
/* 94 */ index = triRef.fetchData(ind2);
/* */ }
/* 96 */ j = findPInd(triRef.points, numSorted, triRef.pUnsorted[index]);
/* 97 */ triRef.updateIndex(ind2, j);
/* */ }
/* */
/* 100 */ triRef.numPoints = numSorted;
/* */
/* 102 */ return removed;
/* */ }
/* */
/* */ static void sort(Point2f[] points, int numPts)
/* */ {
/* 109 */ Point2f swap = new Point2f();
/* */
/* 111 */ for (int i = 0; i < numPts; i++)
/* 112 */ for (int j = i + 1; j < numPts; j++)
/* 113 */ if (pComp(points[i], points[j]) > 0) {
/* 114 */ swap.set(points[i]);
/* 115 */ points[i].set(points[j]);
/* 116 */ points[j].set(swap);
/* */ }
/* */ }
/* */
/* */ static int findPInd(Point2f[] sorted, int numPts, Point2f pnt)
/* */ {
/* 130 */ for (int i = 0; i < numPts; i++) {
/* 131 */ if ((pnt.x == sorted[i].x) && (pnt.y == sorted[i].y))
/* */ {
/* 133 */ return i;
/* */ }
/* */ }
/* 136 */ return -1;
/* */ }
/* */
/* */ static int pComp(Point2f a, Point2f b)
/* */ {
/* 141 */ if (a.x < b.x) return -1;
/* 142 */ if (a.x > b.x) return 1;
/* */
/* 144 */ if (a.y < b.y) return -1;
/* 145 */ if (a.y > b.y) return 1;
/* 146 */ return 0;
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name: com.sun.j3d.utils.geometry.Clean
* JD-Core Version: 0.6.2
*/