public XbimTexture CreateTexture(IfcSurfaceStyle surfaceStyle) { DefinedObjectId = (int)surfaceStyle.EntityLabel; //set render one or both faces renderBothFaces = (surfaceStyle.Side == IfcSurfaceSide.BOTH); //switch if required switchFrontAndRearFaces = (surfaceStyle.Side == IfcSurfaceSide.NEGATIVE); ColourMap.Clear(); foreach (var style in surfaceStyle.Styles) { if (style is IfcSurfaceStyleRendering) { AddColour((IfcSurfaceStyleRendering)style); } else if (style is IfcSurfaceStyleShading) { AddColour((IfcSurfaceStyleShading)style); } else if (style is IfcSurfaceStyleLighting) { AddLighting((IfcSurfaceStyleLighting)style); } } return(this); }
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); }
private static Boolean tryGetColorFromIfcRepresentationItem(IfcRepresentationItem reprItem, out Color color) { color = Color.Black; try { if (reprItem.mStyledByItem != null) { IfcStyledItem ifcStyledItem = reprItem.mStyledByItem; IfcPresentationStyleAssignment sas = (IfcPresentationStyleAssignment)ifcStyledItem.Styles[0]; IfcSurfaceStyle ss = (IfcSurfaceStyle)sas.Styles[0]; IfcSurfaceStyleRendering ssr = (IfcSurfaceStyleRendering)ss.Styles[0]; int alpha = Convert.ToInt32((1 - ssr.Transparency) * 255); color = Color.FromArgb(alpha, ssr.SurfaceColour.Colour); return(true); } } catch (Exception e) { //debug += e.Message + "\n"; } return(false); }
public static XbimMaterialProvider GetRenderMaterial(this XbimModel model, XbimSurfaceStyle style) { if (style.IsIfcSurfaceStyle) { IfcSurfaceStyle surfaceStyle = style.IfcSurfaceStyle(model); if (surfaceStyle != null) { return(new XbimMaterialProvider(surfaceStyle.ToMaterial())); } } //nothing specific go for default of type return(ModelDataProvider.GetDefaultMaterial(style.IfcType)); }
/// <summary> /// Returns a material corresponding to this surface style, materials are cached in the ModelDataProvider /// </summary> /// <param name = "sStyle"></param> /// <returns></returns> public static Material ToMaterial(this IfcSurfaceStyle sStyle) { // todo: need to change this to return a material group that considers all types of Styles var rendering = sStyle.Styles.OfType <IfcSurfaceStyleRendering>().FirstOrDefault(); if (rendering != null) { return(rendering.ToMaterial()); } var shading = sStyle.Styles.OfType <IfcSurfaceStyleShading>().FirstOrDefault(); return((shading != null) ? shading.ToMaterial() : null); }
/// <summary> /// Returns a material corresponding to this surface style, materials are cached in the ModelDataProvider /// </summary> /// <param name = "sStyle"></param> /// <returns></returns> public static Material ToMaterial(this IfcSurfaceStyle sStyle) { //need to change this to return a material group that considers all types of Styles IfcSurfaceStyleRendering rendering = sStyle.Styles.OfType <IfcSurfaceStyleRendering>().FirstOrDefault(); if (rendering != null) { return(rendering.ToMaterial()); } else //try the shading { IfcSurfaceStyleShading shading = sStyle.Styles.OfType <IfcSurfaceStyleShading>().FirstOrDefault(); if (shading != null) { return(shading.ToMaterial()); } } return(null); //no luck }
/// <summary> /// Returns the first IfcSurfaceStyle associated with the representation item /// </summary> /// <param name="repItem"></param> /// <returns></returns> public static IfcSurfaceStyle SurfaceStyle(this IfcRepresentationItem repItem) { IfcStyledItem styledItem = repItem.ModelOf.Instances.Where <IfcStyledItem>(s => s.Item == repItem).FirstOrDefault(); if (styledItem != null) { foreach (var presStyle in styledItem.Styles) { if (presStyle != null) { IfcSurfaceStyle aSurfaceStyle = presStyle.Styles.OfType <IfcSurfaceStyle>().FirstOrDefault(); if (aSurfaceStyle != null) { return(aSurfaceStyle); } } } } return(null); }
internal static DatabaseIfc Generate(ModelView mdv, string path) { DatabaseIfc db = new DatabaseIfc(true, mdv); //IfcGeometricRepresentationContext //IfcCartesianPoint //IfcAxis2Placement3D //IfcDirection //IfcAxis2Placement2D //IfcSIUnit //IfcLocalPlacement IfcSite site = new IfcSite(db, "TestSite"); //IfcPerson NOT RV //IfcOrganization NOT RV //IfcPersonAndOrganization NOT RV //IfcOwnerHistory NOT RV //fcApplication NOT RV // IfcProjectLibrary NOT RV Can't have multiple context IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre) { }; //IfcUnitAssignment //IfcRelAggregates IfcBuilding building = new IfcBuilding(site, "TestBuilding") { }; IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 3000); IfcSpace space = new IfcSpace(buildingStorey, null, null) { Name = "TestSpace" }; space.RelatingType = new IfcSpaceType(db, "TestSpaceType", IfcSpaceTypeEnum.INTERNAL); IfcZone zone = new IfcZone(buildingStorey, "TestZone", "TestZoneLongName", new List <IfcSpace>() { space }); IfcLocalPlacement localPlacement = buildingStorey.Placement as IfcLocalPlacement; IfcMaterial material = new IfcMaterial(db, "TestMaterial") { Description = "TestDescription", Category = "TestCategory" }; IfcMaterialProperties materialProperties = new IfcMaterialProperties("TestMaterialProperties", material); materialProperties.AddProperty(new IfcPropertySingleValue(db, "MassDensity", new IfcMassDensityMeasure(1))); IfcSurfaceStyleShading surfaceStyleShading = new IfcSurfaceStyleShading(new IfcColourRgb(db, 1, 0, 0) { Name = "Red" }); IfcSurfaceStyle surfaceStyle = new IfcSurfaceStyle(surfaceStyleShading, null, null, null, null); IfcMaterialDefinitionRepresentation materialDefinitionRepresentation = new IfcMaterialDefinitionRepresentation(new IfcStyledRepresentation(new IfcStyledItem(surfaceStyle) { Name = "TestStyledItem" }), material); IfcIndexedPolyCurve indexedPolyCurve = IPE200Curve(db); IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", indexedPolyCurve); IfcMaterialProfile materialProfile = new IfcMaterialProfile("TestMaterialProfile", material, arbitraryClosedProfileDef); IfcMaterialProfileSet materialProfileSet = new IfcMaterialProfileSet("TestMaterialProfileSet", materialProfile); IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 1, 0, 0), new IfcDirection(db, 0, 1, 0)), new IfcDirection(db, 0, 0, 1), 5000); IfcBeamType beamType = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM); beamType.MaterialSelect = materialProfileSet; IfcBeam beam = new IfcBeam(buildingStorey, new IfcLocalPlacement(localPlacement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 2000, 0)) { RefDirection = new IfcDirection(db, 0, 1, 0) }), new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid))); //IfcGeometricRepresentationSubContext beam.RelatingType = beamType; //IfcRelDefinesByType // if(mdv != ModelView.Ifc4Reference) // IfcActorRole NOT RV //IfcActuator //IfcActuatorType //IfcAdvancedBrep NOT RV //IfcAdvancedFace NOT RV //IfcAirTerminal //IfcAirTerminalBox //IfcAirTerminalBoxType //IfcAirTerminalType //IfcAirToAirHeatRecovery //IfcAirToAirHeatRecoveryType //IfcAlarm //IfcAlarmType //IfcArbitraryOpenProfileDef //IfcArbitraryProfileDefWithVoids //IfcAsymmetricIShapeProfileDef NOT RV //IfcAudioVisualAppliance //IfcAudioVisualApplianceType //IfcAxis1Placement //IfcBeamStandardCase NOT RV //IfcBlock NOT RV //IfcBoiler //IfcBoilerType //IfcBooleanClippingResult NOT RV //IfcBooleanResult NOT RV //IfcBSplineCurveWithKnots NOT RV //IfcBSplineSurface NOT RV //IfcBSplineSurfaceWithKnots NOT RV //IfcBuildingElementPart //IfcBuildingElementPartType //IfcBuildingElementProxy //IfcBuildingElementProxyType //IfcBuildingSystem //IfcBurner //IfcBurnerType //IfcCableCarrierFitting //IfcCableCarrierFittingType //IfcCableCarrierSegment //IfcCableCarrierSegmentType //IfcCableFitting //IfcCableFittingType //IfcCableSegment //IfcCableSegmentType //IfcCartesianPointList2D //IfcCartesianPointList3D //IfcCartesianTransformationOperator2D //IfcCartesianTransformationOperator2DnonUniform //IfcCartesianTransformationOperator3D //IfcCartesianTransformationOperator3DnonUniform //IfcCenterLineProfileDef //IfcChiller //IfcChillerType //IfcChimney //IfcChimneyType //IfcCircle //IfcCircleHollowProfileDef NOT RV //IfcCircleProfileDef NOT RV //IfcCivilElement //IfcCivilElementType //IfcClassification //IfcClassificationReference //IfcClosedShell //IfcCoil //IfcCoilType //IfcColourRgbList //IfcColourSpecification //IfcColumn //IfcColumnStandardCase NOT RV //IfcColumnType //IfcCommunicationsAppliance //IfcCommunicationsApplianceType //IfcComplexProperty //IfcCompositeProfileDef NOT RV //IfcCompressor //IfcCompressorType //IfcCondenser //IfcCondenserType //IfcConnectedFaceSet NOT RV //IfcConnectionCurveGeometry NOT RV //IfcConnectionVolumeGeometry NOT RV //IfcController //IfcControllerType //IfcConversionBasedUnit //IfcConversionBasedUnitWithOffset //IfcCooledBeam //IfcCooledBeamType //IfcCoolingTower //IfcCoolingTowerType //IfcCovering //IfcCoveringType //IfcCsgSolid NOT RV //IfcCShapeProfileDef NOT RV //IfcCurtainWall //IfcCurtainWallType //IfcCurveStyle //IfcCurveStyleFont //IfcCurveStyleFontPattern //IfcDamper //IfcDamperType //IfcDerivedProfileDef NOT RV //IfcDerivedUnit //IfcDerivedUnitElement //IfcDimensionalExponents //IfcDiscreteAccessory //IfcDiscreteAccessoryType //IfcDistributionChamberElement //IfcDistributionChamberElementType //IfcDistributionCircuit //IfcDistributionControlElement //IfcDistributionControlElementType //IfcDistributionElement //IfcDistributionElementType //IfcDistributionFlowElement //IfcDistributionFlowElementType //IfcDistributionPort //IfcDistributionSystem //IfcDocumentReference //IfcDoor //IfcDoorLiningProperties //IfcDoorPanelProperties //IfcDoorStandardCase NOT RV //IfcDoorType //IfcDuctFitting //IfcDuctFittingType //IfcDuctSegment //IfcDuctSegmentType //IfcDuctSilencer //IfcDuctSilencerType //IfcEdge NOT RV //IfcEdgeCurve NOT RV //IfcEdgeLoop NOT RV //IfcElectricAppliance //IfcElectricApplianceType //IfcElectricDistributionBoard //IfcElectricDistributionBoardType //IfcElectricFlowStorageDevice //IfcElectricFlowStorageDeviceType //IfcElectricGenerator //IfcElectricGeneratorType //IfcElectricMotor //IfcElectricMotorType //IfcElectricTimeControl //IfcElectricTimeControlType //IfcElementAssembly //IfcElementAssemblyType //IfcElementComponent //IfcElementComponentType //IfcElementQuantity //IfcEllipseProfileDef NOT RV //IfcEnergyConversionDevice //IfcEnergyConversionDeviceType //IfcEngine //IfcEngineType //IfcEvaporativeCooler //IfcEvaporativeCoolerType //IfcEvaporator //IfcEvaporatorType //IfcExtendedProperties //IfcExternalInformation //IfcExternalReference //IfcExtrudedAreaSolidTapered NOT RV //IfcFace NOT RV //IfcFaceBasedSurfaceModel NOT RV //IfcFaceBound NOT RV //IfcFaceOuterBound NOT RV //IfcFaceSurface NOT RV //IfcFacetedBrep NOT RV //IfcFan //IfcFanType //IfcFastener //IfcFastenerType //IfcFeatureElement //IfcFeatureElementAddition NOT RV //IfcFeatureElementSubtraction //IfcFillAreaStyle //IfcFillAreaStyleHatching //IfcFilter //IfcFilterType //IfcFireSuppressionTerminal //IfcFireSuppressionTerminalType //IfcFixedReferenceSweptAreaSolid NOT RV //IfcFlowController //IfcFlowControllerType //IfcFlowFitting //IfcFlowFittingType //IfcFlowInstrument //IfcFlowInstrumentType //IfcFlowMeter //IfcFlowMeterType //IfcFlowMovingDevice //IfcFlowMovingDeviceType //IfcFlowSegment //IfcFlowSegmentType //IfcFlowStorageDevice //IfcFlowStorageDeviceType //IfcFlowTerminal //IfcFlowTerminalType //IfcFlowTreatmentDevice //IfcFlowTreatmentDeviceType //IfcFooting //IfcFootingType //IfcFurnishingElement //IfcFurnishingElementType //IfcFurniture //IfcFurnitureType //IfcGeographicElement //IfcGeographicElementType //IfcGeometricCurveSet //IfcGeometricSet //IfcGrid //IfcGridAxis //IfcGridPlacement NOT RV //IfcGroup //IfcHalfSpaceSolid NOT RV //IfcHeatExchanger //IfcHeatExchangerType //IfcHumidifier //IfcHumidifierType //IfcIndexedColourMap //IfcIndexedTextureMap //IfcIndexedTriangleTextureMap //IfcInterceptor //IfcInterceptorType //IfcIShapeProfileDef //IfcJunctionBox //IfcJunctionBoxType //IfcLamp //IfcLampType //IfcLibraryInformation NOT RV //IfcLibraryReference NOT RV //IfcLightFixture //IfcLightFixtureType //IfcLine //IfcLoop NOT RV //IfcLShapeProfileDef NOT RV //IfcMapConversion //IfcMappedItem //IfcMaterialConstituent //IfcMaterialConstituentSet //IfcMaterialLayer //IfcMaterialLayerSet //IfcMaterialLayerSetUsage NOT RV //IfcMaterialLayerWithOffsets NOT RV //IfcMaterialProfileSetUsage NOT RV //IfcMaterialProfileSetUsageTapering NOT RV //IfcMaterialProfileWithOffsets NOT RV //IfcMaterialUsageDefinition NOT RV //IfcMeasureWithUnit //IfcMechanicalFastener //IfcMechanicalFastenerType //IfcMedicalDevice //IfcMedicalDeviceType //IfcMember //IfcMemberStandardCase NOT RV //IfcMemberType //IfcMonetaryUnit //IfcMotorConnection //IfcMotorConnectionType //IfcNamedUnit //IfcOpeningElement //IfcOpeningStandardCase NOT RV //IfcOpenShell NOT RV //IfcOrientedEdge NOT RV //IfcOutlet //IfcOutletType //IfcPcurve NOT RV //IfcPhysicalComplexQuantity //IfcPhysicalQuantity //IfcPhysicalSimpleQuantity //IfcPile //IfcPileType //IfcPipeFitting //IfcPipeFittingType //IfcPipeSegment //IfcPipeSegmentType //IfcPlane NOT RV //IfcPlate //IfcPlateStandardCase NOT RV //IfcPlateType //IfcPoint //IfcPolygonalBoundedHalfSpace NOT RV //IfcPolyline NOT RV //IfcPolyLoop NOT RV //IfcPort //IfcPostalAddress //IfcPreDefinedPropertySet //IfcPresentationItem //IfcPresentationLayerAssignment //IfcPresentationStyle //IfcPresentationStyleAssignment //IfcProductDefinitionShape //IfcProductRepresentation //IfcProfileDef //IfcProfileProperties //IfcProjectedCRS //IfcProjectionElement NOT RV //IfcProperty //IfcPropertyAbstraction //IfcPropertyBoundedValue //IfcPropertyDefinition //IfcPropertyEnumeratedValue //IfcPropertyEnumeration //IfcPropertyListValue //IfcPropertySet //IfcPropertySetTemplate NOT RV //IfcPropertyTableValue //IfcPropertyTemplate NOT RV //IfcPropertyTemplateDefinition NOT RV //IfcProtectiveDevice //IfcProtectiveDeviceTrippingUnit //IfcProtectiveDeviceTrippingUnitType //IfcProtectiveDeviceType //IfcPump //IfcPumpType //IfcQuantityArea //IfcQuantityCount //IfcQuantityLength //IfcQuantitySet //IfcQuantityTime //IfcQuantityVolume //IfcQuantityWeight //IfcRailing //IfcRailingType //IfcRamp //IfcRampFlight //IfcRampFlightType //IfcRampType //IfcRectangleHollowProfileDef NOT RV //IfcRectangleProfileDef NOT RV //IfcRectangularPyramid NOT RV //IfcReinforcingBar //IfcReinforcingBarType //IfcReinforcingElement //IfcReinforcingElementType //IfcReinforcingMesh //IfcReinforcingMeshType //IfcRelAssignsToGroup //IfcRelAssociatesClassification //IfcRelAssociatesDocument //IfcRelAssociatesLibrary NOT RV //IfcRelAssociatesMaterial //IfcRelConnectsElements NOT RV //IfcRelConnectsPathElements NOT RV //IfcRelConnectsPorts //IfcRelConnectsWithRealizingElements NOT RV //IfcRelContainedInSpatialStructure //IfcRelCoversBldgElements //IfcRelDeclares //IfcRelDefinesByProperties //IfcRelFillsElement //IfcRelFlowControlElements NOT RV //IfcRelInterferesElements NOT RV //IfcRelNests //IfcRelProjectsElement NOT RV //IfcRelServicesBuildings //IfcRelVoidsElement //IfcRepresentation //IfcRepresentationContext //IfcRepresentationItem //IfcRepresentationMap //IfcRevolvedAreaSolid //IfcRevolvedAreaSolidTapered NOT RV //IfcRightCircularCone NOT RV //IfcRightCircularCylinder NOT RV //IfcRoof //IfcRoofType //IfcRoundedRectangleProfileDef NOT RV //IfcSanitaryTerminal //IfcSanitaryTerminalType //IfcSensor //IfcSensorType //IfcShadingDevice //IfcShadingDeviceType //IfcShapeRepresentation //IfcShellBasedSurfaceModel NOT RV //IfcSimplePropertyTemplate NOT RV //IfcSlab //IfcSlabElementedCase NOT RV //IfcSlabStandardCase NOT RV //IfcSlabType //IfcSolarDevice //IfcSolarDeviceType //IfcSpaceHeater //IfcSpaceHeaterType //IfcSpatialZone //IfcSpatialZoneType //IfcSphere NOT RV //IfcStackTerminal //IfcStackTerminalType //IfcStair //IfcStairFlight //IfcStairFlightType //IfcStairType //IfcStyleModel //IfcSurface NOT RV //IfcSurfaceCurveSweptAreaSolid NOT RV //IfcSurfaceOfLinearExtrusion NOT RV //IfcSurfaceOfRevolution NOT RV //IfcSurfaceStyleRendering //IfcSurfaceStyleWithTextures surfaceStyleWithTextures = new IfcSurfaceStyleWithTextures(new IfcImageTexture(db,true,true,"")); //IfcSweptDiskSolid //IfcSwitchingDevice //IfcSwitchingDeviceType //IfcSystemFurnitureElement //IfcSystemFurnitureElementType //IfcTank //IfcTankType //IfcTelecomAddress NOT RV //IfcTendon //IfcTendonAnchor //IfcTendonAnchorType //IfcTendonType //IfcTessellatedFaceSet //IfcTessellatedItem //IfcTextureCoordinate //IfcTextureVertexList //IfcTransformer //IfcTransformerType //IfcTransportElement //IfcTransportElementType //IfcTriangulatedFaceSet //IfcTrimmedCurve //IfcTShapeProfileDef NOT RV //IfcTubeBundle //IfcTubeBundleType //IfcUnitaryControlElement //IfcUnitaryControlElementType //IfcUnitaryEquipment //IfcUnitaryEquipmentType //IfcUShapeProfileDef NOT RV //IfcValve //IfcValveType //IfcVector //IfcVertex NOT RV //IfcVertexPoint NOT RV //IfcVibrationIsolator //IfcVibrationIsolatorType //IfcVirtualGridIntersection NOT RV //IfcWall //IfcWallElementedCase NOT RV //IfcWallStandardCase NOT RV //IfcWallType //IfcWasteTerminal //IfcWasteTerminalType //IfcWindow //IfcWindowLiningProperties //IfcWindowPanelProperties //IfcWindowStandardCase NOT RV //IfcWindowType //IfcZShapeProfileDef NOT RV db.WriteFile(Path.Combine(path, mdv.ToString() + ".ifc")); return(db); }
/// <summary> /// Write the model to IFC. /// </summary> /// <param name="model"></param> /// <param name="path">The path to the generated IFC STEP file.</param> public static void ToIFC(this Model model, string path) { var ifc = new Document("Elements", "Elements", Environment.UserName, null, null, null, "Elements", null, null, null, null, null, null, null, null ); var proj = ifc.AllInstancesOfType <IfcProject>().FirstOrDefault(); // Add a site var site = new IfcSite(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, "Hypar Site", "The default site generated by Hypar", null, null, null, null, IfcElementCompositionEnum.ELEMENT, new IfcCompoundPlaneAngleMeasure(new List <int> { 0, 0, 0 }), new IfcCompoundPlaneAngleMeasure(new List <int> { 0, 0, 0 }), 0, null, null); var projAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), proj, new List <IfcObjectDefinition> { site }); // Add building and building storey var building = new IfcBuilding(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, "Default Building", "The default building generated by Hypar.", null, null, null, null, IfcElementCompositionEnum.ELEMENT, 0, 0, null); var storey = new IfcBuildingStorey(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, "Default Storey", "The default storey generated by Hypar", null, null, null, null, IfcElementCompositionEnum.ELEMENT, 0); var aggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), building, new List <IfcObjectDefinition> { storey }); // Aggregate the building into the site var siteAggregate = new IfcRelAggregates(IfcGuid.ToIfcGuid(Guid.NewGuid()), site, new List <IfcObjectDefinition> { building }); ifc.AddEntity(site); ifc.AddEntity(projAggregate); ifc.AddEntity(building); ifc.AddEntity(storey); ifc.AddEntity(aggregate); ifc.AddEntity(siteAggregate); var products = new List <IfcProduct>(); var context = ifc.AllInstancesOfType <IfcGeometricRepresentationContext>().FirstOrDefault(); // IfcRelAssociatesMaterial // IfcMaterialDefinitionRepresentation // https://forums.buildingsmart.org/t/where-and-how-will-my-colors-be-saved-in-ifc/1806/12 var styleAssignments = new Dictionary <Guid, List <IfcStyleAssignmentSelect> >(); var white = Colors.White.ToIfcColourRgb(); ifc.AddEntity(white); // TODO: Fix color support in all applications. // https://forums.buildingsmart.org/t/why-is-it-so-difficult-to-get-colors-to-show-up/2312/12 foreach (var m in model.AllElementsOfType <Material>()) { var material = new IfcMaterial(m.Name, null, "Hypar"); ifc.AddEntity(material); var color = m.Color.ToIfcColourRgb(); ifc.AddEntity(color); var transparency = new IfcNormalisedRatioMeasure(1.0 - m.Color.Alpha); var shading = new IfcSurfaceStyleShading(color, transparency); ifc.AddEntity(shading); var styles = new List <IfcSurfaceStyleElementSelect> { new IfcSurfaceStyleElementSelect(shading), }; var surfaceStyle = new IfcSurfaceStyle(material.Name, IfcSurfaceSide.BOTH, styles); ifc.AddEntity(surfaceStyle); var styleAssign = new IfcStyleAssignmentSelect(surfaceStyle); var assignments = new List <IfcStyleAssignmentSelect>() { styleAssign }; styleAssignments.Add(m.Id, assignments); } foreach (var e in model.Elements.Values.Where(e => { var t = e.GetType(); return(((e is GeometricElement && !((GeometricElement)e).IsElementDefinition) || e is ElementInstance) && t != typeof(ModelCurve) && t != typeof(ModelPoints) && t != typeof(AnalysisMesh)); })) { try { products.AddRange(e.ToIfcProducts(context, ifc, styleAssignments)); } catch (Exception ex) { Console.WriteLine($"There was an error writing an element of type {e.GetType()} to IFC: " + ex.Message); Console.WriteLine(ex.StackTrace); continue; } } var spatialRel = new IfcRelContainedInSpatialStructure(IfcGuid.ToIfcGuid(Guid.NewGuid()), products, storey); ifc.AddEntity(spatialRel); if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, ifc.ToSTEP(path)); }
public static IfcExternallyDefinedSurfaceStyle GetExternallyDefinedSurfaceStyle(this IfcSurfaceStyle sStyle) { return(sStyle.Styles.OfType <IfcExternallyDefinedSurfaceStyle>().FirstOrDefault()); }
public static IfcSurfaceStyleWithTextures GetSurfaceStyleWithTextures(this IfcSurfaceStyle sStyle) { return(sStyle.Styles.OfType <IfcSurfaceStyleWithTextures>().FirstOrDefault()); }
public static IfcSurfaceStyleRefraction GetSurfaceStyleRefraction(this IfcSurfaceStyle sStyle) { return(sStyle.Styles.OfType <IfcSurfaceStyleRefraction>().FirstOrDefault()); }
public static IfcSurfaceStyleLighting GetSurfaceStyleLighting(this IfcSurfaceStyle sStyle) { return(sStyle.Styles.OfType <IfcSurfaceStyleLighting>().FirstOrDefault()); }
public XbimMeshLayer(XbimModel m, IfcSurfaceStyle style) { Model = m; Style = new XbimTexture().CreateTexture(style); }
public XbimColour(IfcSurfaceStyle style) { }
public static void loadProperties(IfcEntity ifcEntity, IfcProduct ifcProduct) { ifcEntity.ColorMethod = colorMethodType.byEntity; #region Identification ifcEntity.Identification.Add("Model", "nome del file"); ifcEntity.Identification.Add("Name", ifcProduct.Name); ifcEntity.Identification.Add("Type", ifcProduct.ObjectType); ifcEntity.Identification.Add("GUID", ifcProduct.GlobalId); ifcEntity.Identification.Add("KeyWord", ifcProduct.KeyWord); #endregion if (ifcProduct is IfcElement) { IfcElement ifcElement = (IfcElement)ifcProduct; #region Material if (ifcElement.MaterialSelect != null) { if (ifcElement.MaterialSelect is IfcMaterialLayerSetUsage) { IfcMaterialLayerSetUsage mlsu = (IfcMaterialLayerSetUsage)ifcElement.MaterialSelect; //foreach(IfcMaterialLayer ml in mlsu.ForLayerSet.MaterialLayers) IfcMaterialLayerSet mls = mlsu.ForLayerSet; for (int i = 0; i < mls.MaterialLayers.Count; i++) { ifcEntity.Material.Add(i + " " + mls.MaterialLayers[i].Material.Name, mls.MaterialLayers[i].LayerThickness); IfcMaterial ifcMaterial = mls.MaterialLayers[i].Material; if (ifcMaterial.HasRepresentation != null) { IfcMaterialDefinitionRepresentation imdr = ifcMaterial.HasRepresentation; foreach (IfcStyledRepresentation isr in imdr.Representations) { foreach (IfcStyledItem isi in isr.Items) { foreach (IfcPresentationStyleAssignment isas in isi.Styles) // se c'e' presentatio style direttamente { foreach (IfcPresentationStyle ips in isas.Styles) { if (ips is IfcSurfaceStyle) { IfcSurfaceStyle iss = (IfcSurfaceStyle)ips; foreach (var item in iss.Styles) { // vedere IFcSurfaceStyleElementSelect if (item is IfcSurfaceStyleRendering) { IfcSurfaceStyleRendering issr = (IfcSurfaceStyleRendering)item; int alpha = Convert.ToInt32((1 - issr.Transparency) * 255); ifcEntity.Color = Color.FromArgb(alpha, issr.SurfaceColour.Colour); ifcEntity.Identification.Add(i + "C" + mls.MaterialLayers[i].Material.Name, issr.SurfaceColour.Colour.ToString()); } } } else if (ips is IfcCurveStyle) { //ddgfdg } } } //IfcStyledItem ifcStyledItem = reprItem.mStyledByItem; //IfcStyleAssignmentSelect sas = (IfcPresentationStyleAssignment)ifcStyledItem.Styles[0]; //IfcSurfaceStyle ss = (IfcSurfaceStyle)sas.Styles[0]; //IfcSurfaceStyleRendering ssr = (IfcSurfaceStyleRendering)ss.Styles[0]; //color = ssr.SurfaceColour.Colour; } } } } } } } #endregion if (ifcEntity.Color == Color.Black) { Color color; if (defaultColor.TryGetValue(ifcProduct.KeyWord, out color)) { ifcEntity.Color = color; } //else //Debug.Write(ifcElement.KeyWord + " default color not set\n"); } }