private static List<EdgeAggregator> InstantiateIntersection(Parallel parallel, Intersection inter1, Intersection inter2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Avoid: // | | // __| ________| // | | // | | // Both intersections (transversal segments) must contain the actual transversal; that is, a direct, segment relationship must exist if (!inter1.CreatesAValidTransversalWith(inter2)) return newGrounded; // No corresponding angles if we have: // // | | | // |__________| |_________ // | // | // if (inter1.StandsOnEndpoint() && inter2.StandsOnEndpoint()) return newGrounded; // if (Utilities.DEBUG) System.Diagnostics.Debug.WriteLine("Working on: \n\t" + inter1.ToString() + "\n\t" + inter2.ToString()); // // Verify we have a parallel / intersection situation using the given information // Segment transversal = inter1.AcquireTransversal(inter2); // Ensure the non-traversal segments align with the parallel segments Segment coincidingParallel1 = parallel.CoincidesWith(inter1.OtherSegment(transversal)); Segment coincidingParallel2 = parallel.CoincidesWith(inter2.OtherSegment(transversal)); // The pair of non-transversals needs to align exactly with the parallel pair of segments if (coincidingParallel1 == null || coincidingParallel2 == null) return newGrounded; // STANDARD Dual Crossings // Corresponding angles: // // | | // ___|__________|__ // | | // | | // if (inter1.Crossing() && inter2.Crossing()) return InstantiateCompleteIntersection(parallel, inter1, inter2); // NOT Corresponding if an H-Shape // // | | // |_____| // | | // | | // if (inter1.CreatesHShape(inter2)) return newGrounded; // NOT Corresponding angles if: // // |______ // | // ______| // | // KeyValuePair<Point, Point> sShapePoints = inter1.CreatesStandardSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) return newGrounded; // NOT Corresponding angles if: // // |______ // | // ______| KeyValuePair<Point, Point> leanerShapePoints = inter1.CreatesLeanerShape(inter2); if (leanerShapePoints.Key != null && leanerShapePoints.Value != null) return newGrounded; // Corresponding angles if: // _____ // | // |_____ // | // | // KeyValuePair<Point, Point> fShapePoints = inter1.CreatesFShape(inter2); if (fShapePoints.Key != null && fShapePoints.Value != null) { return InstantiateFIntersection(parallel, inter1, fShapePoints.Key, inter2, fShapePoints.Value); } sShapePoints = inter1.CreatesSimpleSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) return newGrounded; // Corresponding angles if: // o e // standsOn (o) o e standsOnEndpoint (e) // eeeoeeeeeeee // o // o // KeyValuePair<Point, Point> simpleTShapePoints = inter1.CreatesSimpleTShape(inter2); if (simpleTShapePoints.Key != null && simpleTShapePoints.Value != null) { return InstantiateSimpleTIntersection(parallel, inter1, inter2, simpleTShapePoints.Key, simpleTShapePoints.Value); } // Corresponding angles if: // ____________ // | | // | | // KeyValuePair<Point, Point> piShapePoints = inter1.CreatesSimplePIShape(inter2); if (piShapePoints.Key != null && piShapePoints.Value != null) { return InstantiateSimplePiIntersection(parallel, inter1, inter2, piShapePoints.Key, piShapePoints.Value); } // Corresponding if: // // | | | // |_____|____ |_________ // | | | // | | | // KeyValuePair<Point, Point> chairShapePoints = inter1.CreatesChairShape(inter2); if (chairShapePoints.Key != null && chairShapePoints.Value != null) { return InstantiateChairIntersection(parallel, inter1, chairShapePoints.Key, inter2, chairShapePoints.Value); } // Corresponding angles if: // ____________ // | | // | | // piShapePoints = inter1.CreatesPIShape(inter2); if (piShapePoints.Key != null && piShapePoints.Value != null) { return InstantiatePiIntersection(parallel, inter1, piShapePoints.Key, inter2, piShapePoints.Value); } // // | | // _____|____ ______|______ // | | // |_____ _____| // KeyValuePair<Point, Point> crossedTShapePoints = inter1.CreatesCrossedTShape(inter2); if (crossedTShapePoints.Key != null && crossedTShapePoints.Value != null) { return InstantiateCrossedTIntersection(parallel, inter1, inter2, crossedTShapePoints.Key, crossedTShapePoints.Value); } // Corresponding if a flying-Shape // // | | // |_____|___ // | | // | | // KeyValuePair<Intersection, Point> flyingShapeValues = inter1.CreatesFlyingShape(inter2); if (flyingShapeValues.Key != null && flyingShapeValues.Value != null) { return InstantiateFlyingIntersection(parallel, inter1, inter2, flyingShapeValues.Key, flyingShapeValues.Value); } // | // ______|______ // | // _____|_____ Point offCross = inter1.CreatesFlyingShapeWithCrossing(inter2); if (offCross != null) return InstantiateFlyingCrossedIntersection(parallel, inter1, inter2, offCross); // | // ______|______ // | // |_____ // | offCross = inter1.CreatesExtendedChairShape(inter2); if (offCross != null) return InstantiateExtendedChairIntersection(parallel, inter1, inter2, offCross); return newGrounded; }