Search in sources :

Example 1 with Node

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;
}
Also used : NodeCounter(org.bimserver.geometry.accellerator.NodeCounter) Node(org.bimserver.geometry.accellerator.Node) STile(org.bimserver.interfaces.objects.STile) ArrayList(java.util.ArrayList) Octree(org.bimserver.geometry.accellerator.Octree)

Example 2 with Node

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());
        }
    }
}
Also used : ResultSet(com.googlecode.cqengine.resultset.ResultSet) Set(java.util.Set) HashSet(java.util.HashSet) Query(com.googlecode.cqengine.query.Query) GeometryObject(org.bimserver.geometry.accellerator.GeometryObject) NotImplementedException(org.apache.commons.lang.NotImplementedException) Node(org.bimserver.geometry.accellerator.Node) Traverser(org.bimserver.geometry.accellerator.Traverser) HashSet(java.util.HashSet)

Example 3 with Node

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;
}
Also used : NodeCounter(org.bimserver.geometry.accellerator.NodeCounter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Node(org.bimserver.geometry.accellerator.Node) ArrayList(java.util.ArrayList) Octree(org.bimserver.geometry.accellerator.Octree)

Aggregations

Node (org.bimserver.geometry.accellerator.Node)3 ArrayList (java.util.ArrayList)2 NodeCounter (org.bimserver.geometry.accellerator.NodeCounter)2 Octree (org.bimserver.geometry.accellerator.Octree)2 Query (com.googlecode.cqengine.query.Query)1 ResultSet (com.googlecode.cqengine.resultset.ResultSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 GeometryObject (org.bimserver.geometry.accellerator.GeometryObject)1 Traverser (org.bimserver.geometry.accellerator.Traverser)1 STile (org.bimserver.interfaces.objects.STile)1