⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stripifier.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			swap = seq[len - 3];			// find the neighboring strip			int m = EMPTY;			if (verts[0].index == swap.index) m = 0;			else if (verts[1].index == swap.index) m = 1;			else if (verts[2].index == swap.index) m = 2;			if (m == EMPTY) {			    if (DEBUG) System.out.println("problem finding neighbor strip");			}			int j = face.getNeighbor(m);			if (j == EMPTY) id1 = j;			else id1 = faceTable[j];			if ((id1 != EMPTY) &&			    (((Istream)strips.get(id1)).fan !=			     strm.fan)) {			    id1 = EMPTY;			}			if ((id1 != EMPTY) && (id1 != id)) {			    strm1 = (Istream)strips.get(id1);			    len1 = strm1.length;			    // if the shared face isn't the head, invert			    // the stream			    if (j != strm1.head) {				strm1.invert();				// set the sync var if the length is odd				if ((len1 % 2) != 0) sync1 = true;			    }			    seq1 = strm1.istream;			    // append a singleton strip			    if (len1 == 3) {				//   				System.out.println("reduce2");				m = faces[j].findSharedEdge(i);				strm.append(faces[j].verts[m]);				strm1.length = 0;				strm1.istream = null;				strm.tail = j;				faceTable[i] = EMPTY;				faceTable[j] = id;			    }			    // append a non-singleton strip			    else {				if ((len1 == 4) &&				    (seq[len-2].index == seq1[0].index) &&				    (seq[len-1].index == seq1[2].index)) {				    // swap seq1[1] and seq1[2] so that				    // seq[len-2] == seq1[0] and				    // seq[len-1] == seq1[1]				    swap = seq1[1];				    seq1[1] = seq1[2];				    seq1[2] = swap;				}				// see if we can append the strip				if ((seq[len-2].index == seq1[0].index) &&				    (seq[len-1].index == seq1[1].index)) {				    //   				    System.out.println("reduce2");				    strm.addStream(strm1);				    faceTable[i] = EMPTY;				    faceTable[strm.tail] = id;				    faceTable[j] = EMPTY;				}				else if (sync1) strm1.invert();			    }			}		    }		}	    }	}    }    /**     * find all links that reduce cost by 1     */    void reduceCostByOne(ArrayList strips, Face[] faces, int[] faceTable) {	//  	System.out.println("reduceCostByOne");	// number of faces in the face array	int numFaces = faces.length;	// possible adjacent strips	int id, id1, id2;	// Istreams	Istream strm, strm1;	// the length of the Istream	int len, len1;	// vertex sequences for tristrips	Vertex[] seq, seq1;	// a face	Face face;	// the list of vertices for the face	Vertex[] verts;	// used to synchronize the orientation	boolean sync, sync1;	// a swap variable	Vertex swap;	for (int i = 0; i < numFaces; i++) {	    id = faceTable[i];	    if ((id != EMPTY) && !((Istream)strips.get(id)).fan) {		sync = false;		strm = (Istream)strips.get(id);		seq = strm.istream;		face = faces[i];		verts = face.verts;		len = strm.length;		// a singleton strip		if (len == 3) {		    // consider the three neighboring triangles		    for (int j = 0; j < 3; j++) {			int k = face.getNeighbor(j);			if ((k != EMPTY) &&			    ((id1 = faceTable[k]) != EMPTY) &&			    (id1 != id) &&			    (!((Istream)strips.get(id1)).fan)) {			    // reassign the sequence			    seq[0] = verts[j];			    seq[1] = verts[(j+1)%3];			    seq[2] = verts[(j+2)%3];			    // the neighboring stream			    strm1 = (Istream)strips.get(id1);			    len1 = strm1.length;			    if (k != strm1.head) {				strm1.invert();				if ((len1 % 2) != 0) sync = true;			    }			    seq1 = strm1.istream;			    // see if we can join the strips			    if ((len1 == 4) &&				(((seq[1].index == seq1[2].index) &&				  (seq[2].index == seq1[0].index)) ||				 ((seq[1].index == seq1[0].index) &&				  (seq[2].index == seq1[2].index)))) {				swap = seq1[1];				seq1[1] = seq1[2];				seq1[2] = swap;			    }			    if ((seq[1].index == seq1[0].index) &&				(seq[2].index == seq1[1].index)) {				//  				System.out.println("reduce1");				strm.addStream(strm1);				faceTable[k] = EMPTY;				faceTable[strm.tail] = id;				i--;				break;			    }			    if ((seq[1].index == seq1[1].index) &&				(seq[2].index == seq1[0].index)) {				//   				System.out.println("reduce1");				strm.append(seq1[1]);				strm.addStream(strm1);				faceTable[k] = EMPTY;				faceTable[strm.tail] = id;				i--;				break;			    }			    if ((seq[1].index == seq1[0].index) &&				(seq[2].index == seq1[2].index)) {				//   				System.out.println("reduce1");				seq1[0] = seq1[2];				strm.append(seq1[1]);				strm.addStream(strm1);				faceTable[k] = EMPTY;				faceTable[strm.tail] = id;				i--;				break;			    }			    if (sync) {				strm1.invert();				sync = false;			    }			}		    }		}		// non-singleton strip		else if ((i == strm.tail) || ((len % 2) == 0)) {		    // make sure the face i ends the id-th strip		    if (i != strm.tail) {			strm.invert();			seq = strm.istream;		    }		    swap = seq[len-3];		    // find the neighboring strip		    int m = EMPTY;		    if (verts[0].index == swap.index) m = 0;		    else if (verts[1].index == swap.index) m = 1;		    else if (verts[2].index == swap.index) m = 2;		    if (m == EMPTY) {			if (DEBUG) System.out.println("problem finding neighbor strip");		    }		    int j = face.getNeighbor(m);		    if (j == EMPTY) id1 = j;		    else id1 = faceTable[j];		    if ((id1 != EMPTY) &&			(((Istream)strips.get(id1)).fan != strm.fan)) {			id1 = EMPTY;		    }		    // find another neighboring strip		    swap = seq[len-2];		    m = EMPTY;		    if (verts[0].index == swap.index) m = 0;		    else if (verts[1].index == swap.index) m = 1;		    else if (verts[2].index == swap.index) m = 2;		    if (m == EMPTY) {			if (DEBUG) System.out.println("problem finding neighbor strip.");		    }		    int k = face.getNeighbor(m);		    if (k == EMPTY) id2 = k;		    else id2 = faceTable[k];		    if ((id2 != EMPTY) &&			(((Istream)strips.get(id2)).fan != strm.fan)) {			id2 = EMPTY;		    }		    // consider strip id1		    boolean success = false;		    if ((id1 != EMPTY) && (id1 != id)) {			strm1 = (Istream)strips.get(id1);			len1 = strm1.length;			if (j != strm1.head) {			    strm1.invert();			    if ((len1 % 2) != 0) sync = true;			}			seq1 = strm1.istream;			if ((len1 == 4) &&			    (((seq[len-2].index == seq1[2].index) &&			      (seq[len-1].index == seq1[0].index)) ||			     (seq[len-2].index == seq1[0].index) &&			     (seq[len-1].index == seq1[2].index))) {			    swap = seq1[1];			    seq1[1] = seq1[2];			    seq1[2] = swap;			}			// find matches			if ((seq[len-2].index == seq1[0].index) &&			    (seq[len-1].index == seq1[1].index)) {			    //   			    System.out.println("reduce1");			    strm.addStream(strm1);			    faceTable[i] = EMPTY;			    faceTable[strm.tail] = id;			    faceTable[j] = EMPTY;			    success = true;			}			else if ((seq[len-2].index == seq1[1].index) &&				 (seq[len-1].index == seq1[0].index)) {			    //   			    System.out.println("reduce1");			    strm.append(seq1[1]);			    strm.addStream(strm1);			    faceTable[i] = EMPTY;			    faceTable[strm.tail] = id;			    faceTable[j] = EMPTY;			    success = true;			}			else if ((seq[len-2].index == seq1[0].index) &&				 (seq[len-1].index == seq1[2].index)) {			    //   			    System.out.println("reduce1");			    seq1[0] = seq1[2];			    strm.append(seq1[1]);			    strm.addStream(strm1);			    faceTable[i] = EMPTY;			    faceTable[strm.tail] = id;			    faceTable[j] = EMPTY;			    success = true;			}			else if (sync) {			    strm1.invert();			    sync = false;			}		    }		    // now consider strip id2		    if (!success &&			(id2 != EMPTY) && (id2 != id)) {			strm1 = (Istream)strips.get(id2);			len1 = strm1.length;			if (k != strm1.head) {			    strm1.invert();			    if ((len1 % 2) != 0) sync = true;			}			seq1 = strm1.istream;			if ((len1 == 4) &&			    (seq[len-3].index == seq1[0].index) &&			    (seq[len-1].index == seq1[2].index)) {			    swap = seq1[1];			    seq1[1] = seq1[2];			    seq1[2] = swap;			}			// find matches			if ((seq[len-3].index == seq1[0].index) &&			    (seq[len-1].index == seq1[1].index)) {			    //   			    System.out.println("reduce1");			    strm.swapEnd();			    strm.addStream(strm1);			    faceTable[i] = EMPTY;			    faceTable[strm.tail] = id;			    faceTable[k] = EMPTY;			    success = true;			}			if (!success && sync) strm1.invert();		    }		}	    }	}    }    /**     * find all the links that reduce the cost by 0     */    void reduceCostByZero(ArrayList strips, Face[] faces, int[] faceTable) {	//  	System.out.println("reduceCostByZero");	// number of faces in the face array	int numFaces = faces.length;	// possible adjacent strips	int id, id1, id2;	// Istreams	Istream strm, strm1;	// the length of the Istream	int len, len1;	// vertex sequences for tristrips	Vertex[] seq, seq1;	// a face	Face face;	// the list of vertices for the face	Vertex[] verts;	// used to synchronize the orientation	boolean sync, sync1;	// a swap variable	Vertex swap;	for (int i = 0; i < numFaces; i++) {	    id = faceTable[i];	    if ((id != EMPTY) && !((Istream)strips.get(id)).fan) {		sync = false;		strm = (Istream)strips.get(id);		seq = strm.istream;		len = strm.length;		face = faces[i];		verts = face.verts;		if (len == 3) {		    for (int j = 0; j < 3; j++) {			int k = face.getNeighbor(j);			if ((k != EMPTY) && ((id1 = faceTable[k]) != EMPTY) &&			    (id1 != id) &&			    !((Istream)strips.get(id1)).fan) {			    // reassign the sequence			    seq[0] = verts[j];			    seq[1] = verts[(j+1)%3];			    seq[2] = verts[(j+2)%3];			    // the neighboring stream			    strm1 = (Istream)strips.get(id1);			    len1 = strm1.length;			    if (k != strm1.head) {				strm1.invert();				if ((len1 % 2) != 0) sync = true;			    }			    seq1 = strm1.istream;			    // see if we can join the strips			    if ((seq[1].index == seq1[2].index) &&				(seq[2].index == seq1[0].index)) {				//   				System.out.println("reduce0");				seq1[0] = seq1[2];				strm.append(seq1[0]);				strm.append(seq1[1]);				strm.addStream(strm1);				faceTable[k] = EMPTY;				faceTable[strm.tail] = id;				i--;				break;			    }			    else if (sync) {				strm1.invert();				sync = false;			    }			}		    }		}		else if ((i == strm.tail) || ((len % 2) == 0)) {		    if (i != strm.tail) {			strm.invert();			seq = strm.istream;		    }		    swap = seq[len-3];		    // find neighboring strip		    int m = EMPTY;		    if (verts[0].index == swap.index) m = 0;		    else if (verts[1].index == swap.index) m = 1;		    else if (verts[2].index == swap.index) m = 2;		    if (m == EMPTY) {			if (DEBUG) System.out.println("problem finding neighbor strip");		    }		    int j = face.getNeighbor(m);		    if (j == EMPTY) id1 = j;		    else id1 = faceTable[j];		    if ((id1 != EMPTY) &&			(((Istream)strips.get(id1)).fan != strm.fan)) {			id1 = EMPTY;		    }		    // find another neighboring strip		    swap = seq[len-2];		    m = EMPTY;		    if (verts[0].index == swap.index) m = 0;		    else if (verts[1].index == swap.index) m = 1;		    else if (verts[2].index == swap.index) m = 2;		    if (m == EMPTY) {			if (DEBUG) System.out.println("problem finding neighbor strip.");		    }		    int k = face.getNeighbor(m);		    if (k == EMPTY) id2 = k;		    else id2 = faceTable[k];		    if ((id2 != EMPTY) &&			(((Istream)strips.get(id2)).fan != strm.fan)) {			id2 = EMPTY;		    }		    // consider strip id1		    boolean success = false;		    if ((id1 != EMPTY) && (id1 != id)) {			strm1 = (Istream)strips.get(id1);			len1 = strm1.length;			if (j != strm1.head) {			    strm1.invert();			    if ((len1 % 2) != 0) sync = true;			}			seq1 = strm1.istream;			// find matches			if ((seq[len-2].index == seq1[2].index) &&			    (seq[len-1].index == seq1[0].index)) {			    //   			    System.out.println("reduce0");			    seq1[0] = seq1[2];			    strm.append(seq1[0]);			    strm.append(seq1[1]);			    strm.addStream(strm1);			    faceTable[i] = EMPTY;			    faceTable[strm.tail] = id;			    faceTable[j] = EMPTY;			    success = true;			}			else if (sync) {			    strm1.invert();			    sync = false;			}		    }		    // consider strip id2		    if (!success && (id2 != EMPTY) && (id2 != id)) {			strm1 = (Istream)strips.get(id2);			len1 = strm1.length;			if (k != strm1.head) {			    strm1.invert();			    if ((len1 % 2) != 0) sync = true;			}			seq1 = strm1.istream;			if ((len1 == 4) &&			    (((seq[len-3].index == seq1[2].index) &&			      (seq[len-1].index == seq1[0].index)) ||			     ((seq[len-3].index == seq1[0].index) &&			      (seq[len-1].index == seq1[2].index)))) {			    swap = seq1[1];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -