public String verticesToString() { String result = "List of vertices\n"; Iterator it = this.vertices.iterator(); int cont = 0; while (it.hasNext()) { Vertex v = (Vertex) it.next(); result = result + "v" + cont + " " + v.getPoint().toString() + "\n"; cont++; } return result; }
/** * returns true if the polyhedral surface is combinatorially consistent. If borders==true * normalization of the border edges is checked too. This method checks that each facet is at * least a triangle and that the two incident facets of a non-border edge are distinct. */ public boolean isValid(boolean borders) { boolean valid = true; System.out.print("Checking Polyhedron..."); int n = this.vertices.size(); int e = this.halfedges.size(); int f = this.facets.size(); for (int i = 0; i < this.halfedges.size(); i++) { Halfedge<X> pedge = this.halfedges.get(i); if (pedge.getOpposite() == null) { System.out.print("error opposite: " + i); valid = false; // Face face=pedge.getFace(); // int[] ind=face.getVertexIndices(this); // System.out.println(" "+ind[0]+" "+ind[1]+" "+ind[2]); } if (pedge.getNext() == null) { System.out.println("error next_edge: " + i); valid = false; } if (pedge.getPrev() == null) { System.out.println("error prev_edge: " + i); valid = false; } if (pedge.getVertex() == null) { System.out.println("error vertex: " + i); valid = false; } if (pedge.opposite != null && pedge.face == pedge.getOpposite().face) { System.out.println("error edge: " + i); valid = false; } } for (int i = 0; i < this.facets.size(); i++) { Face<X> pface = this.facets.get(i); if (pface == null) { System.out.println("error face pointer"); valid = false; } if (pface.halfedge == null) { System.out.println("error face.halfedge"); valid = false; } if (pface.degree() < 3) { System.out.println("error face degree"); return valid = false; } } for (int i = 0; i < this.vertices.size(); i++) { Vertex<X> pvertex = this.vertices.get(i); // System.out.println(""+pvertex.toString()); if (pvertex == null) { System.out.println("error vertex pointer:" + i); valid = false; } if (pvertex.halfedge == null) { System.out.println("error vertex.halfedge: " + i); valid = false; } if (pvertex.getPoint() == null) { System.out.println("error vertex.point: " + i); valid = false; } } if (valid == true) System.out.println("ok"); else System.out.println("not valid"); System.out.print("n: " + n + " e: " + e / 2 + " f: " + f + " - "); int g = -(n - e / 2 + f - 2) / 2; System.out.println("genus: " + g); return valid; }