VTK-m  2.0
raytracing/Camera.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_Camera_h
11 #define vtk_m_rendering_raytracing_Camera_h
12 
14 #include <vtkm/rendering/Camera.h>
17 
18 namespace vtkm
19 {
20 namespace rendering
21 {
22 namespace raytracing
23 {
24 
25 class VTKM_RENDERING_EXPORT Camera
26 {
27 
28 private:
29  struct PixelDataFunctor;
40 
47 
48 public:
49  VTKM_CONT
50  Camera();
51 
52  VTKM_CONT
53  ~Camera();
54 
55  // cuda does not compile if this is private
56  class PerspectiveRayGen;
57  class Ortho2DRayGen;
58 
59  std::string ToString();
60 
61  VTKM_CONT
62  void SetParameters(const vtkm::rendering::Camera& camera,
63  const vtkm::Int32 width,
64  const vtkm::Int32 height);
65 
66  VTKM_CONT
67  void SetParameters(const vtkm::rendering::Camera& camera,
69 
70  VTKM_CONT
71  void SetHeight(const vtkm::Int32& height);
72 
73  VTKM_CONT
74  void WriteSettingsToLog();
75 
76  VTKM_CONT
77  vtkm::Int32 GetHeight() const;
78 
79  VTKM_CONT
80  void SetWidth(const vtkm::Int32& width);
81 
82  VTKM_CONT
83  vtkm::Int32 GetWidth() const;
84 
85  VTKM_CONT
86  vtkm::Int32 GetSubsetWidth() const;
87 
88  VTKM_CONT
89  vtkm::Int32 GetSubsetHeight() const;
90 
91  VTKM_CONT
92  void SetZoom(const vtkm::Float32& zoom);
93 
94  VTKM_CONT
95  vtkm::Float32 GetZoom() const;
96 
97  VTKM_CONT
98  void SetFieldOfView(const vtkm::Float32& degrees);
99 
100  VTKM_CONT
101  vtkm::Float32 GetFieldOfView() const;
102 
103  VTKM_CONT
104  void SetUp(const vtkm::Vec3f_32& up);
105 
106  VTKM_CONT
107  void SetPosition(const vtkm::Vec3f_32& position);
108 
109  VTKM_CONT
110  vtkm::Vec3f_32 GetPosition() const;
111 
112  VTKM_CONT
113  vtkm::Vec3f_32 GetUp() const;
114 
115  VTKM_CONT
116  void SetLookAt(const vtkm::Vec3f_32& lookAt);
117 
118  VTKM_CONT
119  vtkm::Vec3f_32 GetLookAt() const;
120 
121  VTKM_CONT
122  void ResetIsViewDirty();
123 
124  VTKM_CONT
125  bool GetIsViewDirty() const;
126 
127  VTKM_CONT
128  void CreateRays(Ray<vtkm::Float32>& rays, vtkm::Bounds bounds);
129 
130  VTKM_CONT
131  void CreateRays(Ray<vtkm::Float64>& rays, vtkm::Bounds bounds);
132 
133  VTKM_CONT
134  void GetPixelData(const vtkm::cont::CoordinateSystem& coords,
135  vtkm::Int32& activePixels,
136  vtkm::Float32& aveRayDistance);
137 
138  template <typename Precision>
139  VTKM_CONT void CreateRaysImpl(Ray<Precision>& rays, const vtkm::Bounds boundingBox);
140 
141  void CreateDebugRay(vtkm::Vec2i_32 pixel, Ray<vtkm::Float32>& rays);
142 
143  void CreateDebugRay(vtkm::Vec2i_32 pixel, Ray<vtkm::Float64>& rays);
144 
145  bool operator==(const Camera& other) const;
146 
147 private:
148  template <typename Precision>
149  void CreateDebugRayImp(vtkm::Vec2i_32 pixel, Ray<Precision>& rays);
150  VTKM_CONT
151  void FindSubset(const vtkm::Bounds& bounds);
152 
153  template <typename Precision>
154  VTKM_CONT void UpdateDimensions(Ray<Precision>& rays,
155  const vtkm::Bounds& boundingBox,
156  bool ortho2D);
157 
158 }; // class camera
159 }
160 }
161 } //namespace vtkm::rendering::raytracing
162 #endif //vtk_m_rendering_raytracing_Camera_h
vtkm::rendering::raytracing::Camera::SubsetHeight
vtkm::Int32 SubsetHeight
Definition: raytracing/Camera.h:33
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::rendering::raytracing::Camera::FovX
vtkm::Float32 FovX
Definition: raytracing/Camera.h:36
vtkm::rendering::raytracing::Camera::CameraView
vtkm::rendering::Camera CameraView
Definition: raytracing/Camera.h:45
vtkm::rendering::raytracing::Camera::Width
vtkm::Int32 Width
Definition: raytracing/Camera.h:31
vtkm::rendering::raytracing::Camera::IsViewDirty
bool IsViewDirty
Definition: raytracing/Camera.h:39
vtkm::rendering::raytracing::Camera::FovY
vtkm::Float32 FovY
Definition: raytracing/Camera.h:37
CanvasRayTracer.h
CoordinateSystem.h
vtkm::rendering::raytracing::Camera
Definition: raytracing/Camera.h:25
vtkm::cont::CoordinateSystem
Definition: CoordinateSystem.h:25
vtkm::rendering::raytracing::Camera::SubsetMinX
vtkm::Int32 SubsetMinX
Definition: raytracing/Camera.h:34
vtkm::rendering::raytracing::Camera::SubsetWidth
vtkm::Int32 SubsetWidth
Definition: raytracing/Camera.h:32
vtkm::rendering::raytracing::Ray
Definition: Ray.h:37
vtkm::rendering::raytracing::Camera::Position
vtkm::Vec3f_32 Position
Definition: raytracing/Camera.h:44
vtkm::rendering::raytracing::Camera::Up
vtkm::Vec3f_32 Up
Definition: raytracing/Camera.h:42
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::rendering::raytracing::Camera::Zoom
vtkm::Float32 Zoom
Definition: raytracing/Camera.h:38
vtkm::operator==
VTKM_EXEC_CONT bool operator==(const vtkm::Matrix< T, NumRow, NumCol > &a, const vtkm::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:615
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm::rendering::raytracing::Camera::SubsetMinY
vtkm::Int32 SubsetMinY
Definition: raytracing/Camera.h:35
vtkm::rendering::raytracing::Camera::LookAt
vtkm::Vec3f_32 LookAt
Definition: raytracing/Camera.h:43
vtkm::rendering::raytracing::Camera::Look
vtkm::Vec3f_32 Look
Definition: raytracing/Camera.h:41
vtkm::Vec< vtkm::Float32, 3 >
vtkm::Matrix< vtkm::Float32, 4, 4 >
vtkm::rendering::raytracing::Camera::ViewProjectionMat
vtkm::Matrix< vtkm::Float32, 4, 4 > ViewProjectionMat
Definition: raytracing/Camera.h:46
vtkm::rendering::raytracing::Camera::Height
vtkm::Int32 Height
Definition: raytracing/Camera.h:29
vtkm::Float32
float Float32
Definition: Types.h:154
Camera.h
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::rendering::CanvasRayTracer
Definition: CanvasRayTracer.h:23
vtkm::rendering::Camera
Definition: Camera.h:28
Ray.h