コード例 #1
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreate(IfcStore model, IfcProfileDef prof, List <Point3D> lstPoints, IfcDirection planeZaxis = null, IfcDirection refDir = null)
        {
            IfcSurfaceCurveSweptAreaSolid body = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>();
            IfcPolyline pLine = model.Instances.New <IfcPolyline>();

            for (int i = 0; i < lstPoints.Count; i++)
            {
                IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z);
                pLine.Points.Add(point);
            }

            body.Directrix = pLine;
            body.SweptArea = prof;

            var plane = model.Instances.New <IfcPlane>();

            plane.Position          = model.Instances.New <IfcAxis2Placement3D>();
            plane.Position.Location = model.Instances.New <IfcCartesianPoint>();
            plane.Position.Location.SetXYZ(lstPoints[0].X, lstPoints[0].Y, lstPoints[0].Z);

            plane.Position.Axis         = planeZaxis;
            plane.Position.RefDirection = refDir;

            body.ReferenceSurface = plane;
            //body.FixedReference.SetXYZ(1, 0, 0);
            return(body);
        }
コード例 #2
0
        private static bool IsClosed(this IfcPolyline pline)
        {
            var start = pline.Points[0];
            var end   = pline.Points[pline.Points.Count - 1];

            return(start.Equals(end));
        }
コード例 #3
0
        public BbCurveGeometry(
            BbPolyline3D bbPolyline3D
            )
        {
            _ifcPolyline = bbPolyline3D.IfcCurve as IfcPolyline;



            _ifcShapeRepresentation = new IfcShapeRepresentation
            {
                ContextOfItems           = BbHeaderSetting.Setting3D.GeometricRepresentationContext,
                RepresentationIdentifier = "Body",
                RepresentationType       = "GeometricCurveSet",
                Items = new List <IfcRepresentationItem>(),
            };
            _ifcShapeRepresentation.Items.Add(_ifcPolyline);

            _ifcProductDefinitionShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List <IfcRepresentation>(),
            };
            _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation);
        }
コード例 #4
0
ファイル: BbPolyline3D.cs プロジェクト: JackTing/ifctoolkit
        public BbPolyline3D(BbCoordinate3D[] points)
        {
            base.IfcCurve = _ifcPolyline = new IfcPolyline();

            _ifcPolyline.Points = new List<IfcCartesianPoint> ();

            foreach (var point in points) {
                _ifcPolyline.Points.Add( point.IfcCartesianPoint);
            }
        }
コード例 #5
0
ファイル: BbPolyline2D.cs プロジェクト: JackTing/ifctoolkit
        public BbPolyline2D(BbCoordinate2D[] points)
        {
            ifcPolyline = new IfcPolyline();

            ifcPolyline.Points = new List<IfcCartesianPoint> ();

            foreach (var point in points) {
                ifcPolyline.Points.Add( point.IfcCartesianPoint);
            }
        }
コード例 #6
0
        public void ExtrudeAndRevolveTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            // -- extruded profile shape
            IfcPolyline outerCurve = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcRepresentationItem extrudedRepresentation = profileDef.Extrude(1).Rotate(new double[] { 45, 0, 45 }).Translate(new double[] { -2, 0, 0 });

            // -- revolved profile shape
            IfcRepresentationItem revolvedRepresentation = profileDef.Revolve(-45,
                                                                              new IfcAxis1Placement(new IfcCartesianPoint(1, 0, 0),
                                                                                                    new IfcDirection(0, 1, 0)),
                                                                              null);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("extruded square"),
                                           new IfcLabel("SweptSolid"),
                                           new IfcRepresentationItem[] { extrudedRepresentation, revolvedRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });;
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./swept_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }
コード例 #7
0
        public BbPolyline3D(BbCoordinate3D[] points)
        {
            base.IfcCurve = _ifcPolyline = new IfcPolyline();

            _ifcPolyline.Points = new List <IfcCartesianPoint> ();

            foreach (var point in points)
            {
                _ifcPolyline.Points.Add(point.IfcCartesianPoint);
            }
        }
コード例 #8
0
ファイル: BbPolyline2D.cs プロジェクト: mind-peace/ifctoolkit
        public BbPolyline2D(BbCoordinate2D[] points)
        {
            ifcPolyline = new IfcPolyline();

            ifcPolyline.Points = new List <IfcCartesianPoint> ();

            foreach (var point in points)
            {
                ifcPolyline.Points.Add(point.IfcCartesianPoint);
            }
        }
コード例 #9
0
        /// <summary>
        /// returns a Hash for the geometric behaviour of this object
        /// </summary>
        /// <param name="solid"></param>
        /// <returns></returns>
        public static int GetGeometryHashCode(this IfcPolyline pLine)
        {
            int hash = pLine.Points.Count;

            if (hash > 20 || hash < 3)
            {
                return(hash);                       //probably good enough
            }
            int midIdx = pLine.Points.Count / 2;

            return(hash ^ pLine.Points.First().GetGeometryHashCode() ^ pLine.Points[midIdx].GetGeometryHashCode());
        }
コード例 #10
0
        private static Polygon ToPolygon(this IfcPolyline polyline, bool dropLastPoint = false)
        {
            var count = dropLastPoint ? polyline.Points.Count - 1 : polyline.Points.Count;
            var verts = new Vector3[count];

            for (var i = 0; i < count; i++)
            {
                var v = polyline.Points[i].ToVector3();
                verts[i] = v;
            }
            return(new Polygon(verts));
        }
コード例 #11
0
        public void RotationTest()
        {
            // ==== Rotate IfcSweptAreaSolid
            var         operandStack = new Stack();
            IfcPolyline outerCurve   = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -1, -1 },
                new double[] { -1, 1 },
                new double[] { 1, 1 },
                new double[] { 1, -1 },
                new double[] { -1, -1 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);

            operandStack.Push(profileDef.Extrude(1));
            operandStack.Push("[-90,0,90]");
            ConstructionOperations.ExecuteOperation(OperationName.ROTATION, operandStack);
            Assert.Single(operandStack);
            var response = operandStack.Pop();

            Assert.IsAssignableFrom <IfcSweptAreaSolid>(response);
            Assert.Equal(0, ((IfcSweptAreaSolid)response).Position.RefDirection.DirectionRatios[0].Value, 10);
            Assert.Equal(0, ((IfcSweptAreaSolid)response).Position.RefDirection.DirectionRatios[1].Value, 10);
            Assert.Equal(-1, ((IfcSweptAreaSolid)response).Position.RefDirection.DirectionRatios[2].Value, 10);

            // ==== Rotate IfcBooleanResult
            operandStack.Clear();
            IfcCsgPrimitive3D union_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D union_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));

            operandStack.Push(union_first.Union(union_second));
            operandStack.Push("[-90,0,90]");
            ConstructionOperations.ExecuteOperation(OperationName.ROTATION, operandStack);
            Assert.Single(operandStack);
            response = operandStack.Pop();
            Assert.IsAssignableFrom <IfcBooleanResult>(response);
            Assert.Equal(0, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).FirstOperand).Position.RefDirection.DirectionRatios[0].Value, 10);
            Assert.Equal(0, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).FirstOperand).Position.RefDirection.DirectionRatios[1].Value, 10);
            Assert.Equal(-1, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).FirstOperand).Position.RefDirection.DirectionRatios[2].Value, 10);
            Assert.Equal(0, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).SecondOperand).Position.RefDirection.DirectionRatios[0].Value, 10);
            Assert.Equal(0, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).SecondOperand).Position.RefDirection.DirectionRatios[1].Value, 10);
            Assert.Equal(-1, ((IfcCsgPrimitive3D)((IfcBooleanResult)response).SecondOperand).Position.RefDirection.DirectionRatios[2].Value, 10);
        }
コード例 #12
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcArbitraryClosedProfileDef ArbitraryClosedProfileCreate(IfcStore model, List <Point3D> lstPoints)
        {
            IfcPolyline pLine = model.Instances.New <IfcPolyline>();

            for (int i = 0; i < lstPoints.Count; i++)
            {
                IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z);
                pLine.Points.Add(point);
            }
            IfcArbitraryClosedProfileDef profile = model.Instances.New <IfcArbitraryClosedProfileDef>();

            profile.ProfileType = IfcProfileTypeEnum.AREA;
            profile.OuterCurve  = pLine;

            return(profile);
        }
コード例 #13
0
 /// <summary>
 /// Compares two objects for geometric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcPolyline a, IfcPolyline b)
 {
     if (a.Equals(b))
     {
         return(true);
     }
     if (a.Points.Count != b.Points.Count)
     {
         return(false);
     }
     for (int i = 0; i < a.Points.Count; i++)
     {
         if (!a.Points[i].GeometricEquals(b.Points[i]))
         {
             return(false);                                           //dioes not deal with plines that have the same points but with a different start point
         }
     }
     return(true);
 }
コード例 #14
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcCompositeCurveSegment CreateCurveSegment(IfcStore model, Point3D p1, Point3D p2)
        {
            // Create PolyLine for rebar
            IfcPolyline pL         = model.Instances.New <IfcPolyline>();
            var         startPoint = model.Instances.New <IfcCartesianPoint>();

            startPoint.SetXYZ(p1.X, p1.Y, p1.Z);
            var EndPoint = model.Instances.New <IfcCartesianPoint>();

            EndPoint.SetXYZ(p2.X, p2.Y, p2.Z);
            pL.Points.Add(startPoint);
            pL.Points.Add(EndPoint);

            IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();

            segment.Transition  = IfcTransitionCode.CONTINUOUS;
            segment.ParentCurve = pL;
            segment.SameSense   = true;
            return(segment);
        }
コード例 #15
0
        public void CanDeserializeArrayWithReferences()
        {
            Entity[] Items = DeserializeAssertISO10303AndExtractItems(Utilities.StepArrayWithReferencesString());

            Assert.AreEqual(6, Items.Length); //FIXME should trim tree so only the root item is left (length == 1)
            Assert.IsNotNull(Items[0]);
            IfcPolyline poly = Items[0] as IfcPolyline;

            Assert.IsNotNull(poly);
            Assert.IsNotNull(poly.Points);
            Assert.IsNotNull(poly.Points.Items);
            Assert.AreEqual(5, poly.Points.Items.Length);
            Assert.IsNotNull(poly.Points[1]);
            IfcCartesianPoint pnt1 = poly.Points[1];

            Assert.IsNotNull(pnt1);
            Assert.IsNotNull(pnt1.Coordinates);
            Assert.IsNotNull(pnt1.Coordinates.Items);
            Assert.AreEqual(2, pnt1.Coordinates.Items.Length);
            Assert.AreEqual(0.3, pnt1.Coordinates[1].Value);
        }
コード例 #16
0
        public void CutByPlaneTest()
        {
            // === Cut IfcSweptAreaSolid
            var         operandStack = new Stack();
            IfcPolyline outerCurve   = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { 6, 0 },
                new double[] { 6, 1 },
                new double[] { 7, 1 },
                new double[] { 7, 0 },
                new double[] { 6, 0 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);

            operandStack.Push(profileDef.Extrude(1));
            operandStack.Push(IfcGeom.CreatePlane(new double[] { 6.5, 0.5, 0 },
                                                  new double[] { 1, 1, 0 }));
            ConstructionOperations.ExecuteOperation(OperationName.CUT_BY_PLANE, operandStack);
            Assert.Single(operandStack);
            var response = operandStack.Pop();

            Assert.IsAssignableFrom <IfcBooleanClippingResult>(response);
            Assert.IsType <IfcExtrudedAreaSolid>(((IfcBooleanClippingResult)response).FirstOperand);
            Assert.IsType <IfcPlane>(((IfcHalfSpaceSolid)((IfcBooleanClippingResult)response).SecondOperand).BaseSurface);

            // === Cut IfcSweptAreaSolid
            operandStack.Push(response);
            operandStack.Push(IfcGeom.CreatePlane(new double[] { 6.5, 0.5, 0 },
                                                  new double[] { 1, 1, 0 }));
            ConstructionOperations.ExecuteOperation(OperationName.CUT_BY_PLANE, operandStack);
            Assert.Single(operandStack);
            response = operandStack.Pop();
            Assert.IsAssignableFrom <IfcBooleanClippingResult>(response);
            Assert.IsType <IfcBooleanClippingResult>(((IfcBooleanClippingResult)response).FirstOperand);
            Assert.IsType <IfcPlane>(((IfcHalfSpaceSolid)((IfcBooleanClippingResult)response).SecondOperand).BaseSurface);
        }
コード例 #17
0
        public BbCurveGeometry(
             BbPolyline3D bbPolyline3D
            )
        {
            _ifcPolyline = bbPolyline3D.IfcCurve as IfcPolyline;

            _ifcShapeRepresentation = new IfcShapeRepresentation
                {
                    ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext,
                    RepresentationIdentifier = "Body",
                    RepresentationType = "GeometricCurveSet",
                    Items = new List<IfcRepresentationItem>(),
                };
            _ifcShapeRepresentation.Items.Add(_ifcPolyline);

            _ifcProductDefinitionShape = new IfcProductDefinitionShape
                {
                    // Name=
                    // Description =
                    Representations = new List<IfcRepresentation>(),
                };
            _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation);
        }
コード例 #18
0
        public void RevolveTest()
        {
            var         operandStack = new Stack();
            IfcPolyline outerCurve   = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);

            operandStack.Push(profileDef);
            operandStack.Push("70.77");
            ConstructionOperations.ExecuteOperation(OperationName.REVOLVE, operandStack);
            Assert.Single(operandStack);
            var response = operandStack.Pop();

            Assert.IsType <IfcRevolvedAreaSolid>(response);
            Assert.Equal(70.77, ((IfcRevolvedAreaSolid)response).Angle.Value);
        }
コード例 #19
0
        private static void AdjustExtrusion(XbimModel model, IfcExtrudedAreaSolid body, HndzStructuralElement genericProducthndz,
                                            IfcProduct genericProductIfc)
        {
            IfcCartesianPoint axisOrigin = model.Instances.New <IfcCartesianPoint>();

            axisOrigin.SetXYZ(0, 0, 0);

            IfcCartesianPoint elementStartPoint = model.Instances.New <IfcCartesianPoint>();

            elementStartPoint.SetXYZ(genericProducthndz.ExtrusionLine.baseNode.Point.X,
                                     genericProducthndz.ExtrusionLine.baseNode.Point.Y, genericProducthndz.ExtrusionLine.baseNode.Point.Z); //insert at arbitrary position//****************Need Revision


            body.Depth             = genericProducthndz.ExtrusionLine.RhinoLine.Length;
            body.ExtrudedDirection = model.Instances.New <IfcDirection>();
            body.ExtrudedDirection.SetXYZ(0, 0, 1);

            //parameters to insert the geometry in the model

            body.Position          = model.Instances.New <IfcAxis2Placement3D>();
            body.Position.Location = axisOrigin;

            //body.Position.RefDirection = model.Instances.New<IfcDirection>();
            //body.Position.RefDirection.SetXYZ(1, 0, 0);

            //Create a Definition shape to hold the geometry
            IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>();

            shape.ContextOfItems           = model.IfcProject.ModelContext();
            shape.RepresentationType       = "SweptSolid";
            shape.RepresentationIdentifier = "Body";
            shape.Items.Add(body);

            //Create a Product Definition and add the model geometry to the wall
            IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>();

            rep.Representations.Add(shape);
            genericProductIfc.Representation = rep;

            //now place the wall into the model
            #region ProfileVectorDir.

            Vector3d perpendicularVector = new Vector3d(genericProducthndz.Profile.OrientationInPlane.X, genericProducthndz.Profile.OrientationInPlane.Y, 0);
            Plane    extrusionPlane;

            bool aa = genericProducthndz.ExtrusionLine.RhinoLine.TryGetPlane(out extrusionPlane);
            if (aa)
            {
                perpendicularVector = extrusionPlane.ZAxis;
            }

            // Vector3d elementDirection = genericProducthndz.ExtrusionLine.RhinoLine.Direction;
            //Plane profilePlane = new Plane(genericProducthndz.ExtrusionLine.baseNode.Point, elementDirection);
            // Vector3d profileXdirection = profilePlane.XAxis;

            #endregion
            IfcLocalPlacement   lp   = model.Instances.New <IfcLocalPlacement>();
            IfcAxis2Placement3D ax3D = model.Instances.New <IfcAxis2Placement3D>();
            ax3D.Location     = elementStartPoint;
            ax3D.RefDirection = model.Instances.New <IfcDirection>();
            ax3D.RefDirection.SetXYZ(perpendicularVector.X, perpendicularVector.Y, perpendicularVector.Z);  //Y-Axis
            //ax3D.RefDirection.SetXYZ(0, 1, 0);  //Y-Axis
            ax3D.Axis = model.Instances.New <IfcDirection>();
            ax3D.Axis.SetXYZ(genericProducthndz.ExtrusionLine.RhinoLine.Direction.X, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Y, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Z);          //Z-Axis


            //XbimVector3D X_Dir = new XbimVector3D(extrusionPlane.XAxis.X, extrusionPlane.XAxis.Y, extrusionPlane.XAxis.Z);
            //XbimVector3D Y_Dir = new XbimVector3D(extrusionPlane.YAxis.X, extrusionPlane.YAxis.Y, extrusionPlane.YAxis.Z);
            //XbimVector3D Z_Dir = new XbimVector3D(extrusionPlane.ZAxis.X, extrusionPlane.ZAxis.Y, extrusionPlane.ZAxis.Z);
            //ax3D.P.Insert(0,X_Dir);
            //ax3D.P.Insert(1,Y_Dir);
            //ax3D.P.Insert(2,Z_Dir);

            lp.RelativePlacement = ax3D;
            genericProductIfc.ObjectPlacement = lp;

            // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage
            IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>();
            IfcMaterialLayerSet      ifcMaterialLayerSet      = model.Instances.New <IfcMaterialLayerSet>();
            IfcMaterialLayer         ifcMaterialLayer         = model.Instances.New <IfcMaterialLayer>();
            ifcMaterialLayer.LayerThickness = 10;
            ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer);
            ifcMaterialLayerSetUsage.ForLayerSet             = ifcMaterialLayerSet;
            ifcMaterialLayerSetUsage.LayerSetDirection       = IfcLayerSetDirectionEnum.AXIS2;
            ifcMaterialLayerSetUsage.DirectionSense          = IfcDirectionSenseEnum.NEGATIVE;
            ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150;

            // Add material to wall
            IfcMaterial material = model.Instances.New <IfcMaterial>();
            material.Name = "STEEL";
            IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>();
            ifcRelAssociatesMaterial.RelatingMaterial = material;
            ifcRelAssociatesMaterial.RelatedObjects.Add(genericProductIfc);

            ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage;

            // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase
            IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>();
            ifcPresentationLayerAssignment.Name = "HANDZteel Assignment";
            ifcPresentationLayerAssignment.AssignedItems.Add(shape);


            // linear segment as IfcPolyline with two points is required for IfcWall
            IfcPolyline       ifcPolyline = model.Instances.New <IfcPolyline>();
            IfcCartesianPoint startPoint  = model.Instances.New <IfcCartesianPoint>();
            startPoint.SetXY(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y);
            IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>();
            endPoint.SetXY(genericProducthndz.ExtrusionLine.EndNode.Point.X, genericProducthndz.ExtrusionLine.EndNode.Point.Y);
            ifcPolyline.Points.Add(startPoint);
            ifcPolyline.Points.Add(endPoint);

            IfcShapeRepresentation shape2D = model.Instances.New <IfcShapeRepresentation>();
            shape2D.ContextOfItems           = model.IfcProject.ModelContext();
            shape2D.RepresentationIdentifier = "Axis";
            shape2D.RepresentationType       = "Curve2D";
            shape2D.Items.Add(ifcPolyline);
            rep.Representations.Add(shape2D);
        }
コード例 #20
0
        internal static void GenerateInstance(IfcBuilding building, bool assembly)
        {
            DatabaseIfc          db = building.Database;
            IfcDocumentReference documentReference = new IfcDocumentReference(db)
            {
                Name = "MyReinforcementCode", Identification = "MyCodeISO3766"
            };
            IfcRelAssociatesDocument associatesDocument = new IfcRelAssociatesDocument(db.Project, documentReference)
            {
                GlobalId = "1R7R97$uLAAv4wci$KGwn8"
            };
            IfcMaterial material = new IfcMaterial(db, "ReinforcingSteel");
            List <Tuple <double, double, double> > points = new List <Tuple <double, double, double> >()
            {
                new Tuple <double, double, double>(-69.0, 0.0, -122.0), new Tuple <double, double, double>(-69.0, 0.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 0.0, -31.0), new Tuple <double, double, double>(21.0, 0.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 0.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 0.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 0.00000000000000089, -321.0), new Tuple <double, double, double>(54.9939785957165, 1.21791490472034, -354.941125496954), new Tuple <double, double, double>(21.1804517666074, 4.15822158551252, -369.0), new Tuple <double, double, double>(-20.6616529376114, 7.79666547283599, -369.0), new Tuple <double, double, double>(-54.4751797667207, 10.7369721536282, -354.941125496954), new Tuple <double, double, double>(-68.4812011710042, 11.9548870583485, -321.0), new Tuple <double, double, double>(-69.0, 12.0, -79.0), new Tuple <double, double, double>(-54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(-21.0, 12.0, -31.0), new Tuple <double, double, double>(21.0, 12.0, -31.0), new Tuple <double, double, double>(54.9411254969541, 12.0, -45.0588745030455), new Tuple <double, double, double>(69.0, 12.0, -78.9999999999999), new Tuple <double, double, double>(69.0, 12.0, -122.0),
            };
            IfcBoundedCurve directrix = null;

            if (db.Release == ReleaseVersion.IFC2x3)
            {
                directrix = new IfcPolyline(db, points);
            }
            else
            {
                List <IfcSegmentIndexSelect> segments = new List <IfcSegmentIndexSelect>();
                segments.Add(new IfcLineIndex(1, 2));
                segments.Add(new IfcArcIndex(2, 3, 4));
                segments.Add(new IfcLineIndex(4, 5));
                segments.Add(new IfcArcIndex(5, 6, 7));
                segments.Add(new IfcLineIndex(7, 8));
                segments.Add(new IfcArcIndex(8, 9, 10));
                segments.Add(new IfcLineIndex(10, 11));
                segments.Add(new IfcArcIndex(11, 12, 13));
                segments.Add(new IfcLineIndex(13, 14));
                segments.Add(new IfcArcIndex(14, 15, 16));
                segments.Add(new IfcLineIndex(16, 17));
                segments.Add(new IfcArcIndex(17, 18, 19));
                segments.Add(new IfcLineIndex(19, 20));
                directrix = new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, points), segments);
            }
            double                barDiameter = 12, area = Math.PI * Math.Pow(barDiameter, 2) / 4;
            IfcSweptDiskSolid     sweptDiskSolid     = new IfcSweptDiskSolid(directrix, barDiameter / 2.0);
            IfcRepresentationMap  representationMap  = new IfcRepresentationMap(sweptDiskSolid);
            string                shapeCode          = ""; //Todo
            IfcReinforcingBarType reinforcingBarType = new IfcReinforcingBarType(db, "12 Diameter Ligature", IfcReinforcingBarTypeEnum.LIGATURE, barDiameter, area, 1150, IfcReinforcingBarSurfaceEnum.TEXTURED, shapeCode, null)
            {
                GlobalId = "0jMRtfHYXE7u4s_CQ2uVE9", MaterialSelect = material
            };

            reinforcingBarType.RepresentationMaps.Add(representationMap);
            db.Context.AddDeclared(reinforcingBarType);
            if (assembly)
            {
                IfcMaterial concrete = new IfcMaterial(db, "Concrete")
                {
                    Category = "Concrete"
                };
                string name = "400x200RC";
                IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, name, 200, 400);
                IfcMaterialProfile     materialProfile     = new IfcMaterialProfile(name, concrete, rectangleProfileDef);

                IfcBeamType beamType = new IfcBeamType(name, materialProfile, IfcBeamTypeEnum.BEAM);
                db.Context.AddDeclared(beamType);
                IfcMaterialProfileSet materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet;
                IfcBeam beam = new IfcBeam(building, new IfcLocalPlacement(building.Placement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0))), null)
                {
                    Description = "Reinforced Beam"
                };
                IfcBeamStandardCase beamStandardCase = new IfcBeamStandardCase(beam, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.TOPMID), new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 0, 1, 0), new IfcDirection(db, -1, 0, 0)), 5000)
                {
                    GlobalId = "1yjQ2DwLnCC8k3i3X6D_ut", RelatingType = beamType
                };
                IfcElementAssembly elementAssembly = new IfcElementAssembly(beam, IfcAssemblyPlaceEnum.FACTORY, IfcElementAssemblyTypeEnum.REINFORCEMENT_UNIT);
                List <string>      ids             = new List <string>()
                {
                    "0ohBfsArr3ruXYxacT4yl5", "3YrK7RbE122fNRsP5djFAe", "0wxAc63nj5AezFhfks7wLL", "0bsov2wZL6tRRZmKy4vuUU", "3qrgfIBb92ZegJTle7jou3", "16m6R3JeT83fJPCze2yU$a", "2SGIIYjSbCuu3HVwoLt1yh", "0PsLby6eL8_hVEt4QwK0lZ", "1325VJou5AngWp1djcV0hL", "20zj_$BcH74xRgR4bDrLNb", "3M4SfEMtHEJukgZR4hw$eV", "23BYnIaOLBZPVTrKVEDJiy", "2XulRByDL8ugyo4Uqv9rJr", "2xvQMSga96XOT3VeCS6ZsK", "2gUE6_w3j77f8YJGz_2RMl", "0J0dRL4tT93REAabfASDom", "048RJ151b81PqODsTMD4EA", "3hXx9Kb6b5bvjgr9pwvpz0", "0FmUHg8ZX0ZfY$0f5nkM2l", "2_zvpwRdvAuRiTlHXX$Qp8", "1mhkXHKfX6PxdS2vZn17wX", "0CeIQzUqP5qOOeAjMtH2OX", "3shtoAQL5BAhvwA_1Ph$lC", "22j4RNKqD2IBRDGig5eaCF", "3Wvu6qGJH4ChhTV3pl9CGh", "37Qrf07Iz3tRMbSxEA4ynH", "2gelqZ1Wv8BvCy6TstVGkd", "1Q21dHc_X7eRppCHrT69Vb", "0e6Wc08NLD59ueqCAK1gxp", "3xdMOSZMj3cBOV_QTbXZha", "1r_U9JTkHDWwkv_nfWFHVe", "29I7_S2fT3WRD4zPH4YjmD", "0$ciATTaP17PJMHQD0$N3Y", "1irBeCCUf82wdGg7qTPCbW"
                };
                int jcounter = 0;
                for (int icounter = 25; icounter < 5000; icounter += 150)
                {
                    IfcElement element = reinforcingBarType.GenerateMappedItemElement(elementAssembly, new IfcCartesianTransformationOperator3D(db)
                    {
                        LocalOrigin = new IfcCartesianPoint(db, 0, icounter, 0)
                    });
                    //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                    element.GlobalId = ids[jcounter++];
                }

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                beam.GlobalId     = "1_KSmTR8T8bO37iRs24GkM";
                beamType.GlobalId = "3bdpqVuWTCbxJ2S3ODYv6q";
                beamType.ObjectTypeOf.GlobalId = "2oaQVVf79BrwRouvtRuQVg";
                beamType.MaterialSelect.Associates.GlobalId         = "2ZEgyI2v184hwa$_diRqS9";
                beamStandardCase.MaterialSelect.Associates.GlobalId = "3DWeleqqjEG9KshbOZXUdY";
                elementAssembly.GlobalId = "0Q1tCJWdj4kOkZUg7rkf2h";
                elementAssembly.IsDecomposedBy[0].GlobalId = "1WdB196Kb72f_pKgj5rklU";
                beam.IsDecomposedBy[0].GlobalId            = "1b1SnKocD0WRevlg8Aqhj5";
            }
            else
            {
                IfcElement element = reinforcingBarType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db));

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                element.GlobalId = "0WUveBtSTDbunNjDLsuRn$";
            }

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise

            reinforcingBarType.ObjectTypeOf.GlobalId = "1iAfl2ERbFmwi7uniy1H7j";
            reinforcingBarType.MaterialSelect.Associates.GlobalId = "3gfVO40P5EfQyKZ_bF0R$6";
        }
コード例 #21
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreate(IfcStore model, IfcProfileDef prof, Entity profPath)
        {
            IfcSurfaceCurveSweptAreaSolid body = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>();

            if (profPath is LinearPath)
            {
                List <Point3D> lstPoints = (profPath as LinearPath).Vertices.ToList();
                IfcPolyline    pLine     = model.Instances.New <IfcPolyline>();
                for (int i = 0; i < lstPoints.Count; i++)
                {
                    IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                    point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z);
                    pLine.Points.Add(point);
                }

                body.Directrix = pLine;
                body.SweptArea = prof;

                var plane = model.Instances.New <IfcPlane>();
                plane.Position          = model.Instances.New <IfcAxis2Placement3D>();
                plane.Position.Location = model.Instances.New <IfcCartesianPoint>();
                plane.Position.Location.SetXYZ(lstPoints[0].X, lstPoints[0].Y, lstPoints[0].Z);

                plane.Position.Axis = model.Instances.New <IfcDirection>();
                plane.Position.Axis.SetXYZ(0, 0, 1);
                plane.Position.RefDirection = model.Instances.New <IfcDirection>();
                plane.Position.RefDirection.SetXYZ(1, 0, 0);
                body.ReferenceSurface = plane;
            }
            else if (profPath is Circle)
            {
                Circle cadCircle = profPath as Circle;

                IfcCircle c = model.Instances.New <IfcCircle>();
                c.Radius = cadCircle.Radius * 2;
                IfcAxis2Placement3D placement = model.Instances.New <IfcAxis2Placement3D>();
                placement.Location = model.Instances.New <IfcCartesianPoint>();
                placement.Location.SetXYZ(cadCircle.Center.X, cadCircle.Center.Y, cadCircle.Center.Z);
                c.Position = placement;


                body.Directrix = c;
                body.SweptArea = prof;

                IfcPlane plane = model.Instances.New <IfcPlane>();
                plane.Position          = model.Instances.New <IfcAxis2Placement3D>();
                plane.Position.Location = model.Instances.New <IfcCartesianPoint>();
                plane.Position.Location.SetXYZ(cadCircle.Center.X, cadCircle.Center.Y, cadCircle.Center.Z);


                plane.Position.RefDirection = model.Instances.New <IfcDirection>();
                plane.Position.RefDirection.SetXYZ(1, 0, 0);

                plane.Position.Axis = model.Instances.New <IfcDirection>();
                plane.Position.Axis.SetXYZ(0, 0, 1);

                body.ReferenceSurface = plane; //plane containing directrix

                //body.StartParam = 0;
                //body.EndParam = 360;
            }
            //body.FixedReference.SetXYZ(1, 0, 0);
            return(body);
        }
コード例 #22
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreateByCompositeCurve(IfcStore model, IfcProfileDef prof, Entity profPath)
        {
            IfcSurfaceCurveSweptAreaSolid body           = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>();
            IfcCompositeCurve             compositeCurve = model.Instances.New <IfcCompositeCurve>();

            if (profPath is LinearPath)
            {
                LinearPath linearPath            = profPath as LinearPath;
                IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                for (int i = 0; i < linearPath.Vertices.Length; i++)
                {
                    IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                    point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z);
                    pLine.Points.Add(point);
                }
                segment.ParentCurve = pLine;
                segment.Transition  = IfcTransitionCode.CONTINUOUS;
                compositeCurve.Segments.Add(segment);
            }
            else
            {
                CompositeCurve compCurvePath = profPath as CompositeCurve;
                for (int i = 0; i < compCurvePath.CurveList.Count; i++)
                {
                    if (compCurvePath.CurveList[i] is Line)
                    {
                        Line line = compCurvePath.CurveList[i] as Line;
                        IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                        IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                        for (int j = 0; j < line.Vertices.Length; j++)
                        {
                            IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                            point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z);
                            pLine.Points.Add(point);
                        }
                        segment.ParentCurve = pLine;
                        segment.Transition  = IfcTransitionCode.CONTINUOUS;
                        compositeCurve.Segments.Add(segment);
                    }
                    else
                    {
                        Arc arc = compCurvePath.CurveList[i] as Arc;
                        IfcCompositeCurveSegment segment      = model.Instances.New <IfcCompositeCurveSegment>();
                        IfcTrimmedCurve          trimmedCurve = model.Instances.New <IfcTrimmedCurve>();
                        IfcCircle cir = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius);
                        cir.Position = model.Instances.New <IfcAxis2Placement3D>(e => e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z)));

                        trimmedCurve.BasisCurve = cir;
                        trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z)));
                        trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z)));
                        trimmedCurve.SenseAgreement       = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true;
                        trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN;
                        segment.ParentCurve = trimmedCurve;
                        segment.Transition  = IfcTransitionCode.CONTINUOUS;
                        compositeCurve.Segments.Add(segment);
                    }
                }
            }



            body.Directrix = compositeCurve;
            body.SweptArea = prof;
            var plane = model.Instances.New <IfcPlane>();

            plane.Position          = model.Instances.New <IfcAxis2Placement3D>();
            plane.Position.Location = model.Instances.New <IfcCartesianPoint>();
            //plane.Position.Location.SetXYZ(profPath.X, lstPoints[0].Y, lstPoints[0].Z);

            plane.Position.Axis = model.Instances.New <IfcDirection>();
            plane.Position.Axis.SetXYZ(0, 0, 1);
            plane.Position.RefDirection = model.Instances.New <IfcDirection>();
            plane.Position.RefDirection.SetXYZ(1, 0, 0);
            body.ReferenceSurface = plane;
            //body.FixedReference.SetXYZ(1, 0, 0);
            return(body);
        }
コード例 #23
0
        /// <summary>
        /// This creates a wall and it's geometry, many geometric representations are possible and extruded rectangular footprint is chosen as this is commonly used for standard case walls
        /// </summary>
        /// <param name="model"></param>
        /// <param name="length">Length of the rectangular footprint</param>
        /// <param name="width">Width of the rectangular footprint (width of the wall)</param>
        /// <param name="height">Height to extrude the wall, extrusion is vertical</param>
        /// <returns></returns>
        private IfcWallStandardCase CreateWall(XbimModel model, double length, double width, double height)
        {
            //
            //begin a transaction
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Wall"))
            {
                IfcWallStandardCase wall = model.Instances.New <IfcWallStandardCase>();
                wall.Name = "A Standard rectangular wall";

                // required parameters for IfcWall
                wall.OwnerHistory.OwningUser        = model.DefaultOwningUser;
                wall.OwnerHistory.OwningApplication = model.DefaultOwningApplication;

                //represent wall as a rectangular profile
                IfcRectangleProfileDef rectProf = model.Instances.New <IfcRectangleProfileDef>();
                rectProf.ProfileType = IfcProfileTypeEnum.AREA;
                rectProf.XDim        = width;
                rectProf.YDim        = length;

                IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>();
                insertPoint.SetXY(0, 400); //insert at arbitrary position
                rectProf.Position          = model.Instances.New <IfcAxis2Placement2D>();
                rectProf.Position.Location = insertPoint;

                //model as a swept area solid
                IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                body.Depth             = height;
                body.SweptArea         = rectProf;
                body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                body.ExtrudedDirection.SetXYZ(0, 0, 1);

                //parameters to insert the geometry in the model
                IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>();
                origin.SetXYZ(0, 0, 0);
                body.Position          = model.Instances.New <IfcAxis2Placement3D>();
                body.Position.Location = origin;

                //Create a Definition shape to hold the geometry
                IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>();
                shape.ContextOfItems           = model.IfcProject.ModelContext();
                shape.RepresentationType       = "SweptSolid";
                shape.RepresentationIdentifier = "Body";
                shape.Items.Add_Reversible(body);

                //Create a Product Definition and add the model geometry to the wall
                IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>();
                rep.Representations.Add_Reversible(shape);
                wall.Representation = rep;

                //now place the wall into the model
                IfcLocalPlacement   lp   = model.Instances.New <IfcLocalPlacement>();
                IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>();
                ax3d.Location     = origin;
                ax3d.RefDirection = model.Instances.New <IfcDirection>();
                ax3d.RefDirection.SetXYZ(0, 1, 0);
                ax3d.Axis = model.Instances.New <IfcDirection>();
                ax3d.Axis.SetXYZ(0, 0, 1);
                lp.RelativePlacement = ax3d;
                wall.ObjectPlacement = lp;


                // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage
                IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>();
                IfcMaterialLayerSet      ifcMaterialLayerSet      = model.Instances.New <IfcMaterialLayerSet>();
                IfcMaterialLayer         ifcMaterialLayer         = model.Instances.New <IfcMaterialLayer>();
                ifcMaterialLayer.LayerThickness = 10;
                ifcMaterialLayerSet.MaterialLayers.Add_Reversible(ifcMaterialLayer);
                ifcMaterialLayerSetUsage.ForLayerSet             = ifcMaterialLayerSet;
                ifcMaterialLayerSetUsage.LayerSetDirection       = IfcLayerSetDirectionEnum.AXIS2;
                ifcMaterialLayerSetUsage.DirectionSense          = IfcDirectionSenseEnum.NEGATIVE;
                ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150;

                // Add material to wall
                IfcMaterial material = model.Instances.New <IfcMaterial>();
                material.Name = "some material";
                IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>();
                ifcRelAssociatesMaterial.RelatingMaterial = material;
                ifcRelAssociatesMaterial.RelatedObjects.Add_Reversible(wall);

                ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage;

                // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase
                IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>();
                ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment";
                ifcPresentationLayerAssignment.AssignedItems.Add(shape);


                // linear segment as IfcPolyline with two points is required for IfcWall
                IfcPolyline       ifcPolyline = model.Instances.New <IfcPolyline>();
                IfcCartesianPoint startPoint  = model.Instances.New <IfcCartesianPoint>();
                startPoint.SetXY(0, 0);
                IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>();
                endPoint.SetXY(4000, 0);
                ifcPolyline.Points.Add_Reversible(startPoint);
                ifcPolyline.Points.Add_Reversible(endPoint);

                IfcShapeRepresentation shape2d = model.Instances.New <IfcShapeRepresentation>();
                shape2d.ContextOfItems           = model.IfcProject.ModelContext();
                shape2d.RepresentationIdentifier = "Axis";
                shape2d.RepresentationType       = "Curve2D";
                shape2d.Items.Add_Reversible(ifcPolyline);
                rep.Representations.Add_Reversible(shape2d);


                //validate write any errors to the console and commit if ok, otherwise abort

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return(wall);
                }
            }
            return(null);
        }
コード例 #24
0
        public BbSlottedHoleProfile(double cToCDistance, double radius)
        {
            var cir1 = new IfcCircle
                {
                    Position = new IfcAxis2Placement
                        {
                            Value =  new IfcAxis2Placement2D
                                {
                                    Location = new IfcCartesianPoint(cToCDistance / 2.0, 0),
                                },
                        },
                    Radius = radius,
                };
            var trimmed1 = new IfcTrimmedCurve
                {
                    BasisCurve = cir1,
                    Trim1 = new List<IfcTrimmingSelect>{new IfcTrimmingSelect{Value = new IfcParameterValue{Value = 270}}},
                    Trim2 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 90 } } },
                    SenseAgreement = true,
                    MasterRepresentation = IfcTrimmingPreference.PARAMETER,
                };

            var line1 = new IfcPolyline
                {
                    Points = new List<IfcCartesianPoint>
                        {
                            new IfcCartesianPoint(cToCDistance / 2.0, radius),
                            new IfcCartesianPoint(cToCDistance / -2.0, radius),
                        },
                };

            var cir2 = new IfcCircle
                {
                    Position = new IfcAxis2Placement
                        {
                            Value = new IfcAxis2Placement2D
                                {
                                    Location = new IfcCartesianPoint(cToCDistance / -2.0, 0),
                                },
                        },
                    Radius = radius,
                };
            var trimmed2 = new IfcTrimmedCurve
                {
                    BasisCurve = cir2,
                    Trim1 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 90 } } },
                    Trim2 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 270 } } },
                    SenseAgreement = true,
                    MasterRepresentation = IfcTrimmingPreference.PARAMETER,
                };

            var line2 = new IfcPolyline
                {
                    Points = new List<IfcCartesianPoint>
                        {
                            new IfcCartesianPoint(cToCDistance / -2.0, -radius),
                            new IfcCartesianPoint(cToCDistance / 2.0, -radius),
                        },
                };

            var seg1 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = trimmed1,
                };
            var seg2 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = line1,
                };

            var seg3 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = trimmed2,
                };
            var seg4 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = line2,
                };

            var cCurve = new IfcCompositeCurve
                {
                    Segments = new List<IfcCompositeCurveSegment>
                        {
                            seg1, seg2, seg3, seg4
                        },
                    SelfIntersect = EbInstanceModel.LOGICAL.dbTrue,

                };

            _ifcProfileDef = new IfcArbitraryClosedProfileDef
                {
                    ProfileType = IfcProfileTypeEnum.AREA,
                    OuterCurve = cCurve,
                };
        }
コード例 #25
0
        public BbSlottedHoleProfile(double cToCDistance, double radius)

        {
            var cir1 = new IfcCircle
            {
                Position = new IfcAxis2Placement
                {
                    Value = new IfcAxis2Placement2D
                    {
                        Location = new IfcCartesianPoint(cToCDistance / 2.0, 0),
                    },
                },
                Radius = radius,
            };
            var trimmed1 = new IfcTrimmedCurve
            {
                BasisCurve = cir1,
                Trim1      = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 270
                        }
                    }
                },
                Trim2 = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 90
                        }
                    }
                },
                SenseAgreement       = true,
                MasterRepresentation = IfcTrimmingPreference.PARAMETER,
            };

            var line1 = new IfcPolyline
            {
                Points = new List <IfcCartesianPoint>
                {
                    new IfcCartesianPoint(cToCDistance / 2.0, radius),
                    new IfcCartesianPoint(cToCDistance / -2.0, radius),
                },
            };

            var cir2 = new IfcCircle
            {
                Position = new IfcAxis2Placement
                {
                    Value = new IfcAxis2Placement2D
                    {
                        Location = new IfcCartesianPoint(cToCDistance / -2.0, 0),
                    },
                },
                Radius = radius,
            };
            var trimmed2 = new IfcTrimmedCurve
            {
                BasisCurve = cir2,
                Trim1      = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 90
                        }
                    }
                },
                Trim2 = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 270
                        }
                    }
                },
                SenseAgreement       = true,
                MasterRepresentation = IfcTrimmingPreference.PARAMETER,
            };

            var line2 = new IfcPolyline
            {
                Points = new List <IfcCartesianPoint>
                {
                    new IfcCartesianPoint(cToCDistance / -2.0, -radius),
                    new IfcCartesianPoint(cToCDistance / 2.0, -radius),
                },
            };


            var seg1 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = trimmed1,
            };
            var seg2 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = line1,
            };

            var seg3 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = trimmed2,
            };
            var seg4 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = line2,
            };


            var cCurve = new IfcCompositeCurve
            {
                Segments = new List <IfcCompositeCurveSegment>
                {
                    seg1, seg2, seg3, seg4
                },
                SelfIntersect = EbInstanceModel.LOGICAL.dbTrue,
            };

            _ifcProfileDef = new IfcArbitraryClosedProfileDef
            {
                ProfileType = IfcProfileTypeEnum.AREA,
                OuterCurve  = cCurve,
            };
        }
コード例 #26
0
 public IXbimFace CreateFace(IfcPolyline pline)
 {
     return(_engine.CreateFace(pline));
 }
コード例 #27
0
        public void Shape()
        {
            var         operandStack = new Stack();
            IfcPolyline outerCurve   = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });

            operandStack.Push('{');
            operandStack.Push(outerCurve);
            var operation = OperationName.SHAPE;

            ConstructionOperations.ExecuteOperation(operation, operandStack);
            Assert.Single(operandStack);
            var response = operandStack.Pop();

            Assert.IsType <IfcArbitraryClosedProfileDef>(response);
            Assert.Collection(((IfcPolyline)((IfcArbitraryClosedProfileDef)response).OuterCurve).Points,
                              p0 => { Assert.Equal(-0.5, p0.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p0.Coordinates[1].Value); },
                              p1 => { Assert.Equal(-0.5, p1.Coordinates[0].Value);
                                      Assert.Equal(0.5, p1.Coordinates[1].Value); },
                              p2 => { Assert.Equal(0.5, p2.Coordinates[0].Value);
                                      Assert.Equal(0.5, p2.Coordinates[1].Value); },
                              p3 => { Assert.Equal(0.5, p3.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p3.Coordinates[1].Value); },
                              p4 => { Assert.Equal(-0.5, p4.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p4.Coordinates[1].Value); });

            IfcPolyline innerCurve = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.25, -0.25 },
                new double[] { -0.25, 0.25 },
                new double[] { 0.25, 0.25 },
                new double[] { 0.25, -0.25 },
                new double[] { -0.25, -0.25 }
            });

            operandStack.Push('{');
            operandStack.Push(outerCurve);
            operandStack.Push(innerCurve);
            ConstructionOperations.ExecuteOperation(operation, operandStack);
            Assert.Single(operandStack);
            response = operandStack.Pop();
            Assert.IsType <IfcArbitraryProfileDefWithVoids>(response);
            Assert.Collection(((IfcPolyline)((IfcArbitraryProfileDefWithVoids)response).OuterCurve).Points,
                              p0 => { Assert.Equal(-0.5, p0.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p0.Coordinates[1].Value); },
                              p1 => { Assert.Equal(-0.5, p1.Coordinates[0].Value);
                                      Assert.Equal(0.5, p1.Coordinates[1].Value); },
                              p2 => { Assert.Equal(0.5, p2.Coordinates[0].Value);
                                      Assert.Equal(0.5, p2.Coordinates[1].Value); },
                              p3 => { Assert.Equal(0.5, p3.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p3.Coordinates[1].Value); },
                              p4 => { Assert.Equal(-0.5, p4.Coordinates[0].Value);
                                      Assert.Equal(-0.5, p4.Coordinates[1].Value); });
            Assert.Single(((IfcArbitraryProfileDefWithVoids)response).InnerCurves);
            var innerCurveEnumerator = ((IfcArbitraryProfileDefWithVoids)response).InnerCurves.GetEnumerator();

            innerCurveEnumerator.MoveNext();
            Assert.Collection(((IfcPolyline)innerCurveEnumerator.Current).Points,
                              p0 => { Assert.Equal(-0.25, p0.Coordinates[0].Value);
                                      Assert.Equal(-0.25, p0.Coordinates[1].Value); },
                              p1 => { Assert.Equal(-0.25, p1.Coordinates[0].Value);
                                      Assert.Equal(0.25, p1.Coordinates[1].Value); },
                              p2 => { Assert.Equal(0.25, p2.Coordinates[0].Value);
                                      Assert.Equal(0.25, p2.Coordinates[1].Value); },
                              p3 => { Assert.Equal(0.25, p3.Coordinates[0].Value);
                                      Assert.Equal(-0.25, p3.Coordinates[1].Value); },
                              p4 => { Assert.Equal(-0.25, p4.Coordinates[0].Value);
                                      Assert.Equal(-0.25, p4.Coordinates[1].Value); });
        }
コード例 #28
0
        public void ArbitraryClosedProfileDefWithIncorrectPlacementTest()
        {
            using (var model = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
            {
                using (var txn = model.BeginTransaction("Create Column"))
                {
                    IfcProject project = model.Instances.New <IfcProject>();
                    project.Initialize(ProjectUnits.SIUnitsUK);
                    project.Name = "Test Project";

                    IfcColumn col = model.Instances.New <IfcColumn>();
                    col.Name = "Column With ArbitraryClosedProfileDef";


                    //Creating IfcArbitraryClosedProfileDef that will contain IfcCompositeCurve
                    IfcArbitraryClosedProfileDef arbClosedProf = model.Instances.New <IfcArbitraryClosedProfileDef>();

                    //To create IfcArbitraryClosedProfileDef, we'll need to create IfcCompositeCurve
                    //Creating IfcCompositeCurve
                    IfcCompositeCurve myCompCurve = model.Instances.New <IfcCompositeCurve>();

                    //To Create IfcCompositeCurve, We'll need to create IfcCompositeCurveSegment
                    //create IfcCompositeCurveSegment (polyline)
                    IfcCompositeCurveSegment polylineSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //create IfcCompositeCurveSegment (arc)
                    IfcCompositeCurveSegment arcSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //Creating IfcPolyline that will be the parent curve for IfcCompositeCurveSegment "polylineSeg"
                    IfcPolyline myPolyline = model.Instances.New <IfcPolyline>();

                    //Creating Points to build the IfcPolyline
                    IfcCartesianPoint p0 = model.Instances.New <IfcCartesianPoint>();
                    p0.SetXY(200, 100);

                    IfcCartesianPoint p1 = model.Instances.New <IfcCartesianPoint>();
                    p1.SetXY(0, 100);

                    IfcCartesianPoint p2 = model.Instances.New <IfcCartesianPoint>();
                    p2.SetXY(0, 0);

                    IfcCartesianPoint p3 = model.Instances.New <IfcCartesianPoint>();
                    p3.SetXY(400, 0);

                    IfcCartesianPoint p4 = model.Instances.New <IfcCartesianPoint>();
                    p4.SetXY(400, 600);

                    IfcCartesianPoint p5 = model.Instances.New <IfcCartesianPoint>();
                    p5.SetXY(0, 600);

                    IfcCartesianPoint p6 = model.Instances.New <IfcCartesianPoint>();
                    p6.SetXY(0, 500);

                    IfcCartesianPoint p7 = model.Instances.New <IfcCartesianPoint>();
                    p7.SetXY(200, 500);

                    //Adding points to the polyline
                    myPolyline.Points.Add(p0);
                    myPolyline.Points.Add(p1);
                    myPolyline.Points.Add(p2);
                    myPolyline.Points.Add(p3);
                    myPolyline.Points.Add(p4);
                    myPolyline.Points.Add(p5);
                    myPolyline.Points.Add(p6);
                    myPolyline.Points.Add(p7);

                    //Assigning myPolyline to the IfcCompositeCurveSegment polylineSeg
                    polylineSeg.ParentCurve = myPolyline;

                    //Creating Arc using IfcTrimmedCurve
                    IfcTrimmedCurve myArc = model.Instances.New <IfcTrimmedCurve>();

                    //To create IfcTrimmedCurve, We'll need to create IfcCircle and trim it using IfcTrimmingSelect
                    IfcCircle myCirc = model.Instances.New <IfcCircle>();
                    myCirc.Radius = 213.554;
                    IfcCartesianPoint cP = model.Instances.New <IfcCartesianPoint>();
                    cP.SetXY(125.1312, 300); //this should really be a 3D point

                    IfcAxis2Placement3D plcmnt = model.Instances.New <IfcAxis2Placement3D>();
                    plcmnt.Location     = cP;
                    plcmnt.RefDirection = model.Instances.New <IfcDirection>();
                    plcmnt.RefDirection.SetXY(0, 1);//this should eb a 3D axis
                    myCirc.Position = plcmnt;

                    myArc.BasisCurve = myCirc;

                    IfcTrimmingSelect v1 = p7;
                    IfcTrimmingSelect v2 = p0;

                    myArc.Trim1.Add(v1);
                    myArc.Trim2.Add(v2);

                    arcSeg.ParentCurve = myArc;

                    //Adding the created two IfcCompositeCurveSegments to the IfcCompositeCurve
                    myCompCurve.Segments.Add(arcSeg);
                    myCompCurve.Segments.Add(polylineSeg);

                    //Assigning IfcCompositeCurve "myCompCurve" to the IfcArbitraryClosedProfileDef
                    arbClosedProf.OuterCurve = myCompCurve;

                    arbClosedProf.ProfileType = IfcProfileTypeEnum.AREA;

                    //model as a swept area solid
                    IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                    body.Depth             = 2000;
                    body.SweptArea         = arbClosedProf;
                    body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                    body.ExtrudedDirection.SetXYZ(0, 0, 1);


                    txn.Commit();
                    var solid = _xbimGeometryCreator.CreateSolid(body);
                    Assert.IsTrue((int)solid.Volume == 239345450);
                }
            }
        }
コード例 #29
0
ファイル: IFCHelper.cs プロジェクト: 15831944/CADTo3D-1
        internal static IfcSweptDiskSolid ProfileSweptDiskSolidByCompositeCurve(IfcStore model, Entity profPath, double raduis)
        {
            IfcSweptDiskSolid body           = model.Instances.New <IfcSweptDiskSolid>();
            IfcCompositeCurve compositeCurve = model.Instances.New <IfcCompositeCurve>();

            compositeCurve.SelfIntersect = false;
            if (profPath is LinearPath)
            {
                LinearPath linearPath            = profPath as LinearPath;
                IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                for (int i = 0; i < linearPath.Vertices.Length; i++)
                {
                    IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                    point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z);
                    pLine.Points.Add(point);
                }
                segment.ParentCurve = pLine;
                segment.Transition  = IfcTransitionCode.CONTINUOUS;
                compositeCurve.Segments.Add(segment);
            }
            else if (profPath is CompositeCurve)
            {
                CompositeCurve compCurvePath = profPath as CompositeCurve;
                for (int i = 0; i < compCurvePath.CurveList.Count; i++)
                {
                    IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                    //segment.Transition = i == compCurvePath.CurveList.Count - 1 ? IfcTransitionCode.DISCONTINUOUS : IfcTransitionCode.CONTINUOUS;
                    segment.Transition = IfcTransitionCode.DISCONTINUOUS;
                    if (compCurvePath.CurveList[i] is Line)
                    {
                        segment.SameSense = true;
                        Line        line  = compCurvePath.CurveList[i] as Line;
                        IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                        for (int j = 0; j < line.Vertices.Length; j++)
                        {
                            IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                            point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z);
                            pLine.Points.Add(point);
                        }
                        segment.ParentCurve = pLine;
                        compositeCurve.Segments.Add(segment);
                    }
                    else
                    {
                        Arc             arc          = compCurvePath.CurveList[i] as Arc;
                        IfcTrimmedCurve trimmedCurve = model.Instances.New <IfcTrimmedCurve>();
                        IfcCircle       cir          = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius);
                        cir.Position = model.Instances.New <IfcAxis2Placement3D>(e =>
                                                                                 e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z)));

                        trimmedCurve.BasisCurve = cir;
                        trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z)));
                        trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z)));
                        trimmedCurve.SenseAgreement = arc.Plane.AxisZ == Vector3D.AxisZ ? true : false;
                        //segment.SameSense = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true;
                        trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN;
                        segment.ParentCurve = trimmedCurve;
                        compositeCurve.Segments.Add(segment);
                    }
                }
            }
            else if (profPath is Circle)
            {
                IfcCircle ifcCirc = model.Instances.New <IfcCircle>();
            }



            body.Directrix   = compositeCurve;
            body.Radius      = raduis;
            body.InnerRadius = raduis * .75;
            return(body);
        }
コード例 #30
0
        private static Polyline ToPolyline(this IfcPolyline polyline)
        {
            var verts = polyline.Points.Select(p => p.ToVector3()).ToArray();

            return(new Polyline(verts));
        }
コード例 #31
0
        static public double Area(this IfcCurve curve)
        {
            //- IfcConic  (abstract)
            //  - IfcCircle (x)
            //  - IfcEllipse (x)
            //- IfcLine (x)
            //- IfcOffsetCurve2D (Throw)
            //- IfcOffsetCurve3D (Throw)
            //- IfcBoundedCurve  (abstract)
            //  - IfcBSplineCurve  (abstract) (Throw)
            //    - IfcBezierCurve (Throw)
            //      - IfcRationalBezierCurve (Throw)
            //  - IfcTrimmedCurve (Throw)
            //  - IfcPolyline (x)
            //  - IfcCompositeCurve (Throw)
            //    - Ifc2DCompositeCurve (Throw)

            if (curve is IfcCircle)
            {
                IfcCircle c = curve as IfcCircle;
                return(Math.PI * Math.Pow(c.Radius, 2));
            }
            else if (curve is IfcEllipse)
            {
                IfcEllipse c = curve as IfcEllipse;
                return(Math.PI * c.SemiAxis1 * c.SemiAxis2);
            }
            else if (curve is IfcLine)
            {
                return(0);
            }
            else if (curve is IfcOffsetCurve2D)
            {
                throw new NotImplementedException("Area not implemented for IfcOffsetCurve2D");
            }
            else if (curve is IfcOffsetCurve3D)
            {
                throw new NotImplementedException("Area not implemented for IfcOffsetCurve3D");
            }
            else if (curve is IfcBSplineCurve)
            {
                throw new NotImplementedException("Area not implemented for IfcBSplineCurve");
            }
            else if (curve is IfcTrimmedCurve)
            {
                throw new NotImplementedException("Area not implemented for IfcTrimmedCurve");
            }
            else if (curve is IfcPolyline)
            {
                // todo: needs testing
                IfcPolyline p = curve as IfcPolyline;

                if (p.Dim != 2)
                {
                    throw new NotImplementedException("Area not implemented for 3D IfcPolyline");
                }

                // http://stackoverflow.com/questions/2553149/area-of-a-irregular-shape
                // it assumes that the last point is NOT the same of the first one, but it tolerates the case.
                double area = 0.0f;

                int numVertices = p.Points.Count;
                for (int i = 0; i < numVertices - 1; ++i)
                {
                    area += p.Points[i].X * p.Points[i + 1].Y - p.Points[i + 1].X * p.Points[i].Y;
                }
                area += p.Points[numVertices - 1].X * p.Points[0].Y - p.Points[0].X * p.Points[numVertices - 1].Y;
                area /= 2.0;
                return(area);
            }
            else if (curve is Ifc2DCompositeCurve)
            {
                // these are complicated and should be solved with opencascade or some other lib
                throw new NotImplementedException("Area not implemented for Ifc2DCompositeCurve");
            }
            else if (curve is IfcCompositeCurve)
            {
                // these are complicated and should be solved with opencascade or some other lib
                throw new NotImplementedException("Area not implemented for IfcCompositeCurve");
            }

            return(double.NaN);
        }
コード例 #32
0
        public void BooleanOperatorTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            IfcCsgPrimitive3D union_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D union_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem unionRepresentation = union_first.Union(union_second);

            IfcCsgPrimitive3D diff_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2, 0, 0), null, null),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D diff_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2.5, 0.5, 0.5), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem diffRepresentation = diff_first.Difference(diff_second);

            IfcCsgPrimitive3D inter_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D inter_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem interRepresentation = inter_first.Intersection(inter_second);
            IfcPolyline           outerCurve          = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { 6, 0 },
                new double[] { 6, 1 },
                new double[] { 7, 1 },
                new double[] { 7, 0 },
                new double[] { 6, 0 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcSweptAreaSolid cut_reference = profileDef.Extrude(1);
            IfcPlane          plane         = IfcGeom.CreatePlane(new double[] { 6.5, 0.5, 0 },
                                                                  new double[] { 1, 1, 0 });
            IfcRepresentationItem cutRepresentation = cut_reference.ClipByPlane(plane);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("union shape"),
                                           new IfcLabel("BooleanResult"),
                                           new IfcRepresentationItem[] { unionRepresentation, diffRepresentation, interRepresentation, cutRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./constructive_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }
コード例 #33
0
ファイル: Conversion.cs プロジェクト: simonedd/TestIFC
        private static ICurve getICurveFromIfcCurve(IfcCurve ifcCurve, ViewportLayout viewportLayout1 = null, Transformation entityTrs = null)
        {
            ICurve result = null;

            if (ifcCurve is IfcConic)
            {
                IfcConic ifcConic = (IfcConic)ifcCurve;

                Plane pln = getPlaneFromPosition((IfcPlacement)ifcConic.Position);

                if (ifcConic is IfcCircle)
                {
                    IfcCircle ifcCircle = (IfcCircle)ifcCurve;

                    Circle circle = new Circle(pln, ifcCircle.Radius);

                    result = circle;
                }
                else
                {
                    IfcEllipse ifcEllipse = (IfcEllipse)ifcConic;

                    Ellipse ellipse = new Ellipse(pln, pln.Origin, ifcEllipse.SemiAxis1, ifcEllipse.SemiAxis2);

                    result = ellipse;
                }
            }
            else if (ifcCurve is IfcPolyline)
            {
                IfcPolyline p = (IfcPolyline)ifcCurve;

                Point3D[] points = new Point3D[p.Points.Count];

                for (int i = 0; i < p.Points.Count; i++)
                {
                    points[i] = getPoint3DFromIfcCartesianPoint(p.Points[i]);
                }
                LinearPath lp = new LinearPath(points);

                result = lp;
            }
            else if (ifcCurve is IfcCompositeCurve)             // verificare sense e transition
            {
                IfcCompositeCurve cc = (IfcCompositeCurve)ifcCurve;

                result = new CompositeCurve();

                foreach (IfcCompositeCurveSegment ccSegment in cc.Segments)
                {
                    ICurve segment = getICurveFromIfcCurve(ccSegment.ParentCurve, viewportLayout1, entityTrs);

                    if (segment != null)
                    {
                        ((CompositeCurve)result).CurveList.Add(segment);
                    }
                    else
                    {
                        result = null;
                        break;
                    }
                }
            }
            else if (ifcCurve is IfcTrimmedCurve)
            {
                IfcTrimmedCurve tc = (IfcTrimmedCurve)ifcCurve;

                ICurve basisCurve = getICurveFromIfcCurve(tc.BasisCurve, viewportLayout1, entityTrs);

                if (basisCurve != null)
                {
                    ICurve trimCurve = null;

                    if (tc.MasterRepresentation == IfcTrimmingPreference.PARAMETER)
                    {
                        double startParam = tc.Trim1.IfcParameterValue * Math.PI / 180;
                        double endParam   = tc.Trim2.IfcParameterValue * Math.PI / 180;

                        if (tc.SenseAgreement)
                        {
                            if (startParam > endParam)
                            {
                                startParam = startParam - Math.PI * 2;
                            }

                            basisCurve.SubCurve(startParam, endParam, out trimCurve);
                        }
                        else
                        {
                            if (endParam > startParam)
                            {
                                endParam = endParam - Math.PI * 2;
                            }

                            basisCurve.SubCurve(endParam, startParam, out trimCurve);

                            trimCurve.Reverse();
                        }
                        result = trimCurve; //new CompositeCurve(trimCurve);
                    }
                    else if (tc.MasterRepresentation == IfcTrimmingPreference.CARTESIAN)
                    {
                        debug += "IfcTrimmed cartesianPoint not supported: \n";
                    }
                    else
                    {
                        debug += "IfcTrimmed not supported: \n";
                    }
                }
            }
            else
            {
                if (!debug.Contains("IfcCurve not supported: " + ifcCurve.KeyWord))
                {
                    debug += "IfcCurve not supported: " + ifcCurve.KeyWord + "\n";
                }
            }
            return(result);
        }