first round of fixes
This commit is contained in:
parent
7e09fb7033
commit
fae4cc4c79
@ -167,7 +167,7 @@ public:
|
||||
/// whether a particular field exists.
|
||||
///@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field GetGhostCellField() const;
|
||||
vtkm::cont::Field GetGhostCellField() const;
|
||||
///@}
|
||||
|
||||
/// \brief Returns the first point field that matches the provided name.
|
||||
@ -243,13 +243,6 @@ public:
|
||||
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>
|
||||
VTKM_CONT void AddCellField(const std::string& fieldName, const std::vector<T>& field)
|
||||
{
|
||||
|
@ -251,15 +251,6 @@ inline vtkm::cont::Field make_FieldCell(std::string name,
|
||||
{
|
||||
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 vtkm
|
||||
|
||||
|
@ -224,10 +224,20 @@ void AmrArrays::ComputeGenerateGhostType()
|
||||
vtkm::cont::CellSetStructured<Dim> cellset;
|
||||
partition.GetCellSet().AsCellSet(cellset);
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8> ghostArrayHandle;
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(vtkm::worklet::ResetGhostTypeWorklet{},
|
||||
partition.GetGhostCellField().GetData().ExtractComponent<vtkm::UInt8>(0),
|
||||
ghostArrayHandle);
|
||||
if (!partition.HasGhostCellField())
|
||||
{
|
||||
ghostArrayHandle.AllocateAndFill(partition.GetNumberOfCells(), 0);
|
||||
// vtkm::cont::ArrayHandleConstant<vtkm::UInt8> ghostArrayHandle = vtkm::cont::ArrayHandleConstant<vtkm::UInt8> (0, partition.GetNumberOfCells());
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(vtkm::worklet::ResetGhostTypeWorklet{},
|
||||
partition.GetGhostCellField()
|
||||
.GetData()
|
||||
.AsArrayHandle<vtkm::cont::ArrayHandle<vtkm::UInt8>>(),
|
||||
ghostArrayHandle);
|
||||
}
|
||||
partition.AddCellField(vtkm::cont::GetGlobalGhostCellFieldName(), ghostArrayHandle);
|
||||
|
||||
auto pointField = partition.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
@ -244,10 +254,11 @@ void AmrArrays::ComputeGenerateGhostType()
|
||||
.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;
|
||||
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(vtkm::worklet::GenerateGhostTypeWorklet<Dim>{ boundsChild },
|
||||
cellset,
|
||||
pointField,
|
||||
partition.GetGhostCellField().GetData().ExtractComponent<vtkm::UInt8>(0));
|
||||
ghostArrayHandle);
|
||||
}
|
||||
this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(bParent), partition);
|
||||
}
|
||||
@ -264,15 +275,21 @@ void AmrArrays::GenerateIndexArrays()
|
||||
{
|
||||
vtkm::cont::DataSet partition = this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(b));
|
||||
|
||||
partition.AddCellField(
|
||||
"vtkAmrLevel", vtkm::cont::ArrayHandleConstant<vtkm::Id>(l, partition.GetNumberOfCells()));
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> fieldAmrLevel;
|
||||
vtkm::cont::ArrayCopy(
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::Id>(l, partition.GetNumberOfCells()), fieldAmrLevel);
|
||||
partition.AddCellField("vtkAmrLevel", fieldAmrLevel);
|
||||
|
||||
partition.AddCellField(
|
||||
"vtkAmrIndex", vtkm::cont::ArrayHandleConstant<vtkm::Id>(b, partition.GetNumberOfCells()));
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> fieldBlockId;
|
||||
vtkm::cont::ArrayCopy(
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::Id>(b, partition.GetNumberOfCells()), fieldBlockId);
|
||||
partition.AddCellField("vtkAmrIndex", fieldBlockId);
|
||||
|
||||
partition.AddCellField("vtkCompositeIndex",
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::Id>(
|
||||
this->PartitionIds.at(l).at(b), partition.GetNumberOfCells()));
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> fieldPartitionIndex;
|
||||
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(
|
||||
this->PartitionIds.at(l).at(b), partition.GetNumberOfCells()),
|
||||
fieldPartitionIndex);
|
||||
partition.AddCellField("vtkCompositeIndex", fieldPartitionIndex);
|
||||
|
||||
this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(b), partition);
|
||||
}
|
||||
|
@ -25,114 +25,94 @@ namespace rendering
|
||||
|
||||
struct Actor::InternalsType
|
||||
{
|
||||
vtkm::cont::UnknownCellSet Cells;
|
||||
vtkm::cont::CoordinateSystem Coordinates;
|
||||
vtkm::cont::Field ScalarField;
|
||||
vtkm::cont::PartitionedDataSet Data;
|
||||
std::string CoordinateName;
|
||||
std::string FieldName;
|
||||
vtkm::cont::Field::Association FieldAssociation;
|
||||
|
||||
vtkm::cont::ColorTable ColorTable;
|
||||
|
||||
vtkm::Range ScalarRange;
|
||||
vtkm::Bounds SpatialBounds;
|
||||
|
||||
vtkm::cont::PartitionedDataSet DataSet;
|
||||
std::string FieldName;
|
||||
|
||||
VTKM_CONT
|
||||
InternalsType(const vtkm::cont::PartitionedDataSet partitionedDataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
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)
|
||||
: Data(partitionedDataSet)
|
||||
, CoordinateName(coordinateName)
|
||||
, 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)
|
||||
: Cells(std::move(cells))
|
||||
, Coordinates(std::move(coordinates))
|
||||
, ScalarField(std::move(scalarField))
|
||||
, ColorTable(vtkm::Range{ 0, 1 }, color.Components, color.Components)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
InternalsType(vtkm::cont::UnknownCellSet cells,
|
||||
vtkm::cont::CoordinateSystem coordinates,
|
||||
vtkm::cont::Field scalarField,
|
||||
InternalsType(const vtkm::cont::PartitionedDataSet partitionedDataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::cont::ColorTable& colorTable = vtkm::cont::ColorTable::Preset::Default)
|
||||
: Cells(std::move(cells))
|
||||
, Coordinates(std::move(coordinates))
|
||||
, ScalarField(std::move(scalarField))
|
||||
: Data(partitionedDataSet)
|
||||
, CoordinateName(coordinateName)
|
||||
, FieldName(fieldName)
|
||||
, ColorTable(colorTable)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Actor::Actor(const vtkm::cont::DataSet dataSet, const std::string fieldName)
|
||||
Actor::Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName)
|
||||
{
|
||||
vtkm::cont::PartitionedDataSet partitionedDataSet;
|
||||
partitionedDataSet.AppendPartition(dataSet);
|
||||
this->Internals = std::make_unique<InternalsType>(partitionedDataSet, fieldName);
|
||||
vtkm::cont::PartitionedDataSet partitionedDataSet(dataSet);
|
||||
this->Internals = std::make_unique<InternalsType>(partitionedDataSet, coordinateName, fieldName);
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
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);
|
||||
vtkm::cont::PartitionedDataSet partitionedDataSet(dataSet);
|
||||
this->Internals =
|
||||
std::make_unique<InternalsType>(partitionedDataSet, coordinateName, fieldName, color);
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
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);
|
||||
vtkm::cont::PartitionedDataSet partitionedDataSet(dataSet);
|
||||
this->Internals =
|
||||
std::make_unique<InternalsType>(partitionedDataSet, coordinateName, fieldName, colorTable);
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet, const std::string fieldName)
|
||||
: Internals(new InternalsType(dataSet, fieldName))
|
||||
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName)
|
||||
: Internals(new InternalsType(dataSet, coordinateName, fieldName))
|
||||
{
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::rendering::Color& color)
|
||||
: Internals(new InternalsType(dataSet, fieldName, color))
|
||||
: Internals(new InternalsType(dataSet, coordinateName, fieldName, color))
|
||||
{
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::cont::ColorTable& colorTable)
|
||||
: Internals(new InternalsType(dataSet, fieldName, colorTable))
|
||||
: Internals(new InternalsType(dataSet, coordinateName, fieldName, colorTable))
|
||||
{
|
||||
this->Init();
|
||||
}
|
||||
@ -140,27 +120,42 @@ Actor::Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
Actor::Actor(const vtkm::cont::UnknownCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField)
|
||||
: Internals(std::make_unique<InternalsType>(cells, coordinates, scalarField))
|
||||
{
|
||||
this->Init(coordinates, scalarField);
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.SetCellSet(cells);
|
||||
dataSet.AddCoordinateSystem(coordinates);
|
||||
dataSet.AddField(scalarField);
|
||||
this->Internals =
|
||||
std::make_unique<InternalsType>(dataSet, coordinates.GetName(), scalarField.GetName());
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::UnknownCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField,
|
||||
const vtkm::rendering::Color& color)
|
||||
: Internals(std::make_unique<InternalsType>(cells, coordinates, scalarField, color))
|
||||
{
|
||||
this->Init(coordinates, scalarField);
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.SetCellSet(cells);
|
||||
dataSet.AddCoordinateSystem(coordinates);
|
||||
dataSet.AddField(scalarField);
|
||||
this->Internals =
|
||||
std::make_unique<InternalsType>(dataSet, coordinates.GetName(), scalarField.GetName(), color);
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const vtkm::cont::UnknownCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField,
|
||||
const vtkm::cont::ColorTable& colorTable)
|
||||
: Internals(std::make_unique<InternalsType>(cells, coordinates, scalarField, colorTable))
|
||||
{
|
||||
this->Init(coordinates, scalarField);
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.SetCellSet(cells);
|
||||
dataSet.AddCoordinateSystem(coordinates);
|
||||
dataSet.AddField(scalarField);
|
||||
this->Internals = std::make_unique<InternalsType>(
|
||||
dataSet, coordinates.GetName(), scalarField.GetName(), colorTable);
|
||||
this->Init();
|
||||
}
|
||||
|
||||
Actor::Actor(const Actor& rhs)
|
||||
@ -194,18 +189,11 @@ Actor::Actor(vtkm::rendering::Actor&&) noexcept = default;
|
||||
Actor& Actor::operator=(Actor&&) noexcept = default;
|
||||
Actor::~Actor() = default;
|
||||
|
||||
void Actor::Init(const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField)
|
||||
{
|
||||
scalarField.GetRange(&this->Internals->ScalarRange);
|
||||
this->Internals->SpatialBounds = coordinates.GetBounds();
|
||||
}
|
||||
|
||||
void Actor::Init()
|
||||
{
|
||||
this->Internals->SpatialBounds = vtkm::cont::BoundsCompute(this->Internals->DataSet);
|
||||
this->Internals->SpatialBounds = vtkm::cont::BoundsCompute(this->Internals->Data);
|
||||
this->Internals->ScalarRange =
|
||||
vtkm::cont::FieldRangeCompute(this->Internals->DataSet, this->Internals->FieldName)
|
||||
vtkm::cont::FieldRangeCompute(this->Internals->Data, this->Internals->FieldName)
|
||||
.ReadPortal()
|
||||
.Get(0);
|
||||
}
|
||||
@ -216,39 +204,27 @@ void Actor::Render(vtkm::rendering::Mapper& mapper,
|
||||
{
|
||||
mapper.SetCanvas(&canvas);
|
||||
mapper.SetActiveColorTable(this->Internals->ColorTable);
|
||||
if (this->Internals->DataSet.GetNumberOfPartitions() > 0)
|
||||
{
|
||||
mapper.RenderCellsPartitioned(this->Internals->DataSet,
|
||||
this->Internals->FieldName,
|
||||
this->Internals->ColorTable,
|
||||
camera,
|
||||
this->Internals->ScalarRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapper.RenderCells(this->Internals->Cells,
|
||||
this->Internals->Coordinates,
|
||||
this->Internals->ScalarField,
|
||||
this->Internals->ColorTable,
|
||||
camera,
|
||||
this->Internals->ScalarRange);
|
||||
}
|
||||
mapper.RenderCellsPartitioned(this->Internals->Data,
|
||||
this->Internals->FieldName,
|
||||
this->Internals->ColorTable,
|
||||
camera,
|
||||
this->Internals->ScalarRange);
|
||||
}
|
||||
|
||||
|
||||
const vtkm::cont::UnknownCellSet& Actor::GetCells() const
|
||||
{
|
||||
return this->Internals->Cells;
|
||||
return this->Internals->Data.GetPartition(0).GetCellSet();
|
||||
}
|
||||
|
||||
const vtkm::cont::CoordinateSystem& Actor::GetCoordinates() const
|
||||
{
|
||||
return this->Internals->Coordinates;
|
||||
return this->Internals->Data.GetPartition(0).GetCoordinateSystem(this->Internals->CoordinateName);
|
||||
}
|
||||
|
||||
const vtkm::cont::Field& Actor::GetScalarField() const
|
||||
{
|
||||
return this->Internals->ScalarField;
|
||||
return this->Internals->Data.GetPartition(0).GetField(this->Internals->FieldName);
|
||||
}
|
||||
|
||||
const vtkm::cont::ColorTable& Actor::GetColorTable() const
|
||||
|
@ -26,23 +26,31 @@ namespace rendering
|
||||
class VTKM_RENDERING_EXPORT Actor
|
||||
{
|
||||
public:
|
||||
Actor(const vtkm::cont::DataSet dataSet, const std::string fieldName);
|
||||
Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName);
|
||||
|
||||
Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::cont::ColorTable& colorTable);
|
||||
|
||||
Actor(const vtkm::cont::DataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
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 coordinateName,
|
||||
const std::string fieldName);
|
||||
|
||||
Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::cont::ColorTable& colorTable);
|
||||
|
||||
Actor(const vtkm::cont::PartitionedDataSet dataSet,
|
||||
const std::string coordinateName,
|
||||
const std::string fieldName,
|
||||
const vtkm::rendering::Color& color);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user