Пример #1
0
        /// <summary>
        /// Reads the given mvdXML File using the mvdReader in the utilities folder
        /// </summary>
        public override void Calculate()
        {
            if (InputPorts[0].Data == null)
            {
                return;
            }
            var file = InputPorts[0].Data.ToString();

            var       titleTextboxControl = ControlElements[0] as TitleTextboxControl;
            TextBlock textBlock           = new TextBlock();

            textBlock = titleTextboxControl.TextBlock;

            if (file != "" && File.Exists(file) && Path.GetExtension(file).ToUpper().ToString() == ".XML")
            {
                MvdXMLReader mvdXmlReader = new MvdXMLReader(file);
                mvdXmlReader.readXML();
                OutputPorts[0].Data = mvdXmlReader.GetModelView();


                textBlock.Background = Brushes.White;
                textBlock.Text       = "File is Valid!";
            }
            else
            {
                textBlock.Background = Brushes.Red;
                textBlock.Text       = "Please select a true mvdXML File!";
            }
        }
        public override void Calculate()
        {
            //Find all ConceptRoots (example Slabs) in Model View

            //Filter IFC for ConceptRoots

            //Find all Concept in Model View and their referencing ConceptTemplate in Templates

            //save the TemplateRule(in Rules<Concept<Model View) information for further use

            //filter IFC for TemplateRule value


            Console.WriteLine(" 1 BEGIN");

            //get xbim-model of the ifc-file from the IfcParseNode
            Console.WriteLine(InputPorts[0].Data.GetType().ToString());

            Type IfcVersionType = InputPorts[0].Data.GetType();

            if (IfcVersionType.Name == "ModelInfoIFC2x3")
            {
                var modelid = ((ModelInfoIFC2x3)(InputPorts[0].Data)).ModelId;
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> elementsids = ((ModelInfoIFC2x3)(InputPorts[0].Data)).ElementIds;
                if (modelid == null)
                {
                    return;
                }
                Console.WriteLine("modelid={0}", modelid);

                xModel = DataController.Instance.GetModel(modelid);

                /*
                 * foreach (IfcGloballyUniqueId uid in elementsids)
                 * {
                 *   Console.WriteLine(uid);
                 * }
                 */
                Console.WriteLine("elementsids.Count()={0}", elementsids.Count());  //-->1076

                var comboBox = ControlElements[2] as ComboBox;
                if (comboBox != null && comboBox.Items.Count > 0)
                {
                    comboBox.SelectedItem = -1;
                    comboBox.Items.Clear();
                }



                //Console.WriteLine("xModel.IfcSite.Count()={0}", IfcCount);

                /*
                 * foreach (IfcGloballyUniqueId el in elementsids)
                 * {
                 *  Console.WriteLine(el.ToString());
                 * }
                 */

                //outputInfo = new ModelInfo(modelid);
                //xModel = DataController.Instance.GetModel(modelid);

                Console.WriteLine(" 2 ");

                //get the mvd-file from the IfcMvdXMLReader
                MvdXMLReader mvd = (MvdXMLReader)InputPorts[1].Data;

                //We find all applicableEntities from all ConceptTemplates and all EntityNames from EntiryRules
                //The ifc-elements of these entity-types are going to be the output
                ChosenEntities = new HashSet <String>();

                Dictionary <string, ConceptTemplate> dict = mvd.templates.getConceptTemplates();

                Console.WriteLine("BEGIN");
                FindEntityNames(dict);
                Console.WriteLine("END");
                foreach (string s in ChosenEntities)
                {
                    Console.WriteLine(s);     //-->
                }


                // var ifcwindow = xModel.IfcProducts.OfType<Xbim.Ifc2x3.SharedBldgElements.IfcWindow>().ToList();
                var ifcLocalPlacement   = xModel.Instances.OfType <Xbim.Ifc2x3.GeometricConstraintResource.IfcLocalPlacement>().ToList();
                var ifcAxis2Placement3D = xModel.Instances.OfType <Xbim.Ifc2x3.GeometryResource.IfcAxis2Placement3D>().ToList();
                var ifcCartesianPoint   = xModel.Instances.OfType <Xbim.Ifc2x3.GeometryResource.IfcCartesianPoint>().ToList();
                var ifcDirection        = xModel.Instances.OfType <Xbim.Ifc2x3.GeometryResource.IfcDirection>().ToList();
                //there are Not in the IFC file
                var ifcRelNests = xModel.Instances.OfType <Xbim.Ifc2x3.Kernel.IfcRelNests>().ToList();
                //var ifcFlowDirectionEnum = xModel.Instances.OfType<Xbim.Ifc2x3.SharedBldgServiceElements.IfcFlowDirectionEnum>().ToList();
                // IfcDistributionSystemEnum --> NOT FOUND

                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcLocalPlacementFiltered    = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcAxis2Placement3DFiltered  = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcCartesianPointFiltered    = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcDirectionFiltered         = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcRelNestsFiltered          = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> IfcFlowDirectionEnumFiltered = new List <Xbim.Ifc2x3.UtilityResource.IfcGloballyUniqueId> {
                };

                foreach (var item in ifcLocalPlacement)
                {
                    //IfcLocalPlacementFiltered.Add(item.GlobalId);
                }
            }
            else if (IfcVersionType.Name == "ModelInfoIFC4")
            {
                var modelid = ((ModelInfoIFC4)(InputPorts[0].Data)).ModelId;
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> elementsids = ((ModelInfoIFC4)(InputPorts[0].Data)).ElementIds;
                if (modelid == null)
                {
                    return;
                }
                Console.WriteLine("modelid={0}", modelid);

                xModel = DataController.Instance.GetModel(modelid);

                /*
                 * foreach (IfcGloballyUniqueId uid in elementsids)
                 * {
                 *   Console.WriteLine(uid);
                 * }
                 */
                Console.WriteLine("elementsids.Count()={0}", elementsids.Count());  //-->1076

                var comboBox = ControlElements[2] as ComboBox;
                if (comboBox != null && comboBox.Items.Count > 0)
                {
                    comboBox.SelectedItem = -1;
                    comboBox.Items.Clear();
                }


                //Console.WriteLine("xModel.IfcSite.Count()={0}", IfcCount);

                /*
                 * foreach (IfcGloballyUniqueId el in elementsids)
                 * {
                 *  Console.WriteLine(el.ToString());
                 * }
                 */

                //outputInfo = new ModelInfo(modelid);
                //xModel = DataController.Instance.GetModel(modelid);

                Console.WriteLine(" 2 ");

                //get the mvd-file from the IfcMvdXMLReader
                MvdXMLReader mvd = (MvdXMLReader)InputPorts[1].Data;

                //We find all applicableEntities from all ConceptTemplates and all EntityNames from EntiryRules
                //The ifc-elements of these entity-types are going to be the output
                ChosenEntities = new HashSet <String>();

                Dictionary <string, ConceptTemplate> dict = mvd.templates.getConceptTemplates();

                Console.WriteLine("BEGIN");
                FindEntityNames(dict);
                Console.WriteLine("END");
                foreach (string s in ChosenEntities)
                {
                    Console.WriteLine(s);     //-->
                }


                // var ifcwindow = xModel.IfcProducts.OfType<Xbim.Ifc4.SharedBldgElements.IfcWindow>().ToList();
                var ifcLocalPlacement   = xModel.Instances.OfType <Xbim.Ifc4.GeometricConstraintResource.IfcLocalPlacement>().ToList();
                var ifcAxis2Placement3D = xModel.Instances.OfType <Xbim.Ifc4.GeometryResource.IfcAxis2Placement3D>().ToList();
                var ifcCartesianPoint   = xModel.Instances.OfType <Xbim.Ifc4.GeometryResource.IfcCartesianPoint>().ToList();
                var ifcDirection        = xModel.Instances.OfType <Xbim.Ifc4.GeometryResource.IfcDirection>().ToList();
                //there are Not in the IFC file
                var ifcRelNests = xModel.Instances.OfType <Xbim.Ifc4.Kernel.IfcRelNests>().ToList();
                //var ifcFlowDirectionEnum = xModel.Instances.OfType<Xbim.Ifc4.SharedBldgServiceElements.IfcFlowDirectionEnum>().ToList();
                // IfcDistributionSystemEnum --> NOT FOUND

                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcLocalPlacementFiltered    = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcAxis2Placement3DFiltered  = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcCartesianPointFiltered    = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcDirectionFiltered         = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcRelNestsFiltered          = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };
                List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> IfcFlowDirectionEnumFiltered = new List <Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId> {
                };

                foreach (var item in ifcLocalPlacement)
                {
                    //IfcLocalPlacementFiltered.Add(item.GlobalId);
                }
            }
        }