private static IfcStyledItem ToIfcStyledItem(this Material material, IfcRepresentationItem shape, Document doc) { var color = material.Color.ToIfcColourRgb(doc); var shading = new IfcSurfaceStyleShading(color); var styles = new List <IfcSurfaceStyleElementSelect> { }; styles.Add(new IfcSurfaceStyleElementSelect(shading)); var surfaceStyle = new IfcSurfaceStyle(material.Name, IfcSurfaceSide.POSITIVE, styles); var styleSelect = new IfcPresentationStyleSelect(surfaceStyle); var assign = new IfcPresentationStyleAssignment(new List <IfcPresentationStyleSelect> { styleSelect }); var assignments = new List <IfcPresentationStyleAssignment>(); assignments.Add(assign); var styledByItem = new IfcStyledItem(shape, assignments, material.Name); doc.AddEntity(color); doc.AddEntity(shading); doc.AddEntity(surfaceStyle); doc.AddEntity(styleSelect); doc.AddEntity(assign); return(styledByItem); }
internal override void ParseXml(XmlElement xml) { base.ParseXml(xml); foreach (XmlNode child in xml.ChildNodes) { string name = child.Name; if (string.Compare(name, "Styles") == 0) { foreach (XmlNode cn in child.ChildNodes) { IfcPresentationStyleSelect s = mDatabase.ParseXml <IfcPresentationStyleSelect>(cn as XmlElement); if (s != null) { addStyle(s); } } } } }
//transformation function to convert/cast IFC2x3 data to appear as IFC4 private static IIfcPresentationStyleSelect StylesToIfc4(IfcPresentationStyleSelect member) { if (member == null) { return(null); } switch (member.GetType().Name) { case "IfcCurveStyle": return(member as IfcCurveStyle); case "IfcSymbolStyle": //## Handle entity IfcSymbolStyle which is not a part of the target select interface IIfcPresentationStyleSelect in property Styles { /* var colour = ifcsymbolstyle.StyleOfSymbol as IIfcColourRgb; * if(colour!=null) * return colour;*/ return(new Ifc4.PresentationAppearanceResource.IfcNullStyle()); } //## case "IfcFillAreaStyle": return(member as IfcFillAreaStyle); case "IfcTextStyle": return(member as IfcTextStyle); case "IfcSurfaceStyle": return(member as IfcSurfaceStyle); case "IfcNullStyle": //## Handle defined type IfcNullStyle which is not a part of the target select interface IItemSet<IIfcPresentationStyleSelect> in property Styles return(null); //## default: throw new System.NotSupportedException(); } }
public static IfcShapeRepresentation NewIfc2x3RepresentationItem(this IModel s, IfcProduct product, IfcGeometricRepresentationItem geometryItem, IfcPresentationStyleSelect style) { if (null != style) { var styleAssignement = s.Instances.New <IfcPresentationStyleAssignment>(); styleAssignement.Styles.Add(style); s.Instances.New <IfcStyledItem>(i => { i.Item = geometryItem; i.Styles.Add(styleAssignement); }); } var shapeRepresentation = s.NewIfc2x3ShapeRepresentation(product); shapeRepresentation.Items.Add(geometryItem); return(shapeRepresentation); }