Пример #1
0
        public static DCEL_Subdivision OverlayMany(IEnumerable <DCEL_Subdivision> subdivisions)
        {
            OA_Algorithm algorithm = new OA_Algorithm(subdivisions);

            algorithm.phase = Phase.SplittingPhase;

            algorithm.Initialize();
            algorithm.Sweep();

            algorithm.phase = Phase.MergingPhase;

            algorithm.Initialize();
            algorithm.Sweep();

            algorithm.outputSubdivision.WriteToFile("outputSubdivision_post_merging.xml");

            algorithm.phase = Phase.FacingPhase;

            algorithm.CreateFaces();

            algorithm.outputSubdivision.WriteToFile("outputSubdivision_final.xml");
            algorithm.outputSubdivision.WriteToFile_Faces("outputSubdivision_final_faces.xml");

            //The inputSubdivisions have been destroyed, so clear them.
            foreach (DCEL_Subdivision inputSubdivision in algorithm.inputSubdivisions)
            {
                inputSubdivision.Clear();
            }

            return(algorithm.outputSubdivision);
        }
Пример #2
0
        /// <summary>
        /// Merge subdivisionA and subdivisionB into a single subdivision, destroying subdivisionA and subdivisionB in the process.
        /// </summary>
        public static DCEL_Subdivision Overlay(DCEL_Subdivision subdivisionA, DCEL_Subdivision subdivisionB)
        {
            OA_Algorithm algorithm = new OA_Algorithm(new[] { subdivisionA, subdivisionB });

            subdivisionA.WriteToFile("subdivisionA_pre_splitting.xml");
            subdivisionB.WriteToFile("subdivisionB_pre_splitting.xml");

            subdivisionA.WriteToFile_Faces("subdivisionA_pre_splitting_faces.xml");
            subdivisionB.WriteToFile_Faces("subdivisionB_pre_splitting_faces.xml");

            algorithm.phase = Phase.SplittingPhase;

            algorithm.Initialize();
            algorithm.Sweep();

            subdivisionA.WriteToFile("subdivisionA_post_splitting.xml");
            subdivisionB.WriteToFile("subdivisionB_post_splitting.xml");

            subdivisionA.WriteToFile_Faces("subdivisionA_post_splitting_faces.xml");
            subdivisionB.WriteToFile_Faces("subdivisionB_post_splitting_faces.xml");

            algorithm.phase = Phase.MergingPhase;

            algorithm.Initialize();
            algorithm.Sweep();

            algorithm.outputSubdivision.WriteToFile("outputSubdivision_post_merging.xml");

            algorithm.phase = Phase.FacingPhase;

            algorithm.CreateFaces();

            algorithm.outputSubdivision.WriteToFile("outputSubdivision_final.xml");
            algorithm.outputSubdivision.WriteToFile_Faces("outputSubdivision_final_faces.xml");

            //The inputSubdivisions have been destroyed, so clear them.
            foreach (DCEL_Subdivision inputSubdivision in algorithm.inputSubdivisions)
            {
                inputSubdivision.Clear();
            }

            return(algorithm.outputSubdivision);
        }
Пример #3
0
 public static DCEL_Subdivision MakeClosedPolygon(params VecRat2[] vertices)
 {
     return(OA_Algorithm.Overlay(
                Enumerable.Range(0, vertices.Length)
                .Select(i => new DCEL_Subdivision(vertices[i], vertices[(i + 1) % vertices.Length]))));
 }