コード例 #1
0
ファイル: Medina.cs プロジェクト: rch-dev/medina.api
        public static List <MedinaSiteSector> LoadSite(string path)
        {
            var file = File3dm.Read(path);

            Console.WriteLine($"Reading {path.Split('\\').Last().Replace(".3dm", "")} with {file.Objects.Count.ToString()} objects...");

            var sectors = new List <MedinaSiteSector>();

            //Read all objects and group by sector.
            var objectDictionary = new Dictionary <string, List <File3dmObject> >();

            foreach (var obj in file.Objects)
            {
                if (obj.Name != null)
                {
                    objectDictionary.TryGetValue(obj.Name, out var res);

                    if (res != null)
                    {
                        //Add object.
                        objectDictionary[obj.Name].Add(obj);
                    }
                    else
                    {
                        //Initialize object list.
                        objectDictionary[obj.Name] = new List <File3dmObject>();
                        objectDictionary[obj.Name].Add(obj);
                    }

                    //Console.WriteLine($@"{file.AllLayers.FindIndex(obj.Attributes.LayerIndex).Name} object @ {obj.Name}");
                }
            }

            foreach (var key in objectDictionary.Keys.Select(x => x.ToString()))
            {
                var builder = new MedinaSiteSectorBuilder();

                var sector = builder.CreateSector(file)
                             .WithId(key)
                             .WithObjects(objectDictionary[key])
                             .CategorizeObjects();

                sectors.Add(sector);
            }

            return(sectors);
        }
コード例 #2
0
        /// <summary>
        /// Constructor for implicit conversion from builder.
        /// </summary>
        /// <param name="builder"></param>
        public MedinaSiteSector(MedinaSiteSectorBuilder builder)
        {
            Id      = new MedinaSiteSectorId(builder.Id);
            File    = builder.File;
            Objects = builder.Objects;

            Base       = builder.Base;
            Footprints = builder.Footprints;
            Courtyards = builder.Courtyards;
            Plazas     = builder.Plazas;
            Floors     = builder.Floors;
            Roofs      = builder.Roofs;
            Balconies  = builder.Balconies;
            Massing    = builder.Massing;
            Doors      = builder.Doors;
            Windows    = builder.Windows;
            RuinPoints = builder.RuinPoints;
        }