Ejemplo n.º 1
0
        private void ShowGeometrySummary(XbimModel model)
        {
            var context = new Xbim3DModelContext(model);

            Console.WriteLine();
            Console.WriteLine("Styles");
            foreach (var styles in context.SurfaceStyles())
            {
                Console.WriteLine("{0,-6} {1,-30} {2,-6}",
                                  styles.DefinedObjectId,
                                  styles.ColourMap.First(),
                                  styles.IsTransparent);
            }
            var largest = context.GetLargestRegion();

            Console.WriteLine();
            Console.WriteLine("Regions");
            foreach (var region in context.GetRegions())
            {
                Console.WriteLine("{0,-20} {1,6} {2}",
                                  region.Name,
                                  region.Population,
                                  (region == largest));
            }



            Console.WriteLine("{0,-8}, {1,-8}, {2,6} {3,8}",
                              "Ifc Label",
                              "Label",
                              "Ref Count",
                              "Bytes");

            var geometries = GetGeom(model)
                             .OrderByDescending(o => o.Cost)
                             .Distinct()
                             .Take(10);

            var items = from inst in context.ShapeInstances()
                        join prod in model.Instances.OfType <IfcProduct>()
                        on inst.IfcProductLabel equals prod.EntityLabel
                        select new
            {
                Instance = inst,
                Geometry = context.ShapeGeometry(inst.InstanceLabel),
                Product  = prod
            };

            var expensiveProducts = items
                                    .OrderByDescending(o => (o.Geometry.IsValid ? o.Geometry.Cost : 0))
                                    .Take(20);

            foreach (var geometry in geometries)
            {
                Console.WriteLine("{0, -8}, {1,-8}, {2,6} {3,8}",
                                  geometry.IfcShapeLabel,
                                  geometry.ShapeLabel,
                                  geometry.ReferenceCount,
                                  geometry.Cost);
            }

            Console.WriteLine();
            Console.WriteLine("Top 20 expensive items");
            foreach (var item in expensiveProducts)
            {
                Console.WriteLine("{0,-6} {1,-40} {2,-20} {3,6}",
                                  item.Product.EntityLabel,
                                  item.Product.Name.ToString().Truncate(40),
                                  item.Product.GetType().Name,
                                  item.Geometry.Cost
                                  );
            }
        }