Beispiel #1
0
        private static Dictionary <int, List <Xbim.Ifc2x3.Kernel.IfcPropertySet> > GetPropertySets2x3()
        {
            Dictionary <int, List <Xbim.Ifc2x3.Kernel.IfcPropertySet> > propSets = new Dictionary <int, List <Xbim.Ifc2x3.Kernel.IfcPropertySet> >();

            Xbim.Ifc2x3.Kernel.IfcProduct productIFC2x3 = null;

            foreach (var product in Products)
            {
                productIFC2x3 = product as Xbim.Ifc2x3.Kernel.IfcProduct;
                propSets.Add(product.EntityLabel, productIFC2x3.PropertySets.ToList());
            }
            return(propSets);
        }
        public TTColorAvailable2 GetTTifExistsCalculateifNot_IFC2x3(Xbim.Ifc2x3.Kernel.IfcProduct ifcProduct)
        {
            //bool found = false;
            var propertySets = ifcProduct.PropertySets.ToList() as List <Xbim.Ifc2x3.Kernel.IfcPropertySet>;
            int ii           = 0;

            while (ii < propertySets.Count)
            {
                var onepropertySet = propertySets[ii].HasProperties.ToList();
                int jj             = 0;
                while (jj < onepropertySet.Count)
                {
                    if (onepropertySet[jj].Name == "ThermalTransmittance")
                    {
                        double thisTT = (double)((Xbim.Ifc2x3.PropertyResource.IfcPropertySingleValue)onepropertySet[jj]).NominalValue.Value;

                        return(new TTColorAvailable2(thisTT, true));
                    }
                    jj++;
                }
                ii++;
            }
            //if it comes up 2 here, no TT was found... we r going 2 calculate it...
            if (ifcProduct.GetType() == typeof(Xbim.Ifc2x3.SharedBldgElements.IfcColumn))
            {
                double thisTT = CalculateTT_IFC2x3((Xbim.Ifc2x3.SharedBldgElements.IfcColumn)ifcProduct);
                return(new TTColorAvailable2(thisTT, false));
            }
            else if (ifcProduct.GetType() == typeof(Xbim.Ifc2x3.SharedBldgElements.IfcDoor))
            {
                double thisTT = CalculateTT_IFC2x3((Xbim.Ifc2x3.SharedBldgElements.IfcDoor)ifcProduct);
                return(new TTColorAvailable2(thisTT, false));
            }
            else if (ifcProduct.GetType() == typeof(Xbim.Ifc2x3.SharedBldgElements.IfcCurtainWall))
            {
                double thisTT = CalculateTT_IFC2x3((Xbim.Ifc2x3.SharedBldgElements.IfcCurtainWall)ifcProduct);
                return(new TTColorAvailable2(thisTT, false));
            }

            return(new TTColorAvailable2(-1, true));//smth may be wrong...
        }
        /// <summary>
        /// Get Style of each Item
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public Material GetStyleFromXbimModel_IFC2x3(Xbim.Ifc2x3.Kernel.IfcProduct item, double opacity = 1)
        {
            var context = new Xbim3DModelContext(item.Model);

            var productShape = context.ShapeInstancesOf((Xbim.Ifc4.Interfaces.IIfcProduct)item)
                               .Where(s => s.RepresentationType != XbimGeometryRepresentationType.OpeningsAndAdditionsExcluded)
                               .ToList();
            Material wpfMaterial = null;

            if (productShape.Count > 0)
            {
                wpfMaterial = GetWpfMaterial(item.Model, productShape[0].StyleLabel);
            }
            else
            {
                wpfMaterial = GetWpfMaterial(item.Model, 0);
            }

            ((System.Windows.Media.Media3D.DiffuseMaterial)wpfMaterial).Brush.Opacity = opacity;
            return(wpfMaterial);
        }
        /// <summary>
        /// On Mouse Select Event
        ///
        /// Output is an List of IDs (ModelInfo)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="ifcParseGeometryNode"></param>
        /// <param name="itemModel"></param>
        /// <param name="indexOfModel"></param>
        protected void OnElementMouseDown_IFC2x3(object sender, MouseButtonEventArgs e, IfcViewerNode ifcParseGeometryNode, Xbim.Ifc2x3.Kernel.IfcProduct itemModel)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            var element = sender as ModelUIElement3D;

            if (element != null)
            {
                var geometryModel3D = element.Model as GeometryModel3D;
                if (geometryModel3D == null)
                {
                    return;
                }

                // If it is already selected ... Deselect
                if (SelectedProductsIFC2x3 != null && SelectedProductsIFC2x3.Contains(itemModel.GlobalId))
                {
                    geometryModel3D.Material = geometryModel3D.BackMaterial;
                    SelectedProductsIFC2x3.Remove(itemModel.GlobalId);
                }
                // If not ... Select!
                else
                {
                    SelectedProductsIFC2x3.Add(itemModel.GlobalId);
                    geometryModel3D.Material = _selectionMaterial;
                }
            }
            var ifcViewerControl = ControlElements[0] as IFCViewerControl;
            var button_2         = ifcViewerControl.RadioButton_2;

            if (button_2 == null)
            {
                return;
            }

            if ((bool)button_2.IsChecked)
            {
                var             modelId         = ((ModelInfoIFC2x3)(InputPorts[0].Data)).ModelId;
                ModelInfoIFC2x3 modelInfoIfc2X3 = new ModelInfoIFC2x3(modelId);
                foreach (var item in SelectedProductsIFC2x3)
                {
                    modelInfoIfc2X3.AddElementIds(item);
                }
                OutputPorts[0].Data = modelInfoIfc2X3;
            }

            e.Handled = true;
        }
        /// <summary>
        ///     VisualizeMesh in the Viewport
        /// </summary>
        /// <param name="meshBuilder"></param>
        /// <param name="mesh"></param>
        /// <param name="mat"></param>
        /// <param name="itemModel"></param>
        /// <param name="indexOfModel"></param>
        public ModelUIElement3D VisualizeMesh_IFC2x3(MeshBuilder meshBuilder, MeshGeometry3D mesh, Material mat, Xbim.Ifc2x3.Kernel.IfcProduct itemModel)
        {
            var points = new List <Point3D>();

            foreach (var item in mesh.Positions)
            {
                points.Add(new Point3D {
                    X = item.X, Y = item.Y, Z = item.Z
                });
            }

            for (var i = 0; i < mesh.TriangleIndices.Count; i += 3)
            {
                meshBuilder.AddTriangle(points[mesh.TriangleIndices[i]], points[mesh.TriangleIndices[i + 1]],
                                        points[mesh.TriangleIndices[i + 2]]);
            }

            var myGeometryModel = new GeometryModel3D
            {
                Material     = mat,
                BackMaterial = mat,
                Geometry     = meshBuilder.ToMesh(true)
            };


            var element = new ModelUIElement3D {
                Model = myGeometryModel
            };

            element.MouseDown += (sender1, e1) => OnElementMouseDown_IFC2x3(sender1, e1, this, itemModel);

            return(element);
        }