-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtut_rendering.cxx
More file actions
49 lines (39 loc) · 1.6 KB
/
tut_rendering.cxx
File metadata and controls
49 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <vtkm/cont/ColorTable.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/rendering/Actor.h>
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/MapperRayTracer.h>
#include <vtkm/rendering/Scene.h>
#include <vtkm/rendering/View3D.h>
int main(int argc, char** argv)
{
auto opts = vtkm::cont::InitializeOptions::DefaultAnyDevice;
vtkm::cont::InitializeResult config = vtkm::cont::Initialize(argc, argv, opts);
//Loading .vtk File
vtkm::io::VTKDataSetReader reader("data/kitchen.vtk");
vtkm::cont::DataSet ds_from_file = reader.ReadDataSet();
//Creating Actor
vtkm::cont::ColorTable colorTable("viridis");
vtkm::rendering::Actor actor(ds_from_file.GetCellSet(),
ds_from_file.GetCoordinateSystem(),
ds_from_file.GetField("c1"),
colorTable);
//Creating Scene and adding Actor
vtkm::rendering::Scene scene;
scene.AddActor(actor);
//Creating and initializing the View using the Canvas, Ray Tracer Mappers, and Scene
vtkm::rendering::MapperRayTracer mapper;
vtkm::rendering::CanvasRayTracer canvas(1920, 1080);
vtkm::rendering::View3D view(scene, mapper, canvas);
//Setting the background and foreground colors; optional.
view.SetBackgroundColor(vtkm::rendering::Color(1.0f, 1.0f, 1.0f));
view.SetForegroundColor(vtkm::rendering::Color(0.0f, 0.0f, 0.0f));
//Painting View
view.Paint();
//Saving View
view.SaveAs("BasicRendering.ppm");
return 0;
}