?? polyhedralboundedsolidsetoperator.java
字號:
{ _PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace l; int i; for ( i = 0; i < nbr.size(); i++ ) { l = nbr.get(i); l.applyRules(op); } } /** Current method implements the set of changes from table [MANT1988].15.3. for the reclassification rules. ----------------------------------------------------------------- Original answer from [.WMANT2008]. */ private static void vertexFaceReclassifyOnEdgesBorrowed( ArrayList<_PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace> nbr, int op) { int i; int nnbr = nbr.size(); _PolyhedralBoundedSolidSetOperatorSectorClassificationOnSector ni; ni = new _PolyhedralBoundedSolidSetOperatorSectorClassificationOnSector(); for ( i = 0; i < nnbr; i++ ) { if ( nbr.get(i).cl == ni.ON ) { if ( nbr.get((nnbr+i-1)%nnbr).cl == ni.IN ) { if ( nbr.get((i+1)%nnbr).cl == ni.IN ) { nbr.get(i).cl = ni.IN; } else { nbr.get(i).cl = ni.IN; } } else { // OUT if ( nbr.get((i+1)%nnbr).cl == ni.IN ) { nbr.get(i).cl = ni.IN; } else { nbr.get(i).cl = ni.OUT; } } } } } private static void vertexFaceInsertNullEdges( ArrayList<_PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace> nbr, _PolyhedralBoundedSolidFace f, _PolyhedralBoundedSolidVertex v, int BvsA, boolean useBorrowed, PolyhedralBoundedSolid inSolidA, PolyhedralBoundedSolid inSolidB) { if ( useBorrowed ) { vertexFaceInsertNullEdgesBorrowed(nbr, f, v, BvsA, inSolidA, inSolidB); } else { vertexFaceInsertNullEdgesNoPeekVersion(nbr, f, v, BvsA, inSolidA, inSolidB); } } /** This method implements the third stage of the vertex/face classifier: given the previously reclassified list of vertex neigbors, insert a new vertex (using operator lmev) in the direction of the last "in" before an "out" sector of the sequence. This implementation follows section [MANT1988].14,6,2 and program [MANT1988].14.7., but it is biased for set operations, as indicated on section [MANT1988].15.6.1. Taking in to account the updated version modifications from [.wMANT2008]. */ private static void vertexFaceInsertNullEdgesNoPeekVersion( ArrayList<_PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace> nbr, _PolyhedralBoundedSolidFace f, _PolyhedralBoundedSolidVertex v, int BvsA, PolyhedralBoundedSolid inSolidA, PolyhedralBoundedSolid inSolidB) { int start, i; _PolyhedralBoundedSolidHalfEdge head, tail; _PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace n; PolyhedralBoundedSolid solida; int nnbr = nbr.size(); ArrayList<_PolyhedralBoundedSolidSetOperatorNullEdge> sone = null; solida = v.emanatingHalfEdge.parentLoop.parentFace.parentSolid; if ( nnbr <= 0 ) return; n = nbr.get(0); //- Locate the head of an ABOVE-sequence -------------------------- i = 0; while ( !( (nbr.get(i).cl == n.AinB || nbr.get(i).cl == n.BinA) && ((nbr.get( (i+1)%nnbr ).cl == n.AoutB) || nbr.get( (i+1)%nnbr ).cl == n.BoutA)) ) { i++; if ( i >= nnbr ) { //System.out.println("**** EMPTY CASE!"); return; } } start = i; head = nbr.get(i).sector; //----------------------------------------------------------------- while ( true ) { //- Locate the final sector of the sequence ------------------ while ( !( (nbr.get(i).cl == n.AoutB || nbr.get(i).cl == n.BoutA) && (nbr.get( (i+1)%nnbr ).cl == n.AinB || nbr.get( (i+1)%nnbr ).cl == n.BinA) ) ) { i = (i+1) % nnbr; } tail = nbr.get(i).sector; //- Insert null edge ----------------------------------------- if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 && (debugFlags & DEBUG_99_SHOWOPERATIONS) != 0x00 ) { System.out.println(" -> LMEV (Vertex/face split):"); System.out.println(" . (" + start + ") H1: " + head); System.out.println(" . (" + i + ") H2: " + tail); } solida.lmev(head, tail, nextVertexId(inSolidA, inSolidB), head.startingVertex.position); if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 && (debugFlags & DEBUG_99_SHOWOPERATIONS) != 0x00 ) { head.startingVertex.debugColor = new ColorRgb(0, 1, 0); System.out.println(" . New vertex: " + head.startingVertex.id); } if ( BvsA != 0 ) { sone = soneb; } else { sone = sonea; } sone.add(new _PolyhedralBoundedSolidSetOperatorNullEdge(head.previous().parentEdge)); //- Pierce face --------------------------------------------------- makering(f, v, BvsA, inSolidA, inSolidB); //- Locate the start of the next sequence -------------------- while ( !( (nbr.get(i).cl == n.AinB || nbr.get(i).cl == n.BinA) && ((nbr.get( (i+1) % nnbr ).cl == n.AoutB || nbr.get( (i+1) % nnbr ).cl == n.BoutA)) ) ) { i = (i+1) % nnbr; if ( i == start ) { return; } } } //----------------------------------------------------------------- } private static void vertexFaceInsertNullEdgesBorrowed( ArrayList<_PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace> nbr, _PolyhedralBoundedSolidFace f, _PolyhedralBoundedSolidVertex v, int BvsA, PolyhedralBoundedSolid inSolidA, PolyhedralBoundedSolid inSolidB) { int start, i; _PolyhedralBoundedSolidHalfEdge head, tail; _PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace n; PolyhedralBoundedSolid solida; int nnbr = nbr.size(); _PolyhedralBoundedSolidSetOperatorSectorClassificationOnSector ni; ArrayList<_PolyhedralBoundedSolidSetOperatorNullEdge> sone = null; ni = new _PolyhedralBoundedSolidSetOperatorSectorClassificationOnSector(); solida = v.emanatingHalfEdge.parentLoop.parentFace.parentSolid; if ( nnbr <= 0 ) return; n = nbr.get(0); //- Locate the head of an ABOVE-sequence -------------------------- i = 0; while ( !( nbr.get(i).cl == ni.IN && nbr.get((i+1)%nnbr).cl == ni.OUT ) ) { i++; if ( i >= nnbr ) { //System.out.println("**** EMPTY CASE!"); return; } } start = i; head = nbr.get(i).sector; //----------------------------------------------------------------- while ( true ) { //- Locate the final sector of the sequence ------------------ while ( !( nbr.get(i).cl == ni.OUT && nbr.get((i+1)%nnbr).cl == ni.IN ) ) { i = (i+1) % nnbr; } tail = nbr.get(i).sector; //- Insert null edge ----------------------------------------- if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 && (debugFlags & DEBUG_99_SHOWOPERATIONS) != 0x00 ) { System.out.println(" -> LMEV (Vertex/face split):"); System.out.println(" . (" + start + ") H1: " + head); System.out.println(" . (" + i + ") H2: " + tail); } solida.lmev(head, tail, nextVertexId(inSolidA, inSolidB), head.startingVertex.position); if ( BvsA != 0 ) { sone = soneb; } else { sone = sonea; } sone.add(new _PolyhedralBoundedSolidSetOperatorNullEdge(head.previous().parentEdge)); //- Pierce face --------------------------------------------------- makering(f, v, BvsA, inSolidA, inSolidB); //- Locate the start of the next sequence -------------------- while ( !( nbr.get(i).cl == ni.IN && nbr.get((i+1)%nnbr).cl == ni.OUT ) ) { i = (i+1) % nnbr; if ( i == start ) { return; } } } //----------------------------------------------------------------- } /** Vertex/Face classifier for the set operations algorithm (big phase 1). Answer to problem [MANT1988].15.4. */ private static void vertexFaceClassify( _PolyhedralBoundedSolidVertex v, _PolyhedralBoundedSolidFace f, int op, int BvsA, PolyhedralBoundedSolid inSolidA, PolyhedralBoundedSolid inSolidB) { //- Following classification strategy from the splitter algorithm - ArrayList<_PolyhedralBoundedSolidSetOperatorSectorClassificationOnFace> nbr; if ( (debugFlags & DEBUG_01_STRUCTURE) != 0x00 ) { if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 ) { System.out.print(" * "); } else { System.out.print(" - "); } System.out.println("Vertex/face pair V[" + v.id + "] / f[" + f.id + "]"); } nbr = vertexFaceGetNeighborhood(v, f.containingPlane, BvsA); if ( inplaneEdgesOn(nbr) ) { // In "strict analogy" to the splitter problem Collections.reverse(nbr); } if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 ) { System.out.println(" - Initial sector neigborhood by near end vertices:"); printNbr(nbr); } vertexFaceReclassifyOnSectorsNoPeekVersion(nbr, f.containingPlane, op, BvsA); //- Adjusting results for set operation interpretation ------------ boolean borrowed = false; int i; for ( i = 0; !borrowed && i < nbr.size(); i++ ) { nbr.get(i).updateLabel(BvsA); } if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 ) { System.out.println(" - Sector neigborhood reclassified on sectors (8-way boundary classification):"); printNbr(nbr); } vertexFaceReclassifyOnEdges(nbr, op, borrowed); if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 ) { System.out.println(" - Sector neigborhood reclassified on edges:"); printNbr(nbr); } vertexFaceInsertNullEdges(nbr, f, v, BvsA, borrowed, inSolidA, inSolidB); } private static void makering( _PolyhedralBoundedSolidFace f, _PolyhedralBoundedSolidVertex v, int type, PolyhedralBoundedSolid inSolidA, PolyhedralBoundedSolid inSolidB) { PolyhedralBoundedSolid solida, solidb; _PolyhedralBoundedSolidHalfEdge he; solida = inSolidA; solidb = inSolidB; if ( type == 1 ) { solida = inSolidB; solidb = inSolidA; } //solida = v.emanatingHalfEdge.parentLoop.parentFace.parentSolid; //solidb = f.parentSolid; he = f.boundariesList.get(0).boundaryStartHalfEdge; int vn1, vn2; vn1 = nextVertexId(solida, solidb); solidb.lmev(he, he, vn1, v.position); he = solidb.findVertex(vn1).emanatingHalfEdge; solidb.lkemr(he.mirrorHalfEdge(), he); vn2 = nextVertexId(solida, solidb); solidb.lmev(he, he, vn2, v.position); if ( (debugFlags & DEBUG_03_VERTEXFACECLASIFFIER) != 0x00 && (debugFlags & DEBUG_99_SHOWOPERATIONS) != 0x00 ) { System.out.println(" -> MAKERING (Vertex/face pierce):"); System.out.println(" . New vertexes: " + vn1 + "/" + vn2 + "."); he.startingVertex.debugColor = new ColorRgb(0, 0, 1); } ArrayList<_PolyhedralBoundedSolidSetOperatorNullEdge> sone = null; if ( type == 1 ) { sone = sonea; } else { sone = soneb; } sone.add(new _PolyhedralBoundedSolidSetOperatorNullEdge(he.parentEdge)); } /** Constructs a vector along the bisector of the sector defined by `he`. that points inward the he's containing face. */ protected static Vector3D inside(_PolyhedralBoundedSolidHalfEdge he) { Vector3D middle = null; Vector3D a, b, n; a = (he.next()).startingVertex.position.substract(he.startingVertex.position); b = (he.previous()).startingVertex.position.substract(he.startingVertex.position); a.normalize(); b.normalize(); n = he.parentLoop.parentFace.containingPlane.getNormal(); middle = n.crossProduct(a);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -