//---------------------------------PRIVATES-------------------------------------// /** * Sets an end as vertex (starting point if none end were defined, ending point otherwise) * * @param vertex the vertex that is an segment end * @return false if all the ends were already defined, true otherwise */ private bool setVertex(Vertex vertex) { //none end were defined - define starting point as VERTEX if (index == 0) { startVertex = vertex; startType = VERTEX; startDist = line.computePointToPointDistance(vertex.getPosition()); startPos = startVertex.getPosition(); index++; return(true); } //starting point were defined - define ending point as VERTEX if (index == 1) { endVertex = vertex; endType = VERTEX; endDist = line.computePointToPointDistance(vertex.getPosition()); endPos = endVertex.getPosition(); index++; //defining middle based on the starting point //VERTEX-VERTEX-VERTEX if (startVertex.equals(endVertex)) { middleType = VERTEX; } //VERTEX-EDGE-VERTEX else if (startType == VERTEX) { middleType = EDGE; } //the ending point distance should be smaller than starting point distance if (startDist > endDist) { swapEnds(); } return(true); } else { return(false); } }
/** * Sets an end as edge (starting point if none end were defined, ending point otherwise) * * @param vertex1 one of the vertices of the intercepted edge * @param vertex2 one of the vertices of the intercepted edge * @return false if all ends were already defined, true otherwise */ private bool setEdge(Vertex vertex1, Vertex vertex2) { Point3d point1 = vertex1.getPosition(); Point3d point2 = vertex2.getPosition(); Vector3d edgeDirection = new Vector3d(point2.x - point1.x, point2.y - point1.y, point2.z - point1.z); Line edgeLine = new Line(edgeDirection, point1); if (index == 0) { startVertex = vertex1; startType = EDGE; startPos = line.computeLineIntersection(edgeLine); startDist = line.computePointToPointDistance(startPos); middleType = FACE; index++; return(true); } else if (index == 1) { endVertex = vertex1; endType = EDGE; endPos = line.computeLineIntersection(edgeLine); endDist = line.computePointToPointDistance(endPos); middleType = FACE; index++; //the ending point distance should be smaller than starting point distance if (startDist > endDist) { swapEnds(); } return(true); } else { return(false); } }
//---------------------------------PRIVATES-------------------------------------// /** * Sets an end as vertex (starting point if none end were defined, ending point otherwise) * * @param vertex the vertex that is an segment end * @return false if all the ends were already defined, true otherwise */ private bool setVertex(Vertex vertex) { //none end were defined - define starting point as VERTEX if (index == 0) { startVertex = vertex; startType = VERTEX; startDist = line.computePointToPointDistance(vertex.getPosition()); startPos = startVertex.getPosition(); index++; return true; } //starting point were defined - define ending point as VERTEX if (index == 1) { endVertex = vertex; endType = VERTEX; endDist = line.computePointToPointDistance(vertex.getPosition()); endPos = endVertex.getPosition(); index++; //defining middle based on the starting point //VERTEX-VERTEX-VERTEX if (startVertex.equals(endVertex)) { middleType = VERTEX; } //VERTEX-EDGE-VERTEX else if (startType == VERTEX) { middleType = EDGE; } //the ending point distance should be smaller than starting point distance if (startDist > endDist) { swapEnds(); } return true; } else { return false; } }
/** * Sets an end as edge (starting point if none end were defined, ending point otherwise) * * @param vertex1 one of the vertices of the intercepted edge * @param vertex2 one of the vertices of the intercepted edge * @return false if all ends were already defined, true otherwise */ private bool setEdge(Vertex vertex1, Vertex vertex2) { Point3d point1 = vertex1.getPosition(); Point3d point2 = vertex2.getPosition(); Vector3d edgeDirection = new Vector3d(point2.x - point1.x, point2.y - point1.y, point2.z - point1.z); Line edgeLine = new Line(edgeDirection, point1); if (index == 0) { startVertex = vertex1; startType = EDGE; startPos = line.computeLineIntersection(edgeLine); startDist = line.computePointToPointDistance(startPos); middleType = FACE; index++; return true; } else if (index == 1) { endVertex = vertex1; endType = EDGE; endPos = line.computeLineIntersection(edgeLine); endDist = line.computePointToPointDistance(endPos); middleType = FACE; index++; //the ending point distance should be smaller than starting point distance if (startDist > endDist) { swapEnds(); } return true; } else { return false; } }
//-------------------------------------GETS-------------------------------------// /** * Gets the face bound * * @return face bound */ public Bound getBound() { return(new Bound(v1.getPosition(), v2.getPosition(), v3.getPosition())); }