Class OctreeOpenCLImpl
java.lang.Object
cz.fidentis.analyst.opencl.services.octree.impl.OctreeOpenCLImpl
- All Implemented Interfaces:
CLResources
,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
ConstructorsConstructorDescriptionOctreeOpenCLImpl
(com.jogamp.opencl.CLContext clContext) Builds an octree from facets for desired CL Context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
build
(Collection<MeshFacet> facets) Builds the octree with provided facets.getBBox()
Gets BBox calculated during the Octree creation.com.jogamp.opencl.CLBuffer
<FloatBuffer> Gets Octree Bounding Box in bufferint
Largest existing leaf - maximal number of trianglescom.jogamp.opencl.CLBuffer
<IntBuffer> getTree()
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 buffercom.jogamp.opencl.CLBuffer
<IntBuffer> Triangle indexes stored in array to represent leaves.Gets Triangles from the octree.void
release()
Explicitly releases GPU resources held by this object
-
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
Description copied from interface:OctreeOpenCL
Gets Triangles from the octree. The triangles are loaded inMeshTriangleBuffer
- Specified by:
getTriangles
in interfaceOctreeOpenCL
- Returns:
- MeshTriangleBuffer instance
-
getMaxTrianglesPerLeaf
public int getMaxTrianglesPerLeaf()Description copied from interface:OctreeOpenCL
Largest existing leaf - maximal number of triangles- Specified by:
getMaxTrianglesPerLeaf
in interfaceOctreeOpenCL
- Returns:
- The Largest existing leaf
-
getTriangleIndices
Description copied from interface:OctreeOpenCL
Triangle indexes stored in array to represent leaves. Each leaf has reserved length ofgetMayTrianglesPerLeaf
- Specified by:
getTriangleIndices
in interfaceOctreeOpenCL
- Returns:
- leaves to triangles indexation
-
getTriangle
Description copied from interface:OctreeOpenCL
Gets triangle corresponding to its index from GPU buffer- Specified by:
getTriangle
in interfaceOctreeOpenCL
- Parameters:
index
- of triangle from GPU- Returns:
- MeshTriangle instance
-
getBBoxBuffer
Description copied from interface:OctreeOpenCL
Gets Octree Bounding Box in buffer- Specified by:
getBBoxBuffer
in interfaceOctreeOpenCL
- Returns:
- CLBuffer containing Bounding Box
-
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 interfaceOctreeOpenCL
- Returns:
- CLBuffer of integers
-
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 interfaceOctreeOpenCL
- 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 interfaceCLResources
-
build
Description copied from interface:OctreeOpenCL
Builds the octree with provided facets. Reuses allocated memory if possible- Specified by:
build
in interfaceOctreeOpenCL
- Parameters:
facets
- Facets to be loaded in octree
-