uniform treatment of primary/secondary field/coordinate_system
This commit is contained in:
parent
6461857e4e
commit
4a63b745aa
@ -279,17 +279,6 @@ public:
|
||||
vtkm::filter::FieldSelection& GetFieldsToPass() { return this->FieldsToPass; }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Select the coordinate system index to make active to use when processing the input
|
||||
/// DataSet. This is used primarily by the Filter to select the coordinate system
|
||||
/// to use as a field when \c UseCoordinateSystemAsField is true.
|
||||
VTKM_CONT
|
||||
void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetActiveCoordinateSystemIndex() const { return this->CoordinateSystemIndex; }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Executes the filter on the input and produces a result dataset.
|
||||
///
|
||||
@ -312,7 +301,6 @@ public:
|
||||
|
||||
protected:
|
||||
vtkm::cont::Invoker Invoke;
|
||||
vtkm::Id CoordinateSystemIndex = 0;
|
||||
|
||||
template <typename Mapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||
|
@ -63,6 +63,38 @@ public:
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Select the coordinate system coord_idx to make active to use when processing the input
|
||||
/// DataSet. This is used primarily by the Filter to select the coordinate system
|
||||
/// to use as a field when \c UseCoordinateSystemAsField is true.
|
||||
VTKM_CONT
|
||||
void SetActiveCoordinateSystem(vtkm::Id coord_idx)
|
||||
{
|
||||
this->SetActiveCoordinateSystem(0, coord_idx);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetActiveCoordinateSystem(vtkm::IdComponent index, vtkm::Id coord_idx)
|
||||
{
|
||||
auto index_st = static_cast<std::size_t>(index);
|
||||
ResizeIfNeeded(index_st);
|
||||
this->ActiveCoordinateSystemIndices[index_st] = coord_idx;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetActiveCoordinateSystemIndex() const
|
||||
{
|
||||
return this->GetActiveCoordinateSystemIndex(0);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetActiveCoordinateSystemIndex(vtkm::IdComponent index) const
|
||||
{
|
||||
auto index_st = static_cast<std::size_t>(index);
|
||||
return this->ActiveCoordinateSystemIndices[index_st];
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// To simply use the active coordinate system as the field to operate on, set
|
||||
/// UseCoordinateSystemAsField to true.
|
||||
@ -99,7 +131,7 @@ protected:
|
||||
{
|
||||
if (this->UseCoordinateSystemAsField[index])
|
||||
{
|
||||
return input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
return input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex(index));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -117,10 +149,12 @@ private:
|
||||
this->ActiveFieldNames.resize(index_st + 1);
|
||||
this->ActiveFieldAssociation.resize(index_st + 1);
|
||||
this->UseCoordinateSystemAsField.resize(index_st + 1);
|
||||
this->ActiveCoordinateSystemIndices.resize(index_st + 1);
|
||||
for (std::size_t i = oldSize; i <= index_st; ++i)
|
||||
{
|
||||
this->ActiveFieldAssociation[i] = cont::Field::Association::ANY;
|
||||
this->UseCoordinateSystemAsField[i] = false;
|
||||
this->ActiveCoordinateSystemIndices[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,6 +164,7 @@ private:
|
||||
std::vector<std::string> ActiveFieldNames;
|
||||
std::vector<vtkm::cont::Field::Association> ActiveFieldAssociation;
|
||||
std::vector<bool> UseCoordinateSystemAsField;
|
||||
std::vector<vtkm ::Id> ActiveCoordinateSystemIndices;
|
||||
};
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
@ -65,17 +65,7 @@ VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(const vtkm::cont::DataSet& i
|
||||
auto ResolveType = [&, this](const auto& concrete) {
|
||||
// use std::decay to remove const ref from the decltype of concrete.
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
const auto& secondaryField = [&]() -> const vtkm::cont::Field& {
|
||||
if (this->GetUseCoordinateSystemAsSecondaryField())
|
||||
{
|
||||
return inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
return inDataSet.GetField(this->GetSecondaryFieldName(),
|
||||
this->GetSecondaryFieldAssociation());
|
||||
}
|
||||
}();
|
||||
const auto& secondaryField = this->GetFieldFromDataSet(1, inDataSet);
|
||||
vtkm::cont::UnknownArrayHandle secondary = vtkm::cont::ArrayHandle<T>{};
|
||||
secondary.CopyShallowIfPossible(secondaryField.GetData());
|
||||
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
VTKM_CONT DotProduct();
|
||||
|
||||
//@{
|
||||
/// Choose the primary field to operate on. In the cross product operation A x B, A is
|
||||
/// Choose the primary field to operate on. In the dot product operation A . B, A is
|
||||
/// the primary field.
|
||||
VTKM_CONT
|
||||
void SetPrimaryField(
|
||||
@ -59,10 +59,13 @@ public:
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Select the coordinate system index to use as the primary field. This only has an effect when
|
||||
/// Select the coordinate system coord_idx to use as the primary field. This only has an effect when
|
||||
/// UseCoordinateSystemAsPrimaryField is true.
|
||||
VTKM_CONT
|
||||
void SetPrimaryCoordinateSystem(vtkm::Id index) { this->SetActiveCoordinateSystem(index); }
|
||||
void SetPrimaryCoordinateSystem(vtkm::Id coord_idx)
|
||||
{
|
||||
this->SetActiveCoordinateSystem(coord_idx);
|
||||
}
|
||||
VTKM_CONT
|
||||
vtkm::Id GetPrimaryCoordinateSystemIndex() const
|
||||
{
|
||||
@ -71,7 +74,7 @@ public:
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Choose the secondary field to operate on. In the cross product operation A x B, B is
|
||||
/// Choose the secondary field to operate on. In the dot product operation A . B, B is
|
||||
/// the secondary field.
|
||||
VTKM_CONT
|
||||
void SetSecondaryField(
|
||||
@ -89,8 +92,8 @@ public:
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// When set to true, uses a coordinate system as the primary field instead of the one selected
|
||||
/// by name. Use SetPrimaryCoordinateSystem to select which coordinate system.
|
||||
/// When set to true, uses a coordinate system as the secondary field instead of the one selected
|
||||
/// by name. Use SetSecondaryCoordinateSystem to select which coordinate system.
|
||||
VTKM_CONT
|
||||
void SetUseCoordinateSystemAsSecondaryField(bool flag)
|
||||
{
|
||||
@ -104,24 +107,19 @@ public:
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Select the coordinate system index to use as the primary field. This only has an effect when
|
||||
/// UseCoordinateSystemAsPrimaryField is true.
|
||||
/// Select the coordinate system index to use as the secondary field. This only has an effect when
|
||||
/// UseCoordinateSystemAsSecondaryField is true.
|
||||
VTKM_CONT
|
||||
void SetSecondaryCoordinateSystem(vtkm::Id index)
|
||||
{
|
||||
this->SecondaryCoordinateSystemIndex = index;
|
||||
}
|
||||
void SetSecondaryCoordinateSystem(vtkm::Id index) { this->SetActiveCoordinateSystem(1, index); }
|
||||
VTKM_CONT
|
||||
vtkm::Id GetSecondaryCoordinateSystemIndex() const
|
||||
{
|
||||
return this->SecondaryCoordinateSystemIndex;
|
||||
return this->GetActiveCoordinateSystemIndex(1);
|
||||
}
|
||||
//@}
|
||||
|
||||
private:
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
vtkm::Id SecondaryCoordinateSystemIndex = 0;
|
||||
};
|
||||
} // namespace vector_calculus
|
||||
} // namespace filter
|
||||
|
Loading…
Reference in New Issue
Block a user