Search in sources :

Example 1 with IfcUnitAssignment

use of org.bimserver.models.ifc2x3tc1.IfcUnitAssignment 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;
}
Also used : IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) IfcUnitAssignment(org.bimserver.models.ifc2x3tc1.IfcUnitAssignment) IfcSIUnit(org.bimserver.models.ifc2x3tc1.IfcSIUnit) IfcUnitEnum(org.bimserver.models.ifc2x3tc1.IfcUnitEnum) IfcUnit(org.bimserver.models.ifc2x3tc1.IfcUnit) IfcSIPrefix(org.bimserver.models.ifc2x3tc1.IfcSIPrefix)

Example 2 with IfcUnitAssignment

use of org.bimserver.models.ifc2x3tc1.IfcUnitAssignment in project BIMserver by opensourceBIM.

the class RichIfcModel method createDefaultProjectStructure.

public IfcBuilding createDefaultProjectStructure() throws IfcModelInterfaceException {
    IfcPerson person = create(IfcPerson.class);
    IfcOrganization organization = create(IfcOrganization.class);
    organization.setName("Required");
    IfcPersonAndOrganization owningUser = create(IfcPersonAndOrganization.class);
    owningUser.setTheOrganization(organization);
    owningUser.setThePerson(person);
    IfcOrganization developer = create(IfcOrganization.class);
    developer.setName("Required");
    IfcApplication application = create(IfcApplication.class);
    application.setApplicationDeveloper(developer);
    application.setApplicationFullName("Required");
    application.setApplicationIdentifier("Required");
    application.setVersion("1.0");
    IfcOwnerHistory ownerHistory = create(IfcOwnerHistory.class);
    ownerHistory.setChangeAction(IfcChangeActionEnum.ADDED);
    ownerHistory.setCreationDate(System.currentTimeMillis() / 1000);
    ownerHistory.setOwningApplication(application);
    ownerHistory.setOwningUser(owningUser);
    setDefaultOwnerHistory(ownerHistory);
    IfcAxis2Placement3D contextAxisPlacement = create(IfcAxis2Placement3D.class);
    contextAxisPlacement.setLocation(createIfcCartesianPoint(0, 0, 0));
    IfcGeometricRepresentationContext representationContext = create(IfcGeometricRepresentationContext.class);
    representationContext.setCoordinateSpaceDimension(3);
    representationContext.setPrecision(0.00001);
    representationContext.setWorldCoordinateSystem(contextAxisPlacement);
    representationContext.setContextType("Model");
    setDefaultRepresentationContext(representationContext);
    IfcUnitAssignment ifcUnitAssigment = create(IfcUnitAssignment.class);
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.MILLI, IfcSIUnitName.METRE));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.VOLUMEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.CUBIC_METRE));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.PLANEANGLEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.RADIAN));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.SOLIDANGLEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.STERADIAN));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.MASSUNIT, IfcSIPrefix.NULL, IfcSIUnitName.GRAM));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.SECOND));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT, IfcSIPrefix.NULL, IfcSIUnitName.DEGREE_CELSIUS));
    ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.LUMINOUSINTENSITYUNIT, IfcSIPrefix.NULL, IfcSIUnitName.LUMEN));
    IfcProject ifcProject = create(IfcProject.class);
    ifcProject.getRepresentationContexts().add(representationContext);
    ifcProject.setUnitsInContext(ifcUnitAssigment);
    ifcProject.setName("Demo Project");
    IfcSite ifcSite = create(IfcSite.class);
    ifcSite.setCompositionType(IfcElementCompositionEnum.ELEMENT);
    ifcSite.setName("Default site");
    IfcBuilding ifcBuilding = create(IfcBuilding.class);
    ifcBuilding.setCompositionType(IfcElementCompositionEnum.ELEMENT);
    ifcBuilding.setName("Default building");
    addDecomposes(ifcProject, ifcSite);
    addDecomposes(ifcSite, ifcBuilding);
    return ifcBuilding;
}
Also used : IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) IfcOrganization(org.bimserver.models.ifc2x3tc1.IfcOrganization) IfcSite(org.bimserver.models.ifc2x3tc1.IfcSite) IfcUnitAssignment(org.bimserver.models.ifc2x3tc1.IfcUnitAssignment) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcGeometricRepresentationContext(org.bimserver.models.ifc2x3tc1.IfcGeometricRepresentationContext) IfcPerson(org.bimserver.models.ifc2x3tc1.IfcPerson) IfcApplication(org.bimserver.models.ifc2x3tc1.IfcApplication) IfcOwnerHistory(org.bimserver.models.ifc2x3tc1.IfcOwnerHistory) IfcPersonAndOrganization(org.bimserver.models.ifc2x3tc1.IfcPersonAndOrganization) IfcBuilding(org.bimserver.models.ifc2x3tc1.IfcBuilding)

Aggregations

IfcProject (org.bimserver.models.ifc2x3tc1.IfcProject)2 IfcUnitAssignment (org.bimserver.models.ifc2x3tc1.IfcUnitAssignment)2 IfcApplication (org.bimserver.models.ifc2x3tc1.IfcApplication)1 IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)1 IfcBuilding (org.bimserver.models.ifc2x3tc1.IfcBuilding)1 IfcGeometricRepresentationContext (org.bimserver.models.ifc2x3tc1.IfcGeometricRepresentationContext)1 IfcOrganization (org.bimserver.models.ifc2x3tc1.IfcOrganization)1 IfcOwnerHistory (org.bimserver.models.ifc2x3tc1.IfcOwnerHistory)1 IfcPerson (org.bimserver.models.ifc2x3tc1.IfcPerson)1 IfcPersonAndOrganization (org.bimserver.models.ifc2x3tc1.IfcPersonAndOrganization)1 IfcSIPrefix (org.bimserver.models.ifc2x3tc1.IfcSIPrefix)1 IfcSIUnit (org.bimserver.models.ifc2x3tc1.IfcSIUnit)1 IfcSite (org.bimserver.models.ifc2x3tc1.IfcSite)1 IfcUnit (org.bimserver.models.ifc2x3tc1.IfcUnit)1 IfcUnitEnum (org.bimserver.models.ifc2x3tc1.IfcUnitEnum)1