/** * Removes the geometry data from main memory (and disables it). */ public void unload() { synchronized ( LOCK ) { if ( data != null ) { data.freeBuffers(); data = null; } } }
/** * @return size in bytes of this fragment. */ public int size() { return fragment.size(); }
void append(ByteBuffer nodesBuffer, float error, float[][] bbox) { org.deegree.rendering.r3d.multiresolution.Node.store(nodesBuffer, lowestOutgoingArc, highestOutgoingArc, lowestIncomingArc, bbox); } }
/** * Extracts the smallest LOD fragment that satisfies the given LOD criterion . * * @param crit * criterion that the LOD must satisfies * @param roi * @return smallest LOD that satisfies the given LOD criterion */ public List<MeshFragment> extractLODFragment( LODCriterion crit, ViewFrustum roi ) { return new SpatialSelection( this, crit, roi, 1.0f ).determineLODFragment(); }
/** * Extracts the smallest LOD that satisfies the given LOD criterion. * * @param crit * criterion that the LOD must satisfies * @return smallest LOD that satisfies the given LOD criterion */ public List<MeshFragment> extractLOD( LODCriterion crit ) { return new SelectiveRefinement( this, crit ).determineLOD(); }
/** * Checks whether all fragments denoted by the given {@link Arc} are texturable with respect to the max texture size * and texture resolutions. * * @param arc * @return true, if all are texturable, false otherwise (at least one is not texturable) */ private boolean isTexturable( Arc arc ) { if ( textureManagers.length == 0 ) { return true; } for ( MeshFragment fragment : arc.getFragments() ) { if ( !isTexturable( fragment ) ) { return false; } } return true; }
private void forceRefinement( Arc region, List<Arc> toDo ) { Node modification = mt.nodes[region.sourceNode]; int incomingArc = modification.lowestIncomingArc; while ( incomingArc != -1 ) { if ( applied[mt.arcs[incomingArc].sourceNode] ) { lod.remove( mt.arcs[incomingArc] ); } else { forceRefinement( mt.arcs[incomingArc], toDo ); } incomingArc = mt.arcs[incomingArc].nextArcWithSameDestination; } for ( int arcId = modification.lowestOutgoingArc; arcId <= modification.highestOutgoingArc; arcId++ ) { if ( arcId != region.id ) { Arc arc2 = mt.arcs[arcId]; if ( arc2.interferes( roi, zScale ) ) { lod.add( arc2 ); toDo.add( arc2 ); } } } applied[modification.id] = true; } }
private boolean isInViewVolume( Arc arc ) { float[][] scaledBBox = arc.getBBox(); scaledBBox[0][2] *= zScale; scaledBBox[1][2] *= zScale; return viewRegion.intersects( scaledBBox ); }
void append(ByteBuffer buffer) { org.deegree.rendering.r3d.multiresolution.Arc.store(buffer, sourceNode, destinationNode, lowestPatch, highestPatch, nextArcWithSameDestination, error); } }
/** * @return true if the used direct buffer pool can allocate enough direct memory for the given data. */ public boolean canAllocateEnoughMemory() { return this.fragment.canAllocateEnoughMemory(); }
/** * Loads the geometry data into main memory. * * @throws IOException */ public void load() throws IOException { synchronized ( LOCK ) { if ( data == null ) { data = fragment.loadData(); } } }
@Override public int compareTo( RenderMeshFragment o ) { return this.fragment.compareTo( o.fragment ); }
void append(ByteBuffer buffer) { MeshFragment.store(buffer, minX, minY, minZ, maxX, maxY, maxZ, geometricError, blobPosition, blobLength); }
/** * Returns the bounding box of the region that this arc represents. * * @return the bounding box */ public float[][] getBBox() { float[][] bbox = new float[2][3]; bbox[0][0] = mt.fragments[lowestPatch].bbox[0][0]; bbox[0][1] = mt.fragments[lowestPatch].bbox[0][1]; bbox[0][2] = mt.fragments[lowestPatch].bbox[0][2]; bbox[1][0] = mt.fragments[lowestPatch].bbox[1][0]; bbox[1][1] = mt.fragments[lowestPatch].bbox[1][1]; bbox[1][2] = mt.fragments[lowestPatch].bbox[1][2]; for ( int patchId = lowestPatch + 1; patchId <= highestPatch; patchId++ ) { enlargeBBox( bbox, mt.fragments[patchId].bbox ); } return bbox; }
private Node[] createNodes( ByteBuffer nodesBuffer ) { Node[] nodes = new Node[nodesBuffer.capacity() / Node.SIZE]; for ( int i = 0; i < nodes.length; i++ ) { nodes[i] = new Node( this, i, nodesBuffer, i * Node.SIZE ); } return nodes; }
private Arc[] createArcs( ByteBuffer arcsBuffer ) { Arc[] arcs = new Arc[arcsBuffer.capacity() / Arc.SIZE]; for ( int i = 0; i < arcs.length; i++ ) { arcs[i] = new Arc( this, i, arcsBuffer, i * Arc.SIZE ); } return arcs; }
private MeshFragment[] createFragmentInfos( ByteBuffer patchBuffer, MeshFragmentDataReader patchDataReader ) { MeshFragment[] patches = new MeshFragment[patchBuffer.capacity() / MeshFragment.SIZE]; for ( int i = 0; i < patches.length; i++ ) { int baseOffset = i * MeshFragment.SIZE; patchBuffer.position( baseOffset ).limit( baseOffset + MeshFragment.SIZE ); ByteBuffer singlePatchBuffer = patchBuffer.slice(); patches[i] = new MeshFragment( i, singlePatchBuffer, patchDataReader ); } return patches; } }
/** * Initializes the cut, so it is just below the root node. */ private void initializeCut() { lod = new HashSet<Arc>(); applied = new boolean[mt.nodes.length]; Node root = mt.nodes[0]; int[] outgoingArcs = new int[root.highestOutgoingArc - root.lowestOutgoingArc + 1]; for ( int i = 0; i < outgoingArcs.length; i++ ) { Arc arc = mt.arcs[i + root.lowestOutgoingArc]; if ( arc.interferes( roi, zScale ) ) { lod.add( arc ); } } applied[0] = true; }
/** * Determines the LOD fragment that corresponds to the associated {@link LODCriterion} and region of interest. * * @return PatchInfo objects of all patches that make up the LOD fragment */ public List<MeshFragment> determineLODFragment() { List<MeshFragment> fragments = new ArrayList<MeshFragment>(); adaptTopDown(); for ( Arc arc : lod ) { for ( int fragmentId = arc.lowestPatch; fragmentId <= arc.highestPatch; fragmentId++ ) { MeshFragment fragment = mt.fragments[fragmentId]; fragments.add( fragment ); } } return fragments; }
/** * Determines if this arc interferes with the given {@link Geometry}. * * @param roi * geometry that is tested for interference * @param zScale * scaling factor applied to z values of the mesh geometry (and bounding boxes) * @return true, if the arc interferes with the geometry, false otherwise */ public boolean interferes( ViewFrustum roi, float zScale ) { float[][] nodeBBox = getBBox(); nodeBBox[0][2] *= zScale; nodeBBox[1][2] *= zScale; return roi.intersects( nodeBBox ); }