public Edge(int tIndex, Vertex tBeginVert, Vertex tEndvert) { index = tIndex; beginVert = tBeginVert; endVert = tEndvert; beginVert.connectedEdges.Add(this); endVert.connectedEdges.Add(this); boundaryEdge = true; if (beginVert.index == endVert.index) { } }
private void intersect4PlanesAndUpdateMesh(Vertex vertex) { Point3d firstIntersectionPoint = new Point3d(); Boolean intersectionWork = Rhino.Geometry.Intersect.Intersection.PlanePlanePlane(proxies[vertex.connectedFaces[0].index].rhinoPlane, proxies[vertex.connectedFaces[1].index].rhinoPlane, proxies[vertex.connectedFaces[3].index].rhinoPlane, out firstIntersectionPoint); if (intersectionWork) { proxyToMesh.splitVertexAndRebuild(vertex, firstIntersectionPoint); } else { //shift the planes a bit? controller.errorContainer.Add("an intersection failed! two or more planes are probably planar"); } }
private void intersect2BoundaryPlanes(Vertex vertex) { Line intersectionLine = new Line(); Boolean intersectionWork = Rhino.Geometry.Intersect.Intersection.PlanePlane(proxies[vertex.connectedFaces[0].index].rhinoPlane, proxies[vertex.connectedFaces[1].index].rhinoPlane, out intersectionLine); if (intersectionWork) { intersectionLine.Extend(1000, 1000); Point3d newPositionForVertex = intersectionLine.ClosestPoint(UsefulFunctions.convertVertexToPoint3d(vertex), false); vertex.position = UsefulFunctions.convertPoint3dToVector(newPositionForVertex); } }
private void intersect3PlanesAndUpdateMesh(Vertex vertex) { Point3d intersection = new Point3d(); Boolean intersectionWork = Rhino.Geometry.Intersect.Intersection.PlanePlanePlane(proxies[vertex.connectedFaces[0].index].rhinoPlane, proxies[vertex.connectedFaces[1].index].rhinoPlane, proxies[vertex.connectedFaces[2].index].rhinoPlane, out intersection); if (intersectionWork)//can change this to work directly on the vertex! { vertex.position = UsefulFunctions.convertPoint3dToVector(intersection); } else { controller.errorContainer.Add("an intersection failed! two or more planes are probably planar"); } }
private int findVertexPositionInList(List<Vertex> list, Vertex vertexToLocate) { for (int i = 0; i < list.Count; i++) { if (list[i] == vertexToLocate) { return i; } } return -1; }
private void updateBeginEndVert(Edge edge, Vertex vertex, Vertex newVertex) { if (edge.beginVert == vertex) { edge.beginVert = newVertex; } else { edge.endVert = newVertex; } }
internal void splitVertexAndRebuild(Vertex vertex, Point3d firstIntersectionPoint) { if (vertex.boundaryVert) {//probably won't have four on a boundary but if this happens we should be notified } Face f0 = vertex.connectedFaces[0]; Face f1 = vertex.connectedFaces[1]; Face f2 = vertex.connectedFaces[2]; Face f3 = vertex.connectedFaces[3]; Edge e0 = vertex.connectedEdges[0]; Edge e1 = vertex.connectedEdges[1]; Edge e2 = vertex.connectedEdges[2]; Edge e3 = vertex.connectedEdges[3]; Vector3f orignalPosition = new Vector3f(vertex.position.X, vertex.position.Y, vertex.position.Z); vertex.position = UsefulFunctions.convertPoint3dToVector(firstIntersectionPoint);//move vertex to the position of the intersection //create new vertex at the old position and reference as newVertex addVertex(orignalPosition); Vertex newVertex = vertices[vertices.Count - 1]; newVertex.boundaryVert = false; //create the new edge - remember it will add itself to the vertex in the wrong order and as a edge boundar addEdge(vertex, newVertex); Edge newEdge = edges[edges.Count - 1]; //need to remove the two edges (for each vertex) that are no longer connected vertex.connectedEdges.Remove(e2); vertex.connectedEdges.Remove(e3); //and add them to the new vertex. newVertex.connectedEdges.Add(e2); newVertex.connectedEdges.Add(e3); //should check the above both have three edge (maybe keep to the end and check they have three faces too! //set newedges right and leftfaces newEdge.rightFace = f1; newEdge.leftFace = f3; newEdge.boundaryEdge = false; //need to update e2 and e3 begin and endverts! updateBeginEndVert(e2, vertex, newVertex); updateBeginEndVert(e3, vertex, newVertex); //remove faces from vertex and add all to newVertex (make sure done in same order as the edges...****) vertex.connectedFaces.Remove(f2); newVertex.connectedFaces.Add(f1); newVertex.connectedFaces.Add(f2); newVertex.connectedFaces.Add(f3); //add newEdge and newVertex into f3 and f1, in order! int insertRef = findEdgePositionInList(f1.faceEdges, e2); if (insertRef != -1) { f1.faceEdges.Insert(insertRef + 1, newEdge); } insertRef = findEdgePositionInList(f3.faceEdges, e0); if (insertRef != -1) { f3.faceEdges.Insert(insertRef + 1, newEdge); } //for f3 need to find vertex and for f1 need to find e2's vertex that isn't newVertex.. //remember to +1 onto the ref that is returned! if (e2.beginVert == newVertex) { insertRef = findVertexPositionInList(f1.faceVerts, e2.endVert); } else { insertRef = findVertexPositionInList(f1.faceVerts, e2.beginVert); } if (insertRef != -1) { f1.faceVerts.Insert(insertRef + 1, newVertex); } insertRef = findVertexPositionInList(f3.faceVerts, vertex); if (insertRef != -1) { f3.faceVerts.Insert(insertRef + 1, newVertex); } //update f2 to new Vertex instead of vertex! insertRef = findVertexPositionInList(f2.faceVerts, vertex); f2.faceVerts[insertRef] = newVertex; //set surrounding faces, should be in order now as edges should be correct. f1.setSurroundingFaces(); f3.setSurroundingFaces(); }
internal int isEdgeNew(Vertex vert1, Vertex vert2) { for (int i = 0; i < edges.Count; i++) { Edge edge = edges[i]; if (vert1.index == edge.beginVert.index || vert1.index == edge.endVert.index) { if (vert2.index == edge.beginVert.index || vert2.index == edge.endVert.index) { return i; } } } return -1; }
internal void addEdge(Vertex vert1, Vertex vert2) { if (vert1.index != vert2.index)//check not adding an edge between the same vertex (might want to do this check earlier?) { edges.Add(new Edge(edges.Count, vert1, vert2)); } else { containerForErrors.Add("attempted to add an edge between the same vertex (or the same index) - this was not done"); } }
public void TearDown() { SUT = null; }
public void Setup() { SUT = new Vertex(0, new Vector3f(0.0f,10.0f,0.0f)); }