Search in sources :

Example 1 with GeometryTargetImpl

use of org.bimserver.client.GeometryTargetImpl in project BIMserver by opensourceBIM.

the class TestGetGeometry method test.

@Test
public void test() throws Exception {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/export1.ifc");
            SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, (title, progress) -> System.out.println(title + ": " + progress));
            PackageMetaData packageMetaData = client.getMetaDataManager().getPackageMetaData("ifc2x3tc1");
            GeometryTargetImpl geometryTargetImpl = new GeometryTargetImpl(packageMetaData);
            GeometryLoader geometryLoader = new GeometryLoader(client, packageMetaData, geometryTargetImpl);
            Set<Long> oids = new HashSet<>();
            // Only to gather oids
            ClientIfcModel model = client.getModel(project, actionState.getRoid(), true, false, false);
            for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
                oids.add(ifcWall.getOid());
            }
            geometryLoader.loadProducts(actionState.getRoid(), oids);
            System.out.println(geometryTargetImpl);
            Set<Long> geometryDataOids = new HashSet<>();
            for (GeometryInfo geometryInfo : geometryTargetImpl.getAllGeometryInfo()) {
                GeometryData geometryData = geometryInfo.getData();
                System.out.println(geometryInfo.getPrimitiveCount());
                System.out.println(geometryData.getNrIndices());
                geometryDataOids.add(geometryData.getOid());
            }
            geometryTargetImpl = new GeometryTargetImpl(packageMetaData);
            geometryLoader = new GeometryLoader(client, packageMetaData, geometryTargetImpl);
            geometryLoader.loadGeometryData(actionState.getRoid(), geometryDataOids);
            System.out.println(geometryTargetImpl);
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) GeometryTargetImpl(org.bimserver.client.GeometryTargetImpl) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) PackageMetaData(org.bimserver.emf.PackageMetaData) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) GeometryData(org.bimserver.models.geometry.GeometryData) SProject(org.bimserver.interfaces.objects.SProject) GeometryLoader(org.bimserver.client.GeometryLoader) BimServerClient(org.bimserver.client.BimServerClient) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 BimServerClient (org.bimserver.client.BimServerClient)1 ClientIfcModel (org.bimserver.client.ClientIfcModel)1 GeometryLoader (org.bimserver.client.GeometryLoader)1 GeometryTargetImpl (org.bimserver.client.GeometryTargetImpl)1 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)1 PackageMetaData (org.bimserver.emf.PackageMetaData)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SLongCheckinActionState (org.bimserver.interfaces.objects.SLongCheckinActionState)1 SProject (org.bimserver.interfaces.objects.SProject)1 GeometryData (org.bimserver.models.geometry.GeometryData)1 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)1 IfcWall (org.bimserver.models.ifc2x3tc1.IfcWall)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 Test (org.junit.Test)1