コード例 #1
0
        protected override void OnLoad(EventArgs e)
        {
            _treeModify = false;

            testLayer = viewportLayout1.Layers.Add("testLayer", Color.Red);
            int testLayer1 = viewportLayout1.Layers.Add("onPlane", Color.Blue);

            spatialLayer = viewportLayout1.Layers.Add("spatialLayer", Color.Green);

            viewportLayout1.Layers[0].Name = "Default";
            //viewportLayout1.Layers[0].Color = Color.Gray;

            //viewportLayout1.Layers[spatialLayer].Visible = true;
            //viewportLayout1.Layers[0].Visible = false;

            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC Model.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devdept\\IFC\\Martti_Ahtisaaren_RAK.ifc");                //gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\MOD-Padrão\\MOD-Padrão.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Blueberry031105_Complete_optimized.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Clinic_Handover_WithProperty3.ifc");      //Gym exception
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Duplex_A_20110907.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NER-38d.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\NHS Office.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\Office_A_20110811.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\porur duplex.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Data\\c_rvt8_Townhouse.ifc");

            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\01 Fire Protection.ifc");
            DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\ArchiCAD IFC Buildsoft.ifc");
            //DatabaseIfc db = new DatabaseIfc("C:\\devDept\\IFC\\IFC Samples\\Clinic_S_20110715_optimized.ifc");

            IfcProject project = db.Project;

            List <IfcBuildingElement> ifcBuildingElement = project.Extract <IfcBuildingElement>();

            List <IfcSpatialElement> ifcSpatialElement = project.Extract <IfcSpatialElement>();

            List <IfcDistributionElement> ifcDistributionElement = project.Extract <IfcDistributionElement>();

            //List<IfcRoot> ifcRoot = project.Extract<IfcRoot>();

            foreach (IfcSpatialElement ifcElement in ifcSpatialElement)  //ifcmesh
            {
                Entity eyeElement = null;

                Transformation elementTrs = new Transformation(1);

                if (ifcElement.Placement != null)
                {
                    elementTrs = Conversion.getPlacementTransformtion(ifcElement.Placement);
                }
                if (ifcElement.Representation != null)
                {
                    eyeElement = Conversion.getEntityFromIfcProductRepresentation(ifcElement.Representation, viewportLayout1, elementTrs);
                }
                if (eyeElement != null)
                {
                    eyeElement.TransformBy(elementTrs);

                    if (eyeElement is BlockReference)
                    {
                        UtilityIfc.loadProperties((IfcBlockReference)eyeElement, ifcElement);
                    }
                    else
                    {
                        IfcMesh ifcMesh;

                        Mesh eyeElementMesh;

                        if (eyeElement is Solid)
                        {
                            Solid eyeElementSolid = (Solid)eyeElement;

                            eyeElementMesh = eyeElementSolid.ConvertToMesh();
                        }
                        else
                        {
                            eyeElementMesh = (Mesh)eyeElement;
                        }
                        Color           color = eyeElementMesh.Color;
                        colorMethodType cmt   = eyeElementMesh.ColorMethod;

                        ifcMesh = new IfcMesh(eyeElementMesh.Vertices, eyeElementMesh.Triangles);

                        ifcMesh.Color       = color;
                        ifcMesh.ColorMethod = cmt;

                        UtilityIfc.loadProperties(ifcMesh, ifcElement);

                        eyeElement = ifcMesh;
                    }
                    viewportLayout1.Entities.Add(eyeElement, spatialLayer);
                }
            }

            foreach (IfcBuildingElement ifcElement in ifcBuildingElement)
            {
                if (ifcElement.GlobalId.StartsWith("3LHl4aR6j6bfwjDqKa2Mh9") && /**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            foreach (IfcDistributionElement ifcElement in ifcDistributionElement)
            {
                if (/*ifcElement.GlobalId.StartsWith("2O_tcxRRn1gegwp_L0mkmi") &&/**/ ifcElement.Decomposes == null)
                {
                    Entity eyeElement = Conversion.getEntityFromIfcElement(ifcElement, viewportLayout1);

                    if (eyeElement != null)
                    {
                        viewportLayout1.Entities.Add(eyeElement, 0);
                    }
                }
            }

            debug += Conversion.Debug;

            Debug.WriteLine(debug);

            TreeViewManager.PopulateTree(modelTree, viewportLayout1.Entities.ToList(), viewportLayout1.Blocks);

            viewportLayout1.ZoomFit();
        }
コード例 #2
0
ファイル: Conversion.cs プロジェクト: simonedd/TestIFC
        public static Entity getEntityFromIfcElement(IfcElement ifcElement, ViewportLayout viewportLayout1)
        {
            Entity eyeElement = null;

            Transformation elementTrs = new Transformation(1);

            if (ifcElement.Placement != null)
            {
                elementTrs = Conversion.getPlacementTransformtion(ifcElement.Placement);
            }
            if (ifcElement.Representation != null)
            {
                eyeElement = Conversion.getEntityFromIfcProductRepresentation(ifcElement.Representation, viewportLayout1, elementTrs);
            }
            if (eyeElement != null)
            {
                eyeElement.TransformBy(elementTrs);
            }
            if (ifcElement.IsDecomposedBy.Count > 0)
            {
                Block b = new Block();

                foreach (IfcRelAggregates relAg in ifcElement.IsDecomposedBy)
                {
                    foreach (IfcElement el in relAg.RelatedObjects)
                    {
                        Entity entity = getEntityFromIfcElement(el, viewportLayout1);

                        if (entity != null)
                        {
                            b.Entities.Add(entity);
                        }
                    }
                }
                if (eyeElement != null)
                {
                    b.Entities.Add(eyeElement);
                }

                viewportLayout1.Blocks.Add(ifcElement.GlobalId, b);

                eyeElement = new IfcBlockReference(ifcElement.GlobalId);
            }
            if (eyeElement != null)
            {
                if (ifcElement.HasOpenings.Count > 0)
                {
                    eyeElement = createOpenings(eyeElement, ifcElement, viewportLayout1);
                }
                if (eyeElement is BlockReference)
                {
                    UtilityIfc.loadProperties((IfcBlockReference)eyeElement, ifcElement);
                }
                else
                {
                    IfcMesh ifcMesh;

                    Mesh eyeElementMesh;

                    if (eyeElement is Solid)
                    {
                        Solid eyeElementSolid = (Solid)eyeElement;

                        eyeElementMesh = eyeElementSolid.ConvertToMesh();
                    }
                    else
                    {
                        eyeElementMesh = (Mesh)eyeElement;
                    }
                    Color           color = eyeElementMesh.Color;
                    colorMethodType cmt   = eyeElementMesh.ColorMethod;

                    ifcMesh = new IfcMesh(eyeElementMesh.Vertices, eyeElementMesh.Triangles);

                    ifcMesh.Color       = color;
                    ifcMesh.ColorMethod = cmt;

                    UtilityIfc.loadProperties(ifcMesh, ifcElement);

                    eyeElement = ifcMesh;
                }
            }
            return(eyeElement);
        }