Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

add separate options to turn off world and sceen annots #220

Merged
merged 2 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/tests/vtkh/t_vtk-h_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,74 @@ TEST(vtkh_render, vtkh_no_bg_or_annotations)
scene.Render();
}

TEST(vtkh_render, vtkh_no_world_annotations)
{
vtkh::DataSet data_set;

const int base_size = 32;
const int num_blocks = 2;

for(int i = 0; i < num_blocks; ++i)
{
data_set.AddDomain(CreateTestData(i, num_blocks, base_size), i);
}

vtkm::Bounds bounds = data_set.GetGlobalBounds();

vtkm::rendering::Camera camera;
camera.SetPosition(vtkm::Vec<vtkm::Float64,3>(-16, -16, -16));
camera.ResetToBounds(bounds);
vtkh::Render render = vtkh::MakeRender(512,
512,
camera,
data_set,
"no_world");
render.DoRenderWorldAnnotations(false);
vtkh::RayTracer tracer;

tracer.SetInput(&data_set);
tracer.SetField("point_data_Float64");

vtkh::Scene scene;
scene.AddRender(render);
scene.AddRenderer(&tracer);
scene.Render();
}

TEST(vtkh_render, vtkh_no_screen_annotations)
{
vtkh::DataSet data_set;

const int base_size = 32;
const int num_blocks = 2;

for(int i = 0; i < num_blocks; ++i)
{
data_set.AddDomain(CreateTestData(i, num_blocks, base_size), i);
}

vtkm::Bounds bounds = data_set.GetGlobalBounds();

vtkm::rendering::Camera camera;
camera.SetPosition(vtkm::Vec<vtkm::Float64,3>(-16, -16, -16));
camera.ResetToBounds(bounds);
vtkh::Render render = vtkh::MakeRender(512,
512,
camera,
data_set,
"no_screen");
render.DoRenderScreenAnnotations(false);
vtkh::RayTracer tracer;

tracer.SetInput(&data_set);
tracer.SetField("point_data_Float64");

vtkh::Scene scene;
scene.AddRender(render);
scene.AddRenderer(&tracer);
scene.Render();
}

TEST(vtkh_render, vtkh_bg_color)
{
vtkh::DataSet data_set;
Expand Down
19 changes: 19 additions & 0 deletions src/vtkh/rendering/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Render::Render()
: m_width(1024),
m_height(1024),
m_render_annotations(true),
m_render_world_annotations(true),
m_render_screen_annotations(true),
m_render_background(true),
m_shading(true),
m_canvas(m_width, m_height)
Expand Down Expand Up @@ -44,6 +46,20 @@ Render::DoRenderAnnotations(bool on)
m_render_annotations = on;
}

void
Render::DoRenderWorldAnnotations(bool on)
{
m_render_world_annotations = on;
}


void
Render::DoRenderScreenAnnotations(bool on)
{
m_render_screen_annotations = on;
}


void
Render::DoRenderBackground(bool on)
{
Expand Down Expand Up @@ -168,6 +184,7 @@ void
Render::RenderWorldAnnotations()
{
if(!m_render_annotations) return;
if(!m_render_world_annotations) return;
#ifdef VTKH_PARALLEL
if(vtkh::GetMPIRank() != 0) return;
#endif
Expand All @@ -184,6 +201,8 @@ Render::RenderScreenAnnotations(const std::vector<std::string> &field_names,
const std::vector<vtkm::Range> &ranges,
const std::vector<vtkm::cont::ColorTable> &colors)
{
if(!m_render_annotations) return;
if(!m_render_screen_annotations) return;
#ifdef VTKH_PARALLEL
if(vtkh::GetMPIRank() != 0) return;
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/vtkh/rendering/Render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class VTKH_API Render
void Print() const;

void DoRenderAnnotations(bool on);
void DoRenderWorldAnnotations(bool on);
void DoRenderScreenAnnotations(bool on);
void DoRenderBackground(bool on);
void ScaleWorldAnnotations(float x, float y, float z);
void SetWidth(const vtkm::Int32 width);
Expand Down Expand Up @@ -68,6 +70,8 @@ class VTKH_API Render
vtkm::rendering::Color m_fg_color;
vtkmCanvas CreateCanvas() const;
bool m_render_annotations;
bool m_render_world_annotations;
bool m_render_screen_annotations;
bool m_render_background;
bool m_shading;
vtkmCanvas m_canvas;
Expand Down