use of org.bimserver.geometry.accellerator.Node in project BIMserver by opensourceBIM.
the class ServiceImpl method getTiles.
@Override
public List<STile> getTiles(Set<Long> roids, Set<String> excludedTypes, Set<Long> geometryIdsToReuse, Float minimumThreshold, Float maximumThreshold, Integer maxDepth) throws ServerException, UserException {
Octree octree = getBimServer().getGeometryAccellerator().getOctree(roids, excludedTypes, geometryIdsToReuse, maxDepth, minimumThreshold, maximumThreshold);
List<STile> result = new ArrayList<>();
// TODO non-breath-first is probably faster, don't think it matters for the
// client (ATM)
octree.breathFirstCounts(minimumThreshold, maximumThreshold, new NodeCounter() {
@Override
public void counted(Node node, int count) {
if (count > 0) {
STile tile = new STile();
tile.setTileId(node.getId());
tile.setNrObjects(count);
tile.setBounds(node.getBounds().toSBounds());
tile.setMinBounds(node.getMinimumBounds().toSBounds());
result.add(tile);
}
}
}, maxDepth);
return result;
}
use of org.bimserver.geometry.accellerator.Node in project BIMserver by opensourceBIM.
the class TilingImplementation method queryOids.
@Override
public void queryOids(List<Long> oids, List<Long> oidsFiltered, long croid, EClass eClass, Tiles tiles) {
if (tiles.getTileIds().size() > 1) {
throw new NotImplementedException("Only one tile id supported in this method");
}
Set<Query<GeometryObject>> queries = new HashSet<>();
queries.add(QueryFactory.equal(CROID, croid));
if (eClass != null) {
queries.add(QueryFactory.equal(ECLASS, eClass));
}
if (tiles.getTileIds().contains(0) && tiles.getMaxDepth() == 0) {
// When we are querying TILE_ID = 0 in a context where the maxdepth = 0, we need to get all levels, basically we can omit the TILE_ID
} else {
// For every tile we load that has a level < maxdepth -> Just load the tile
// For every tile we load that has a level > maxdepth, log a message, makes no sense
// For every tile we load that has a level == maxdepth, we need to make sure to also load all tiles of lower levels (level > q < actual max depth of octree)
// TODO this code for now assumes one single tileId
Integer tileId = tiles.getTileIds().iterator().next();
int level = Octree.getLevelOfId(tileId);
if (level < tiles.getMaxDepth()) {
queries.add(QueryFactory.equal(TILE_ID, tileId));
} else if (level > tiles.getMaxDepth()) {
LOGGER.info("Not cool");
} else {
// TODO it must be possible to make this faster...
Node node = octree.getById(tileId);
Set<Integer> in = new HashSet<>();
node.traverseBreathFirst(new Traverser() {
@Override
public void traverse(Node t) {
in.add(t.getId());
}
});
queries.add(QueryFactory.in(TILE_ID, in));
}
}
if (tiles.getMaximumThreshold() != -1 && tiles.getMinimumThreshold() != -1) {
queries.add(QueryFactory.between(DENSITY, tiles.getMinimumThreshold(), false, tiles.getMaximumThreshold(), true));
} else {
if (tiles.getMaximumThreshold() != -1) {
queries.add(QueryFactory.lessThanOrEqualTo(DENSITY, tiles.getMaximumThreshold()));
}
if (tiles.getMinimumThreshold() != -1) {
queries.add(QueryFactory.greaterThan(DENSITY, tiles.getMinimumThreshold()));
}
}
Query<GeometryObject> query = null;
if (queries.size() == 1) {
query = queries.iterator().next();
} else {
query = new And<>(queries);
}
ResultSet<GeometryObject> retrieve = objects.retrieve(query, QueryFactory.queryOptions(QueryFactory.orderBy(QueryFactory.descending(ORDER)), QueryFactory.applyThresholds(QueryFactory.threshold(EngineThresholds.INDEX_ORDERING_SELECTIVITY, 1.0))));
for (GeometryObject geometryObject : retrieve) {
if (tiles.getMinimumReuseThreshold() != -1 && tiles.getMinimumReuseThreshold() <= geometryObject.getSaveableTriangles()) {
// We still have to send this object, we just need to somehow make sure the associated GeometryData is not sent
oidsFiltered.add(geometryObject.getOid());
} else {
oids.add(geometryObject.getOid());
}
}
}
use of org.bimserver.geometry.accellerator.Node in project BIMserver by opensourceBIM.
the class ServiceImpl method getTileCounts.
@Override
public List<Number> getTileCounts(Set<Long> roids, Set<String> excludedTypes, Set<Long> geometryIdsToReuse, Float minimumThreshold, Float maximumThreshold, Integer maxDepth) throws ServerException, UserException {
Octree octree = getBimServer().getGeometryAccellerator().getOctree(roids, excludedTypes, geometryIdsToReuse, maxDepth, minimumThreshold, maximumThreshold);
List<Number> result = new ArrayList<>();
AtomicInteger totalObjects = new AtomicInteger(0);
// TODO non-breath-first is probably faster, don't think it matters for the
// client (ATM)
octree.breathFirstCounts(minimumThreshold, maximumThreshold, new NodeCounter() {
@Override
public void counted(Node node, int count) {
if (count > 0) {
result.add(node.getId());
result.add(count);
totalObjects.addAndGet(count);
}
}
}, maxDepth);
return result;
}
Aggregations