Search in sources :

Example 6 with IfcAxis2Placement3D

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

the class RichIfcModel method createBasicPosition.

public IfcAxis2Placement3D createBasicPosition(int i, int j, int k) throws IfcModelInterfaceException {
    IfcAxis2Placement3D axisPlacement = create(IfcAxis2Placement3D.class);
    axisPlacement.setLocation(createIfcCartesianPoint(i, j, k));
    IfcDirection axis = createDirection(0, 0, 1);
    IfcDirection direction = createDirection(1, 0, 0);
    axisPlacement.setAxis(axis);
    axisPlacement.setRefDirection(direction);
    return axisPlacement;
}
Also used : IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcDirection(org.bimserver.models.ifc2x3tc1.IfcDirection)

Example 7 with IfcAxis2Placement3D

use of org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D 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)

Example 8 with IfcAxis2Placement3D

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

the class TestMoveObject method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        // Checkin the file
        bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project info
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
        for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
            IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
            if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
                IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
                IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
                if (relativePlacement != null) {
                    if (relativePlacement instanceof IfcAxis2Placement3D) {
                        IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
                        IfcCartesianPoint location = axis2Placement3D.getLocation();
                        double newValue = location.getCoordinates().get(2) + 50;
                        System.out.println("Changing z value of " + ifcFurnishingElement.getName() + " from " + location.getCoordinates().get(2) + " to " + newValue);
                        location.getCoordinates().set(2, newValue);
                    }
                }
            }
        }
        long newRoid = model.commit("Moved all furniture 50 meters up");
        SSerializerPluginConfiguration ifcSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
        bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) URL(java.net.URL) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IfcAxis2Placement(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement) Test(org.junit.Test)

Aggregations

IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)8 IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)5 IfcCartesianPoint (org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)4 IfcAxis2Placement (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)3 IfcFurnishingElement (org.bimserver.models.ifc2x3tc1.IfcFurnishingElement)3 IfcObjectPlacement (org.bimserver.models.ifc2x3tc1.IfcObjectPlacement)3 IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 IfcDirection (org.bimserver.models.ifc2x3tc1.IfcDirection)2 IfcOwnerHistory (org.bimserver.models.ifc2x3tc1.IfcOwnerHistory)2 Area (java.awt.geom.Area)1 Path2D (java.awt.geom.Path2D)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URL (java.net.URL)1 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SProject (org.bimserver.interfaces.objects.SProject)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 IfcApplication (org.bimserver.models.ifc2x3tc1.IfcApplication)1 IfcArbitraryClosedProfileDef (org.bimserver.models.ifc2x3tc1.IfcArbitraryClosedProfileDef)1