enable partitioned rendering by ghost blanking and depth sorting

This commit is contained in:
Roxana Bujack 2023-11-06 17:42:43 -07:00
parent b7125bd6fc
commit c720744fb9
40 changed files with 480 additions and 91 deletions

@ -165,6 +165,42 @@ struct Bounds
VTKM_EXEC_CONT VTKM_EXEC_CONT
vtkm::Vec3f_64 MaxCorner() const { return vtkm::Vec3f_64(this->X.Max, this->Y.Max, this->Z.Max); } vtkm::Vec3f_64 MaxCorner() const { return vtkm::Vec3f_64(this->X.Max, this->Y.Max, this->Z.Max); }
/// \b Returns all cornes of the bounds
///
/// \c Corders returns the cornerst of the bounds.If the bounds
/// are empty, the results are undefined.
///
VTKM_EXEC_CONT
void Corners(vtkm::Vec3f_64* corners) const
{
corners[0] = vtkm::Vec3f(this->X.Min, this->Y.Min, this->Z.Min);
corners[1] = vtkm::Vec3f(this->X.Min, this->Y.Min, this->Z.Max);
corners[2] = vtkm::Vec3f(this->X.Min, this->Y.Max, this->Z.Min);
corners[3] = vtkm::Vec3f(this->X.Min, this->Y.Max, this->Z.Max);
corners[4] = vtkm::Vec3f(this->X.Max, this->Y.Min, this->Z.Min);
corners[5] = vtkm::Vec3f(this->X.Max, this->Y.Min, this->Z.Max);
corners[6] = vtkm::Vec3f(this->X.Max, this->Y.Max, this->Z.Min);
corners[7] = vtkm::Vec3f(this->X.Max, this->Y.Max, this->Z.Max);
}
/// \b Returns the max point of the bounds
///
/// \c Distance returns the Euclidean distance of the bounding box to a given point. If the bounds
/// are empty, the results are undefined.
///
VTKM_EXEC_CONT
vtkm::Float64 Distance(vtkm::Vec3f_64 point) const
{
vtkm::Vec3f_64 corners[8];
Corners(corners);
vtkm::Float64 distance = std::numeric_limits<double>::max();
for (unsigned int p = 0; p < 8; p++)
{
distance = std::min(distance, std::sqrt(vtkm::Dot(corners[p] - point, corners[p] - point)));
}
return distance;
}
/// \b Expand bounds to include a point. /// \b Expand bounds to include a point.
/// ///
/// This version of \c Include expands the bounds just enough to include the /// This version of \c Include expands the bounds just enough to include the

@ -45,18 +45,8 @@ void CellLocatorPartitioned::Build()
this->LocatorsCont.at(index) = cellLocator; this->LocatorsCont.at(index) = cellLocator;
// fill vector of ghostFields // fill vector of ghostFields
vtkm::cont::ArrayHandle<vtkm::UInt8> ghostArrayHandle; this->GhostsCont.at(index) =
if (dataset.HasCellField("vtkGhostType")) dataset.GetGhostCellField().GetData().ExtractComponent<vtkm::UInt8>(0);
{
dataset.GetField("vtkGhostType").GetData().AsArrayHandle(ghostArrayHandle);
}
else
{
vtkm::cont::ArrayCopy(
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(0, dataset.GetNumberOfCells()),
ghostArrayHandle);
}
this->GhostsCont.at(index) = ghostArrayHandle;
} }
} }

@ -47,9 +47,9 @@ public:
private: private:
vtkm::cont::PartitionedDataSet Partitions; vtkm::cont::PartitionedDataSet Partitions;
std::vector<CellLocatorGeneral> LocatorsCont; std::vector<CellLocatorGeneral> LocatorsCont;
std::vector<vtkm::cont::ArrayHandle<vtkm::UInt8>> GhostsCont; std::vector<vtkm::cont::ArrayHandleStride<vtkm::UInt8>> GhostsCont;
vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType> LocatorsExec; vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType> LocatorsExec;
vtkm::cont::ArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>::ReadPortalType> GhostsExec; vtkm::cont::ArrayHandle<vtkm::cont::ArrayHandleStride<vtkm::UInt8>::ReadPortalType> GhostsExec;
bool Modified = true; bool Modified = true;
}; };
} // namespace cont } // namespace cont

@ -153,7 +153,7 @@ bool DataSet::HasGhostCellField() const
return this->HasCellField(this->GetGhostCellFieldName()); return this->HasCellField(this->GetGhostCellFieldName());
} }
const vtkm::cont::Field& DataSet::GetGhostCellField() const const vtkm::cont::Field DataSet::GetGhostCellField() const
{ {
if (this->HasGhostCellField()) if (this->HasGhostCellField())
{ {
@ -161,7 +161,9 @@ const vtkm::cont::Field& DataSet::GetGhostCellField() const
} }
else else
{ {
throw vtkm::cont::ErrorBadValue("No Ghost Cell Field"); return make_FieldCell(
this->GetGhostCellFieldName(),
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(0, this->GetNumberOfCells()));
} }
} }

@ -163,11 +163,11 @@ public:
/// \brief Returns the cell field that matches the ghost cell field name. /// \brief Returns the cell field that matches the ghost cell field name.
/// ///
/// This method will throw an exception if no match is found. Use `HasGhostCellField()` to query /// This method will return a constant array of zeros if no match is found. Use `HasGhostCellField()` to query
/// whether a particular field exists. /// whether a particular field exists.
///@{ ///@{
VTKM_CONT VTKM_CONT
const vtkm::cont::Field& GetGhostCellField() const; const vtkm::cont::Field GetGhostCellField() const;
///@} ///@}
/// \brief Returns the first point field that matches the provided name. /// \brief Returns the first point field that matches the provided name.
@ -243,6 +243,13 @@ public:
this->AddField(make_FieldCell(fieldName, field)); this->AddField(make_FieldCell(fieldName, field));
} }
template <typename T>
VTKM_CONT void AddCellField(const std::string& fieldName,
const vtkm::cont::ArrayHandleConstant<T>& field)
{
this->AddField(make_FieldCell(fieldName, field));
}
template <typename T> template <typename T>
VTKM_CONT void AddCellField(const std::string& fieldName, const std::vector<T>& field) VTKM_CONT void AddCellField(const std::string& fieldName, const std::vector<T>& field)
{ {

@ -16,6 +16,7 @@
#include <vtkm/Types.h> #include <vtkm/Types.h>
#include <vtkm/cont/ArrayHandle.h> #include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/CastAndCall.h> #include <vtkm/cont/CastAndCall.h>
#include <vtkm/cont/UnknownArrayHandle.h> #include <vtkm/cont/UnknownArrayHandle.h>
@ -251,6 +252,14 @@ inline vtkm::cont::Field make_FieldCell(std::string name,
return vtkm::cont::Field(name, vtkm::cont::Field::Association::Cells, data); return vtkm::cont::Field(name, vtkm::cont::Field::Association::Cells, data);
} }
/// Convenience function to build cell fields from vtkm::cont::ArrayHandleConstant
template <typename T>
inline vtkm::cont::Field make_FieldCell(std::string name,
const vtkm::cont::ArrayHandleConstant<T>& data)
{
return vtkm::cont::Field(name, vtkm::cont::Field::Association::Cells, data);
}
} // namespace cont } // namespace cont
} // namespace vtkm } // namespace vtkm

@ -22,16 +22,16 @@ class VTKM_ALWAYS_EXPORT CellLocatorPartitioned
{ {
private: private:
vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType>::ReadPortalType Locators; vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType>::ReadPortalType Locators;
vtkm::cont::ArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>::ReadPortalType>::ReadPortalType vtkm::cont::ArrayHandle<
Ghosts; vtkm::cont::ArrayHandleStride<vtkm::UInt8>::ReadPortalType>::ReadPortalType Ghosts;
public: public:
VTKM_CONT CellLocatorPartitioned() = default; VTKM_CONT CellLocatorPartitioned() = default;
VTKM_CONT CellLocatorPartitioned( VTKM_CONT CellLocatorPartitioned(
const vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType>::ReadPortalType& const vtkm::cont::ArrayHandle<vtkm::cont::CellLocatorGeneral::ExecObjType>::ReadPortalType&
locators, locators,
vtkm::cont::ArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>::ReadPortalType>::ReadPortalType vtkm::cont::ArrayHandle<
ghosts) vtkm::cont::ArrayHandleStride<vtkm::UInt8>::ReadPortalType>::ReadPortalType ghosts)
: Locators(locators) : Locators(locators)
, Ghosts(ghosts) , Ghosts(ghosts)
{ {

@ -223,21 +223,12 @@ void AmrArrays::ComputeGenerateGhostType()
this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent)); this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent));
vtkm::cont::CellSetStructured<Dim> cellset; vtkm::cont::CellSetStructured<Dim> cellset;
partition.GetCellSet().AsCellSet(cellset); partition.GetCellSet().AsCellSet(cellset);
vtkm::cont::ArrayHandle<vtkm::UInt8> ghostField; vtkm::cont::ArrayHandle<vtkm::UInt8> ghostArrayHandle;
if (!partition.HasField("vtkGhostType", vtkm::cont::Field::Association::Cells)) vtkm::cont::Invoker invoke;
{ invoke(vtkm::worklet::ResetGhostTypeWorklet{},
ghostField.AllocateAndFill(partition.GetNumberOfCells(), 0); partition.GetGhostCellField().GetData().ExtractComponent<vtkm::UInt8>(0),
} ghostArrayHandle);
else partition.AddCellField(vtkm::cont::GetGlobalGhostCellFieldName(), ghostArrayHandle);
{
vtkm::cont::Invoker invoke;
invoke(vtkm::worklet::ResetGhostTypeWorklet{},
partition.GetField("vtkGhostType", vtkm::cont::Field::Association::Cells)
.GetData()
.AsArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>>(),
ghostField);
}
partition.AddCellField("vtkGhostType", ghostField);
auto pointField = partition.GetCoordinateSystem().GetDataAsMultiplexer(); auto pointField = partition.GetCoordinateSystem().GetDataAsMultiplexer();
@ -253,11 +244,10 @@ void AmrArrays::ComputeGenerateGhostType()
.GetBounds(); .GetBounds();
// std::cout<<" is (partly) contained in level "<<l + 1<<" block "<<bChild<<" which is partition "<<this->ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).at(bChild)<<" with bounds "<<boundsChild<<std::endl; // std::cout<<" is (partly) contained in level "<<l + 1<<" block "<<bChild<<" which is partition "<<this->ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).at(bChild)<<" with bounds "<<boundsChild<<std::endl;
vtkm::cont::Invoker invoke;
invoke(vtkm::worklet::GenerateGhostTypeWorklet<Dim>{ boundsChild }, invoke(vtkm::worklet::GenerateGhostTypeWorklet<Dim>{ boundsChild },
cellset, cellset,
pointField, pointField,
ghostField); partition.GetGhostCellField().GetData().ExtractComponent<vtkm::UInt8>(0));
} }
this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(bParent), partition); this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(bParent), partition);
} }

@ -40,7 +40,7 @@ private:
template <vtkm::IdComponent Dim> template <vtkm::IdComponent Dim>
void ComputeGenerateParentChildInformation(); void ComputeGenerateParentChildInformation();
/// generate the vtkGhostType array based on the overlap analogously to vtk /// generate the GhostType array based on the overlap analogously to vtk
/// blanked cells: 8 normal cells: 0 /// blanked cells: 8 normal cells: 0
VTKM_CONT VTKM_CONT
void GenerateGhostType(); void GenerateGhostType();

@ -10,6 +10,9 @@
#include <vtkm/rendering/Actor.h> #include <vtkm/rendering/Actor.h>
#include <vtkm/Assert.h>
#include <vtkm/cont/BoundsCompute.h>
#include <vtkm/cont/FieldRangeCompute.h>
#include <vtkm/cont/TryExecute.h> #include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/UnknownCellSet.h> #include <vtkm/cont/UnknownCellSet.h>
@ -30,10 +33,39 @@ struct Actor::InternalsType
vtkm::Range ScalarRange; vtkm::Range ScalarRange;
vtkm::Bounds SpatialBounds; vtkm::Bounds SpatialBounds;
vtkm::cont::PartitionedDataSet DataSet;
std::string FieldName;
VTKM_CONT VTKM_CONT
InternalsType(vtkm::cont::UnknownCellSet cells, InternalsType(const vtkm::cont::PartitionedDataSet partitionedDataSet,
vtkm::cont::CoordinateSystem coordinates, const std::string fieldName,
vtkm::cont::Field scalarField, const vtkm::rendering::Color& color)
: Cells(partitionedDataSet.GetPartition(0).GetCellSet())
, Coordinates(partitionedDataSet.GetPartition(0).GetCoordinateSystem())
, ScalarField(partitionedDataSet.GetPartition(0).GetField(fieldName))
, ColorTable(vtkm::Range{ 0, 1 }, color.Components, color.Components)
, DataSet(partitionedDataSet)
, FieldName(fieldName)
{
}
VTKM_CONT
InternalsType(const vtkm::cont::PartitionedDataSet partitionedDataSet,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable = vtkm::cont::ColorTable::Preset::Default)
: Cells(partitionedDataSet.GetPartition(0).GetCellSet())
, Coordinates(partitionedDataSet.GetPartition(0).GetCoordinateSystem())
, ScalarField(partitionedDataSet.GetPartition(0).GetField(fieldName))
, ColorTable(colorTable)
, DataSet(partitionedDataSet)
, FieldName(fieldName)
{
}
VTKM_CONT
InternalsType(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::CoordinateSystem& coordinates,
const vtkm::cont::Field& scalarField,
const vtkm::rendering::Color& color) const vtkm::rendering::Color& color)
: Cells(std::move(cells)) : Cells(std::move(cells))
, Coordinates(std::move(coordinates)) , Coordinates(std::move(coordinates))
@ -55,6 +87,56 @@ struct Actor::InternalsType
} }
}; };
Actor::Actor(const vtkm::cont::DataSet dataSet, const std::string fieldName)
{
vtkm::cont::PartitionedDataSet partitionedDataSet;
partitionedDataSet.AppendPartition(dataSet);
this->Internals = std::make_unique<InternalsType>(partitionedDataSet, fieldName);
this->Init();
}
Actor::Actor(const vtkm::cont::DataSet dataSet,
const std::string fieldName,
const vtkm::rendering::Color& color)
{
vtkm::cont::PartitionedDataSet partitionedDataSet;
partitionedDataSet.AppendPartition(dataSet);
this->Internals = std::make_unique<InternalsType>(partitionedDataSet, fieldName, color);
this->Init();
}
Actor::Actor(const vtkm::cont::DataSet dataSet,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable)
{
vtkm::cont::PartitionedDataSet partitionedDataSet;
partitionedDataSet.AppendPartition(dataSet);
this->Internals = std::make_unique<InternalsType>(partitionedDataSet, fieldName, colorTable);
this->Init();
}
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet, const std::string fieldName)
: Internals(new InternalsType(dataSet, fieldName))
{
this->Init();
}
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
const std::string fieldName,
const vtkm::rendering::Color& color)
: Internals(new InternalsType(dataSet, fieldName, color))
{
this->Init();
}
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable)
: Internals(new InternalsType(dataSet, fieldName, colorTable))
{
this->Init();
}
Actor::Actor(const vtkm::cont::UnknownCellSet& cells, Actor::Actor(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::CoordinateSystem& coordinates, const vtkm::cont::CoordinateSystem& coordinates,
const vtkm::cont::Field& scalarField) const vtkm::cont::Field& scalarField)
@ -119,20 +201,41 @@ void Actor::Init(const vtkm::cont::CoordinateSystem& coordinates,
this->Internals->SpatialBounds = coordinates.GetBounds(); this->Internals->SpatialBounds = coordinates.GetBounds();
} }
void Actor::Init()
{
this->Internals->SpatialBounds = vtkm::cont::BoundsCompute(this->Internals->DataSet);
this->Internals->ScalarRange =
vtkm::cont::FieldRangeCompute(this->Internals->DataSet, this->Internals->FieldName)
.ReadPortal()
.Get(0);
}
void Actor::Render(vtkm::rendering::Mapper& mapper, void Actor::Render(vtkm::rendering::Mapper& mapper,
vtkm::rendering::Canvas& canvas, vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera) const const vtkm::rendering::Camera& camera) const
{ {
mapper.SetCanvas(&canvas); mapper.SetCanvas(&canvas);
mapper.SetActiveColorTable(this->Internals->ColorTable); mapper.SetActiveColorTable(this->Internals->ColorTable);
mapper.RenderCells(this->Internals->Cells, if (this->Internals->DataSet.GetNumberOfPartitions() > 0)
this->Internals->Coordinates, {
this->Internals->ScalarField, mapper.RenderCellsPartitioned(this->Internals->DataSet,
this->Internals->ColorTable, this->Internals->FieldName,
camera, this->Internals->ColorTable,
this->Internals->ScalarRange); camera,
this->Internals->ScalarRange);
}
else
{
mapper.RenderCells(this->Internals->Cells,
this->Internals->Coordinates,
this->Internals->ScalarField,
this->Internals->ColorTable,
camera,
this->Internals->ScalarRange);
}
} }
const vtkm::cont::UnknownCellSet& Actor::GetCells() const const vtkm::cont::UnknownCellSet& Actor::GetCells() const
{ {
return this->Internals->Cells; return this->Internals->Cells;

@ -26,6 +26,26 @@ namespace rendering
class VTKM_RENDERING_EXPORT Actor class VTKM_RENDERING_EXPORT Actor
{ {
public: public:
Actor(const vtkm::cont::DataSet dataSet, const std::string fieldName);
Actor(const vtkm::cont::DataSet dataSet,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable);
Actor(const vtkm::cont::DataSet dataSet,
const std::string fieldName,
const vtkm::rendering::Color& color);
Actor(const vtkm::cont::PartitionedDataSet dataSet, const std::string fieldName);
Actor(const vtkm::cont::PartitionedDataSet dataSet,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable);
Actor(const vtkm::cont::PartitionedDataSet dataSet,
const std::string fieldName,
const vtkm::rendering::Color& color);
Actor(const vtkm::cont::UnknownCellSet& cells, Actor(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::CoordinateSystem& coordinates, const vtkm::cont::CoordinateSystem& coordinates,
const vtkm::cont::Field& scalarField); const vtkm::cont::Field& scalarField);
@ -70,6 +90,8 @@ private:
std::unique_ptr<InternalsType> Internals; std::unique_ptr<InternalsType> Internals;
void Init(const vtkm::cont::CoordinateSystem& coordinates, const vtkm::cont::Field& scalarField); void Init(const vtkm::cont::CoordinateSystem& coordinates, const vtkm::cont::Field& scalarField);
void Init();
}; };
} }
} //namespace vtkm::rendering } //namespace vtkm::rendering

@ -130,7 +130,11 @@ public:
if (this->Mode == RenderMode::Volume) if (this->Mode == RenderMode::Volume)
{ {
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords); Tracer.SetVolumeData(this->ScalarField,
this->ScalarRange,
this->Cells,
this->Coords,
this->Dataset.GetGhostCellField());
} }
else else
{ {
@ -149,7 +153,11 @@ public:
{ {
if (this->Mode == RenderMode::Volume) if (this->Mode == RenderMode::Volume)
{ {
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords); Tracer.SetVolumeData(this->ScalarField,
this->ScalarRange,
this->Cells,
this->Coords,
this->Dataset.GetGhostCellField());
} }
else else
{ {
@ -169,7 +177,11 @@ public:
if (this->Mode == RenderMode::Volume) if (this->Mode == RenderMode::Volume)
{ {
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords); Tracer.SetVolumeData(this->ScalarField,
this->ScalarRange,
this->Cells,
this->Coords,
this->Dataset.GetGhostCellField());
} }
else else
{ {
@ -188,7 +200,11 @@ public:
{ {
if (this->Mode == RenderMode::Volume) if (this->Mode == RenderMode::Volume)
{ {
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords); Tracer.SetVolumeData(this->ScalarField,
this->ScalarRange,
this->Cells,
this->Coords,
this->Dataset.GetGhostCellField());
} }
else else
{ {
@ -220,7 +236,11 @@ public:
if (this->Mode == RenderMode::Volume) if (this->Mode == RenderMode::Volume)
{ {
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords); Tracer.SetVolumeData(this->ScalarField,
this->ScalarRange,
this->Cells,
this->Coords,
this->Dataset.GetGhostCellField());
} }
else else
{ {

@ -8,6 +8,7 @@
// PURPOSE. See the above copyright notice for more information. // PURPOSE. See the above copyright notice for more information.
//============================================================================ //============================================================================
#include <vtkm/cont/BoundsCompute.h>
#include <vtkm/rendering/Mapper.h> #include <vtkm/rendering/Mapper.h>
namespace vtkm namespace vtkm
@ -17,6 +18,70 @@ namespace rendering
Mapper::~Mapper() {} Mapper::~Mapper() {}
void Mapper::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange)
{
RenderCells(cellset,
coords,
scalarField,
colorTable,
camera,
scalarRange,
make_FieldCell(
vtkm::cont::GetGlobalGhostCellFieldName(),
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>(0, scalarField.GetNumberOfValues())));
};
struct CompareIndices
{
vtkm::Vec3f CameraDirection;
vtkm::Vec3f* Centers;
CompareIndices(vtkm::Vec3f* centers, vtkm::Vec3f cameraDirection)
: CameraDirection(cameraDirection)
, Centers(centers)
{
}
bool operator()(int i, int j) const
{
return (vtkm::Dot(Centers[i], CameraDirection) > vtkm::Dot(Centers[j], CameraDirection));
}
};
void Mapper::RenderCellsPartitioned(const vtkm::cont::PartitionedDataSet partitionedData,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange)
{
// sort partitions back to front for best rendering with the volume renderer
vtkm::Vec3f centers[partitionedData.GetNumberOfPartitions()];
std::vector<int> indices(partitionedData.GetNumberOfPartitions());
for (unsigned int p = 0; p < partitionedData.GetNumberOfPartitions(); p++)
{
indices[p] = p;
centers[p] = vtkm::cont::BoundsCompute(partitionedData.GetPartition(p)).Center();
}
CompareIndices comparator(centers, camera.GetLookAt() - camera.GetPosition());
std::sort(indices.begin(), indices.end(), comparator);
for (unsigned int p = 0; p < partitionedData.GetNumberOfPartitions(); p++)
{
auto partition = partitionedData.GetPartition(indices[p]);
this->RenderCells(partition.GetCellSet(),
partition.GetCoordinateSystem(),
partition.GetField(fieldName.c_str()),
colorTable,
camera,
scalarRange,
partition.GetGhostCellField());
}
}
void Mapper::SetActiveColorTable(const vtkm::cont::ColorTable& colorTable) void Mapper::SetActiveColorTable(const vtkm::cont::ColorTable& colorTable)
{ {

@ -13,6 +13,7 @@
#include <vtkm/cont/ColorTable.h> #include <vtkm/cont/ColorTable.h>
#include <vtkm/cont/CoordinateSystem.h> #include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/Field.h> #include <vtkm/cont/Field.h>
#include <vtkm/cont/PartitionedDataSet.h>
#include <vtkm/cont/UnknownCellSet.h> #include <vtkm/cont/UnknownCellSet.h>
#include <vtkm/rendering/Camera.h> #include <vtkm/rendering/Camera.h>
#include <vtkm/rendering/Canvas.h> #include <vtkm/rendering/Canvas.h>
@ -34,7 +35,21 @@ public:
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) = 0; const vtkm::Range& scalarRange);
virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField = vtkm::cont::Field()) = 0;
virtual void RenderCellsPartitioned(const vtkm::cont::PartitionedDataSet partitionedData,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange);
virtual void SetActiveColorTable(const vtkm::cont::ColorTable& ct); virtual void SetActiveColorTable(const vtkm::cont::ColorTable& ct);

@ -64,9 +64,18 @@ void MapperConnectivity::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
vtkm::rendering::ConnectivityProxy tracerProxy(cellset, coords, scalarField); vtkm::cont::DataSet dataset;
dataset.SetCellSet(cellset);
dataset.AddCoordinateSystem(coords);
dataset.AddField(scalarField);
dataset.AddField(ghostField);
vtkm::rendering::ConnectivityProxy tracerProxy(dataset, scalarField.GetName());
if (SampleDistance == -1.f) if (SampleDistance == -1.f)
{ {
// set a default distance // set a default distance

@ -30,12 +30,15 @@ public:
void SetCanvas(vtkm::rendering::Canvas* canvas) override; void SetCanvas(vtkm::rendering::Canvas* canvas) override;
virtual vtkm::rendering::Canvas* GetCanvas() const override; virtual vtkm::rendering::Canvas* GetCanvas() const override;
using Mapper::RenderCells;
virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset, virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable&, //colorTable const vtkm::cont::ColorTable&, //colorTable
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;
void CreateDefaultView(); void CreateDefaultView();

@ -120,7 +120,8 @@ void MapperCylinder::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();
logger->OpenLogEntry("mapper_cylinder"); logger->OpenLogEntry("mapper_cylinder");

@ -61,12 +61,15 @@ public:
*/ */
void SetRadiusDelta(const vtkm::Float32& delta); void SetRadiusDelta(const vtkm::Float32& delta);
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
void SetCompositeBackground(bool on); void SetCompositeBackground(bool on);
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;

@ -325,7 +325,8 @@ void MapperGlyphScalar::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();

@ -34,12 +34,15 @@ public:
/// @copydoc GetGlyphType /// @copydoc GetGlyphType
void SetGlyphType(vtkm::rendering::GlyphType glyphType); void SetGlyphType(vtkm::rendering::GlyphType glyphType);
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;

@ -55,7 +55,8 @@ void MapperGlyphVector::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& field, const vtkm::cont::Field& field,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& vtkmNotUsed(fieldRange)) const vtkm::Range& vtkmNotUsed(fieldRange),
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();

@ -35,12 +35,15 @@ public:
/// @copydoc GetGlyphType /// @copydoc GetGlyphType
void SetGlyphType(vtkm::rendering::GlyphType glyphType); void SetGlyphType(vtkm::rendering::GlyphType glyphType);
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;

@ -111,7 +111,8 @@ void MapperPoint::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();

@ -72,12 +72,15 @@ public:
*/ */
void SetRadiusDelta(const vtkm::Float32& delta); void SetRadiusDelta(const vtkm::Float32& delta);
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
void SetCompositeBackground(bool on); void SetCompositeBackground(bool on);
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;

@ -75,7 +75,8 @@ void MapperQuad::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();
logger->OpenLogEntry("mapper_ray_tracer"); logger->OpenLogEntry("mapper_ray_tracer");

@ -37,12 +37,15 @@ public:
void SetCanvas(vtkm::rendering::Canvas* canvas) override; void SetCanvas(vtkm::rendering::Canvas* canvas) override;
virtual vtkm::rendering::Canvas* GetCanvas() const override; virtual vtkm::rendering::Canvas* GetCanvas() const override;
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
void SetCompositeBackground(bool on); void SetCompositeBackground(bool on);
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;

@ -10,6 +10,7 @@
#include <vtkm/rendering/MapperRayTracer.h> #include <vtkm/rendering/MapperRayTracer.h>
#include <vtkm/cont/BoundsCompute.h>
#include <vtkm/cont/Timer.h> #include <vtkm/cont/Timer.h>
#include <vtkm/cont/TryExecute.h> #include <vtkm/cont/TryExecute.h>
@ -28,6 +29,52 @@ namespace vtkm
namespace rendering namespace rendering
{ {
struct MapperRayTracer::CompareIndices
{
vtkm::Vec3f CameraDirection;
vtkm::Vec3f* Centers;
CompareIndices(vtkm::Vec3f* centers, vtkm::Vec3f cameraDirection)
: CameraDirection(cameraDirection)
, Centers(centers)
{
}
bool operator()(int i, int j) const
{
return (vtkm::Dot(Centers[i], CameraDirection) < vtkm::Dot(Centers[j], CameraDirection));
}
};
void MapperRayTracer::RenderCellsPartitioned(const vtkm::cont::PartitionedDataSet partitionedData,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange)
{
// sort partitions back to front for best rendering with the volume renderer
vtkm::Vec3f centers[partitionedData.GetNumberOfPartitions()];
std::vector<int> indices(partitionedData.GetNumberOfPartitions());
for (unsigned int p = 0; p < partitionedData.GetNumberOfPartitions(); p++)
{
indices[p] = p;
centers[p] = vtkm::cont::BoundsCompute(partitionedData.GetPartition(p)).Center();
}
CompareIndices comparator(centers, camera.GetLookAt() - camera.GetPosition());
std::sort(indices.begin(), indices.end(), comparator);
for (unsigned int p = 0; p < partitionedData.GetNumberOfPartitions(); p++)
{
auto partition = partitionedData.GetPartition(indices[p]);
this->RenderCells(partition.GetCellSet(),
partition.GetCoordinateSystem(),
partition.GetField(fieldName.c_str()),
colorTable,
camera,
scalarRange,
partition.GetGhostCellField());
}
}
struct MapperRayTracer::InternalsType struct MapperRayTracer::InternalsType
{ {
vtkm::rendering::CanvasRayTracer* Canvas; vtkm::rendering::CanvasRayTracer* Canvas;
@ -78,7 +125,8 @@ void MapperRayTracer::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
raytracing::Logger* logger = raytracing::Logger::GetInstance(); raytracing::Logger* logger = raytracing::Logger::GetInstance();
logger->OpenLogEntry("mapper_ray_tracer"); logger->OpenLogEntry("mapper_ray_tracer");
@ -93,7 +141,8 @@ void MapperRayTracer::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
// //
vtkm::Bounds shapeBounds; vtkm::Bounds shapeBounds;
raytracing::TriangleExtractor triExtractor; raytracing::TriangleExtractor triExtractor;
triExtractor.ExtractCells(cellset); triExtractor.ExtractCells(cellset, ghostField);
if (triExtractor.GetNumberOfTriangles() > 0) if (triExtractor.GetNumberOfTriangles() > 0)
{ {
auto triIntersector = std::make_shared<raytracing::TriangleIntersector>(); auto triIntersector = std::make_shared<raytracing::TriangleIntersector>();
@ -116,8 +165,6 @@ void MapperRayTracer::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
raytracing::RayOperations::MapCanvasToRays( raytracing::RayOperations::MapCanvasToRays(
this->Internals->Rays, camera, *this->Internals->Canvas); this->Internals->Rays, camera, *this->Internals->Canvas);
this->Internals->Tracer.SetField(scalarField, scalarRange); this->Internals->Tracer.SetField(scalarField, scalarRange);
this->Internals->Tracer.SetColorMap(this->ColorMap); this->Internals->Tracer.SetColorMap(this->ColorMap);

@ -31,12 +31,21 @@ public:
void SetCanvas(vtkm::rendering::Canvas* canvas) override; void SetCanvas(vtkm::rendering::Canvas* canvas) override;
virtual vtkm::rendering::Canvas* GetCanvas() const override; virtual vtkm::rendering::Canvas* GetCanvas() const override;
using Mapper::RenderCells;
void RenderCells(const vtkm::cont::UnknownCellSet& cellset, void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
void RenderCellsPartitioned(const vtkm::cont::PartitionedDataSet partitionedData,
const std::string fieldName,
const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override;
void SetCompositeBackground(bool on); void SetCompositeBackground(bool on);
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;
@ -45,6 +54,7 @@ public:
private: private:
struct InternalsType; struct InternalsType;
std::shared_ptr<InternalsType> Internals; std::shared_ptr<InternalsType> Internals;
struct CompareIndices;
}; };
} }
} //namespace vtkm::rendering } //namespace vtkm::rendering

@ -77,7 +77,8 @@ void MapperVolume::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& vtkmNotUsed(colorTable), const vtkm::cont::ColorTable& vtkmNotUsed(colorTable),
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
if (!cellset.CanConvert<vtkm::cont::CellSetStructured<3>>()) if (!cellset.CanConvert<vtkm::cont::CellSetStructured<3>>())
{ {

@ -29,12 +29,15 @@ public:
void SetCanvas(vtkm::rendering::Canvas* canvas) override; void SetCanvas(vtkm::rendering::Canvas* canvas) override;
virtual vtkm::rendering::Canvas* GetCanvas() const override; virtual vtkm::rendering::Canvas* GetCanvas() const override;
using Mapper::RenderCells;
virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset, virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable&, //colorTable const vtkm::cont::ColorTable&, //colorTable
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
vtkm::rendering::Mapper* NewCopy() const override; vtkm::rendering::Mapper* NewCopy() const override;
void SetSampleDistance(const vtkm::Float32 distance); void SetSampleDistance(const vtkm::Float32 distance);

@ -232,7 +232,8 @@ void MapperWireframer::RenderCells(const vtkm::cont::UnknownCellSet& inCellSet,
const vtkm::cont::Field& inScalarField, const vtkm::cont::Field& inScalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField)
{ {
vtkm::cont::UnknownCellSet cellSet = inCellSet; vtkm::cont::UnknownCellSet cellSet = inCellSet;
@ -331,7 +332,8 @@ void MapperWireframer::RenderCells(const vtkm::cont::UnknownCellSet& inCellSet,
MapperRayTracer raytracer; MapperRayTracer raytracer;
raytracer.SetCanvas(&canvas); raytracer.SetCanvas(&canvas);
raytracer.SetActiveColorTable(colorTable); raytracer.SetActiveColorTable(colorTable);
raytracer.RenderCells(cellSet, actualCoords, actualField, colorTable, camera, scalarRange); raytracer.RenderCells(
cellSet, actualCoords, actualField, colorTable, camera, scalarRange, ghostField);
renderer.SetSolidDepthBuffer(canvas.GetDepthBuffer()); renderer.SetSolidDepthBuffer(canvas.GetDepthBuffer());
} }
else else

@ -42,12 +42,15 @@ public:
bool GetIsOverlay() const; bool GetIsOverlay() const;
void SetIsOverlay(bool isOverlay); void SetIsOverlay(bool isOverlay);
using Mapper::RenderCells;
virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset, virtual void RenderCells(const vtkm::cont::UnknownCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField, const vtkm::cont::Field& scalarField,
const vtkm::cont::ColorTable& colorTable, const vtkm::cont::ColorTable& colorTable,
const vtkm::rendering::Camera& camera, const vtkm::rendering::Camera& camera,
const vtkm::Range& scalarRange) override; const vtkm::Range& scalarRange,
const vtkm::cont::Field& ghostField) override;
virtual vtkm::rendering::Mapper* NewCopy() const override; virtual vtkm::rendering::Mapper* NewCopy() const override;

@ -77,7 +77,7 @@ void ScalarRenderer::SetInput(vtkm::cont::DataSet& dataSet)
raytracing::TriangleExtractor triExtractor; raytracing::TriangleExtractor triExtractor;
vtkm::cont::UnknownCellSet cellSet = this->Internals->DataSet.GetCellSet(); vtkm::cont::UnknownCellSet cellSet = this->Internals->DataSet.GetCellSet();
vtkm::cont::CoordinateSystem coords = this->Internals->DataSet.GetCoordinateSystem(); vtkm::cont::CoordinateSystem coords = this->Internals->DataSet.GetCoordinateSystem();
triExtractor.ExtractCells(cellSet); triExtractor.ExtractCells(cellSet, dataSet.GetGhostCellField());
if (triExtractor.GetNumberOfTriangles() > 0) if (triExtractor.GetNumberOfTriangles() > 0)
{ {

@ -643,7 +643,8 @@ public:
VTKM_CONT VTKM_CONT
void Run(const vtkm::cont::UnknownCellSet& cellset, void Run(const vtkm::cont::UnknownCellSet& cellset,
vtkm::cont::ArrayHandle<vtkm::Id4>& outputIndices, vtkm::cont::ArrayHandle<vtkm::Id4>& outputIndices,
vtkm::Id& outputTriangles) vtkm::Id& outputTriangles,
const vtkm::cont::Field& ghostField)
{ {
bool fastPath = false; bool fastPath = false;
if (cellset.CanConvert<vtkm::cont::CellSetStructured<3>>()) if (cellset.CanConvert<vtkm::cont::CellSetStructured<3>>())
@ -702,6 +703,23 @@ public:
outputTriangles = totalTriangles; outputTriangles = totalTriangles;
} }
// removed blanked triangles
vtkm::cont::ArrayHandle<vtkm::Id4> nonGhostTriangles;
nonGhostTriangles.Allocate(outputTriangles);
vtkm::Id counter = 0;
for (vtkm::Id i = 0; i < outputTriangles; ++i)
{
if (int(ghostField.GetData().ExtractComponent<vtkm::UInt8>(0).ReadPortal().Get(
outputIndices.ReadPortal().Get(i)[0])) == 0)
{
nonGhostTriangles.WritePortal().Set(counter, outputIndices.ReadPortal().Get(i));
counter++;
}
}
nonGhostTriangles.Allocate(counter, vtkm::CopyFlag::On);
outputIndices = nonGhostTriangles;
outputTriangles = counter;
//get rid of any triagles we cannot see //get rid of any triagles we cannot see
if (!fastPath) if (!fastPath)
{ {

@ -22,10 +22,11 @@ namespace internal
void RunTriangulator(const vtkm::cont::UnknownCellSet& cellSet, void RunTriangulator(const vtkm::cont::UnknownCellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Id4>& indices, vtkm::cont::ArrayHandle<vtkm::Id4>& indices,
vtkm::Id& numberOfTriangles) vtkm::Id& numberOfTriangles,
const vtkm::cont::Field& ghostField)
{ {
vtkm::rendering::Triangulator triangulator; vtkm::rendering::Triangulator triangulator;
triangulator.Run(cellSet, indices, numberOfTriangles); triangulator.Run(cellSet, indices, numberOfTriangles, ghostField);
} }
} }
} }

@ -31,7 +31,8 @@ namespace internal
VTKM_RENDERING_EXPORT VTKM_RENDERING_EXPORT
void RunTriangulator(const vtkm::cont::UnknownCellSet& cellSet, void RunTriangulator(const vtkm::cont::UnknownCellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Id4>& indices, vtkm::cont::ArrayHandle<vtkm::Id4>& indices,
vtkm::Id& numberOfTriangles); vtkm::Id& numberOfTriangles,
const vtkm::cont::Field& ghostField);
} }
} }
} // namespace vtkm::rendering::internal } // namespace vtkm::rendering::internal

@ -196,10 +196,12 @@ void ConnectivityTracer::SetColorMap(const vtkm::cont::ArrayHandle<vtkm::Vec4f_3
void ConnectivityTracer::SetVolumeData(const vtkm::cont::Field& scalarField, void ConnectivityTracer::SetVolumeData(const vtkm::cont::Field& scalarField,
const vtkm::Range& scalarBounds, const vtkm::Range& scalarBounds,
const vtkm::cont::UnknownCellSet& cellSet, const vtkm::cont::UnknownCellSet& cellSet,
const vtkm::cont::CoordinateSystem& coords) const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& ghostField)
{ {
//TODO: Need a way to tell if we have been updated //TODO: Need a way to tell if we have been updated
ScalarField = scalarField; ScalarField = scalarField;
GhostField = ghostField;
ScalarBounds = scalarBounds; ScalarBounds = scalarBounds;
CellSet = cellSet; CellSet = cellSet;
Coords = coords; Coords = coords;
@ -892,8 +894,8 @@ public:
InvDeltaScalar = (minScalar == maxScalar) ? 1.f : 1.f / (maxScalar - minScalar); InvDeltaScalar = (minScalar == maxScalar) ? 1.f : 1.f / (maxScalar - minScalar);
} }
using ControlSignature = void(FieldIn, using ControlSignature = void(FieldIn,
WholeArrayIn,
WholeArrayIn, WholeArrayIn,
FieldIn, FieldIn,
FieldIn, FieldIn,
@ -902,11 +904,15 @@ public:
WholeArrayIn, WholeArrayIn,
WholeArrayInOut, WholeArrayInOut,
FieldIn); FieldIn);
using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8, WorkIndex, _9); using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8, _9, WorkIndex, _10);
template <typename ScalarPortalType, typename ColorMapType, typename FrameBufferType> template <typename ScalarPortalType,
typename GhostPortalType,
typename ColorMapType,
typename FrameBufferType>
VTKM_EXEC inline void operator()(const vtkm::Id& currentCell, VTKM_EXEC inline void operator()(const vtkm::Id& currentCell,
ScalarPortalType& scalarPortal, ScalarPortalType& scalarPortal,
GhostPortalType& ghostPortal,
const FloatType& enterDistance, const FloatType& enterDistance,
const FloatType& exitDistance, const FloatType& exitDistance,
FloatType& currentDistance, FloatType& currentDistance,
@ -919,6 +925,8 @@ public:
if (rayStatus != RAY_ACTIVE) if (rayStatus != RAY_ACTIVE)
return; return;
if (int(ghostPortal.Get(currentCell)) != 0)
return;
vtkm::Vec4f_32 color; vtkm::Vec4f_32 color;
BOUNDS_CHECK(frameBuffer, pixelIndex * 4 + 0); BOUNDS_CHECK(frameBuffer, pixelIndex * 4 + 0);
@ -1228,6 +1236,7 @@ void ConnectivityTracer::SampleCells(Ray<FloatType>& rays, detail::RayTracking<F
dispatcher.Invoke(rays.HitIdx, dispatcher.Invoke(rays.HitIdx,
vtkm::rendering::raytracing::GetScalarFieldArray(this->ScalarField), vtkm::rendering::raytracing::GetScalarFieldArray(this->ScalarField),
GhostField.GetData().ExtractComponent<vtkm::UInt8>(0),
*(tracker.EnterDist), *(tracker.EnterDist),
*(tracker.ExitDist), *(tracker.ExitDist),
tracker.CurrentDistance, tracker.CurrentDistance,

@ -96,7 +96,8 @@ public:
void SetVolumeData(const vtkm::cont::Field& scalarField, void SetVolumeData(const vtkm::cont::Field& scalarField,
const vtkm::Range& scalarBounds, const vtkm::Range& scalarBounds,
const vtkm::cont::UnknownCellSet& cellSet, const vtkm::cont::UnknownCellSet& cellSet,
const vtkm::cont::CoordinateSystem& coords); const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& ghostField);
void SetEnergyData(const vtkm::cont::Field& absorption, void SetEnergyData(const vtkm::cont::Field& absorption,
const vtkm::Int32 numBins, const vtkm::Int32 numBins,
@ -181,6 +182,7 @@ protected:
// Data set info // Data set info
vtkm::cont::Field ScalarField; vtkm::cont::Field ScalarField;
vtkm::cont::Field EmissionField; vtkm::cont::Field EmissionField;
vtkm::cont::Field GhostField;
vtkm::cont::UnknownCellSet CellSet; vtkm::cont::UnknownCellSet CellSet;
vtkm::cont::CoordinateSystem Coords; vtkm::cont::CoordinateSystem Coords;
vtkm::Range ScalarBounds; vtkm::Range ScalarBounds;

@ -18,10 +18,11 @@ namespace rendering
namespace raytracing namespace raytracing
{ {
void TriangleExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells) void TriangleExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::Field& ghostField)
{ {
vtkm::Id numberOfTriangles; vtkm::Id numberOfTriangles;
vtkm::rendering::internal::RunTriangulator(cells, this->Triangles, numberOfTriangles); vtkm::rendering::internal::RunTriangulator(cells, this->Triangles, numberOfTriangles, ghostField);
} }
vtkm::cont::ArrayHandle<vtkm::Id4> TriangleExtractor::GetTriangles() vtkm::cont::ArrayHandle<vtkm::Id4> TriangleExtractor::GetTriangles()

@ -25,7 +25,7 @@ class VTKM_RENDERING_EXPORT TriangleExtractor
protected: protected:
vtkm::cont::ArrayHandle<vtkm::Id4> Triangles; // (cellid, v0, v1, v2) vtkm::cont::ArrayHandle<vtkm::Id4> Triangles; // (cellid, v0, v1, v2)
public: public:
void ExtractCells(const vtkm::cont::UnknownCellSet& cells); void ExtractCells(const vtkm::cont::UnknownCellSet& cells, const vtkm::cont::Field& ghostField);
vtkm::cont::ArrayHandle<vtkm::Id4> GetTriangles(); vtkm::cont::ArrayHandle<vtkm::Id4> GetTriangles();
vtkm::Id GetNumberOfTriangles() const; vtkm::Id GetNumberOfTriangles() const;