VTK-m  2.0
ConnectivityTracer.h
Go to the documentation of this file.
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_rendering_raytracing_ConnectivityTracer_h
11 #define vtk_m_rendering_raytracing_ConnectivityTracer_h
12 
13 #include <vtkm/rendering/vtkm_rendering_export.h>
14 
15 #include <vtkm/cont/ArrayHandle.h>
17 
20 
21 
22 namespace vtkm
23 {
24 namespace rendering
25 {
26 namespace raytracing
27 {
28 namespace detail
29 {
30 
31 //forward declare so we can be friends
32 struct RenderFunctor;
33 
34 //
35 // Ray tracker manages memory and pointer
36 // swapping for current cell intersection data
37 //
38 template <typename FloatType>
39 class RayTracking
40 {
41 public:
43  vtkm::cont::ArrayHandle<FloatType> CurrentDistance;
48 
49  RayTracking()
50  {
51  EnterDist = &Distance1;
52  ExitDist = &Distance2;
53  }
54 
55  void Compact(vtkm::cont::ArrayHandle<FloatType>& compactedDistances,
57 
58  void Init(const vtkm::Id size, vtkm::cont::ArrayHandle<FloatType>& distances);
59 
60  void Swap();
61 };
62 
63 } //namespace detail
64 
71 class VTKM_RENDERING_EXPORT ConnectivityTracer
72 {
73 public:
75  : MeshContainer(nullptr)
76  , BumpEpsilon(1e-3)
77  , CountRayStatus(false)
78  , UnitScalar(1.f)
79  {
80  }
81 
83  {
84  if (MeshContainer != nullptr)
85  {
86  delete MeshContainer;
87  }
88  }
89 
91  {
93  Energy
94  };
95 
96  void SetVolumeData(const vtkm::cont::Field& scalarField,
97  const vtkm::Range& scalarBounds,
98  const vtkm::cont::UnknownCellSet& cellSet,
99  const vtkm::cont::CoordinateSystem& coords);
100 
101  void SetEnergyData(const vtkm::cont::Field& absorption,
102  const vtkm::Int32 numBins,
103  const vtkm::cont::UnknownCellSet& cellSet,
104  const vtkm::cont::CoordinateSystem& coords,
105  const vtkm::cont::Field& emission);
106 
107  void SetBackgroundColor(const vtkm::Vec4f_32& backgroundColor);
108  void SetSampleDistance(const vtkm::Float32& distance);
109  void SetColorMap(const vtkm::cont::ArrayHandle<vtkm::Vec4f_32>& colorMap);
110 
111  MeshConnectivityContainer* GetMeshContainer() { return MeshContainer; }
112 
113  void Init();
114 
115  void SetDebugOn(bool on) { CountRayStatus = on; }
116 
117  void SetUnitScalar(const vtkm::Float32 unitScalar) { UnitScalar = unitScalar; }
118  void SetEpsilon(const vtkm::Float64 epsilon) { BumpEpsilon = epsilon; }
119 
120 
121  vtkm::Id GetNumberOfMeshCells() const;
122 
123  void ResetTimers();
124  void LogTimers();
125 
132  template <typename FloatType>
133  void FullTrace(Ray<FloatType>& rays);
134 
141  template <typename FloatType>
142  std::vector<PartialComposite<FloatType>> PartialTrace(Ray<FloatType>& rays);
143 
149  template <typename FloatType>
150  void IntegrateMeshSegment(Ray<FloatType>& rays);
151 
155  template <typename FloatType>
156  void FindMeshEntry(Ray<FloatType>& rays);
157 
158 private:
159  template <typename FloatType>
160  void IntersectCell(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker);
161 
162  template <typename FloatType>
163  void AccumulatePathLengths(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker);
164 
165  template <typename FloatType>
166  void FindLostRays(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker);
167 
168  template <typename FloatType>
169  void SampleCells(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker);
170 
171  template <typename FloatType>
172  void IntegrateCells(Ray<FloatType>& rays, detail::RayTracking<FloatType>& tracker);
173 
174  template <typename FloatType>
175  void OffsetMinDistances(Ray<FloatType>& rays);
176 
177  template <typename FloatType>
178  void PrintRayStatus(Ray<FloatType>& rays);
179 
180 protected:
181  // Data set info
187  vtkm::Float32 BoundingBox[6];
188 
190 
195 
200  //
201  // flags
205  bool ReEnterMesh; // Do not try to re-enter the mesh
208  bool HasEmission; // Mode for integrating through energy bins
209 
210  // timers
217 
218 }; // class ConnectivityTracer<CellType,ConnectivityType>
219 }
220 }
221 } // namespace vtkm::rendering::raytracing
222 #endif
vtkm::rendering::raytracing::ConnectivityTracer::MeshContainer
MeshConnectivityContainer * MeshContainer
Definition: ConnectivityTracer.h:196
vtkm::rendering::raytracing::ConnectivityTracer::GetMeshContainer
MeshConnectivityContainer * GetMeshContainer()
Definition: ConnectivityTracer.h:111
vtkm::rendering::raytracing::ConnectivityTracer::CountRayStatus
bool CountRayStatus
Definition: ConnectivityTracer.h:202
vtkm::rendering::raytracing::ConnectivityTracer::IntegrationMode
IntegrationMode
Definition: ConnectivityTracer.h:90
vtkm::rendering::raytracing::ConnectivityTracer::SampleDistance
vtkm::Float32 SampleDistance
Definition: ConnectivityTracer.h:192
vtkm::Swap
VTKM_EXEC_CONT void Swap(T &a, T &b)
Performs a swap operation. Safe to call from cuda code.
Definition: Swap.h:59
vtkm::cont::ArrayHandle< vtkm::Int32 >
ArrayHandle.h
vtkm::rendering::raytracing::ConnectivityTracer::SetDebugOn
void SetDebugOn(bool on)
Definition: ConnectivityTracer.h:115
vtkm::rendering::raytracing::ConnectivityTracer::Coords
vtkm::cont::CoordinateSystem Coords
Definition: ConnectivityTracer.h:185
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::rendering::raytracing::ConnectivityTracer::Volume
@ Volume
Definition: ConnectivityTracer.h:92
vtkm::rendering::raytracing::ConnectivityTracer::SampleTime
vtkm::Float64 SampleTime
Definition: ConnectivityTracer.h:213
vtkm::rendering::raytracing::ConnectivityTracer::FieldAssocPoints
bool FieldAssocPoints
Definition: ConnectivityTracer.h:207
vtkm::rendering::raytracing::ConnectivityTracer::UnitScalar
vtkm::Float32 UnitScalar
Definition: ConnectivityTracer.h:216
vtkm::rendering::raytracing::ConnectivityTracer::ColorMap
vtkm::cont::ArrayHandle< vtkm::Vec4f_32 > ColorMap
Definition: ConnectivityTracer.h:189
vtkm::rendering::raytracing::ConnectivityTracer::BumpEpsilon
vtkm::Float64 BumpEpsilon
Definition: ConnectivityTracer.h:198
vtkm::rendering::raytracing::ConnectivityTracer::LostRayTime
vtkm::Float64 LostRayTime
Definition: ConnectivityTracer.h:214
vtkm::rendering::raytracing::ConnectivityTracer::Locator
vtkm::cont::CellLocatorGeneral Locator
Definition: ConnectivityTracer.h:197
vtkm::rendering::raytracing::ConnectivityTracer::MeshEntryTime
vtkm::Float64 MeshEntryTime
Definition: ConnectivityTracer.h:215
vtkm::rendering::raytracing::ConnectivityTracer::ConnectivityTracer
ConnectivityTracer()
Definition: ConnectivityTracer.h:74
vtkm::cont::UnknownCellSet
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::rendering::raytracing::ConnectivityTracer::BumpDistance
vtkm::Float64 BumpDistance
Definition: ConnectivityTracer.h:199
vtkm::cont::CoordinateSystem
Definition: CoordinateSystem.h:25
vtkm::rendering::raytracing::ConnectivityTracer::RaysLost
vtkm::Id RaysLost
Definition: ConnectivityTracer.h:193
vtkm::rendering::raytracing::ConnectivityTracer::CellSet
vtkm::cont::UnknownCellSet CellSet
Definition: ConnectivityTracer.h:184
vtkm::rendering::raytracing::Ray
Definition: Ray.h:37
PartialComposite.h
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: cont/Field.h:31
vtkm::rendering::raytracing::ConnectivityTracer
ConnectivityTracer is volumetric ray tracer for unstructured grids.
Definition: ConnectivityTracer.h:71
vtkm::rendering::raytracing::ConnectivityTracer::SetUnitScalar
void SetUnitScalar(const vtkm::Float32 unitScalar)
Definition: ConnectivityTracer.h:117
vtkm::rendering::raytracing::ConnectivityTracer::EmissionField
vtkm::cont::Field EmissionField
Definition: ConnectivityTracer.h:183
MeshConnectivityContainers.h
vtkm::rendering::raytracing::ConnectivityTracer::CreatePartialComposites
bool CreatePartialComposites
Definition: ConnectivityTracer.h:206
vtkm::rendering::raytracing::ConnectivityTracer::IntegrateTime
vtkm::Float64 IntegrateTime
Definition: ConnectivityTracer.h:212
vtkm::rendering::raytracing::ConnectivityTracer::HasEmission
bool HasEmission
Definition: ConnectivityTracer.h:208
vtkm::cont::CellLocatorGeneral
A CellLocator that works generally well for any supported cell set.
Definition: CellLocatorGeneral.h:41
vtkm::rendering::raytracing::ConnectivityTracer::ReEnterMesh
bool ReEnterMesh
Definition: ConnectivityTracer.h:205
vtkm::rendering::raytracing::ConnectivityTracer::~ConnectivityTracer
~ConnectivityTracer()
Definition: ConnectivityTracer.h:82
vtkm::rendering::raytracing::ConnectivityTracer::IntersectTime
vtkm::Float64 IntersectTime
Definition: ConnectivityTracer.h:211
vtkm::rendering::raytracing::ConnectivityTracer::BackgroundColor
vtkm::Vec4f_32 BackgroundColor
Definition: ConnectivityTracer.h:191
vtkm::Vec< vtkm::Float32, 4 >
vtkm::rendering::raytracing::ConnectivityTracer::DebugFiltersOn
bool DebugFiltersOn
Definition: ConnectivityTracer.h:204
vtkm::rendering::raytracing::ConnectivityTracer::ScalarBounds
vtkm::Range ScalarBounds
Definition: ConnectivityTracer.h:186
vtkm::Float32
float Float32
Definition: Types.h:154
vtkm::rendering::raytracing::ConnectivityTracer::SetEpsilon
void SetEpsilon(const vtkm::Float64 epsilon)
Definition: ConnectivityTracer.h:118
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::rendering::raytracing::ConnectivityTracer::MeshConnIsConstructed
bool MeshConnIsConstructed
Definition: ConnectivityTracer.h:203
vtkm::rendering::raytracing::ConnectivityTracer::ScalarField
vtkm::cont::Field ScalarField
Definition: ConnectivityTracer.h:182
CellLocatorGeneral.h
vtkm::rendering::raytracing::MeshConnectivityContainer
Definition: MeshConnectivityContainers.h:24
vtkm::rendering::raytracing::ConnectivityTracer::Integrator
IntegrationMode Integrator
Definition: ConnectivityTracer.h:194
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31