Ejemplo n.º 1
0
        /// <summary>
        /// Returns the fire rating if defined
        /// </summary>
        /// <param name="door"></param>
        /// <returns></returns>
        public static IfcLabel?GetFireRating(this IfcDoor door)
        {
            IfcValue val = door.GetPropertySingleNominalValue("Pset_DoorCommon", "FireRating ");

            if (val != null && val is IfcLabel)
            {
                return((IfcLabel)val);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns whether the door is a Fire Exit or not, null if not known
        /// </summary>
        /// <param name="door"></param>
        /// <returns></returns>
        public static IfcBoolean?GetFireExit(this IfcDoor door)
        {
            IfcValue val = door.GetPropertySingleNominalValue("Pset_DoorCommon", "FireExit ");

            if (val != null && val is IfcBoolean)
            {
                return((IfcBoolean)val);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns if the door is external, default is false if not specified
        /// </summary>
        /// <param name="door"></param>
        /// <returns></returns>
        public static IfcBoolean GetIsExternal(this IfcDoor door)
        {
            IfcValue val = door.GetPropertySingleNominalValue("Pset_DoorCommon", "IsExternal");

            if (val != null && val is IfcBoolean)
            {
                return((IfcBoolean)val);
            }
            else
            {
                return(new IfcBoolean(false)); //default is to return false
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the Reference ID for this specified type in this project (e.g. type 'A-1'), if known
        /// </summary>
        /// <param name="door"></param>
        /// <returns></returns>
        public static IfcIdentifier?GetReference(this IfcDoor door)
        {
            IfcValue val = door.GetPropertySingleNominalValue("Pset_DoorCommon", "Reference ");

            if (val != null && val is IfcIdentifier)
            {
                return((IfcIdentifier)val);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public void Run()
        {
            //to start we need an ifc file, here it is Clinic_Example.ifc
            string ifcFile  = @"IfcFiles/Clinic_Example.ifc";
            string xbimFile = Path.ChangeExtension(ifcFile, "xBIM");  //will generate if not existing

            if (File.Exists(ifcFile))
            {
                using (XbimModel model = new XbimModel())
                {
                    if (File.Exists(xbimFile))
                    {
                        //assume the xbim file has the geometry already generated from ifc file, as below
                        model.Open(xbimFile, XbimDBAccess.Read);
                    }
                    else
                    {
                        //create the xbim file from the ifc file
                        model.CreateFrom(ifcFile, xbimFile, delegate(int percentProgress, object userState)
                        {
                            Console.Write("\rReading File {0}", percentProgress);
                        });

                        model.Open(xbimFile, XbimDBAccess.ReadWrite); //readwrite as we need to add the geometry
                        //add the the geometry information to the model
                        int total = (int)model.Instances.CountOf <IfcProduct>();
                        ReportProgressDelegate progDelegate = delegate(int percentProgress, object userState)
                        {
                            Console.Write("\rGeometry {0} / {1}", total, (total * percentProgress / 100));
                        };
                        XbimMesher.GenerateGeometry(model, null, progDelegate);
                    }

                    //get all the IfcDoors in the model
                    IEnumerable <IfcDoor> ifcDoors = model.IfcProducts.OfType <IfcDoor>(); //get all the ifcdoors for this model
                    if (ifcDoors.Any())
                    {
                        IfcDoor          ifcDoor = ifcDoors.First(); //we use the first door to get the bounding box from
                        XbimGeometryData geoData = model.GetGeometryData(ifcDoor, XbimGeometryType.BoundingBox).FirstOrDefault();
                        if (geoData != null)
                        {
                            XbimRect3D boundBox = XbimRect3D.FromArray(geoData.ShapeData); //size information for the IfcDoor, but the information is for the bounding box which encloses the door

                            //if want want in World space
                            XbimMatrix3D worldMatrix = geoData.Transform;
                            //if we want to convert to World space we can use the geoData.Transform property and create the world matrix
                            XbimPoint3D MinPtOCS = new XbimPoint3D(boundBox.X, boundBox.Y, boundBox.Z);
                            XbimPoint3D MaxPtOCS = new XbimPoint3D(boundBox.X + boundBox.SizeX, boundBox.Y + boundBox.SizeY, boundBox.Z + boundBox.SizeZ);
                            //transformed values, may no longer a valid bounding box in the new space if any Pitch or Yaw, i.e. stairs ceiling supports
                            XbimPoint3D MinPtWCS = worldMatrix.Transform(MinPtOCS);
                            XbimPoint3D MaxPtWCS = worldMatrix.Transform(MaxPtOCS);
                            //if you product is at any angle to the World space then the bounding box can be recalculated,
                            //a example of this can be found here https://sbpweb.svn.codeplex.com/svn/SBPweb.Workbench/Workbench%20Framework%202.0.0.x/Presentation/Windows.WPF/Utils/Maths.cs
                            //in the TransformBounds function
                            Console.WriteLine("\n-------------Bounding Box Information-------------");
                            Console.WriteLine("Entity Type = {0}", IfcMetaData.GetType(geoData.IfcTypeId).Name);
                            Console.WriteLine("Entity Label = {0}", Math.Abs(ifcDoor.EntityLabel).ToString());
                            Console.WriteLine("Size X = {0:F2}", boundBox.SizeX.ToString());
                            Console.WriteLine("Size Y = {0:F2}", boundBox.SizeY.ToString());
                            Console.WriteLine("Size Z = {0:F2}", boundBox.SizeZ.ToString());
                            Console.WriteLine("Object space minimum point {0}", MinPtOCS);
                            Console.WriteLine("Object space maximum point {0}", MaxPtOCS);
                            Console.WriteLine("World space minimum point {0}", MinPtWCS);
                            Console.WriteLine("World space maximum point {0}", MaxPtWCS);
                            Console.WriteLine("---------------------------------------------");
                        }
                    }
                    else
                    {
                        Console.WriteLine(string.Format("Failed to find any IfcDoor's in {0}", ifcFile));
                        return;  //exit
                    }
                }
            }
            else
            {
                Console.WriteLine(string.Format("Failed to find {0} in executable directory", ifcFile));
            }
            Console.WriteLine("\nFinished");
        }
Ejemplo n.º 6
0
        public void Run()
        {
            //to start we need an ifc file, here it is Clinic_Example.ifc
            string ifcFile  = @"IfcFiles/Clinic_Example.ifc";
            string xbimFile = Path.ChangeExtension(ifcFile, "xBIM");  //will generate if not existing

            if (File.Exists(ifcFile))
            {
                using (XbimModel model = new XbimModel())
                {
                    if (File.Exists(xbimFile))
                    {
                        //assume the xbim file has the geometry already generated from ifc file, as below
                        model.Open(xbimFile, XbimDBAccess.Read);
                    }
                    else
                    {
                        //create the xbim file from the ifc file
                        model.CreateFrom(ifcFile, xbimFile, delegate(int percentProgress, object userState)
                        {
                            Console.Write("\rReading File {0}", percentProgress);
                        });

                        model.Open(xbimFile, XbimDBAccess.ReadWrite); //readwrite as we need to add the geometry
                        //add the the geometry information to the model
                        int total = (int)model.Instances.CountOf <IfcProduct>();
                        ReportProgressDelegate progDelegate = delegate(int percentProgress, object userState)
                        {
                            Console.Write("\rGeometry {0} / {1}", total, (total * percentProgress / 100));
                        };
                        XbimMesher.GenerateGeometry(model, null, progDelegate);
                    }
                    XbimScene <XbimMeshGeometry3D, WpfMaterial> scene = GetModelScene(model);

                    IEnumerable <IfcDoor> ifcDoors = model.IfcProducts.OfType <IfcDoor>(); //get all the ifcdoors for this model
                    if (ifcDoors.Any())
                    {
                        IfcDoor ifcDoor = ifcDoors.First(); //we use the first door
                        int     entLbl  = Math.Abs(ifcDoor.EntityLabel);

                        foreach (var layer in scene.Layers)                  //loop material layers
                        {
                            var hidden = layer.Hidden as XbimMeshGeometry3D; //stored the points in Hidden
                            if (hidden != null)
                            {
                                foreach (var m in hidden.Meshes) //display simple count information
                                {
                                    if (m.EntityLabel != entLbl)
                                    {
                                        continue;                          //skip doors that do not match label
                                    }
                                    int startIndex                     = m.StartPosition;
                                    int endIndex                       = m.EndPosition;
                                    int startTriIndex                  = m.StartTriangleIndex;
                                    int endTriIndex                    = m.EndTriangleIndex;
                                    List <XbimPoint3D>  vertex         = hidden.Positions.GetRange(startIndex, (endIndex - startIndex) + 1);
                                    List <XbimVector3D> normals        = hidden.Normals.GetRange(startIndex, (endIndex - startIndex) + 1);
                                    List <int>          triangleIndexs = hidden.TriangleIndices.GetRange(startIndex, (endTriIndex - startTriIndex) + 1);
                                    Console.WriteLine("\n-------------Geometry Triangle Information-------------");
                                    Console.WriteLine("Entity Type = IfcDoor");
                                    Console.WriteLine("Entity Label = {0}", entLbl);
                                    Console.WriteLine("Layer = {0}", layer.Name);
                                    Console.WriteLine("Vertex count = {0}", vertex.Count);
                                    Console.WriteLine("Normal count = {0}", normals.Count);
                                    Console.WriteLine("TriangleIndexs count = {0}", triangleIndexs.Count);
                                    Console.WriteLine("---------------------------------------------------------");
                                }
                            }
                        }
                    }
                }
            }
        }