use of org.bimserver.models.geometry.Buffer in project BIMserver by opensourceBIM.
the class TestChangeGeometryError 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");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
bimServerClient.checkinSync(newProject.getOid(), "test", deserializer.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, true, true);
List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
IfcWall firstWall = walls.get(0);
Buffer buffer = GeometryFactory.eINSTANCE.createBuffer();
buffer.setData(new byte[10]);
firstWall.getGeometry().getData().setVertices(buffer);
model.commit("Tried to change geometry, which should not be possible");
fail("This have thrown an error");
} catch (Throwable e) {
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
e.printStackTrace();
assertEquals("Only objects from the following schemas are allowed to be changed: Ifc2x3tc1 and IFC4, this object (GeometryData) is from the \"geometry\" package", e.getMessage());
}
}
use of org.bimserver.models.geometry.Buffer in project BIMserver by opensourceBIM.
the class OfflineGeometryGenerator method createBuffer.
private Buffer createBuffer(ByteBuffer data) {
Buffer buffer = GeometryFactory.eINSTANCE.createBuffer();
buffer.setData(data.array());
return buffer;
}
use of org.bimserver.models.geometry.Buffer in project BIMserver by opensourceBIM.
the class GeometryGenerator method createBuffer.
private Buffer createBuffer(IfcModelInterface model, DatabaseSession databaseSession, ByteBuffer data, boolean store, int pid, int rid) throws ObjectAlreadyExistsException, IfcModelInterfaceException, BimserverDatabaseException {
Buffer buffer = null;
if (store) {
buffer = model.createAndAdd(GeometryPackage.eINSTANCE.getBuffer(), databaseSession.newOid(GeometryPackage.eINSTANCE.getBuffer()));
databaseSession.store(buffer, pid, rid);
} else {
buffer = GeometryFactory.eINSTANCE.createBuffer();
}
buffer.setData(data.array());
return buffer;
}
use of org.bimserver.models.geometry.Buffer in project BIMserver by opensourceBIM.
the class StreamingCheckinDatabaseAction method generateQuantizedVertices.
private void generateQuantizedVertices(DatabaseSession databaseSession, Revision revision, float[] quantizationMatrix, float multiplierToMm) {
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
Query query = new Query(packageMetaData);
QueryPart queryPart = query.createQueryPart();
queryPart.addType(GeometryPackage.eINSTANCE.getGeometryData(), false);
Include geometryDataInclude = queryPart.createInclude();
try {
geometryDataInclude.addType(GeometryPackage.eINSTANCE.getGeometryData(), false);
geometryDataInclude.addFieldDirect("vertices");
QueryObjectProvider objectProvider = new QueryObjectProvider(getDatabaseSession(), getBimServer(), query, Collections.singleton(revision.getOid()), packageMetaData);
HashMapVirtualObject next = objectProvider.next();
while (next != null) {
HashMapVirtualObject verticesBuffer = (HashMapVirtualObject) next.get("vertices");
ByteBuffer verticesData = ByteBuffer.wrap((byte[]) verticesBuffer.get("data"));
verticesData.order(ByteOrder.LITTLE_ENDIAN);
FloatBuffer vertices = verticesData.asFloatBuffer();
ByteBuffer verticesQuantized = quantizeVertices(vertices.array(), quantizationMatrix, multiplierToMm);
Buffer buffer = getDatabaseSession().create(Buffer.class);
buffer.setData(verticesQuantized.array());
next.setReference(GeometryPackage.eINSTANCE.getGeometryData_VerticesQuantized(), buffer.getOid(), -1);
next.saveOverwrite();
next = objectProvider.next();
System.out.println("Generating quantized vertices");
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
Aggregations