use of org.bimserver.shared.interfaces.LowLevelInterface in project BIMserver by opensourceBIM.
the class TestSetWrappedIntegerGeometry method test.
@Test
public void test() {
try {
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
long tid = lowLevelInterface.startTransaction(newProject.getOid());
IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
bimServerClient.getLowLevelInterface().setWrappedLongAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcInteger", 12345L);
long roid = lowLevelInterface.commitTransaction(tid, "v2");
IfcModelInterface newModel = bimServerClient.getModel(newProject, roid, true, false, true);
SVector3f minBounds = newModel.getModelMetaData().getMinBounds();
SVector3f maxBounds = newModel.getModelMetaData().getMaxBounds();
org.junit.Assert.assertNotNull(minBounds);
org.junit.Assert.assertNotNull(maxBounds);
bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.shared.interfaces.LowLevelInterface in project BIMserver by opensourceBIM.
the class TestUnsetReference method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Start a transaction
Long tid = lowLevelInterface.startTransaction(newProject.getOid());
Long ifcRelContainedInSpatialStructureOid = lowLevelInterface.createObject(tid, "IfcRelContainedInSpatialStructure", true);
Long ifcBuildingOid = lowLevelInterface.createObject(tid, "IfcBuilding", true);
lowLevelInterface.setReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure", ifcBuildingOid);
lowLevelInterface.commitTransaction(tid, "Initial");
tid = lowLevelInterface.startTransaction(newProject.getOid());
lowLevelInterface.unsetReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure");
lowLevelInterface.commitTransaction(tid, "unset reference");
tid = lowLevelInterface.startTransaction(newProject.getOid());
if (lowLevelInterface.getReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure") != -1) {
fail("Relation should be unset");
}
lowLevelInterface.abortTransaction(tid);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.shared.interfaces.LowLevelInterface in project BIMserver by opensourceBIM.
the class TestCreateLists method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Start a transaction
Long tid = lowLevelInterface.startTransaction(newProject.getOid());
Long cartesianPointOid = lowLevelInterface.createObject(tid, "IfcCartesianPoint", false);
double firstVal = 5.1;
lowLevelInterface.addDoubleAttribute(tid, cartesianPointOid, "Coordinates", firstVal);
double secondVal = 6.2;
lowLevelInterface.addDoubleAttribute(tid, cartesianPointOid, "Coordinates", secondVal);
double thirdVal = 7.3;
lowLevelInterface.addDoubleAttribute(tid, cartesianPointOid, "Coordinates", thirdVal);
// Commit the transaction
lowLevelInterface.commitTransaction(tid, "test");
tid = lowLevelInterface.startTransaction(newProject.getOid());
List<Double> coordinates = lowLevelInterface.getDoubleAttributes(tid, cartesianPointOid, "Coordinates");
assertTrue(coordinates.get(0) == firstVal && coordinates.get(1) == secondVal && coordinates.get(2) == thirdVal);
tid = lowLevelInterface.startTransaction(newProject.getOid());
ArrayList<Double> al = new ArrayList<Double>();
al.add(1.0);
al.add(2.0);
al.add(3.0);
lowLevelInterface.setDoubleAttributes(tid, cartesianPointOid, "Coordinates", al);
lowLevelInterface.commitTransaction(tid, "replace");
tid = lowLevelInterface.startTransaction(newProject.getOid());
coordinates = lowLevelInterface.getDoubleAttributes(tid, cartesianPointOid, "Coordinates");
if (coordinates.size() != 3) {
fail("Coordinates size should be 3, it is " + coordinates.size());
}
assertTrue(coordinates.get(0) == 1.0 && coordinates.get(1) == 2.0 && coordinates.get(2) == 3.0);
tid = lowLevelInterface.startTransaction(newProject.getOid());
lowLevelInterface.setDoubleAttributeAtIndex(tid, cartesianPointOid, "Coordinates", 1, 5.0);
lowLevelInterface.commitTransaction(tid, "changed middle one");
tid = lowLevelInterface.startTransaction(newProject.getOid());
coordinates = lowLevelInterface.getDoubleAttributes(tid, cartesianPointOid, "Coordinates");
if (coordinates.size() != 3) {
fail("Coordinates size should be 3, it is " + coordinates.size());
}
assertTrue(coordinates.get(0) + ", " + coordinates.get(1) + ", " + coordinates.get(2), coordinates.get(0) == 1.0 && coordinates.get(1) == 5.0 && coordinates.get(2) == 3.0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.shared.interfaces.LowLevelInterface in project BIMserver by opensourceBIM.
the class TestGeometry method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Get the low level interface
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
// Create a new project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
long start = System.nanoTime();
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, Paths.get("D:\\Dropbox\\Shared\\IFC files\\ArenA 2014\\3D IFC\\arena.ifc"));
long end = System.nanoTime();
System.out.println(((end - start) / 1000000) + " ms");
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
int nrTriangles = 0;
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true, true);
Assert.assertNotNull(model.getModelMetaData().getMinBounds());
Assert.assertNotNull(model.getModelMetaData().getMaxBounds());
for (IfcProduct ifcProduct : model.getAllWithSubTypes(IfcProduct.class)) {
GeometryInfo geometryInfo = ifcProduct.getGeometry();
if (geometryInfo != null) {
Vector3f minBounds = geometryInfo.getMinBounds();
Vector3f maxBounds = geometryInfo.getMinBounds();
Assert.assertNotNull(minBounds);
Assert.assertNotNull(maxBounds);
nrTriangles += geometryInfo.getPrimitiveCount();
}
}
Assert.assertEquals(45260, nrTriangles);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.shared.interfaces.LowLevelInterface in project BIMserver by opensourceBIM.
the class TestRemoveObject method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Start a transaction
Long tid = lowLevelInterface.startTransaction(newProject.getOid());
Long ifcRelContainedInSpatialStructureOid = lowLevelInterface.createObject(tid, "IfcRelContainedInSpatialStructure", true);
Long ifcBuildingOid = lowLevelInterface.createObject(tid, "IfcBuilding", true);
lowLevelInterface.addReference(tid, ifcBuildingOid, "ContainsElements", ifcRelContainedInSpatialStructureOid);
lowLevelInterface.commitTransaction(tid, "Initial");
tid = lowLevelInterface.startTransaction(newProject.getOid());
lowLevelInterface.removeObject(tid, ifcBuildingOid);
lowLevelInterface.commitTransaction(tid, "removed");
tid = lowLevelInterface.startTransaction(newProject.getOid());
long reference = lowLevelInterface.getReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure");
if (reference != -1) {
fail("Should be unset (is " + reference + ")");
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations