VTK-m  2.2
ANARIMapperPoints.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_ANARIMapperPoints_h
12 #define vtk_m_interop_anari_ANARIMapperPoints_h
13 
16 
17 namespace vtkm
18 {
19 namespace interop
20 {
21 namespace anari
22 {
23 
27 {
28  struct VertexData
29  {
30  anari_cpp::Array1D Position{ nullptr };
31  anari_cpp::Array1D Radius{ nullptr };
32  std::array<anari_cpp::Array1D, 4> Attribute;
33  std::array<std::string, 4> AttributeName;
34  } Vertex{};
35 
36  unsigned int NumPrimitives{ 0 };
37 };
38 
42 {
45  std::shared_ptr<vtkm::cont::Token> Token{ new vtkm::cont::Token };
46 };
47 
51 {
54  std::string Field1Name;
57  std::string Field2Name;
60  std::string Field3Name;
63  std::string Field4Name;
64  std::shared_ptr<vtkm::cont::Token> Token{ new vtkm::cont::Token };
65 };
66 
71 struct VTKM_ANARI_EXPORT ANARIMapperPoints : public ANARIMapper
72 {
76  anari_cpp::Device device,
77  const ANARIActor& actor = {},
78  const std::string& name = "<points>",
80 
83  ~ANARIMapperPoints() override;
84 
88  void SetActor(const ANARIActor& actor) override;
89 
93  void SetMapFieldAsAttribute(bool enabled) override;
94 
98  void SetANARIColorMap(anari_cpp::Array1D color,
99  anari_cpp::Array1D opacity,
100  bool releaseArrays = true) override;
101 
104  void SetANARIColorMapValueRange(const vtkm::Vec2f_32& valueRange) override;
105 
106  anari_cpp::Geometry GetANARIGeometry() override;
107  anari_cpp::Surface GetANARISurface() override;
108 
109 private:
113  void ConstructArrays(bool regenerate = false);
115  void UpdateGeometry();
117  void UpdateMaterial();
118 
121  {
122  anari_cpp::Device Device{ nullptr };
123  anari_cpp::Geometry Geometry{ nullptr };
124  anari_cpp::Sampler Sampler{ nullptr };
125  anari_cpp::Material Material{ nullptr };
126  anari_cpp::Surface Surface{ nullptr };
128  ~ANARIHandles();
129  void ReleaseArrays();
130  };
131 
132  std::shared_ptr<ANARIHandles> Handles;
133  vtkm::IdComponent PrimaryField{ 0 };
136 };
137 
138 } // namespace anari
139 } // namespace interop
140 } // namespace vtkm
141 
142 #endif
vtkm::interop::anari::PointsFieldArrays::NumberOfField1Components
int NumberOfField1Components
Definition: ANARIMapperPoints.h:53
anari
Definition: VtkmANARITypes.h:30
vtkm::interop::anari::ANARIMapperPoints::ANARIHandles
Container of all relevant ANARI scene object handles.
Definition: ANARIMapperPoints.h:120
ANARIMapper.h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::interop::anari::PointsFieldArrays::NumberOfField2Components
int NumberOfField2Components
Definition: ANARIMapperPoints.h:56
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
vtkm::interop::anari::PointsFieldArrays::Field4
vtkm::cont::ArrayHandleRuntimeVec< vtkm::Float32 > Field4
Definition: ANARIMapperPoints.h:61
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::interop::anari::PointsParameters::VertexData::Position
anari_cpp::Array1D Position
Definition: ANARIMapperPoints.h:30
vtkm::interop::anari::ANARIMapper
This is the base class used for all ANARI mappers.
Definition: ANARIMapper.h:37
vtkm::interop::anari::PointsParameters::NumPrimitives
unsigned int NumPrimitives
Definition: ANARIMapperPoints.h:36
vtkm::interop::anari::ANARIMapperPoints::Handles
std::shared_ptr< ANARIHandles > Handles
Definition: ANARIMapperPoints.h:132
vtkm::interop::anari::PointsFieldArrays::Field1Name
std::string Field1Name
Definition: ANARIMapperPoints.h:54
vtkm::interop::anari::PointsFieldArrays::Field2
vtkm::cont::ArrayHandleRuntimeVec< vtkm::Float32 > Field2
Definition: ANARIMapperPoints.h:55
vtkm::interop::anari::ANARIMapperPoints
Mapper which turns each point into ANARI sphere geometry.
Definition: ANARIMapperPoints.h:71
vtkm::interop::anari::PointsParameters::VertexData::AttributeName
std::array< std::string, 4 > AttributeName
Definition: ANARIMapperPoints.h:33
vtkm::interop::anari::PointsArrays
VTK-m data arrays underlying the ANARIArray handles created by the mapper.
Definition: ANARIMapperPoints.h:41
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::interop::anari::PointsParameters::Vertex
struct vtkm::interop::anari::PointsParameters::VertexData Vertex
vtkm::interop::anari::PointsFieldArrays
VTK-m data arrays underlying the ANARIArray handles created by the mapper for field attributes.
Definition: ANARIMapperPoints.h:50
vtkm::interop::anari::PointsParameters::VertexData::Radius
anari_cpp::Array1D Radius
Definition: ANARIMapperPoints.h:31
vtkm::interop::anari::ANARIActor
Collects cells, coords, and 0-4 fields for ANARI mappers to consume.
Definition: ANARIActor.h:52
vtkm::interop::anari::ANARIMapperPoints::ANARIHandles::Parameters
PointsParameters Parameters
Definition: ANARIMapperPoints.h:127
vtkm::interop::anari::PointsArrays::Token
std::shared_ptr< vtkm::cont::Token > Token
Definition: ANARIMapperPoints.h:45
vtkm::cont::ArrayHandleRuntimeVec< vtkm::Float32 >
vtkm::interop::anari::PointsParameters
Raw ANARI arrays and parameter values set on the ANARIGeometry.
Definition: ANARIMapperPoints.h:26
vtkm::cont::ColorTable::Preset::Default
@ Default
vtkm::interop::anari::PointsFieldArrays::Field1
vtkm::cont::ArrayHandleRuntimeVec< vtkm::Float32 > Field1
Definition: ANARIMapperPoints.h:52
vtkm::interop::anari::PointsParameters::VertexData::Attribute
std::array< anari_cpp::Array1D, 4 > Attribute
Definition: ANARIMapperPoints.h:32
vtkm::Vec< vtkm::Float32, 2 >
vtkm::interop::anari::PointsFieldArrays::Token
std::shared_ptr< vtkm::cont::Token > Token
Definition: ANARIMapperPoints.h:64
vtkm::interop::anari::PointsParameters::VertexData
Definition: ANARIMapperPoints.h:28
vtkm::interop::anari::PointsFieldArrays::Field3
vtkm::cont::ArrayHandleRuntimeVec< vtkm::Float32 > Field3
Definition: ANARIMapperPoints.h:58
vtkm::interop::anari::PointsFieldArrays::Field3Name
std::string Field3Name
Definition: ANARIMapperPoints.h:60
ArrayHandleRuntimeVec.h
vtkm::interop::anari::PointsArrays::Vertices
vtkm::cont::ArrayHandle< vtkm::Vec3f_32 > Vertices
Definition: ANARIMapperPoints.h:43
vtkm::interop::anari::PointsFieldArrays::Field4Name
std::string Field4Name
Definition: ANARIMapperPoints.h:63
vtkm::interop::anari::PointsFieldArrays::NumberOfField4Components
int NumberOfField4Components
Definition: ANARIMapperPoints.h:62
vtkm::interop::anari::ANARIMapperPoints::FieldArrays
PointsFieldArrays FieldArrays
Definition: ANARIMapperPoints.h:135
vtkm::interop::anari::PointsFieldArrays::NumberOfField3Components
int NumberOfField3Components
Definition: ANARIMapperPoints.h:59
vtkm::interop::anari::PointsFieldArrays::Field2Name
std::string Field2Name
Definition: ANARIMapperPoints.h:57
vtkm::interop::anari::ANARIMapperPoints::Arrays
PointsArrays Arrays
Definition: ANARIMapperPoints.h:134
vtkm::interop::anari::PointsArrays::Radii
vtkm::cont::ArrayHandle< vtkm::Float32 > Radii
Definition: ANARIMapperPoints.h:44