VTK-m  2.2
ANARIMapper.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 
11 #ifndef vtk_m_interop_anari_ANARIMapper_h
12 #define vtk_m_interop_anari_ANARIMapper_h
13 
14 // vtk-m
15 #include <vtkm/cont/ColorTable.h>
17 
18 #include <vtkm/interop/anari/vtkm_anari_export.h>
19 
20 namespace vtkm
21 {
22 namespace interop
23 {
24 namespace anari
25 {
26 
27 inline void NoopANARIDeleter(const void*, const void*) {}
28 
37 struct VTKM_ANARI_EXPORT ANARIMapper
38 {
39  ANARIMapper(anari_cpp::Device device,
40  const ANARIActor& actor = {},
41  const std::string& name = "<noname>",
43  virtual ~ANARIMapper() = default;
44 
45  anari_cpp::Device GetDevice() const;
46  const ANARIActor& GetActor() const;
47  const char* GetName() const;
48  const vtkm::cont::ColorTable& GetColorTable() const;
49 
50  void SetName(const char* name);
51  void SetColorTable(const vtkm::cont::ColorTable& colorTable);
52 
59  virtual void SetActor(const ANARIActor& actor);
60 
66  virtual void SetMapFieldAsAttribute(bool enabled);
67  bool GetMapFieldAsAttribute() const;
68 
73  virtual void SetANARIColorMap(anari_cpp::Array1D color,
74  anari_cpp::Array1D opacity,
75  bool releaseArrays = true);
76 
79  virtual void SetANARIColorMapValueRange(const vtkm::Vec2f_32& valueRange);
80 
83  virtual void SetANARIColorMapOpacityScale(vtkm::Float32 opacityScale);
84 
88  virtual anari_cpp::Geometry GetANARIGeometry();
89 
93  virtual anari_cpp::SpatialField GetANARISpatialField();
94 
98  virtual anari_cpp::Surface GetANARISurface();
99 
103  virtual anari_cpp::Volume GetANARIVolume();
104 
105  anari_cpp::Group GetANARIGroup();
106  anari_cpp::Instance GetANARIInstance();
107 
108  bool GroupIsEmpty() const;
109 
110 protected:
111  std::string MakeObjectName(const char* suffix) const;
112  void RefreshGroup();
113 
114  vtkm::cont::ColorTable& GetColorTable();
115 
116  bool Valid{ false };
117  bool Current{ false };
118 
119 private:
121  {
122  anari_cpp::Device Device{ nullptr };
123  anari_cpp::Group Group{ nullptr };
124  anari_cpp::Instance Instance{ nullptr };
125  ~ANARIHandles();
126  };
127 
128  std::shared_ptr<ANARIHandles> Handles;
131  std::string Name;
132  bool MapFieldAsAttribute{ true };
133 };
134 
135 } // namespace anari
136 } // namespace interop
137 } // namespace vtkm
138 
139 #endif
vtkm::interop::anari::ANARIMapper::Actor
ANARIActor Actor
Definition: ANARIMapper.h:129
anari
Definition: VtkmANARITypes.h:30
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ColorTable
Color Table for coloring arbitrary fields.
Definition: cont/ColorTable.h:89
ANARIActor.h
vtkm::interop::anari::ANARIMapper::ANARIHandles
Definition: ANARIMapper.h:120
vtkm::interop::anari::ANARIMapper
This is the base class used for all ANARI mappers.
Definition: ANARIMapper.h:37
vtkm::interop::anari::NoopANARIDeleter
void NoopANARIDeleter(const void *, const void *)
Definition: ANARIMapper.h:27
ColorTable.h
vtkm::interop::anari::ANARIActor
Collects cells, coords, and 0-4 fields for ANARI mappers to consume.
Definition: ANARIActor.h:52
vtkm::interop::anari::ANARIMapper::Name
std::string Name
Definition: ANARIMapper.h:131
vtkm::interop::anari::ANARIMapper::ColorTable
vtkm::cont::ColorTable ColorTable
Definition: ANARIMapper.h:130
vtkm::cont::ColorTable::Preset::Default
@ Default
vtkm::Vec< vtkm::Float32, 2 >
vtkm::Float32
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
vtkm::interop::anari::ANARIMapper::Handles
std::shared_ptr< ANARIHandles > Handles
Definition: ANARIMapper.h:128