Class OctreeOpenCLImpl

java.lang.Object
cz.fidentis.analyst.opencl.services.octree.impl.OctreeOpenCLImpl
All Implemented Interfaces:
CLResources, OctreeOpenCL

public class OctreeOpenCLImpl extends Object implements OctreeOpenCL
Builds Octree on GPU in top-down direction. Mesh Facet triangles are copied to GPU and subdivided into uniform octants until maximum depth constraint is reached. The process involves: Memory allocation / initialization Builds tree structure from vertices. Finds non-empty leaves and largest leaf size Allocates leaf memory Populates structure with triangles
  • Constructor Summary

    Constructors
    Constructor
    Description
    OctreeOpenCLImpl(com.jogamp.opencl.CLContext clContext)
    Builds an octree from facets for desired CL Context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Builds the octree with provided facets.
    Gets BBox calculated during the Octree creation.
    com.jogamp.opencl.CLBuffer<FloatBuffer>
    Gets Octree Bounding Box in buffer
    int
    Largest existing leaf - maximal number of triangles
    com.jogamp.opencl.CLBuffer<IntBuffer>
    Get indexes pointing from parent nodes to their children and leaves to their respective triangle content index -1 --> reserved as empty value indexes > -1 --> Pointers to nodes, each value points to where node's children are stored continuously For example: If we find 64 at index 5, it means children of node 5 are stored at indexes 64-72 indexes invalid input: '<' -1 --> To save memory, the negative value signify the child is leaf.
    getTriangle(int index)
    Gets triangle corresponding to its index from GPU buffer
    com.jogamp.opencl.CLBuffer<IntBuffer>
    Triangle indexes stored in array to represent leaves.
    Gets Triangles from the octree.
    void
    Explicitly releases GPU resources held by this object

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OctreeOpenCLImpl

      public OctreeOpenCLImpl(com.jogamp.opencl.CLContext clContext)
      Builds an octree from facets for desired CL Context. Everyone working with the octree needs to have the same CL Context
      Parameters:
      clContext - Desired CL Context
  • Method Details

    • getTriangles

      public WriteBufferGPU<MeshTriangle> getTriangles()
      Description copied from interface: OctreeOpenCL
      Gets Triangles from the octree. The triangles are loaded in MeshTriangleBuffer
      Specified by:
      getTriangles in interface OctreeOpenCL
      Returns:
      MeshTriangleBuffer instance
    • getMaxTrianglesPerLeaf

      public int getMaxTrianglesPerLeaf()
      Description copied from interface: OctreeOpenCL
      Largest existing leaf - maximal number of triangles
      Specified by:
      getMaxTrianglesPerLeaf in interface OctreeOpenCL
      Returns:
      The Largest existing leaf
    • getTriangleIndices

      public com.jogamp.opencl.CLBuffer<IntBuffer> getTriangleIndices()
      Description copied from interface: OctreeOpenCL
      Triangle indexes stored in array to represent leaves. Each leaf has reserved length of getMayTrianglesPerLeaf
      Specified by:
      getTriangleIndices in interface OctreeOpenCL
      Returns:
      leaves to triangles indexation
    • getTriangle

      public MeshTriangle getTriangle(int index)
      Description copied from interface: OctreeOpenCL
      Gets triangle corresponding to its index from GPU buffer
      Specified by:
      getTriangle in interface OctreeOpenCL
      Parameters:
      index - of triangle from GPU
      Returns:
      MeshTriangle instance
    • getBBoxBuffer

      public com.jogamp.opencl.CLBuffer<FloatBuffer> getBBoxBuffer()
      Description copied from interface: OctreeOpenCL
      Gets Octree Bounding Box in buffer
      Specified by:
      getBBoxBuffer in interface OctreeOpenCL
      Returns:
      CLBuffer containing Bounding Box
    • getTree

      public com.jogamp.opencl.CLBuffer<IntBuffer> getTree()
      Description copied from interface: OctreeOpenCL
      Get indexes pointing from parent nodes to their children and leaves to their respective triangle content index -1 --> reserved as empty value indexes > -1 --> Pointers to nodes, each value points to where node's children are stored continuously For example: If we find 64 at index 5, it means children of node 5 are stored at indexes 64-72 indexes invalid input: '<' -1 --> To save memory, the negative value signify the child is leaf. Making the value positive gives us pointer to the leaf's triangles in Triangle Indices
      Specified by:
      getTree in interface OctreeOpenCL
      Returns:
      CLBuffer of integers
    • getBBox

      public Box getBBox()
      Description copied from interface: OctreeOpenCL
      Gets BBox calculated during the Octree creation. Equal to Bounding Box of all vertices of the submitted facets
      Specified by:
      getBBox in interface OctreeOpenCL
      Returns:
      Octree Bounding Box
    • release

      public void release()
      Description copied from interface: CLResources
      Explicitly releases GPU resources held by this object
      Specified by:
      release in interface CLResources
    • build

      public void build(Collection<MeshFacet> facets)
      Description copied from interface: OctreeOpenCL
      Builds the octree with provided facets. Reuses allocated memory if possible
      Specified by:
      build in interface OctreeOpenCL
      Parameters:
      facets - Facets to be loaded in octree