Search in sources :

Example 1 with Octree

use of org.bimserver.geometry.accellerator.Octree 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 Octree

use of org.bimserver.geometry.accellerator.Octree 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

ArrayList (java.util.ArrayList)2 Node (org.bimserver.geometry.accellerator.Node)2 NodeCounter (org.bimserver.geometry.accellerator.NodeCounter)2 Octree (org.bimserver.geometry.accellerator.Octree)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 STile (org.bimserver.interfaces.objects.STile)1