SENSEI
A frame work for generic in situ analytics
OSPRayAnalysisAdaptor.h
1 /**
2  *
3  */
4 
5 #ifndef OSPRayAnalysisAdaptor_h
6 #define OSPRayAnalysisAdaptor_h
7 
8 // SENSEI
9 #include <AnalysisAdaptor.h>
10 
11 // VTK
12 class svtkDataObject;
13 #include <svtkObject.h>
14 #include <svtkSetGet.h>
15 #include <svtkSmartPointer.h>
16 
17 #include <vector>
18 
19 namespace sensei {
20 
21 /// An analysis adaptor for OSPRay based rendering pipelines
23 public:
24  static OSPRayAnalysisAdaptor *New();
25  senseiTypeMacro(OSPRayAnalysisAdaptor, AnalysisAdaptor);
26 
27  /// Initialize OSPRay library
28  int Initialize();
29  // Run in situ OSPRay Rendering
30  bool Execute(sensei::DataAdaptor *, sensei::DataAdaptor **) override;
31  /// Shut down and clean up OSPRay
32  int Finalize() override;
33 
34  /// one of "SPHERES", "UGRID", "SGRID"
35  virtual void SetRenderAs(const char *_arg);
36 
37  virtual void SetMeshName(const char *_arg) {
38  this->MeshName = _arg;
39  }
40 
41  /// point or cell data
42  virtual void SetAssociation(const char *_arg) {
43  this->Association = _arg;
44  }
45  /// data array name
46  virtual void SetArrayName(const char *_arg) {
47  this->ArrayName = _arg;
48  }
49 
50  virtual void SetDirectory(const char *_arg) {
51  this->Directory = _arg;
52  }
53  virtual void SetFileName(const char *_arg) {
54  this->FileName = _arg;
55  }
56 
57  virtual void SetWidth(int _arg) {
58  this->Width = _arg;
59  }
60 
61  virtual void SetHeight(int _arg) {
62  this->Height = _arg;
63  }
64 
65  void SetUseD3(bool _arg) {
66  this->UseD3 = _arg;
67  }
68  // linearized colormap of colors and opacities. Colors should be 3x opacities
69  void SetColormap(const std::vector<float>& colors, const std::vector<float>& opacities) {
70  this->Colors = colors;
71  this->Opacities = opacities;
72  }
73 
74  void SetColormapRange(float v1, float v2) {
75  this->TFRange[0] = v1;
76  this->TFRange[1] = v2;
77  }
78 
79  void SetParticleRadius(float radius) {
80  this->ParticleRadius = radius;
81  }
82 
83  void SetParticleColor(float color[3]) {
84  this->ParticleColor[0] = color[0];
85  this->ParticleColor[1] = color[1];
86  this->ParticleColor[2] = color[2];
87  this->ParticleColorSet = true;
88  }
89 
90  void SetBackgroundColor(float color[4]) {
91  this->BackgroundColor[0] = color[0];
92  this->BackgroundColor[1] = color[1];
93  this->BackgroundColor[2] = color[2];
94  this->BackgroundColor[3] = color[3];
95  }
96 
97  /// OSPRay specific camera data
98  struct Camera {
99  std::vector<double> Position = {30.0, 30.0, 150.0};
100  std::vector<double> Direction = {0.0, 0.0, -1.0};
101  std::vector<double> Up = {0.0, 1.0, 0.0};
102  double Fovy = 35.0;
103  double FocusDistance = 0.0;
104  };
105 
106  void SetCamera(OSPRayAnalysisAdaptor::Camera camera) {
107  this->CameraData = camera;
108  }
109 
110 private:
111  int RenderAs = 0;
112  std::string MeshName;
113  std::string Association;
114  std::string ArrayName;
115 
116  std::string Directory = ".";
117  std::string FileName = "output";
118  int Width;
119  int Height;
120  std::vector<float> Colors;
121  std::vector<float> Opacities;
122  float TFRange[2] = {0.f, 0.5f};
124  float ParticleRadius = 0.7f;
125  float ParticleColor[3] {0.f, 0.f, 0.f};
126  bool ParticleColorSet = false;
127  float BackgroundColor[4] {0.f, 0.f, 0.f, 1.f};
128 
129  bool UseD3{false};
130 
131  struct InternalsType;
132  InternalsType *Internals;
133 
134  void RenderAsSpheresImpl(svtkDataObject *, int);
135  void RenderAsUGridImpl(svtkDataObject *, int);
136  void RenderAsSGridImpl(svtkDataObject *, int);
137 };
138 
139 } /* namespace sensei */
140 
141 #endif /* OSPRayAnalysisAdaptor_h */
virtual void SetRenderAs(const char *_arg)
one of "SPHERES", "UGRID", "SGRID"
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
OSPRay specific camera data.
Definition: OSPRayAnalysisAdaptor.h:98
virtual void SetArrayName(const char *_arg)
data array name
Definition: OSPRayAnalysisAdaptor.h:46
int Initialize()
Initialize OSPRay library.
bool Execute(sensei::DataAdaptor *, sensei::DataAdaptor **) override
Invokes in situ processing, data movement or I/O.
SENSEI.
Definition: ADIOS2AnalysisAdaptor.h:27
int Finalize() override
Shut down and clean up OSPRay.
virtual void SetAssociation(const char *_arg)
point or cell data
Definition: OSPRayAnalysisAdaptor.h:42
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25
An analysis adaptor for OSPRay based rendering pipelines.
Definition: OSPRayAnalysisAdaptor.h:22