/// <summary> /// Builds a windows Matrix3D from an ObjectPlacement /// Conversion fo c++ function CartesianTransform::ConvertMatrix3D from CartesianTransform.cpp /// </summary> /// <param name="objPlacement">IfcObjectPlacement object</param> /// <returns>Matrix3D</returns> protected XbimMatrix3D ConvertMatrix3D(IfcObjectPlacement objPlacement) { if (objPlacement is IfcLocalPlacement) { IfcLocalPlacement locPlacement = (IfcLocalPlacement)objPlacement; if (locPlacement.RelativePlacement is IfcAxis2Placement3D) { IfcAxis2Placement3D axis3D = (IfcAxis2Placement3D)locPlacement.RelativePlacement; XbimVector3D ucsXAxis = new XbimVector3D(axis3D.RefDirection.DirectionRatios[0], axis3D.RefDirection.DirectionRatios[1], axis3D.RefDirection.DirectionRatios[2]); XbimVector3D ucsZAxis = new XbimVector3D(axis3D.Axis.DirectionRatios[0], axis3D.Axis.DirectionRatios[1], axis3D.Axis.DirectionRatios[2]); ucsXAxis = ucsXAxis.Normalized(); ucsZAxis = ucsZAxis.Normalized(); XbimVector3D ucsYAxis = XbimVector3D.CrossProduct(ucsZAxis, ucsXAxis); ucsYAxis = ucsYAxis.Normalized(); XbimPoint3D ucsCentre = axis3D.Location.XbimPoint3D(); XbimMatrix3D ucsTowcs = new XbimMatrix3D(ucsXAxis.X, ucsXAxis.Y, ucsXAxis.Z, 0, ucsYAxis.X, ucsYAxis.Y, ucsYAxis.Z, 0, ucsZAxis.X, ucsZAxis.Y, ucsZAxis.Z, 0, ucsCentre.X, ucsCentre.Y, ucsCentre.Z, 1); if (locPlacement.PlacementRelTo != null) { return(XbimMatrix3D.Multiply(ucsTowcs, ConvertMatrix3D(locPlacement.PlacementRelTo))); } return(ucsTowcs); } throw new NotImplementedException("Support for Placements other than 3D not implemented"); } throw new NotImplementedException("Support for Placements other than Local not implemented"); }
/// <summary> /// Add floor placement point /// </summary> /// <param name="row">COBieCoordinateRow holding the data</param> private void AddFloorPlacement(COBieCoordinateRow row) { IfcBuildingStorey ifcBuildingStorey = null; if (ValidateString(row.ExtIdentifier)) { IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier); ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcBuildingStorey == null) && (ValidateString(row.RowName))) { ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault(); } if (ifcBuildingStorey != null) { var placementRelToIfcProduct = ifcBuildingStorey.GetContainingStructuralElement(); IfcLocalPlacement objectPlacement = CalcObjectPlacement(row, placementRelToIfcProduct); if (objectPlacement != null) { //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuildingStorey.OwnerHistory)) { ifcBuildingStorey.ObjectPlacement = objectPlacement; } } } }
private IfcBuilding CreateBuilding(XbimModel model, string name, double elevHeight) { using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Building")) { IfcBuilding building = model.Instances.New <IfcBuilding>(); building.Name = name; building.OwnerHistory.OwningUser = model.DefaultOwningUser; building.OwnerHistory.OwningApplication = model.DefaultOwningApplication; //building.ElevationOfRefHeight = elevHeight; building.CompositionType = IfcElementCompositionEnum.ELEMENT; building.ObjectPlacement = model.Instances.New <IfcLocalPlacement>(); IfcLocalPlacement localPlacement = building.ObjectPlacement as IfcLocalPlacement; if (localPlacement.RelativePlacement == null) { localPlacement.RelativePlacement = model.Instances.New <IfcAxis2Placement3D>(); } IfcAxis2Placement3D placement = localPlacement.RelativePlacement as IfcAxis2Placement3D; placement.SetNewLocation(0.0, 0.0, 0.0); model.IfcProject.AddBuilding(building); //validate and commit changes if (model.Validate(txn.Modified(), Console.Out) == 0) { txn.Commit(); return(building); } } return(null); }
/// <summary> /// Create and setup the IfcBuilding building object /// </summary> /// <param name="row">COBieFacilityRow object to read data from</param> private void CreateBuilding(COBieFacilityRow row) { IfcBuilding ifcBuilding = Model.Instances.New <IfcBuilding>(); SetNewOwnerHistory(ifcBuilding, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcBuilding.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuilding.OwnerHistory)) { AddGlobalId(row.ExternalFacilityIdentifier, ifcBuilding); if (ValidateString(row.Name)) { ifcBuilding.Name = row.Name; } //add category AddCategory(row.Category, ifcBuilding); if (ValidateString(row.Description)) { ifcBuilding.Description = row.Description; } if (ValidateString(row.AreaMeasurement)) { SetAreaMeasure(ifcBuilding, row); } ifcBuilding.CompositionType = IfcElementCompositionEnum.ELEMENT; IfcLocalPlacement lp = Model.Instances.New <IfcLocalPlacement>(); lp.RelativePlacement = WCS; lp.PlacementRelTo = GetSite().ObjectPlacement; ifcBuilding.ObjectPlacement = lp; } }
/// <summary> /// Create and setup IfcSite object /// </summary> /// <param name="row">COBieFacilityRow object to read data from</param> /// <returns>IfcSite object</returns> private void CreateSite(COBieFacilityRow row) { IfcSite ifcSite = Model.Instances.New <IfcSite>(); //set owner history SetNewOwnerHistory(ifcSite, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcSite.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcSite.OwnerHistory)) { AddGlobalId(row.ExternalSiteIdentifier, ifcSite); if (ValidateString(row.SiteName)) { ifcSite.Name = row.SiteName; } ifcSite.CompositionType = IfcElementCompositionEnum.ELEMENT; IfcLocalPlacement lp = Model.Instances.New <IfcLocalPlacement>(); lp.RelativePlacement = WCS; ifcSite.ObjectPlacement = lp; if (ValidateString(row.SiteDescription)) { ifcSite.Description = row.SiteDescription; } } }
BbLocalPlacement3D( BbLocalPlacement3D placementRelTo, BbPosition3D relativePlacement) { if (placementRelTo != null && relativePlacement != null) { IfcLocalPlacement = new IfcLocalPlacement { PlacementRelTo = placementRelTo.IfcLocalPlacement, RelativePlacement = new IfcAxis2Placement { Value = relativePlacement.IfcAxis2Placement3D, }, }; } else if (placementRelTo == null && relativePlacement != null) { IfcLocalPlacement = new IfcLocalPlacement { RelativePlacement = new IfcAxis2Placement { Value = relativePlacement.IfcAxis2Placement3D, }, }; } else { IfcLocalPlacement = new IfcLocalPlacement { RelativePlacement = new IfcAxis2Placement { Value = BbHeaderSetting.Setting3D.DefaultBbPosition3D.IfcAxis2Placement3D, }, }; } }
public static BbLocalPlacement3D Create(IfcLocalPlacement ifcLocalPlacement) { var placement3D = new BbLocalPlacement3D(ifcLocalPlacement); BbInstanceDB.AddToExport(placement3D); return(placement3D); }
public static Transformation getPlacementTransformtion(IfcObjectPlacement obPL) { if (obPL is IfcLocalPlacement) { IfcLocalPlacement locPl = (IfcLocalPlacement)obPL; Plane pln = Conversion.getPlaneFromPosition((IfcPlacement)locPl.RelativePlacement); Align3D align = new Align3D(Plane.XY, pln); if (locPl.PlacementRelTo == null) { return(align); } else { return(getPlacementTransformtion(locPl.PlacementRelTo) * align); } } else if (obPL is IfcGridPlacement) { throw new Exception("IfcGridPlacement"); } return(null); }
private static IfcPlate ToIfc(this Panel panel, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var plate = new IfcPlate(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, shape, null); return(plate); }
private static IfcMember ToIfc(this Brace column, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var member = new IfcMember(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, shape, null); return(member); }
private static IfcColumn ToIfc(this Column column, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcColumn = new IfcColumn(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, shape, null); return(ifcColumn); }
private static IfcBeam ToIfc(this Beam beam, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcBeam = new IfcBeam(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, shape, null); return(ifcBeam); }
private static IfcWall ToIfc(this Wall wall, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcWall = new IfcWall(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, wall.Name, null, null, localPlacement, shape, null); return(ifcWall); }
/// <summary> /// Convert a transform to an IfcLocalPlacement. /// </summary> /// <param name="transform"></param> /// <param name="doc"></param> /// <returns></returns> private static IfcLocalPlacement ToIfcLocalPlacement(this Transform transform, Document doc) { var placement = transform.ToIfcAxis2Placement3D(doc); var localPlacement = new IfcLocalPlacement(new IfcAxis2Placement(placement)); doc.AddEntity(placement); return(localPlacement); }
private static IfcBuildingElementProxy ToIfc(this Mass mass, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var proxy = new IfcBuildingElementProxy(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcBuildingElementProxyTypeEnum.ELEMENT); return(proxy); }
private static IfcMember ToIfc(this Brace column, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var member = new IfcMember(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcMemberTypeEnum.NOTDEFINED); return(member); }
private static IfcPlate ToIfc(this Panel panel, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var plate = new IfcPlate(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcPlateTypeEnum.NOTDEFINED); return(plate); }
private static IfcBeam ToIfc(this Beam beam, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcBeam = new IfcBeam(IfcGuid.ToIfcGuid(beam.Id), null, null, null, null, localPlacement, shape, null, IfcBeamTypeEnum.BEAM); return(ifcBeam); }
private static IfcColumn ToIfc(this Column column, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcColumn = new IfcColumn(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcColumnTypeEnum.COLUMN); return(ifcColumn); }
private static IfcSlab ToIfc(this Floor floor, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var slab = new IfcSlab(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcSlabTypeEnum.FLOOR); return(slab); }
public List <ModelUIElement3D> CreateModelUiElementsDs(IfcModel model, List <IfcGloballyUniqueId> elementIdsList, bool visualizeUnselectedElementsTransparent = true, DiffuseMaterial overrideMaterial = null) { tempMaterialLibrary = new Dictionary <string, DiffuseMaterial>(); // Refresh the selected Models SelectedModels = new Dictionary <string, GeometryModel3D>(); VisualizedModels = new Dictionary <string, ModelUIElement3D>(); xModel = model.GetModel(); context = model.GetModelContext(); // Loop through Entities and visualze them in the viewport var res = new HashSet <IfcGloballyUniqueId>(elementIdsList); var elementList = new List <ModelUIElement3D>(); // GET GEOREFERENCING var wcsTransformation = new XbimMatrix3D(); var myIfcSite = xModel.Instances.OfType <Xbim.Ifc2x3.ProductExtension.IfcSite>(); var ifcSites = myIfcSite as IList <Xbim.Ifc2x3.ProductExtension.IfcSite> ?? myIfcSite.ToList(); if (ifcSites.Count == 1) { Xbim.Ifc2x3.ProductExtension.IfcSite mySite = ifcSites.First(); IfcLocalPlacement relplacement = mySite.ObjectPlacement.ReferencedByPlacements.First(); wcsTransformation = relplacement.ToMatrix3D(); } foreach (var item in xModel.Instances.OfType <IIfcProduct>()) { if (visualizeUnselectedElementsTransparent == false) { if (!res.Contains(item.GlobalId)) { continue; } } // Get the Material var mat = new DiffuseMaterial(); if (overrideMaterial == null) { mat = res.Contains(item.GlobalId) ? GeometryHandler.GetStyleFromXbimModel(item, context) : GeometryHandler.GetStyleFromXbimModel(item, context, 0.03); } else { mat = overrideMaterial; } var m = GeometryHandler.WriteTriangles(item, context, wcsTransformation); tempMaterialLibrary.Add(item.GlobalId, mat); var element = CreateModelUIElement3D(m, mat); element.MouseDown += ElementOnMouseDown; elementList.Add(element); VisualizedModels.Add(item.GlobalId, element); } return(elementList); }
// TODO: There is a lot of duplicate code used to create products. // Can we make a generic method like ToIfc<TProduct>()? There are // exceptions for which this won't work like IfcSpace. private static IfcSpace ToIfc(this Space space, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcSpace = new IfcSpace(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, shape, null, IfcElementCompositionEnum.ELEMENT, IfcInternalOrExternalEnum.NOTDEFINED, new IfcLengthMeasure(space.Transform.Origin.Z)); return(ifcSpace); }
private static Transform ToTransform(this IfcLocalPlacement placement) { var t = placement.RelativePlacement.ToTransform(); if (placement.PlacementRelTo != null) { var tr = placement.PlacementRelTo.ToTransform(); t.Concatenate(tr); } return(t); }
internal static IfcLocalPlacement LocalPlacemetCreate(IfcStore model, IfcAxis2Placement3D _relativePlacement, IfcObjectPlacement _placementRelTo = null) { IfcLocalPlacement localPlacement = model.Instances.New <IfcLocalPlacement>(); localPlacement.RelativePlacement = _relativePlacement; if (_placementRelTo != null) { localPlacement.PlacementRelTo = _placementRelTo; } return(localPlacement); }
static void Main(string[] args) { var dbInitial = new DatabaseIfc(ModelView.Ifc4NotAssigned); dbInitial.Factory.Options.GenerateOwnerHistory = false; var site = new IfcSite(dbInitial, "site") { Guid = new Guid("aa4019f8-2584-44a1-a132-c17dfff69c41") }; var project = new IfcProject(dbInitial, "GeomRep") { Guid = new Guid("94d4ddac-9120-4fb9-bea0-7a414ee725d4") }; new IfcRelAggregates(project, new List <IfcObjectDefinition>() { site }) { Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad") }; IfcAxis2Placement3D placement1 = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 2, 5, 1)); IfcLocalPlacement objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1); IfcAxis2Placement3D placement2 = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 14, 5, 1)); IfcLocalPlacement objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2); var profile1 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 4, 6); IfcExtrudedAreaSolid extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35); IfcProductDefinitionShape shape1 = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1)); var profile2 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 5, 8); IfcExtrudedAreaSolid extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 4.1); IfcProductDefinitionShape shape2 = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2)); var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1) { Name = "Cuboid1", Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bbaa") }; var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2) { Name = "Cuboid2", Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706727a") }; dbInitial.WriteFile("cube_double.ifc"); }
internal static IfcLocalPlacement ToIfcLocalPlacement(this Transform transform, Document doc, IfcObjectPlacement parent = null) { var placement = transform.ToIfcAxis2Placement3D(doc); var localPlacement = new IfcLocalPlacement(new IfcAxis2Placement(placement)); if (parent != null) { localPlacement.PlacementRelTo = parent; } doc.AddEntity(placement); return(localPlacement); }
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 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 IfcOpeningElement ToIfc(this Opening opening, Guid id, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { var ifcOpening = new IfcOpeningElement(IfcGuid.ToIfcGuid(id), null, null, null, null, localPlacement, shape, null, IfcOpeningElementTypeEnum.OPENING); return(ifcOpening); }
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); }