// // Remove all triangles that are inside the constraint // //This assumes the vertices in the constraint are ordered clockwise private IEnumerator RemoveSuperfluousTriangles(HalfEdgeData2 triangleData, List <MyVector2> constraints, Normalizer2 normalizer) { //This assumes we have at least 3 vertices in the constraint because we cant delete triangles inside a line if (constraints.Count < 3) { yield return(null); } HashSet <HalfEdgeFace2> trianglesToBeDeleted = FindTrianglesWithinConstraint(triangleData, constraints); if (trianglesToBeDeleted == null) { Debug.Log("There are no triangles to delete"); yield return(null); } //Delete the triangles foreach (HalfEdgeFace2 t in trianglesToBeDeleted) { HalfEdgeHelpMethods.DeleteTriangleFace(t, triangleData, true); // // PAUSE AND VISUALIZE // visualizeController.DisplayMeshMain(triangleData, normalizer); yield return(new WaitForSeconds(0.5f)); } }
//Remove the supertriangle IEnumerator RemoveSuperTriangle(Triangle2 superTriangle, HalfEdgeData2 triangulationData) { //The super triangle doesnt exists anymore because we have split it into many new triangles //But we can use its vertices to figure out which new triangles (or faces belonging to the triangle) //we should delete HashSet <HalfEdgeFace2> triangleFacesToDelete = new HashSet <HalfEdgeFace2>(); //Loop through all vertices belongin to the triangulation foreach (HalfEdgeVertex2 v in triangulationData.vertices) { //If the face attached to this vertex already exists in the list of faces we want to delete //Then dont add it again if (triangleFacesToDelete.Contains(v.edge.face)) { continue; } MyVector2 v1 = v.position; //Is this vertex in the triangulation a vertex in the super triangle? if (v1.Equals(superTriangle.p1) || v1.Equals(superTriangle.p2) || v1.Equals(superTriangle.p3)) { triangleFacesToDelete.Add(v.edge.face); } } //Debug.Log("Triangles to delete: " + trianglesToDelete.Count); //Delete the new triangles with vertices attached to the super triangle foreach (HalfEdgeFace2 f in triangleFacesToDelete) { HalfEdgeHelpMethods.DeleteTriangleFace(f, triangulationData, shouldSetOppositeToNull: true); //VISUALZ ShowTriangles(triangulationData); yield return(new WaitForSeconds(controller.pauseTime)); } //VISUALZ - show the colored mesh when its finished controller.shouldDisplayColoredMesh = true; yield return(null); }