//------------------------------------ADDS----------------------------------------// /** * Method used to add a face properly for internal methods * * @param v1 a face vertex * @param v2 a face vertex * @param v3 a face vertex */ private Face addFace(Vertex v1, Vertex v2, Vertex v3) { if (!(v1.equals(v2) || v1.equals(v3) || v2.equals(v3))) { Face face = new Face(v1, v2, v3); if (face.getArea() > TOL) { faces.Add(face); return(face); } else { return(null); } } else { return(null); } }
/** * Face breaker for VERTEX-FACE-EDGE / EDGE-FACE-VERTEX * * @param facePos face position on the faces array * @param newPos new vertex position * @param endVertex vertex used for splitting */ private void breakFaceInTwo(int facePos, Point3d newPos, Vertex endVertex) { Face face = faces[facePos]; faces.RemoveAt(facePos); Vertex vertex = addVertex(newPos, face.v1.getColor(), Vertex.BOUNDARY); if (endVertex.equals(face.v1)) { addFace(face.v1, vertex, face.v3); addFace(vertex, face.v2, face.v3); } else if (endVertex.equals(face.v2)) { addFace(face.v2, vertex, face.v1); addFace(vertex, face.v3, face.v1); } else { addFace(face.v3, vertex, face.v2); addFace(vertex, face.v1, face.v2); } }
/** * Method used to add a vertex properly for internal methods * * @param pos vertex position * @param color vertex color * @param status vertex status * @return the vertex inserted (if a similar vertex already exists, this is returned) */ private Vertex addVertex(Point3d pos, Color3f color, int status) { int i; //if already there is an equal vertex, it is not inserted Vertex vertex = new Vertex(pos, color, status); for (i = 0; i < vertices.Count; i++) { if (vertex.equals(vertices[i])) break; } if (i == vertices.Count) { vertices.Add(vertex); return vertex; } else { vertex = vertices[i]; vertex.setStatus(status); return vertex; } }
/** * Face breaker for EDGE-FACE-EDGE * * @param facePos face position on the faces array * @param newPos1 new vertex position * @param newPos2 new vertex position * @param startVertex vertex used the new faces creation * @param endVertex vertex used for the new faces creation */ private void breakFaceInThree(int facePos, Point3d newPos1, Point3d newPos2, Vertex startVertex, Vertex endVertex) { Face face = faces[facePos]; faces.RemoveAt(facePos); Vertex vertex1 = addVertex(newPos1, face.v1.getColor(), Vertex.BOUNDARY); Vertex vertex2 = addVertex(newPos2, face.v1.getColor(), Vertex.BOUNDARY); if (startVertex.equals(face.v1) && endVertex.equals(face.v2)) { addFace(face.v1, vertex1, vertex2); addFace(face.v1, vertex2, face.v3); addFace(vertex1, face.v2, vertex2); } else if (startVertex.equals(face.v2) && endVertex.equals(face.v1)) { addFace(face.v1, vertex2, vertex1); addFace(face.v1, vertex1, face.v3); addFace(vertex2, face.v2, vertex1); } else if (startVertex.equals(face.v2) && endVertex.equals(face.v3)) { addFace(face.v2, vertex1, vertex2); addFace(face.v2, vertex2, face.v1); addFace(vertex1, face.v3, vertex2); } else if (startVertex.equals(face.v3) && endVertex.equals(face.v2)) { addFace(face.v2, vertex2, vertex1); addFace(face.v2, vertex1, face.v1); addFace(vertex2, face.v3, vertex1); } else if (startVertex.equals(face.v3) && endVertex.equals(face.v1)) { addFace(face.v3, vertex1, vertex2); addFace(face.v3, vertex2, face.v2); addFace(vertex1, face.v1, vertex2); } else { addFace(face.v3, vertex2, vertex1); addFace(face.v3, vertex1, face.v2); addFace(vertex2, face.v1, vertex1); } }
//------------------------------------ADDS----------------------------------------// /** * Method used to add a face properly for internal methods * * @param v1 a face vertex * @param v2 a face vertex * @param v3 a face vertex */ private Face addFace(Vertex v1, Vertex v2, Vertex v3) { if (!(v1.equals(v2) || v1.equals(v3) || v2.equals(v3))) { Face face = new Face(v1, v2, v3); if (face.getArea() > TOL) { faces.Add(face); return face; } else { return null; } } else { return null; } }