/// <summary> /// set the second unit, used for time duration units /// </summary> private void SetSecondUnit() { if (_secondUnit == null) { _secondUnit = Model.Instances.New <IfcSIUnit>(si => { si.UnitType = IfcUnitEnum.TIMEUNIT; si.Prefix = null; si.Name = IfcSIUnitName.SECOND; }); } if (_dimensionalExponents == null) { _dimensionalExponents = Model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 1; de.MassExponent = 1; de.TimeExponent = 1; de.ElectricCurrentExponent = 1; de.ThermodynamicTemperatureExponent = 1; de.AmountOfSubstanceExponent = 1; de.LuminousIntensityExponent = 1; }); } }
public IfcSIUnit(IfcUnitEnum unitType, IfcSIUnitName name) { Dimensions = new IfcDimensionalExponents(); Dimensions.IsDerived = true; UnitType = unitType; Name = name; }
private IfcDimensionalExponents GetOrCreateExponents(IList <int> exponents) { var result = Model.Instances.FirstOrDefault <IfcDimensionalExponents>(e => e.LengthExponent == exponents[0] && e.MassExponent == exponents[1] && e.TimeExponent == exponents[2] && e.ElectricCurrentExponent == exponents[3] && e.ThermodynamicTemperatureExponent == exponents[4] && e.AmountOfSubstanceExponent == exponents[5] && e.LuminousIntensityExponent == exponents[6] ); if (result != null) { return(result); } result = new IfcDimensionalExponents(null, -1, true); for (var i = 0; i < 7; i++) { result.Parse(i, new PropVal(exponents[i]), null); } return(result); }
public void Reset() { Contacts.Clear(); _ifcConversionBasedUnitYear = null; _ifcConversionBasedUnitMonth = null; _ifcConversionBasedUnitWeek = null; _secondUnit = null; _dimensionalExponents = null; WorkBook = null; }
internal static bool IfcCorrectDimensions(IfcUnitEnum unitType, IfcDimensionalExponents dimensions) { var val = NullableIfcCorrectDimensions(unitType, dimensions); if (!val.HasValue) { throw new ArgumentException("Undetermined value in where clause."); } return(val.Value); }
private bool Equals(IfcDimensionalExponents a, IfcDimensionalExponents b) { for (int i = 0; i < 7; i++) { if (a[i] != b[i]) { return(false); } } return(true); }
private static IfcDimensionalExponents GetMassDimension(IModel model) { IfcDimensionalExponents dimension = model.Instances.New <IfcDimensionalExponents>(); dimension.AmountOfSubstanceExponent = 0; dimension.ElectricCurrentExponent = 0; dimension.LengthExponent = 0; dimension.LuminousIntensityExponent = 0; dimension.MassExponent = 1; dimension.ThermodynamicTemperatureExponent = 0; dimension.TimeExponent = 0; return(dimension); }
private static void SetConversionUnitsParameters(IModel model, IfcConversionBasedUnit unit, IfcLabel name, IfcRatioMeasure ratio, IfcUnitEnum unitType, IfcSIUnitName siUnitName, IfcSIPrefix?siUnitPrefix, IfcDimensionalExponents dimensions) { unit.Name = name; unit.ConversionFactor = model.Instances.New <IfcMeasureWithUnit>(); unit.ConversionFactor.ValueComponent = ratio; unit.ConversionFactor.UnitComponent = model.Instances.New <IfcSIUnit>(s => { s.UnitType = unitType; s.Name = siUnitName; s.Prefix = siUnitPrefix; }); unit.Dimensions = dimensions; }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: _dimensions = (IfcDimensionalExponents)(value.EntityVal); return; case 1: _unitType = (IfcUnitEnum)System.Enum.Parse(typeof(IfcUnitEnum), value.EnumVal, true); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
/// <summary> /// Creates an IfcUnit from the this object and adds it to the database, only works for SI at the moment /// </summary> /// <param name="units"></param> /// <param name="model"></param> /// <returns></returns> public IfcUnit IfcUnit(Dictionary <string, IfcUnit> units, XbimModel model) { if (SiUnitName == null) { return(null); } IfcUnit unit; var key = SiPrefix.HasValue? SiPrefix.Value.ToString() :""; key += SiUnitName.Value; if (units.TryGetValue(key, out unit)) { return(unit); } var siUnit = model.Instances.New <IfcSIUnit>(); siUnit.Name = SiUnitName.Value; siUnit.Prefix = SiPrefix; siUnit.UnitType = UnitName; siUnit.Dimensions = IfcDimensionalExponents.DimensionsForSiUnit(SiUnitName.Value); units.Add(key, siUnit); return(siUnit); }
private static bool?NullableIfcCorrectDimensions(IfcUnitEnum m, IfcDimensionalExponents Dim) { switch (m) { case IfcUnitEnum.LENGTHUNIT: if ( HasIfcDimensionalExponents(Dim, 1, 0, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.MASSUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 1, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.TIMEUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 1, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICCURRENTUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 1, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 1, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.AMOUNTOFSUBSTANCEUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 0, 1, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.LUMINOUSINTENSITYUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 0, 0, 1) ) { return(true); } else { return(false); } case IfcUnitEnum.PLANEANGLEUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.SOLIDANGLEUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.AREAUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 0, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.VOLUMEUNIT: if ( HasIfcDimensionalExponents(Dim, 3, 0, 0, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ABSORBEDDOSEUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 0, -2, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.RADIOACTIVITYUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, -1, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICCAPACITANCEUNIT: if ( HasIfcDimensionalExponents(Dim, -2, -1, 4, 2, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.DOSEEQUIVALENTUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 0, -2, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICCHARGEUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 1, 1, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICCONDUCTANCEUNIT: if ( HasIfcDimensionalExponents(Dim, -2, -1, 3, 2, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICVOLTAGEUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -3, -1, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ELECTRICRESISTANCEUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -3, -2, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ENERGYUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -2, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.FORCEUNIT: if ( HasIfcDimensionalExponents(Dim, 1, 1, -2, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.FREQUENCYUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, -1, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.INDUCTANCEUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -2, -2, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.ILLUMINANCEUNIT: if ( HasIfcDimensionalExponents(Dim, -2, 0, 0, 0, 0, 0, 1) ) { return(true); } else { return(false); } case IfcUnitEnum.LUMINOUSFLUXUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 0, 0, 0, 0, 0, 1) ) { return(true); } else { return(false); } case IfcUnitEnum.MAGNETICFLUXUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -2, -1, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.MAGNETICFLUXDENSITYUNIT: if ( HasIfcDimensionalExponents(Dim, 0, 1, -2, -1, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.POWERUNIT: if ( HasIfcDimensionalExponents(Dim, 2, 1, -3, 0, 0, 0, 0) ) { return(true); } else { return(false); } case IfcUnitEnum.PRESSUREUNIT: if ( HasIfcDimensionalExponents(Dim, -1, 1, -2, 0, 0, 0, 0) ) { return(true); } else { return(false); } default: return(null); } }
public Model(IDictionary <Guid, BaseIfc> storage, string name, string description, IfcAddress address, IfcPerson user, IfcOrganization owner) { this.storage = storage; this.storage.Add(address.Id, address); this.storage.Add(user.Id, user); this.storage.Add(owner.Id, owner); // Create an organization for app creation. var appOrg = new IfcOrganization(APPNAME); this.storage.Add(appOrg.Id, appOrg); // Create an authoring application. var v = owner.GetType().Assembly.GetName().Version.ToString(); var app = new IfcApplication(appOrg, v, APPNAME, APPNAME); this.storage.Add(app.Id, app); // Create an person and history for the owner history. var personAndOrg = new IfcPersonAndOrganization(user, owner); this.storage.Add(personAndOrg.Id, personAndOrg); // Create an owner history for the project. var history = new IfcOwnerHistory(personAndOrg, app, UnixNow()); this.storage.Add(history.Id, history); var lu = new IfcSIUnit(null, IfcUnitEnum.LENGTHUNIT, IfcSIUnitName.METRE); this.storage.Add(lu.Id, lu); var lengthUnit = new IfcUnit(lu); var au = new IfcSIUnit(null, IfcUnitEnum.AREAUNIT, IfcSIUnitName.SQUARE_METRE); this.storage.Add(au.Id, au); var areaUnit = new IfcUnit(au); var vu = new IfcSIUnit(null, IfcUnitEnum.VOLUMEUNIT, IfcSIUnitName.CUBIC_METRE); this.storage.Add(vu.Id, vu); var volumeUnit = new IfcUnit(vu); var sau = new IfcSIUnit(null, IfcUnitEnum.SOLIDANGLEUNIT, IfcSIUnitName.STERADIAN); this.storage.Add(sau.Id, sau); var solidAngleUnit = new IfcUnit(sau); var mu = new IfcSIUnit(null, IfcUnitEnum.MASSUNIT, IfcSIUnitName.GRAM); this.storage.Add(mu.Id, mu); var massUnit = new IfcUnit(mu); var tu = new IfcSIUnit(null, IfcUnitEnum.TIMEUNIT, IfcSIUnitName.SECOND); this.storage.Add(tu.Id, tu); var timeUnit = new IfcUnit(tu); var thu = new IfcSIUnit(null, IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT, IfcSIUnitName.DEGREE_CELSIUS); this.storage.Add(thu.Id, thu); var thermUnit = new IfcUnit(thu); var lmu = new IfcSIUnit(null, IfcUnitEnum.LUMINOUSINTENSITYUNIT, IfcSIUnitName.LUMEN); this.storage.Add(lmu.Id, lmu); var lumUnit = new IfcUnit(lmu); var pau = new IfcSIUnit(null, IfcUnitEnum.PLANEANGLEUNIT, IfcSIUnitName.RADIAN); this.storage.Add(pau.Id, pau); var planeAngleUnit = new IfcUnit(pau); var measure = new IfcMeasureWithUnit(new IfcValue(new IfcMeasureValue(new IfcPlaneAngleMeasure(1.745e-2))), planeAngleUnit); this.storage.Add(measure.Id, measure); var dimExp = new IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0); this.storage.Add(dimExp.Id, dimExp); var du = new IfcConversionBasedUnit(dimExp, IfcUnitEnum.PLANEANGLEUNIT, "DEGREE", measure); this.storage.Add(du.Id, du); var degree = new IfcUnit(du); var units = new List <IfcUnit> { lengthUnit, areaUnit, volumeUnit, solidAngleUnit, massUnit, timeUnit, thermUnit, lumUnit, planeAngleUnit, degree }; var unitAss = new IfcUnitAssignment(units); this.storage.Add(unitAss.Id, unitAss); // Create the project. var proj = new IfcProject(IfcGuid.ToIfcGuid(Guid.NewGuid()), history, name, description, null, null, null, null, unitAss); this.storage.Add(proj.Id, proj); }