public SemTextGeometry( string literal, SemPosition2D position2D ) { _ifcTextLiteral = new IfcTextLiteral{ Literal = literal, Placement = new IfcAxis2Placement(), Path = IfcTextPath.RIGHT, }; _ifcTextLiteral.Placement.Value = position2D.IfcAxis2Placement2D; _ifcShapeRepresentation = new IfcShapeRepresentation { ContextOfItems = SemHeaderSetting.Setting3D.GeometricRepresentationContext, RepresentationIdentifier = "GeometricCurveSet", RepresentationType = "Annotation2D", Items = new List<IfcRepresentationItem>(), }; _ifcShapeRepresentation.Items.Add(_ifcTextLiteral); _ifcProductDefinitionShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List<IfcRepresentation>(), }; _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation); }
public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext, IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth) { var extruded = new IfcExtrudedAreaSolid { SweptArea = ifcProfileDef, Position = placement3D, ExtrudedDirection = direction , Depth = depth, }; var shaperep = new IfcShapeRepresentation { ContextOfItems = representationContext, RepresentationIdentifier = "Body", RepresentationType = "SweptSolid", Items = new List<IfcRepresentationItem>(), }; shaperep.Items.Add(extruded); var ifcShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List<IfcRepresentation>(), }; ifcShape.Representations.Add(shaperep); return ifcShape; }
public BbExtrudedGeometry( BbProfile profile, BbPosition3D position3D, BbDirection3D direction3D, double depth ) { _ifcExtrudedAreaSolid = new IfcExtrudedAreaSolid{ SweptArea = profile.IfcProfileDef, Position = position3D.IfcAxis2Placement3D, ExtrudedDirection = direction3D.IfcDirection, Depth = depth, }; _ifcShapeRepresentation = new IfcShapeRepresentation { ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext, RepresentationIdentifier = "Body", RepresentationType = "SweptSolid", Items = new List<IfcRepresentationItem>(), }; _ifcShapeRepresentation.Items.Add(_ifcExtrudedAreaSolid); _ifcProductDefinitionShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List<IfcRepresentation>(), }; _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation); }
private static IfcProductDefinitionShape ToIfcProductDefinitionShape(this List <IfcRepresentationItem> geoms, string shapeType, IfcRepresentationContext context, Document doc) { var rep = new IfcShapeRepresentation(context, "Body", shapeType, geoms); var shape = new IfcProductDefinitionShape(new List <IfcRepresentation> { rep }); doc.AddEntity(rep); return(shape); }
internal static IfcShapeRepresentation ShapeRepresentationCreate(IfcStore model, string repType, string repId) { IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); IfcGeometricRepresentationContext modelContext = model.Instances.OfType <IfcGeometricRepresentationContext>().FirstOrDefault(); shape.ContextOfItems = modelContext; shape.RepresentationType = repType; shape.RepresentationIdentifier = repId; return(shape); }
private static IfcBeam CreateBeam(IfcStore model, string name, IfcShapeRepresentation shape, Plane insertPlane) { var beam = model.Instances.New <IfcBeam>(); beam.Name = name; beam.PredefinedType = IfcBeamTypeEnum.BEAM; ApplyRepresentationAndPlacement(model, beam, shape, insertPlane); return(beam); }
private static IfcColumn CreateColumn(IfcStore model, string name, IfcShapeRepresentation shape, Plane insertPlane) { var column = model.Instances.New <IfcColumn>(); column.Name = name; column.PredefinedType = IfcColumnTypeEnum.COLUMN; ApplyRepresentationAndPlacement(model, column, shape, insertPlane); return(column); }
/// <summary> /// Returns first set of IFC representation items or null; /// </summary> public static IfcShapeRepresentation GetFirstShapeRepresentation(this IfcProduct prod) { IfcProductDefinitionShape definitionShape = prod.Representation as IfcProductDefinitionShape; if (definitionShape == null) { return(null); } IfcShapeRepresentation shapeRepresentation = definitionShape.Representations.FirstOrDefault() as IfcShapeRepresentation; return(shapeRepresentation); }
internal static IfcColumn createColumn(IfcProduct host, IfcProfileDef profile, IfcCartesianPoint cartesianPoint, string globalId) { DatabaseIfc db = host.Database; IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(profile, 5000); IfcShapeRepresentation shapeRepresentation = new IfcShapeRepresentation(extrudedAreaSolid); IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(shapeRepresentation); IfcLocalPlacement localPlacement = createLocalPlacement(host, cartesianPoint, db.Factory.YAxis); IfcColumn column = new IfcColumn(host, localPlacement, productDefinitionShape); setGlobalId(column, globalId); return(column); }
private void setShapeRep(List <IfcGridAxis> axis) { if (axis == null || axis.Count == 0) { return; } IfcProductDefinitionShape pds = Representation as IfcProductDefinitionShape; if (pds == null) { List <IfcGeometricSetSelect> set = new List <IfcGeometricSetSelect>(); foreach (IfcGridAxis a in axis) { IfcCurve c = a.AxisCurve; if (c != null) { set.Add(c); } } if (set.Count > 0) { Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(mDatabase.Factory.SubContext(IfcGeometricRepresentationSubContext.SubContextIdentifier.FootPrint), new IfcGeometricCurveSet(set), ShapeRepresentationType.GeometricCurveSet)); } } else { foreach (IfcShapeModel sm in pds.Representations) { IfcShapeRepresentation sr = sm as IfcShapeRepresentation; if (sr != null) { foreach (IfcRepresentationItem gri in sr.Items) { IfcGeometricCurveSet curveSet = gri as IfcGeometricCurveSet; if (curveSet != null) { foreach (IfcGridAxis a in axis) { IfcCurve c = a.AxisCurve; if (c != null && !curveSet.Elements.Contains(c)) { curveSet.Elements.Add(c); } } return; } } } } } }
private IfcSlab CreateIfcLanding(IfcStore model, LinearPath landingPline, double landingThickness) { //begin a transaction using (var trans = model.BeginTransaction("Create Wall")) { IfcSlab landing = model.Instances.New <IfcSlab>(); IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (landingPline.Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, landingThickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, 0); shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); landing.Representation = prDefShape; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); landing.ObjectPlacement = lp; trans.Commit(); return(landing); } }
private static IfcProductDefinitionShape ToIfcProductDefinitionShape(this IfcGeometricRepresentationItem geom, IfcRepresentationContext context, Document doc) { var rep = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> { geom }); var shape = new IfcProductDefinitionShape(new List <IfcRepresentation> { rep }); doc.AddEntity(rep); return(shape); }
internal static IfcBeam createBeam(IfcProduct host, IfcProfileDef profile, IfcCartesianPoint cartesianPoint, string globalId) { DatabaseIfc db = host.Database; IfcAxis2Placement3D position = new IfcAxis2Placement3D(db.Factory.Origin, db.Factory.XAxis, db.Factory.YAxisNegative); IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(profile, position, 5000); IfcShapeRepresentation shapeRepresentation = new IfcShapeRepresentation(extrudedAreaSolid); IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(shapeRepresentation); IfcLocalPlacement localPlacement = createLocalPlacement(host, cartesianPoint, db.Factory.YAxis); IfcBeam beam = new IfcBeam(host, localPlacement, productDefinitionShape); setGlobalId(beam, globalId); return(beam); }
private IfcProductRepresentation CreateProductRepresentation(List <IfcRepresentationContext> contextList, IEnumerable <Representation> reperesentationList) { var shapeRepresenations = new List <IfcShapeRepresentation>(); foreach (Representation representation in reperesentationList) { IfcShapeRepresentation shapeRepresentation = CreateShapeRepresentation(contextList[0], representation); shapeRepresenations.Add(shapeRepresentation); } return(new IfcProductDefinitionShape(new IfcLabel(""), new IfcText(""), shapeRepresenations.ToArray())); }
/// <summary> /// If the space has a footprint represenation this will generate a set of walls conforming to that footprint, otherwise returns null /// </summary> /// <param name = "space"></param> /// <param name = "model"></param> /// <returns></returns> public static List <IfcWall> GenerateWalls(this IfcSpace space, IModel model) { IfcShapeRepresentation fp = GetFootPrintRepresentation(space); if (fp != null) { IfcRepresentationItem rep = fp.Items.FirstOrDefault(); if (rep != null && rep is IfcGeometricCurveSet) //we have a set of curves and inner boundaries { } else if (rep != null) { } } return(null); }
public static List <IfcBuildingElement> CreateBuildingElements(IfcStore model, ElementType type, string name, IfcShapeRepresentation shape, List <Plane> insertPlanes, IfcRelAssociatesMaterial relAssociatesMaterial) { var buildingElements = new List <IfcBuildingElement>(); switch (type) { case ElementType.PadFooting: case ElementType.StripFooting: { foreach (var insertPlane in insertPlanes) { var footing = CreateFooting(model, type, name, shape, insertPlane); relAssociatesMaterial.RelatedObjects.Add(footing); buildingElements.Add(footing); } break; } case ElementType.Beam: { foreach (var insertPlane in insertPlanes) { var beam = CreateBeam(model, name, shape, insertPlane); relAssociatesMaterial.RelatedObjects.Add(beam); buildingElements.Add(beam); } break; } case ElementType.Column: { foreach (var insertPlane in insertPlanes) { var column = CreateColumn(model, name, shape, insertPlane); relAssociatesMaterial.RelatedObjects.Add(column); buildingElements.Add(column); } break; } default: throw new ArgumentException("Element type not recognized"); } return(buildingElements); }
public IfcWallStandardCase(IfcProduct container, IfcMaterialLayerSetUsage layerSetUsage, IfcAxis2Placement3D placement, double length, double height) : base(container, new IfcLocalPlacement(container.Placement, placement), null) { DatabaseIfc db = mDatabase; double tol = mDatabase.Tolerance; setMaterial(layerSetUsage); IfcShapeRepresentation asr = IfcShapeRepresentation.GetAxisRep(new IfcPolyline(new IfcCartesianPoint(db, 0, 0, 0), new IfcCartesianPoint(db, length, 0, 0))); List <IfcShapeModel> reps = new List <IfcShapeModel>(); reps.Add(asr); double t = layerSetUsage.ForLayerSet.MaterialLayers.ToList().ConvertAll(x => x.LayerThickness).Sum(); reps.Add(new IfcShapeRepresentation(new IfcExtrudedAreaSolid(new IfcRectangleProfileDef(db, "", length, t), new IfcAxis2Placement3D(new IfcCartesianPoint(db, length / 2.0, layerSetUsage.OffsetFromReferenceLine + (layerSetUsage.DirectionSense == IfcDirectionSenseEnum.POSITIVE ? 1 : -1) * t / 2.0, 0)), height))); Representation = new IfcProductDefinitionShape(reps); }
public ShapeRepresentation(IfcStore model, GeometricRepresentationSubContext contextOfItems, List <ExtrudedAreaSolid> extrudedSolids, string representationIdentifier = "Body", string representationType = "SweptSolid") { this.Model = model; this.contextOfItems = contextOfItems; this.representationType = representationType; this.representationIdentifier = representationIdentifier; this.extrudedSolidList = extrudedSolids; ifcShapeRepresenation = model.Instances.New <IfcShapeRepresentation>(r => { foreach (var shape in extrudedSolids) { r.Items.Add(shape.IfcExtrusionSolid); } r.ContextOfItems = contextOfItems.IfcRepresentationSubContext; r.RepresentationType = representationType; r.RepresentationIdentifier = RepresentationIdentifier; }); }
protected override void setJSON(JObject obj, BaseClassIfc host, HashSet <int> processed) { base.setJSON(obj, host, processed); string contextIdentifier = ContextIdentifier; if (!string.IsNullOrEmpty(contextIdentifier)) { obj["ContextIdentifier"] = contextIdentifier; } string contextType = ContextType; if (!string.IsNullOrEmpty(contextType)) { obj["ContextType"] = contextType; } JArray reps = new JArray(); foreach (IfcRepresentation r in RepresentationsInContext) { if (!processed.Contains(r.Index)) { reps.Add(r.getJson(this, processed)); } } if (reps.Count > 0) { obj["RepresentationsInContext"] = reps; } DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4NotAssigned); db.Factory.Options.GenerateOwnerHistory = false; IfcProject project = new IfcProject(db, "MyProjectNumber"); project.UnitsInContext = new IfcUnitAssignment(db).SetUnits(IfcUnitAssignment.Length.Inch); IfcPolyline line = new IfcPolyline(new IfcCartesianPoint(db, 0, 0, 0), new IfcCartesianPoint(db, 10, 0, 0)); new IfcPresentationLayerAssignment("Default", line) { }; IfcShapeRepresentation sr = new IfcShapeRepresentation(line); }
public BbSurfaceGeometry( BbPolyline2D outerCurve, IEnumerable <BbPolyline2D> innerCurves ) { ifcCurveBoundedPlane = new IfcCurveBoundedPlane { BasisSurface = new IfcPlane { Position = BbHeaderSetting.Setting3D.DefaultBbPosition3D.IfcAxis2Placement3D, }, OuterBoundary = outerCurve.IfcCurve, InnerBoundaries = new List <IfcCurve>() }; if (innerCurves != null) { foreach (var inn in innerCurves) { ifcCurveBoundedPlane.InnerBoundaries.Add(inn.IfcCurve); } } _ifcShapeRepresentation = new IfcShapeRepresentation { ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext, RepresentationIdentifier = "Surface", RepresentationType = "GeometricSet", Items = new List <IfcRepresentationItem>(), }; _ifcShapeRepresentation.Items.Add(ifcCurveBoundedPlane); _ifcProductDefinitionShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List <IfcRepresentation>(), }; _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation); }
private static IfcBeam ToIfcBeam(this Beam beam, IfcRepresentationContext context, Document doc) { var sweptArea = beam.ElementType.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc); var line = beam.Curve as Line; if (line == null) { throw new Exception("The beam could not be exported to IFC. Only linear beams are currently supported."); } // We use the Z extrude direction because the direction is // relative to the local placement, which is a transform at the // beam's end with the Z axis pointing along the direction. var extrudeDirection = Vector3.ZAxis.ToIfcDirection(); var position = new Transform().ToIfcAxis2Placement3D(doc); var repItem = new IfcExtrudedAreaSolid(sweptArea, position, extrudeDirection, new IfcPositiveLengthMeasure(beam.Curve.Length())); var localPlacement = beam.Curve.TransformAt(0.0).ToIfcLocalPlacement(doc); var rep = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> { repItem }); var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> { rep }); var ifcBeam = new IfcBeam(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null); doc.AddEntity(sweptArea); doc.AddEntity(extrudeDirection); doc.AddEntity(position); doc.AddEntity(repItem); doc.AddEntity(rep); doc.AddEntity(localPlacement); doc.AddEntity(productRep); doc.AddEntity(ifcBeam); return(ifcBeam); }
public BbBRepGeometry( IList <BbFace> faces ) { var _faces = new List <IfcFace> (); foreach (var item in faces) { _faces.Add(item.IfcFace); } ifcFacetedBrep = new IfcFacetedBrep { Outer = new IfcClosedShell { CfsFaces = _faces, }, // SweptArea = profile.IfcProfileDef, // Position = position3D.IfcAxis2Placement3D, // ExtrudedDirection = direction3D.IfcDirection, // Depth = depth, }; _ifcShapeRepresentation = new IfcShapeRepresentation { ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext, RepresentationIdentifier = "Body", RepresentationType = "Brep", Items = new List <IfcRepresentationItem>(), }; _ifcShapeRepresentation.Items.Add(ifcFacetedBrep); _ifcProductDefinitionShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List <IfcRepresentation>(), }; _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation); }
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); }
/// <summary> /// Returns set of IFC representation items from the specified context or null; /// </summary> public static XbimSet <IfcRepresentationItem> GetShapeRepresentationItems(this IfcProduct prod, IfcRepresentationContext context) { IfcProductDefinitionShape definitionShape = prod.Representation as IfcProductDefinitionShape; if (definitionShape == null) { return(null); } IfcShapeRepresentation shapeRepresentation = definitionShape.Representations.Where(rep => rep.ContextOfItems == context).FirstOrDefault() as IfcShapeRepresentation; if (shapeRepresentation == null) { return(null); } XbimSet <IfcRepresentationItem> shapeRepresentationItems = shapeRepresentation.Items; return(shapeRepresentationItems); }
private static IfcOpeningElement ToIfcOpeningElement(this Opening opening, IfcRepresentationContext context, Document doc, IfcObjectPlacement parent) { // var sweptArea = opening.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc); // We use the Z extrude direction because the direction is // relative to the local placement, which is a transform at the // beam's end with the Z axis pointing along the direction. // var extrudeDirection = opening.ExtrudeDirection.ToIfcDirection(); // var position = new Transform().ToIfcAxis2Placement3D(doc); // var solid = new IfcExtrudedAreaSolid(sweptArea, position, // extrudeDirection, new IfcPositiveLengthMeasure(opening.ExtrudeDepth)); var solid = opening.ToIfcExtrudedAreaSolid(new Transform(), doc); var localPlacement = new Transform().ToIfcLocalPlacement(doc, parent); var shape = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> { solid }); var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> { shape }); var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null); // doc.AddEntity(sweptArea); // doc.AddEntity(extrudeDirection); // doc.AddEntity(position); // doc.AddEntity(repItem); doc.AddEntity(solid); doc.AddEntity(localPlacement); doc.AddEntity(shape); doc.AddEntity(productRep); return(ifcOpening); }
public BbBRepGeometry( IList<BbFace> faces ) { var _faces = new List<IfcFace> (); foreach (var item in faces) { _faces.Add(item.IfcFace); } ifcFacetedBrep = new IfcFacetedBrep{ Outer = new IfcClosedShell{ CfsFaces = _faces, }, // SweptArea = profile.IfcProfileDef, // Position = position3D.IfcAxis2Placement3D, // ExtrudedDirection = direction3D.IfcDirection, // Depth = depth, }; _ifcShapeRepresentation = new IfcShapeRepresentation { ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext, RepresentationIdentifier = "Body", RepresentationType = "Brep", Items = new List<IfcRepresentationItem>(), }; _ifcShapeRepresentation.Items.Add(ifcFacetedBrep); _ifcProductDefinitionShape = new IfcProductDefinitionShape { // Name= // Description = Representations = new List<IfcRepresentation>(), }; _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation); }
private static IfcFooting CreateFooting(IfcStore model, ElementType type, string name, IfcShapeRepresentation shape, Plane insertPlane) { var footing = model.Instances.New <IfcFooting>(); footing.Name = name; switch (type) { case ElementType.PadFooting: footing.PredefinedType = IfcFootingTypeEnum.PAD_FOOTING; break; case ElementType.StripFooting: footing.PredefinedType = IfcFootingTypeEnum.STRIP_FOOTING; break; default: throw new ArgumentException("Footing type not recognized, can be only Pad or Strip"); } ApplyRepresentationAndPlacement(model, footing, shape, insertPlane); return(footing); }
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); } }
static void Main(string[] args) { var ut_name = "Alignment-TUMAdsk-1"; var db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned); db.Factory.Options.GenerateOwnerHistory = false; var site = new IfcSite(db, "site"); var project = new IfcProject(db, ut_name) { Name = ut_name, Description = "sample for a single horizontal line segment - geometry + semantic part" }; new IfcRelAggregates(project, new List <IfcObjectDefinition>() { site }); // alignment var alignment = new IfcAlignment(site); alignment.AddComment("Entry point for alignment container"); var horiz = new IfcAlignmentHorizontal(alignment); horiz.AddComment("groups all horizontal segments using an IfcRelNests rel"); var pt1 = new IfcCartesianPoint(db, 3, 1, 0); var semanticPartOfTheSegment = new IfcAlignmentHorizontalSegment( pt1, 0, 0, 0, 56.4, IfcAlignmentHorizontalSegmentTypeEnum.LINE); semanticPartOfTheSegment.AddComment("Semantic part of the line segment"); var semanticSegment1 = new IfcAlignmentSegment(horiz, semanticPartOfTheSegment); semanticSegment1.AddComment("link semantic segment with horizontal alignment container"); // build geometric part var line = new IfcLine(pt1, new IfcVector(new IfcDirection(db, 0, 0), 1)); line.AddComment("line geometry"); var curveSeg = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis1Placement(pt1), new IfcNonNegativeLengthMeasure(0), new IfcNonNegativeLengthMeasure(56.4), line); curveSeg.AddComment("Trim the entire line"); var shapeRep = new IfcShapeRepresentation(curveSeg, ShapeRepresentationType.Curve2D); IfcProductDefinitionShape shape1 = new IfcProductDefinitionShape(shapeRep) { Name = "Horizontal alignment geom rep" }; shape1.AddComment("link the geometric rep of a line to the representation of the horizontal segment"); horiz.Representation = shape1; db.WriteFile(ut_name + ".ifc"); }
private static void Main(string[] args) { var database = new DatabaseIfc(ModelView.Ifc4X3NotAssigned); database.Factory.ApplicationDeveloper = "Sebastian Esser"; // turn owner history off database.Factory.Options.GenerateOwnerHistory = false; // basic setup var site = new IfcSite(database, "SiteA"); var project = new IfcProject( site, "SampleProject with a span annotation", IfcUnitAssignment.Length.Metre ); // create an annotation var annotation = new IfcAnnotation(database) { Name = "DesignSpeed", }; annotation.AddComment("Annotation item span-placed along the alignment"); // link annotation with site var contained = new IfcRelContainedInSpatialStructure(site); contained.RelatedElements.Add(annotation); #region Alignment var alignment = new IfcAlignment(site) { Name = "Basic alignment with a single horizontal segment" }; alignment.AddComment("Generate alignment representation"); // semantic var horizSegment = new IfcAlignmentHorizontalSegment( new IfcCartesianPoint(database, 5, 10), 0, 0, 0, 200, IfcAlignmentHorizontalSegmentTypeEnum.LINE); // geometric representation of a single segment. It gets referenced by IfcCompositeCurve.segments and IfcAlignmentSegment.Representation var curveSegment = new IfcCurveSegment( IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 0)), new IfcParameterValue(0), new IfcParameterValue(200), null); var segments = new List <IfcSegment> { curveSegment }; var compositeCurve = new IfcCompositeCurve(segments); var rep = new IfcShapeRepresentation(compositeCurve) { RepresentationIdentifier = "Axis", RepresentationType = "Curve2D" }; alignment.Representation = new IfcProductDefinitionShape(rep); alignment.Axis = compositeCurve; // create an alignment horizontal instance that takes a list of horizontal segments var alignmentHorizontal = new IfcAlignmentHorizontal(database) { Segments = new LIST <IfcAlignmentHorizontalSegment>() { horizSegment } }; // link alignment and and its horizontal part semantically new IfcRelAggregates(alignment, alignmentHorizontal); // create a new alignmentSegment with then gets one curve segment as its geometric representation var alignmentSegment = new IfcAlignmentSegment(database); // link horizontal alignment with the recently created alignment segment new IfcRelNests(alignmentHorizontal, alignmentSegment); // sorted list -> IfcRelNests // connect geom representation to this segment alignmentSegment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(curveSegment)); #endregion Alignment #region Annotation placement alignmentSegment.AddComment("Create placement for annotation"); var axis2place = new IfcAxis2PlacementLinear( new IfcPointByDistanceExpression(25, compositeCurve), null, null); var linPlacement = new IfcLinearPlacement(axis2place); linPlacement.Distance = new IfcPointByDistanceExpression(128, compositeCurve); annotation.ObjectPlacement = linPlacement; #endregion Annotation placement #region PSet //var lengthUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.NONE, IfcSIUnitName.METRE); var lengthDerivedUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.KILO, IfcSIUnitName.METRE); lengthDerivedUnit.AddComment("PSet setup"); var timeBaseUnit = new IfcSIUnit(database, IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NONE, IfcSIUnitName.SECOND); var timeDerivedUnit = new IfcConversionBasedUnit(IfcUnitEnum.TIMEUNIT, "hour", new IfcMeasureWithUnit(new IfcPositiveInteger(3600), timeBaseUnit)); var ifcderivedunitelem1 = new IfcDerivedUnitElement(lengthDerivedUnit, 1); var ifcderivedunitelem2 = new IfcDerivedUnitElement(timeDerivedUnit, -1); var speedUnit = new IfcDerivedUnit( new List <IfcDerivedUnitElement> { ifcderivedunitelem1, ifcderivedunitelem2 }, IfcDerivedUnitEnum.LINEARVELOCITYUNIT); var pSet = new IfcPropertySet(annotation, "PSET_SpeedData", new List <IfcProperty> { new IfcPropertySingleValue(database, "CargoSpeed", new IfcLinearVelocityMeasure(60), speedUnit), new IfcPropertySingleValue(database, "DesignSpeed", new IfcLinearVelocityMeasure(110), speedUnit) }); #endregion PSet database.WriteFile("AlignmentWithSpanAnnotation.ifc"); }
private static IfcGeographicElement createTerrain(IfcStore model, IfcLabel name, IfcIdentifier tag, Axis2Placement3D placement, IfcShapeRepresentation representation) { //begin a transaction using (var txn = model.BeginTransaction("Create Terrain")) { // Gelände var terrain = model.Instances.New <IfcGeographicElement>(s => { s.Name = name; s.PredefinedType = IfcGeographicElementTypeEnum.TERRAIN; s.Tag = tag; placement = placement ?? Axis2Placement3D.Standard; s.ObjectPlacement = createLocalPlacement(model, placement); s.Representation = model.Instances.New <IfcProductDefinitionShape>(r => r.Representations.Add(representation)); }); txn.Commit(); return(terrain); } }
public static void ApplyRepresentationAndPlacement(IfcStore model, IfcReinforcingBar element, IfcShapeRepresentation shape, Plane insertPlane) { var representation = model.Instances.New <IfcProductDefinitionShape>(); representation.Representations.Add(shape); element.Representation = representation; var localPlacement = CreateLocalPlacement(model, insertPlane); element.ObjectPlacement = localPlacement; }
/// <summary> /// Add a Bounding Box extrusion onto the ifcProduct /// </summary> /// <param name="row">COBieCoordinateRow holding the data for one corner</param> /// <param name="rowNext">COBieCoordinateRow holding the data for the other corner</param> /// <param name="placementRelToIfcProduct">Product which is parent of ifcProduct passed product to add extrusion onto</param> /// <param name="ifcProduct">IfcProduct to add the extrusion onto</param> private void AddExtrudedRectangle(COBieCoordinateRow row, COBieCoordinateRow rowNext, IfcProduct ifcProduct, IfcProduct placementRelToIfcProduct) { if (ifcProduct != null) { COBieCoordinateRow lowerLeftRow, upperRightRow; if (row.Category.ToLower() == "box-lowerleft") { lowerLeftRow = row; upperRightRow = rowNext; } else { lowerLeftRow = rowNext; upperRightRow = row; } IfcLocalPlacement objectPlacement = CalcObjectPlacement(lowerLeftRow, placementRelToIfcProduct); if (objectPlacement != null) { //set the object placement for the space ifcProduct.ObjectPlacement = objectPlacement; //get matrix to the space placement XbimMatrix3D matrix3D = ConvertMatrix3D(objectPlacement); //invert matrix so we can convert row points back to the object space matrix3D.Invert(); //lets get the points from the two rows XbimPoint3D lowpt, highpt; if ((GetPointFromRow(upperRightRow, out highpt)) && (GetPointFromRow(lowerLeftRow, out lowpt)) ) { //transform the points back to object space lowpt = matrix3D.Transform(lowpt); highpt = matrix3D.Transform(highpt); //in object space so we can use Rect3D as this will be aligned with coordinates systems X and Y XbimRect3D bBox = new XbimRect3D(); bBox.Location = lowpt; bBox.Union(highpt); if ((double.NaN.CompareTo(bBox.SizeX) != 0) && (double.NaN.CompareTo(bBox.SizeY) != 0)) { XbimPoint3D ctrPt = new XbimPoint3D(bBox.X + (bBox.SizeX / 2.0), bBox.Y + (bBox.SizeY / 2.0), bBox.Z + (bBox.SizeZ / 2.0)); //Create IfcRectangleProfileDef IfcCartesianPoint IfcCartesianPointCtr = Model.Instances.New <IfcCartesianPoint>(cp => { cp.X = ctrPt.X; cp.Y = ctrPt.Y; cp.Z = 0.0; }); //centre point of 2D box IfcDirection IfcDirectionXDir = Model.Instances.New <IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; }); //default to X direction IfcAxis2Placement2D ifcAxis2Placement2DCtr = Model.Instances.New <IfcAxis2Placement2D>(a2p => { a2p.Location = IfcCartesianPointCtr; a2p.RefDirection = IfcDirectionXDir; }); IfcRectangleProfileDef ifcRectangleProfileDef = Model.Instances.New <IfcRectangleProfileDef>(rpd => { rpd.ProfileType = IfcProfileTypeEnum.AREA; rpd.ProfileName = row.RowName; rpd.Position = ifcAxis2Placement2DCtr; rpd.XDim = bBox.SizeX; rpd.YDim = bBox.SizeY; }); //Create IfcExtrudedAreaSolid IfcDirection IfcDirectionAxis = Model.Instances.New <IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; }); //default to Z direction IfcDirection IfcDirectionRefDir = Model.Instances.New <IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; }); //default to X direction IfcCartesianPoint IfcCartesianPointPosition = Model.Instances.New <IfcCartesianPoint>(cp => { cp.X = 0.0; cp.Y = 0.0; cp.Z = 0.0; }); //centre point of 2D box IfcAxis2Placement3D ifcAxis2Placement3DPosition = Model.Instances.New <IfcAxis2Placement3D>(a2p3D => { a2p3D.Location = IfcCartesianPointPosition; a2p3D.Axis = IfcDirectionAxis; a2p3D.RefDirection = IfcDirectionRefDir; }); IfcDirection IfcDirectionExtDir = Model.Instances.New <IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; }); //default to Z direction IfcExtrudedAreaSolid ifcExtrudedAreaSolid = Model.Instances.New <IfcExtrudedAreaSolid>(eas => { eas.SweptArea = ifcRectangleProfileDef; eas.Position = ifcAxis2Placement3DPosition; eas.ExtrudedDirection = IfcDirectionExtDir; eas.Depth = bBox.SizeZ; }); var project = Model.FederatedInstances.OfType <IfcProject>().FirstOrDefault(); //Create IfcShapeRepresentation IfcShapeRepresentation ifcShapeRepresentation = Model.Instances.New <IfcShapeRepresentation>(sr => { sr.ContextOfItems = project.ModelContext; sr.RepresentationIdentifier = "Body"; sr.RepresentationType = "SweptSolid"; }); ifcShapeRepresentation.Items.Add(ifcExtrudedAreaSolid); //create IfcProductDefinitionShape IfcProductDefinitionShape ifcProductDefinitionShape = Model.Instances.New <IfcProductDefinitionShape>(pds => { pds.Name = row.Name; pds.Description = row.SheetName; }); ifcProductDefinitionShape.Representations.Add(ifcShapeRepresentation); //Link to the IfcProduct ifcProduct.Representation = ifcProductDefinitionShape; } else { #if DEBUG Console.WriteLine("Failed to calculate box size for {0}", row.Name); #endif } } } else { #if DEBUG Console.WriteLine("Failed to add Object placement for {0}", row.Name); #endif } } }
private IfcStair CreateIfcStair(IfcStore model, Stair stair) { //begin a transaction using (var trans = model.BeginTransaction("Create Stair")) { IfcStair stairToCreate = model.Instances.New <IfcStair>(); stairToCreate.Name = " stair - Wall:UC305x305x97:" + 1500; IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); for (int i = 0; i < stair.LstStep.Count; i++) { IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (stair.LstStep[i].Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, stair.Thickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, stair.IsUp ? stair.Thickness * i : stair.Thickness * -i); shape.Items.Add(body); } //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); IfcStairFlight flight = model.Instances.New <IfcStairFlight>(); flight.Representation = prDefShape; IfcRelAggregates relAggregate = model.Instances.New <IfcRelAggregates>(); relAggregate.RelatingObject = stairToCreate; relAggregate.RelatedObjects.Add(flight); //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); flight.ObjectPlacement = lp; trans.Commit(); return(stairToCreate); } }
public IfcShapeRepresentation NewGeometricRepresentation(IfcProduct product, IfcGeometricRepresentationItem representationItem, IfcStyleAssignmentSelect style = null, string representationContext = "Model", string representationContextId = "Body") { if (Store != product.Model || Store != representationItem.Model) { throw new ArgumentException("Model mismatch"); } IfcShapeRepresentation shapeRepresentation = null; Wrap(s => { var productDefinitionShape = product.Representation; if (null == productDefinitionShape) { productDefinitionShape = s.Instances.New <IfcProductDefinitionShape>(); } if (null != style) { s.Instances.New <IfcStyledItem>(i => { i.Item = representationItem; i.Styles.Add(style); }); } product.Representation = productDefinitionShape; shapeRepresentation = s.Instances.New <IfcShapeRepresentation>(); productDefinitionShape.Representations.Add(shapeRepresentation); var project = Scopes.OfType <IfcProject>().FirstOrDefault(); var contexts = project .RepresentationContexts .Where <IfcGeometricRepresentationContext>(c => c.ContextType == representationContext); IfcGeometricRepresentationContext context = null; if (contexts.Count() > 1) { context = contexts.Where(c => c.ContextIdentifier == representationContextId).FirstOrDefault(); } else { context = contexts.FirstOrDefault(); } if (null == context) { context = Store.NewIfc4GeometricContext(representationContextId, representationContext); } shapeRepresentation.ContextOfItems = context; shapeRepresentation.Items.Add(representationItem); }); return(shapeRepresentation); }