public void AddSortedIntersections(Guid crvGuid, SortedIntersections sortedIntersections) { sortedIntersections.SortIntersections(); SortedIntersections.Add(crvGuid, sortedIntersections); // Assign Ids to Intersections based on their corresponding node foreach (var inter in sortedIntersections.myIntersections) { if (IntersectionNodes.Count != 0) { // Check if theres a point existing at that intersection. If so, assign the intersection Id that point Id foreach (var ptPair in IntersectionNodes) { if (inter.ComparePoints(ptPair.Value, tolerance)) { inter.Id = ptPair.Key; break; } } // If no existing point for this intersection, give the intersection a new Id and assign the point and Id to the dictionary if (inter.Id == Guid.Empty) { inter.Id = Guid.NewGuid(); IntersectionNodes.Add(inter.Id, inter.pA); } } else { // If the dictionary is empty, add the first entry inter.Id = Guid.NewGuid(); IntersectionNodes.Add(inter.Id, inter.pA); } } }
public FlatFries(List <Curve> fryCurves, double thickness) { // Process: // 01 - Init (Clear memory) // 02 - Remove duplicate instances of curve // 03 - Add all of the curves into a single dictionary curveDict // 04 - Intersect all curves against eachother and create FryResults // Init this.Init(); // Remove duplicate instances for (int i = fryCurves.Count - 1; i > 0; i--) { var crv = fryCurves[i]; var hash = crv.GetHashCode(); bool self = false; for (int j = fryCurves.Count - 1; j > 0; j--) { var crv2 = fryCurves[j]; if (hash == crv2.GetHashCode()) { if (!self) { self = true; } else { fryCurves.Remove(crv2); } } } } // Add fryCurves to Results foreach (var crv in fryCurves) { // Reparameterize Curves crv.Domain = new Interval(0.0, 1.0); results.Curves.Add(Guid.NewGuid(), crv); } // Procedural intersection foreach (var crv in results.Curves) { var intersections = new SortedIntersections(crv); foreach (var crv2 in results.Curves) { // If equal, continue if (crv.Key == crv2.Key) { continue; } // Perform an intersection var crvIntersections = Rhino.Geometry.Intersect.Intersection.CurveCurve(crv.Value, crv2.Value, tolerance, tolerance); // If there is no intersection, continue if (crvIntersections.Count == 0) { continue; } // If overlap intersection, continue if (crvIntersections[0].IsOverlap) { continue; } // Add Intersections intersections.AddIntersections(crv2, crvIntersections); } // Add Intersections to Results results.AddSortedIntersections(crv.Key, intersections); } string wait = ""; // Now we have an organized list of intersection events by curve. // Before we can construct the lattice, we need to do some work to support 3+ curve intersections. }