use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.
the class Region method toSBounds.
public SBounds toSBounds() {
SBounds sBounds = new SBounds();
SVector3f min = new SVector3f();
SVector3f max = new SVector3f();
min.setX(this.min[0]);
min.setY(this.min[1]);
min.setZ(this.min[2]);
max.setX(this.max[0]);
max.setY(this.max[1]);
max.setZ(this.max[2]);
sBounds.setMin(min);
sBounds.setMax(max);
return sBounds;
}
use of org.bimserver.interfaces.objects.SVector3f 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.checkinSync(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, 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", false);
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.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.
the class ServiceImpl method getTotalUntransformedBounds.
@Override
public SBounds getTotalUntransformedBounds(Set<Long> roids) throws ServerException, UserException {
// TODO duplicate code with getTotalBounds
try (DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY)) {
double[] totalMin = new double[] { Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE };
double[] totalMax = new double[] { -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE };
for (Long roid : roids) {
Revision revision = session.get(roid, OldQuery.getDefault());
Bounds bounds = revision.getBoundsUntransformedMm();
if (bounds.getMin().getX() == Double.MAX_VALUE || bounds.getMin().getY() == Double.MAX_VALUE || bounds.getMin().getZ() == Double.MAX_VALUE || bounds.getMax().getX() == -Double.MAX_VALUE || bounds.getMax().getY() == -Double.MAX_VALUE || bounds.getMax().getZ() == -Double.MAX_VALUE) {
// Probably no objects or weird error, let's skip this one
continue;
}
Vector3f min = bounds.getMin();
Vector3f max = bounds.getMax();
if (min.getX() < totalMin[0]) {
totalMin[0] = min.getX();
}
if (min.getY() < totalMin[1]) {
totalMin[1] = min.getY();
}
if (min.getZ() < totalMin[2]) {
totalMin[2] = min.getZ();
}
if (max.getX() > totalMax[0]) {
totalMax[0] = max.getX();
}
if (max.getY() > totalMax[1]) {
totalMax[1] = max.getY();
}
if (max.getZ() > totalMax[2]) {
totalMax[2] = max.getZ();
}
}
SBounds sBounds = new SBounds();
SVector3f sMin = new SVector3f();
SVector3f sMax = new SVector3f();
sBounds.setMin(sMin);
sBounds.setMax(sMax);
sMin.setX(totalMin[0]);
sMin.setY(totalMin[1]);
sMin.setZ(totalMin[2]);
sMax.setX(totalMax[0]);
sMax.setY(totalMax[1]);
sMax.setZ(totalMax[2]);
return sBounds;
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.
the class Bounds method toSBounds.
public SBounds toSBounds() {
SBounds bounds = new SBounds();
SVector3f min = new SVector3f();
min.setX(getMinX());
min.setY(getMinY());
min.setZ(getMinZ());
SVector3f max = new SVector3f();
max.setX(getMaxX());
max.setY(getMaxY());
max.setZ(getMaxZ());
bounds.setMin(min);
bounds.setMax(max);
return bounds;
}
use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.
the class ServiceImpl method getTotalBounds.
@Override
public SBounds getTotalBounds(Set<Long> roids) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
double[] totalMin = new double[] { Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE };
double[] totalMax = new double[] { -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE };
for (Long roid : roids) {
Revision revision = session.get(roid, OldQuery.getDefault());
Bounds bounds = revision.getBoundsMm();
if (bounds.getMin().getX() == Double.MAX_VALUE || bounds.getMin().getY() == Double.MAX_VALUE || bounds.getMin().getZ() == Double.MAX_VALUE || bounds.getMax().getX() == -Double.MAX_VALUE || bounds.getMax().getY() == -Double.MAX_VALUE || bounds.getMax().getZ() == -Double.MAX_VALUE) {
// Probably no objects or weird error, let's skip this one
continue;
}
Vector3f min = bounds.getMin();
Vector3f max = bounds.getMax();
// }
if (min.getX() < totalMin[0]) {
totalMin[0] = min.getX();
}
if (min.getY() < totalMin[1]) {
totalMin[1] = min.getY();
}
if (min.getZ() < totalMin[2]) {
totalMin[2] = min.getZ();
}
if (max.getX() > totalMax[0]) {
totalMax[0] = max.getX();
}
if (max.getY() > totalMax[1]) {
totalMax[1] = max.getY();
}
if (max.getZ() > totalMax[2]) {
totalMax[2] = max.getZ();
}
}
SBounds sBounds = new SBounds();
SVector3f sMin = new SVector3f();
SVector3f sMax = new SVector3f();
sBounds.setMin(sMin);
sBounds.setMax(sMax);
sMin.setX(totalMin[0]);
sMin.setY(totalMin[1]);
sMin.setZ(totalMin[2]);
sMax.setX(totalMax[0]);
sMax.setY(totalMax[1]);
sMax.setZ(totalMax[2]);
return sBounds;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations