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

Commit

Permalink
fixing a compositing issue and never set the radius to 0 (#205)
Browse files Browse the repository at this point in the history
* fixing a compositing issue and never set the radius to 0

* account for an empty data set for clipping

* add a test for rendering particles with no data
  • Loading branch information
mclarsen authored Mar 17, 2021
1 parent 580b38f commit 879ff43
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
54 changes: 54 additions & 0 deletions src/tests/vtkh/t_vtk-h_point_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <vtkh/vtkh.hpp>
#include <vtkh/DataSet.hpp>
#include <vtkh/rendering/PointRenderer.hpp>
#include <vtkh/filters/MarchingCubes.hpp>
#include <vtkh/rendering/Scene.hpp>
#include "t_test_utils.hpp"

Expand Down Expand Up @@ -82,6 +83,59 @@ TEST(vtkh_point_renderer, vtkh_variable_point_render)



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

}

TEST(vtkh_point_renderer, vtkh_point_no_data)
{
vtkh::DataSet data_set;

const int base_size = 16;
const int num_blocks = 2;

for(int i = 0; i < num_blocks; ++i)
{
data_set.AddDomain(CreateTestData(i, num_blocks, base_size), i);
}
vtkh::MarchingCubes marcher;
marcher.SetInput(&data_set);
marcher.SetField("point_data_Float64");

const int num_vals = 1;
double iso_vals [num_vals];
iso_vals[0] = -1; // ask for something that does not exist

marcher.SetIsoValues(iso_vals, num_vals);
marcher.AddMapField("point_data_Float64");
marcher.AddMapField("cell_data_Float64");
marcher.Update();

vtkh::DataSet *iso_output = marcher.GetOutput();
data_set = *iso_output;
delete iso_output;

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

vtkm::rendering::Camera camera;
camera.ResetToBounds(bounds);
camera.SetPosition(vtkm::Vec<vtkm::Float64,3>(16, 36, -36));
vtkh::Render render = vtkh::MakeRender(512,
512,
camera,
data_set,
"render_no_data");
vtkh::PointRenderer renderer;
renderer.SetInput(&data_set);
renderer.SetField("point_data_Float64");
renderer.UseVariableRadius(true);
renderer.SetRadiusDelta(1.0f);



vtkh::Scene scene;
scene.AddRenderer(&renderer);
scene.AddRender(render);
Expand Down
4 changes: 2 additions & 2 deletions src/vtkh/DataSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void MemSet(vtkm::cont::ArrayHandle<T> &array, const T value, const vtkm::Id num
bool
DataSet::OneDomainPerRank() const
{
bool at_least_one = GetNumberOfDomains() < 2;
return detail::GlobalAgreement(at_least_one);
bool one = GetNumberOfDomains() == 1;
return detail::GlobalAgreement(one);
}

void
Expand Down
11 changes: 11 additions & 0 deletions src/vtkh/filters/Clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ void Clip::DoExecute()
{

DataSet data_set;
const int global_domains = this->m_input->GetGlobalNumberOfDomains();
if(global_domains == 0)
{
// if the number of domains zero there is no work to do,
// additionally, a multiplane clip will fail since it will
// check if 'mclip_field' will exist, which it wont.
DataSet *output = new DataSet();
*output = *(this->m_input);
this->m_output = output;
return;
}
const int num_domains = this->m_input->GetNumberOfDomains();
// we now have to work around this since
// vtkm dropped support for new implicit functions
Expand Down
5 changes: 5 additions & 0 deletions src/vtkh/rendering/PointRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ PointRenderer::PreExecute()
// same as used in vtk ospray
constexpr vtkm::Float64 heuristic = 1000.;
radius = static_cast<vtkm::Float32>(mag / heuristic);
// we likely have a data set with no cells so just set some radius
if(radius == 0.f)
{
radius = 0.00001f;
}
mesh_mapper->SetRadius(radius);
}

Expand Down
1 change: 1 addition & 0 deletions src/vtkh/rendering/VolumeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ VolumeRenderer::DoExecute()
{
if(m_input->OneDomainPerRank() && !m_has_unstructured)
{
// Danger: this logic only works if there is exactly one per rank
RenderOneDomainPerRank();
}
else
Expand Down

0 comments on commit 879ff43

Please sign in to comment.