VTK-m  2.2
ANARIMapperTriangles.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_ANARIMapperTriangles_h
12 #define vtk_m_interop_anari_ANARIMapperTriangles_h
13 
15 
16 namespace vtkm
17 {
18 namespace interop
19 {
20 namespace anari
21 {
22 
26 {
27  struct VertexData
28  {
29  anari_cpp::Array1D Position{ nullptr };
30  anari_cpp::Array1D Normal{ nullptr };
31  std::array<anari_cpp::Array1D, 4> Attribute;
32  std::array<std::string, 4> AttributeName;
33  } Vertex{};
34 
36  {
37  anari_cpp::Array1D Index{ nullptr };
38  } Primitive{};
39 
40  unsigned int NumPrimitives{ 0 };
41 };
42 
46 {
49  std::shared_ptr<vtkm::cont::Token> Token{ new vtkm::cont::Token };
50 };
51 
55 {
57  std::string Field1Name;
59  std::string Field2Name;
61  std::string Field3Name;
63  std::string Field4Name;
64  std::shared_ptr<vtkm::cont::Token> Token{ new vtkm::cont::Token };
65 };
66 
72 struct VTKM_ANARI_EXPORT ANARIMapperTriangles : public ANARIMapper
73 {
77  anari_cpp::Device device,
78  const ANARIActor& actor = {},
79  const std::string& name = "<triangles>",
81 
84  ~ANARIMapperTriangles() override;
85 
89  void SetActor(const ANARIActor& actor) override;
90 
94  void SetMapFieldAsAttribute(bool enabled) override;
95 
99  void SetANARIColorMap(anari_cpp::Array1D color,
100  anari_cpp::Array1D opacity,
101  bool releaseArrays = true) override;
102 
105  void SetANARIColorMapValueRange(const vtkm::Vec2f_32& valueRange) override;
106 
109  void SetCalculateNormals(bool enabled);
110 
111  anari_cpp::Geometry GetANARIGeometry() override;
112  anari_cpp::Surface GetANARISurface() override;
113 
114 private:
115  bool NeedToGenerateData() const;
119  void ConstructArrays(bool regenerate = false);
121  void UpdateGeometry();
123  void UpdateMaterial();
124 
127  {
128  anari_cpp::Device Device{ nullptr };
129  anari_cpp::Geometry Geometry{ nullptr };
130  anari_cpp::Sampler Sampler{ nullptr };
131  anari_cpp::Material Material{ nullptr };
132  anari_cpp::Surface Surface{ nullptr };
134  ~ANARIHandles();
135  void ReleaseArrays();
136  };
137 
138  std::shared_ptr<ANARIHandles> Handles;
139 
140  bool CalculateNormals{ false };
141  vtkm::IdComponent PrimaryField{ 0 };
144 };
145 
146 } // namespace anari
147 } // namespace interop
148 } // namespace vtkm
149 
150 #endif
vtkm::interop::anari::TriangleFieldArrays::Token
std::shared_ptr< vtkm::cont::Token > Token
Definition: ANARIMapperTriangles.h:64
anari
Definition: VtkmANARITypes.h:30
vtkm::interop::anari::TrianglesParameters::VertexData::Attribute
std::array< anari_cpp::Array1D, 4 > Attribute
Definition: ANARIMapperTriangles.h:31
ANARIMapper.h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::interop::anari::ANARIMapperTriangles::ANARIHandles::Parameters
TrianglesParameters Parameters
Definition: ANARIMapperTriangles.h:133
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::TriangleFieldArrays::Field4Name
std::string Field4Name
Definition: ANARIMapperTriangles.h:63
vtkm::interop::anari::TrianglesParameters::Primitive
struct vtkm::interop::anari::TrianglesParameters::PrimitiveData Primitive
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::interop::anari::ANARIMapperTriangles
Mapper which triangulates cells into ANARI triangle geometry.
Definition: ANARIMapperTriangles.h:72
vtkm::interop::anari::ANARIMapperTriangles::FieldArrays
TriangleFieldArrays FieldArrays
Definition: ANARIMapperTriangles.h:143
vtkm::interop::anari::TrianglesParameters::VertexData::AttributeName
std::array< std::string, 4 > AttributeName
Definition: ANARIMapperTriangles.h:32
vtkm::interop::anari::ANARIMapper
This is the base class used for all ANARI mappers.
Definition: ANARIMapper.h:37
vtkm::interop::anari::TriangleArrays::Vertices
vtkm::cont::ArrayHandle< vtkm::Vec3f_32 > Vertices
Definition: ANARIMapperTriangles.h:47
vtkm::interop::anari::TriangleArrays::Normals
vtkm::cont::ArrayHandle< vtkm::Vec3f_32 > Normals
Definition: ANARIMapperTriangles.h:48
vtkm::interop::anari::TriangleFieldArrays::Field2
vtkm::cont::ArrayHandle< vtkm::Float32 > Field2
Definition: ANARIMapperTriangles.h:58
vtkm::interop::anari::TriangleArrays::Token
std::shared_ptr< vtkm::cont::Token > Token
Definition: ANARIMapperTriangles.h:49
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::interop::anari::TrianglesParameters
Raw ANARI arrays and parameter values set on the ANARIGeometry.
Definition: ANARIMapperTriangles.h:25
vtkm::interop::anari::TriangleFieldArrays::Field1
vtkm::cont::ArrayHandle< vtkm::Float32 > Field1
Definition: ANARIMapperTriangles.h:56
vtkm::interop::anari::ANARIMapperTriangles::ANARIHandles
Container of all relevant ANARI scene object handles.
Definition: ANARIMapperTriangles.h:126
vtkm::interop::anari::ANARIActor
Collects cells, coords, and 0-4 fields for ANARI mappers to consume.
Definition: ANARIActor.h:52
vtkm::interop::anari::TriangleFieldArrays
VTK-m data arrays underlying the ANARIArray handles created by the mapper for field attributes.
Definition: ANARIMapperTriangles.h:54
vtkm::interop::anari::ANARIMapperTriangles::Handles
std::shared_ptr< ANARIHandles > Handles
Definition: ANARIMapperTriangles.h:138
vtkm::interop::anari::TrianglesParameters::Vertex
struct vtkm::interop::anari::TrianglesParameters::VertexData Vertex
vtkm::cont::ColorTable::Preset::Default
@ Default
vtkm::interop::anari::TrianglesParameters::PrimitiveData
Definition: ANARIMapperTriangles.h:35
vtkm::interop::anari::TrianglesParameters::NumPrimitives
unsigned int NumPrimitives
Definition: ANARIMapperTriangles.h:40
vtkm::interop::anari::TriangleFieldArrays::Field3Name
std::string Field3Name
Definition: ANARIMapperTriangles.h:61
vtkm::interop::anari::TrianglesParameters::VertexData
Definition: ANARIMapperTriangles.h:27
vtkm::Vec< vtkm::Float32, 2 >
vtkm::interop::anari::TrianglesParameters::VertexData::Normal
anari_cpp::Array1D Normal
Definition: ANARIMapperTriangles.h:30
vtkm::interop::anari::TriangleArrays
VTK-m data arrays underlying the ANARIArray handles created by the mapper.
Definition: ANARIMapperTriangles.h:45
vtkm::interop::anari::TriangleFieldArrays::Field4
vtkm::cont::ArrayHandle< vtkm::Float32 > Field4
Definition: ANARIMapperTriangles.h:62
vtkm::interop::anari::TrianglesParameters::VertexData::Position
anari_cpp::Array1D Position
Definition: ANARIMapperTriangles.h:29
vtkm::interop::anari::TrianglesParameters::PrimitiveData::Index
anari_cpp::Array1D Index
Definition: ANARIMapperTriangles.h:37
vtkm::interop::anari::TriangleFieldArrays::Field1Name
std::string Field1Name
Definition: ANARIMapperTriangles.h:57
vtkm::interop::anari::TriangleFieldArrays::Field3
vtkm::cont::ArrayHandle< vtkm::Float32 > Field3
Definition: ANARIMapperTriangles.h:60
vtkm::interop::anari::ANARIMapperTriangles::Arrays
TriangleArrays Arrays
Definition: ANARIMapperTriangles.h:142
vtkm::interop::anari::TriangleFieldArrays::Field2Name
std::string Field2Name
Definition: ANARIMapperTriangles.h:59