use of org.bimserver.models.ifc2x3tc1.IfcUnit in project BIMserver by opensourceBIM.
the class IfcUtils method getLengthUnitPrefix.
public static float getLengthUnitPrefix(IfcModelInterface model) {
float lengthUnitPrefix = 1.0f;
boolean prefixFound = false;
for (IfcProject ifcProject : model.getAll(IfcProject.class)) {
IfcUnitAssignment unitsInContext = ifcProject.getUnitsInContext();
if (unitsInContext != null) {
EList<IfcUnit> units = unitsInContext.getUnits();
for (IfcUnit unit : units) {
if (unit instanceof IfcSIUnit) {
IfcSIUnit ifcSIUnit = (IfcSIUnit) unit;
IfcUnitEnum unitType = ifcSIUnit.getUnitType();
if (unitType == IfcUnitEnum.LENGTHUNIT) {
IfcSIPrefix prefix = ifcSIUnit.getPrefix();
if (prefix != null) {
prefixFound = true;
switch(prefix) {
case EXA:
lengthUnitPrefix = 1.0e18f;
break;
case PETA:
lengthUnitPrefix = 1.0e15f;
break;
case TERA:
lengthUnitPrefix = 1.0e12f;
break;
case GIGA:
lengthUnitPrefix = 1.0e9f;
break;
case MEGA:
lengthUnitPrefix = 1.0e6f;
break;
case KILO:
lengthUnitPrefix = 1.0e3f;
break;
case HECTO:
lengthUnitPrefix = 1.0e2f;
break;
case DECA:
lengthUnitPrefix = 1.0e1f;
break;
case DECI:
lengthUnitPrefix = 1.0e-1f;
break;
case CENTI:
lengthUnitPrefix = 1.0e-2f;
break;
case MILLI:
lengthUnitPrefix = 1.0e-3f;
break;
case MICRO:
lengthUnitPrefix = 1.0e-6f;
break;
case NANO:
lengthUnitPrefix = 1.0e-9f;
break;
case PICO:
lengthUnitPrefix = 1.0e-12f;
break;
case FEMTO:
lengthUnitPrefix = 1.0e-15f;
break;
case ATTO:
lengthUnitPrefix = 1.0e-18f;
break;
case NULL:
break;
}
break;
}
}
}
}
}
if (prefixFound)
break;
}
return lengthUnitPrefix;
}
use of org.bimserver.models.ifc2x3tc1.IfcUnit in project BIMserver by opensourceBIM.
the class RichIfcModel method createIfcSiUnit.
public IfcUnit createIfcSiUnit(IfcUnitEnum lengthunit, IfcSIPrefix milli, IfcSIUnitName metre) throws IfcModelInterfaceException {
IfcSIUnit ifcSIUnit = create(IfcSIUnit.class);
ifcSIUnit.setName(metre);
ifcSIUnit.setPrefix(milli);
ifcSIUnit.setUnitType(lengthunit);
return ifcSIUnit;
}
Aggregations