1 //============================================================================ 2 // Copyright (c) Kitware, Inc. 3 // All rights reserved. 4 // See LICENSE.txt for details. 5 // 6 // This software is distributed WITHOUT ANY WARRANTY; without even 7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 8 // PURPOSE. See the above copyright notice for more information. 9 //============================================================================ 10 #ifndef vtk_m_worklet_BoundingVolumeHierachy_h 11 #define vtk_m_worklet_BoundingVolumeHierachy_h 12 13 #include <vtkm/cont/ArrayHandle.h> 14 #include <vtkm/cont/DataSet.h> 15 #include <vtkm/rendering/vtkm_rendering_export.h> 16 17 namespace vtkm 18 { 19 namespace rendering 20 { 21 namespace raytracing 22 { 23 24 struct AABBs 25 { 26 vtkm::cont::ArrayHandle<vtkm::Float32> xmins; 27 vtkm::cont::ArrayHandle<vtkm::Float32> ymins; 28 vtkm::cont::ArrayHandle<vtkm::Float32> zmins; 29 vtkm::cont::ArrayHandle<vtkm::Float32> xmaxs; 30 vtkm::cont::ArrayHandle<vtkm::Float32> ymaxs; 31 vtkm::cont::ArrayHandle<vtkm::Float32> zmaxs; 32 }; 33 34 // 35 // This is the data structure that is passed to the ray tracer. 36 // 37 class VTKM_RENDERING_EXPORT LinearBVH 38 { 39 public: 40 using InnerNodesHandle = vtkm::cont::ArrayHandle<vtkm::Vec4f_32>; 41 using LeafNodesHandle = vtkm::cont::ArrayHandle<Id>; 42 AABBs AABB; 43 InnerNodesHandle FlatBVH; 44 LeafNodesHandle Leafs; 45 vtkm::Bounds TotalBounds; 46 vtkm::Id LeafCount; 47 48 protected: 49 bool IsConstructed; 50 bool CanConstruct; 51 52 public: 53 LinearBVH(); 54 55 VTKM_CONT 56 LinearBVH(AABBs& aabbs); 57 58 VTKM_CONT 59 LinearBVH(const LinearBVH& other); 60 61 VTKM_CONT void Allocate(const vtkm::Id& leafCount); 62 63 VTKM_CONT 64 void Construct(); 65 66 VTKM_CONT 67 void SetData(AABBs& aabbs); 68 69 VTKM_CONT 70 AABBs& GetAABBs(); 71 72 VTKM_CONT 73 bool GetIsConstructed() const; 74 75 vtkm::Id GetNumberOfAABBs() const; 76 }; // class LinearBVH 77 } 78 } 79 } // namespace vtkm::rendering::raytracing 80 #endif //vtk_m_worklet_BoundingVolumeHierachy_h 81