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; }
private static List<EdgeAggregator> CheckAndGenerateParallelImplySameSide(Intersection inter1, Intersection inter2, Parallel parallel) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // The two intersections should not be at the same vertex if (inter1.intersect.Equals(inter2.intersect)) return newGrounded; // Determine the transversal Segment transversal = inter1.AcquireTransversal(inter2); if (transversal == null) return newGrounded; // // Ensure the non-traversal segments align with the parallel segments // Segment parallel1 = inter1.OtherSegment(transversal); Segment parallel2 = inter2.OtherSegment(transversal); // The non-transversals should not be the same (coinciding) if (parallel1.IsCollinearWith(parallel2)) return newGrounded; Segment coincidingParallel1 = parallel.CoincidesWith(parallel1); Segment coincidingParallel2 = parallel.CoincidesWith(parallel2); // The pair of non-transversals needs to align exactly with the parallel pair of segments if (coincidingParallel1 == null || coincidingParallel2 == null) return newGrounded; // Both intersections should not be referring to an intersection point on the same parallel segment if (parallel.segment1.PointLiesOn(inter1.intersect) && parallel.segment1.PointLiesOn(inter2.intersect)) return newGrounded; if (parallel.segment2.PointLiesOn(inter1.intersect) && parallel.segment2.PointLiesOn(inter2.intersect)) return newGrounded; // The resultant candidate parallel segments shouldn't share any vertices if (coincidingParallel1.SharedVertex(coincidingParallel2) != null) return newGrounded; if (inter1.StandsOnEndpoint() && inter2.StandsOnEndpoint()) { // // Creates a basic S-Shape with standsOnEndpoints // // ______ offThat // | // offThis ______| // // Return <offThis, offThat> KeyValuePair<Point, Point> sShapePoints = inter1.CreatesBasicSShape(inter2); if (sShapePoints.Key != null && sShapePoints.Value != null) return newGrounded; // // Creates a basic C-Shape with standsOnEndpoints // // offThis ______ // | // offThat ______| // // Return <offThis, offThat> KeyValuePair<Point, Point> cShapePoints = inter1.CreatesBasicCShape(inter2); if (cShapePoints.Key != null && cShapePoints.Value != null) { return GenerateSimpleC(parallel, inter1, cShapePoints.Key, inter2, cShapePoints.Value); } return newGrounded; } // _______/________ // / // / // ______/_______ // / if (inter1.Crossing() && inter2.Crossing()) return GenerateDualCrossings(parallel, inter1, inter2); // Alt. Int if an H-Shape // // | | // |_____| // | | // | | // if (inter1.CreatesHShape(inter2)) return GenerateH(parallel, inter1, inter2); // Corresponding if a flying-Shape // // | | // |_____|___ offCross // | | // | | // Point offCross = inter1.CreatesFlyingShapeWithCrossing(inter2); if (offCross != null) { return GenerateFlying(parallel, inter1, inter2, offCross); } // // Creates a shape like an extended t // offCross offCross // | | // _____|____ ______|______ // | | // |_____ offStands offStands _____| // // Returns <offStands, offCross> KeyValuePair<Point, Point> tShapePoints = inter1.CreatesCrossedTShape(inter2); if (tShapePoints.Key != null && tShapePoints.Value != null) { return GenerateCrossedT(parallel, inter1, inter2, tShapePoints.Key, tShapePoints.Value); } // // Creates a Topped F-Shape // top // offLeft __________ offEnd <--- Stands on // | // |_____ off <--- Stands on // | // | // bottom // // Returns: <bottom, off> KeyValuePair<Intersection, Point> toppedFShapePoints = inter1.CreatesToppedFShape(inter2); if (toppedFShapePoints.Key != null && toppedFShapePoints.Value != null) { return GenerateToppedFShape(parallel, inter1, inter2, toppedFShapePoints.Key, toppedFShapePoints.Value); } // Corresponding angles if: // ____________ // | | // | | // KeyValuePair<Point, Point> piShapePoints = inter1.CreatesPIShape(inter2); if (piShapePoints.Key != null && piShapePoints.Value != null) { return InstantiatePiIntersection(parallel, inter1, piShapePoints.Key, inter2, piShapePoints.Value); } // 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); } return newGrounded; }