Esempio n. 1
0
        public XbimShapeGeometry Mesh(IIfcRepresentationItem shape)
        {
            var fbm = shape as IIfcFaceBasedSurfaceModel;

            if (fbm != null)
            {
                return(Mesh(fbm));
            }
            var sbm = shape as IIfcShellBasedSurfaceModel;

            if (sbm != null)
            {
                return(Mesh(sbm));
            }
            var cfs = shape as IIfcConnectedFaceSet;

            if (cfs != null)
            {
                return(Mesh(cfs));
            }
            var fbr = shape as IIfcFacetedBrep;

            if (fbr != null)
            {
                return(Mesh(fbr));
            }
            var tfs = shape as IIfcTriangulatedFaceSet;

            if (tfs != null)
            {
                return(Mesh(tfs));
            }
            throw new ArgumentException("Unsupported representation type for tessellation, " + shape.GetType().Name);
        }
Esempio n. 2
0
 private static void Report(IIfcRepresentationItem item, TextHighliter sb)
 {
     if (item is IIfcFaceBasedSurfaceModel)
     {
         Report((IIfcFaceBasedSurfaceModel)item, sb);
     }
     else
     {
     }
 }
Esempio n. 3
0
        public static Dictionary <int, LinearPath> DicLinPathOfProductsGet(List <IIfcProduct> lstProduct)
        {
            Dictionary <int, LinearPath> dicLinPath = new Dictionary <int, LinearPath>();

            for (int i = 0; i < lstProduct.Count; i++)
            {
                IIfcRepresentationItem repItem = lstProduct[i].Representation.Representations.First.Items.First;
                IIfcProfileDef         profile = (repItem as IIfcExtrudedAreaSolid).SweptArea;
                IIfcCurve curve = (profile as IIfcArbitraryClosedProfileDef).OuterCurve;

                IIfcPolyline pLine = curve as IfcPolyline;
                IItemSet <IIfcCartesianPoint> ptSet = pLine.Points;

                List <Point3D> lstPt = new List <Point3D>();

                for (int j = 0; j < ptSet.Count; j++)
                {
                    lstPt.Add(new Point3D(ptSet[j].X, ptSet[j].Y, ptSet[j].Z));
                }
                dicLinPath.Add(lstProduct[i].EntityLabel, new LinearPath(lstPt));
            }
            return(dicLinPath);
        }
Esempio n. 4
0
        public ActionResult SubmitBlahBlah(List <int> axesIds, SubmissionStages subItem)
        {
            List <string>      files = Directory.GetFiles(FileStruc.CurrentVersion).ToList();
            List <IIfcProduct> Axes;

            List <IIfcProduct> lstProductSubmission;
            List <Line>        lstAxesLines = new List <Line>();
            string             ifcFile      = files.Where(a => Path.GetExtension(a) == ".ifc").FirstOrDefault();

            using (var model = IfcStore.Open(ifcFile))
            {
                Axes = model.Instances.OfType <IIfcProduct>().Where(b => axesIds.Contains(b.EntityLabel)).ToList();
                List <IIfcProduct> lstProduct = model.Instances.OfType <IIfcProduct>().Where(p => lstProductId.Contains(p.EntityLabel)).ToList();

                List <Line> lstLines = IFCHelper.AxesLinesGet(Axes);


                //Axes Boundaries
                LinearPath linPathSubmittal = MathHelper.LinPathAxesIntersection(lstLines);

                Dictionary <int, LinearPath> dicElement = IFCHelper.DicLinPathOfProductsGet(lstProduct);

                //get products within the axes boundary
                Dictionary <int, LinearPath> elementsWithinAxesBoundary = CadHelper.SubmittedElementsGet(linPathSubmittal, dicElement);

                //reinforcement IFC file
                using (IfcStore subModelRFT = IFCHelper.CreateandInitModel("Reinforcement File", model.Instances.OfType <IfcProject>().FirstOrDefault().UnitsInContext))
                {
                    IfcBuilding bldng = IFCHelper.CreateBuilding(subModelRFT, "bldngRFT", new Point3D(0, 0, 0));
                    using (var txn = subModelRFT.BeginTransaction("I"))
                    {
                        IfcBuildingStorey storey = subModelRFT.Instances.New <IfcBuildingStorey>();
                        bldng.AddToSpatialDecomposition(storey);
                        switch (subItem)
                        {
                        case SubmissionStages.FormWork:
                            for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++)
                            {
                                IIfcProduct            product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]);
                                IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First;
                                double height = (repItem as IIfcExtrudedAreaSolid).Depth;

                                IfcOpeningElement open;
                                XbimCreateBuilding.CreateFormWork(subModelRFT, elementsWithinAxesBoundary.Values.ToList()[i], DefaultValues.FormWorkThickness,
                                                                  height, out open, "", false, false, false);
                            }
                            //switch (elemTypeFormwork)
                            //{
                            //    case ElementType.PCF:
                            //        break;
                            //    case ElementType.RCF:
                            //        break;
                            //    case ElementType.SEM:
                            //        break;
                            //    case ElementType.SHW:
                            //        break;
                            //    case ElementType.RTW:
                            //        break;
                            //    case ElementType.COL:
                            //        for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++)
                            //        {
                            //            Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]);
                            //            ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0);

                            //            IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]);
                            //            IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First;
                            //            double height = (repItem as IIfcExtrudedAreaSolid).Depth;

                            //            IfcOpeningElement open;
                            //            XbimCreateBuilding.CreateFormWork(subModelRFT, rftCol.CadColumn.ColPath, DefaultValues.FormWorkThickness,
                            //                height, out open, false, false, false);

                            //        }
                            //        break;
                            //    case ElementType.SLB:
                            //        break;
                            //    default:
                            //        break;
                            //}

                            break;

                        case SubmissionStages.Concrete:
                            lstProductSubmission = lstProduct.Where(p => elementsWithinAxesBoundary.ContainsKey(p.EntityLabel)).ToList();
                            var map = new XbimInstanceHandleMap(model, subModelRFT);
                            for (int i = 0; i < lstProductSubmission.Count; i++)
                            {
                                IIfcProduct product = subModelRFT.InsertCopy(lstProductSubmission[i], map, null, false, false);
                                storey.AddElement(product as IfcProduct);
                            }
                            break;

                        case SubmissionStages.Reinforcement:
                            Enum.TryParse(ElementTypeSubmitted, out ElementType elemType);

                            switch (elemType)
                            {
                            case ElementType.PCF:
                                break;

                            case ElementType.RCF:
                                break;

                            case ElementType.SEM:
                                break;

                            case ElementType.SHW:
                                break;

                            case ElementType.RTW:
                                break;

                            case ElementType.COL:
                                for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++)
                                {
                                    Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]);
                                    ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0);

                                    IIfcProduct            product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]);
                                    IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First;
                                    double height = (repItem as IIfcExtrudedAreaSolid).Depth;

                                    XbimCreateBuilding.CreateColumnRft(rftCol, storey, subModelRFT, height, "");
                                }
                                break;

                            case ElementType.SLB:
                                break;

                            default:
                                break;
                            }
                            break;

                        default:
                            break;
                        }

                        txn.Commit();
                        subModelRFT.SaveAs(@"E:\01. Work\demo.ifc");
                        var context = new Xbim3DModelContext(subModelRFT);
                        context.CreateContext();

                        //var wexBimFilename = Path.ChangeExtension(, "wexBIM");
                        using (var wexBiMfile = System.IO.File.Create((@"E:\01. Work\demo.wexBIM")))
                        {
                            using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile))
                            {
                                subModelRFT.SaveAsWexBim(wexBimBinaryWriter);
                                wexBimBinaryWriter.Close();
                            }
                            wexBiMfile.Close();
                        }
                    }
                }
            }

            return(new EmptyResult());
        }