public bool Contains(IfcProduct first, IfcProduct second) { //this type of relation is always recursive if (first == second) { return(true); } //check the case of spatial strucure element (specific relations) IfcSpatialStructureElement spatStruct = first as IfcSpatialStructureElement; IEnumerable <IfcProduct> prods = null; if (spatStruct != null) { prods = GetProductsInSpatStruct(spatStruct); foreach (var prod in prods) { if (Contains(prod, second)) { return(true); } } } prods = GetProductsInProduct(first); foreach (var prod in prods) { if (Contains(prod, second)) { return(true); } } //if we don't know return(false); }
public TransformNode(IfcProduct prod) { if (prod != null) { _productLabel = prod.EntityLabel; } }
private IEnumerable <IfcProduct> GetFillingProducts(IfcProduct prod) { //voids var element = prod as IfcElement; if (element != null) { var voidsRels = _model.Instances.Where <IfcRelVoidsElement>(r => r.RelatingBuildingElement == element); foreach (var rel in voidsRels) { foreach (var item in GetFillingProducts(rel.RelatedOpeningElement)) { yield return(item); } } } //fills var opening = prod as IfcOpeningElement; if (opening != null) { var fillsRels = _model.Instances.Where <IfcRelFillsElement>(r => r.RelatingOpeningElement == opening); foreach (var rel in fillsRels) { yield return(rel.RelatedBuildingElement); } } }
private static void CountExistInPset(IfcProduct ifcProduct, NodeItem classNode) { var ifcPropertySets = ifcProduct.IsDefinedBy .Where(r => r.RelatingPropertyDefinition is IIfcPropertySet) .Select(r => ((IIfcPropertySet)r.RelatingPropertyDefinition)); foreach (var ifcPropertySet in ifcPropertySets) { if (classNode.Children.Any(ps => ps.Name == ifcPropertySet.Name)) { NodeItem propSetNode = classNode.Children.Where(ps => ps.Name == ifcPropertySet.Name).FirstOrDefault(); List <IIfcProperty> ifcProperties = new List <IIfcProperty>(); // Remove duplication foreach (var ifcProperty in ifcPropertySet.HasProperties) { if (!ifcProperties.Any(p => p.Name == ifcProperty.Name)) { ifcProperties.Add(ifcProperty); } } foreach (var ifcProperty in ifcProperties) { if (propSetNode.Children.Any(p => p.Name == ifcProperty.Name)) { NodeItem propNode = propSetNode.Children.Where(p => p.Name == ifcProperty.Name).FirstOrDefault(); propNode.ExistCount++; } } } } }
/// <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.Instances.Where <IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcBuildingStorey == null) && (ValidateString(row.RowName))) { ifcBuildingStorey = Model.Instances.Where <IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault(); } if (ifcBuildingStorey != null) { IfcProduct placementRelToIfcProduct = ifcBuildingStorey.SpatialStructuralElementParent as IfcProduct; 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; } } } }
/// <summary> /// Creates new body representation it as "Body", "Brep". /// </summary> /// <param name = "context">Geometry context</param> /// <returns>New empty set of representation items</returns> public static IfcShapeRepresentation GetNewSweptSolidShapeRepresentation(this IfcProduct prod, IfcRepresentationContext context) { var model = (prod as IPersistEntity).Model; if (model == null) { model = prod.Model; } var definitionShape = prod.Representation as IfcProductDefinitionShape; if (definitionShape == null) { definitionShape = model.Instances.New <IfcProductDefinitionShape>(); prod.Representation = definitionShape; } var shapeRepresentation = model.Instances.New <IfcShapeRepresentation>(); shapeRepresentation.ContextOfItems = context; // model.IfcProject.ModelContext(); shapeRepresentation.RepresentationIdentifier = "Body"; shapeRepresentation.RepresentationType = "SweptSolid"; definitionShape.Representations.Add(shapeRepresentation); return(shapeRepresentation); }
public bool Contains(IfcProduct first, IfcProduct second) { //check if it is not identical obect if (first == second) { return(false); } //use sematic relations as a first criterium if (_semanticAnalyser.Contains(first, second)) { return(true); } //BBox approximation if (!( _bboxAnalyser.Equals(first, second) || _bboxAnalyser.Contains(first, second) )) { return(false); } //exact calculation should be performed at this step throw new NotImplementedException(); }
public void ParseProduct(IfcProduct product) { this.Name = product.FriendlyName; this.IfcType = product.GetType().Name; this.PropertySummary = this.CreatePropertySummary(product); Console.Write(this.PropertySummary); }
public XPreviewElement(IfcProduct ifcEntity) : base(ifcEntity) { Color = ifcEntity.Description; ProfilePath = LoadProfilePath(); XPolygon LoadProfilePath() { XPolygon profile = new XPolygon(); foreach (var rep in ifcEntity.Representation.Representations) { if (rep.RepresentationIdentifier == "Plan" && rep.RepresentationType == "Curve2D") { foreach (var item in rep.Items) { if (item is IfcPolyline polyline) { foreach (var point in polyline.Points) { profile.Add(new XbimPoint3D(point.X, point.Y, point.Z)); } } } } } return(profile); } }
private static IfcProduct ConvertElementToIfcProduct(Guid id, GeometricElement element, IfcLocalPlacement localPlacement, IfcProductDefinitionShape shape) { try { IfcProduct e = null; if (element is Beam) { e = ((Beam)element).ToIfc(id, localPlacement, shape); } if (element is Brace) { e = ((Brace)element).ToIfc(id, localPlacement, shape); } else if (element is Column) { e = ((Column)element).ToIfc(id, localPlacement, shape); } else if (element is StandardWall) { e = ((StandardWall)element).ToIfc(id, localPlacement, shape); } else if (element is Wall) { e = ((Wall)element).ToIfc(id, localPlacement, shape); } else if (element is Floor) { e = ((Floor)element).ToIfc(id, localPlacement, shape); } else if (element is Space) { e = ((Space)element).ToIfc(id, localPlacement, shape); } else if (element is Panel) { e = ((Panel)element).ToIfc(id, localPlacement, shape); } else if (element is Mass) { e = ((Mass)element).ToIfc(id, localPlacement, shape); } else if (element is Opening) { e = ((Opening)element).ToIfc(id, localPlacement, shape); } else { e = element.ToIfc(id, localPlacement, shape); } return(e); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine($"{element.GetType()} cannot be serialized to IFC."); } return(null); }
internal static IfcLocalPlacement createLocalPlacement(IfcProduct host, IfcCartesianPoint cartesianPoint, IfcDirection direction) { IfcAxis2Placement3D axis2Placement3D = new IfcAxis2Placement3D(cartesianPoint); if (direction != null) { axis2Placement3D.RefDirection = direction; } return(new IfcLocalPlacement(host.ObjectPlacement, axis2Placement3D)); }
public bool Disjoint(IfcProduct first, IfcProduct second) { if (first == second) { return(false); } //can't tell from semantics throw new NotImplementedException(); }
/// <summary> /// Returns the first Body(Solid) Representation, null if none exists /// </summary> /// <returns></returns> public static IfcShapeRepresentation GetBodyRepresentation(this IfcProduct prod) { if (prod.Representation != null) { return (prod.Representation.Representations.OfType <IfcShapeRepresentation>().Where( r => string.Compare(r.RepresentationIdentifier.GetValueOrDefault(), "Body", true) == 0).FirstOrDefault()); } return(null); }
private static IEnumerable <T> RepresentationsOfType <T>(this IfcProduct product) where T : IfcGeometricRepresentationItem { var reps = product.Representation.Representations.SelectMany(r => r.Items); if (reps.Any()) { return(reps.OfType <T>()); } return(null); }
/// <summary> /// Resolves the objects placement into a global wcs transformation. /// </summary> /// <param name="product"></param> /// <returns></returns> public static XbimMatrix3D Transform(this IfcProduct product) { if (product.ObjectPlacement != null) { return(product.ObjectPlacement.ToMatrix3D()); } else { return(XbimMatrix3D.Identity); } }
public static IEnumerable <XbimGeometryData> GeometryData(this IfcProduct product, XbimGeometryType geomType) { XbimModel model = product.ModelOf as XbimModel; if (model != null) { foreach (var item in model.GetGeometryData(product, geomType)) { yield return(item); } } }
private static void AnalyseProperties(IfcProduct ifcProduct, List <NodeItem> nodes) { string entityName = GetEntityNameFromType(ifcProduct.GetType().ToString()); if (nodes.Any(n => n.Name == entityName)) { NodeItem classNode = nodes.Where(n => n.Name == entityName && n.Type == NodeItem.NodeItemType.Classification).FirstOrDefault(); classNode.ExistCount++; CountExistInPset(ifcProduct, classNode); CountExistInQto(ifcProduct, classNode); } }
public static IEnumerable <XbimGeometryData> GeometryData(this IfcProduct product, XbimGeometryType geomType) { var model = product.Model as EsentModel; if (model != null) { foreach (var item in model.GetGeometryData(product.EntityLabel, geomType)) { yield return(item); } } }
private void GetGeometryData(XbimModel model, IfcProduct product) { var context = new Xbim3DModelContext(model); //TODO: WCS var metre = model.ModelFactors.OneMetre; var units = model.IfcProject.UnitsInContext.Units .Where <IfcSIUnit>(u => u.UnitType == IfcUnitEnum.LENGTHUNIT) .ToList(); string defaultLengthUnit = ""; if (units.Count > 0) { defaultLengthUnit = units.First().GetSymbol(); } var styles = context.SurfaceStyles().ToList(); var productShape = context.ShapeInstancesOf(product) .Where(p => p.RepresentationType != XbimGeometryRepresentationType.OpeningsAndAdditionsExcluded) .Distinct(); if (productShape.Any()) { foreach (var shapeInstance in productShape) { var shapeGeometry = context.ShapeGeometry(shapeInstance.ShapeGeometryLabel); XbimColour style = XbimColour.Default; if (shapeInstance.HasStyle) { style = styles.First(s => s.DefinedObjectId == shapeInstance.StyleLabel).ColourMap.FirstOrDefault(); } Console.WriteLine("--Style: {0}", style); Console.WriteLine("-- x:{0:0.0000} \n-- y:{1:0.0000} \n-- z:{2:0.0000} \n", shapeGeometry.BoundingBox.Location.X, shapeGeometry.BoundingBox.Location.Y, shapeGeometry.BoundingBox.Location.Z); Console.WriteLine("-- sx:{0:0.0000} {3} \n-- sy:{1:0.0000} {3} \n-- sz:{2:0.0000} {3} \n", shapeGeometry.BoundingBox.SizeX, shapeGeometry.BoundingBox.SizeY, shapeGeometry.BoundingBox.SizeZ, defaultLengthUnit); } } }
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); }
/// <summary> /// Returns first set of IFC representation items or null; /// </summary> public static IfcShapeRepresentation GetFirstShapeRepresentation(this IfcProduct prod) { var definitionShape = prod.Representation as IfcProductDefinitionShape; if (definitionShape == null) { return(null); } var shapeRepresentation = definitionShape.Representations.FirstOrDefault() as IfcShapeRepresentation; return(shapeRepresentation); }
public JsonProductIfcElement(IfcProduct product, JsonStoreyIfcElement parent, JsonConversionContext context) : base(product) { userData.buildingStorey = new string[] { }; userData.siteId = parent.userData?.siteId; userData.projectId = parent.userData?.projectId; userData.buildingId = parent.userData?.buildingId; // Environnement element userData.buildingStorey = new[] { parent.id }; // Extract pset product.ExtractPset(this); }
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); }
public TransformNode this[IfcProduct product] { get { var pl = product.ObjectPlacement; if (pl == null) { return(null); } TransformNode node; return(_placementNodes.TryGetValue(pl, out node) ? node : null); } }
public void AddElement(IfcProduct element) { var spatialStructure = ContainsElements.FirstOrDefault(); if (spatialStructure == null) //none defined create the relationship { var relSe = Model.Instances.New <IfcRelContainedInSpatialStructure>(); relSe.RelatingStructure = this; relSe.RelatedElements.Add(element); } else { spatialStructure.RelatedElements.Add(element); } }
/// <summary> /// Returns set of IFC representation items from the specified context or null; /// </summary> public static IItemSet <IfcRepresentationItem> GetShapeRepresentationItems(this IfcProduct prod, IfcRepresentationContext context) { var definitionShape = prod.Representation as IfcProductDefinitionShape; if (definitionShape == null) { return(null); } var shapeRepresentation = definitionShape.Representations.FirstOrDefault <IfcShapeRepresentation>(rep => rep.ContextOfItems == context); return(shapeRepresentation == null ? null : shapeRepresentation.Items); }
/// <summary> /// Sets new object placement as LocalPlacement with defined coordinates. If any placement exists it is overwritten; /// </summary> /// <param name = "placementX">X coordinate of placement</param> /// <param name = "placementY">Y coordinate of placement</param> /// <param name = "placementZ">Z coordinate of placement</param> public static void SetNewObjectLocalPlacement(this IfcProduct prod, double placementX, double placementY, double placementZ) { var model = prod.Model; prod.ObjectPlacement = model.Instances.New <IfcLocalPlacement>(); var localPlacement = prod.ObjectPlacement as IfcLocalPlacement; if (localPlacement.RelativePlacement == null) { localPlacement.RelativePlacement = model.Instances.New <IfcAxis2Placement3D>(); } var placement = localPlacement.RelativePlacement as IfcAxis2Placement3D; placement.SetNewLocation(placementX, placementY, placementZ); }
public static void AddElement(this IfcSite site, IfcProduct element) { IEnumerable <IfcRelContainedInSpatialStructure> relatedElements = site.ContainsElements; if (relatedElements.Count() == 0) //none defined create the relationship { IfcRelContainedInSpatialStructure relSe = site.ModelOf.Instances.New <IfcRelContainedInSpatialStructure>(); relSe.RelatingStructure = site; relSe.RelatedElements.Add(element); } else { relatedElements.First().RelatedElements.Add(element); } }
public bool Intersects(IfcProduct first, IfcProduct second) { //check if it is not identical obect if (first == second) { return(false); } //If BBox approximation doesn't intersect or is not spatialy equal there can't be an intersection if (!_bboxAnalyser.Intersects(first, second) && !_bboxAnalyser.Equals(first, second)) { return(false); } //exact calculation should be performed at this step throw new NotImplementedException(); }
public bool Equals(IfcProduct first, IfcProduct second) { //check if it is not identical obect if (first == second) { return(true); } //if BBoxes are not equal it can't be equal if (!_bboxAnalyser.Equals(first, second)) { return(false); } //exact calculation should be performed at this step throw new NotImplementedException(); }