Go to the documentation of this file.
10 #ifndef vtk_m_filter_Filter_h
11 #define vtk_m_filter_Filter_h
199 std::initializer_list<std::string> fields,
204 std::initializer_list<std::pair<std::string, vtkm::cont::Field::Association>> fields,
210 const std::string& fieldname,
255 const std::string& name,
258 this->SetActiveField(0, name, association);
264 const std::string& name,
267 auto index_st =
static_cast<std::size_t
>(index);
268 this->ResizeIfNeeded(index_st);
269 this->ActiveFieldNames[index_st] = name;
270 this->ActiveFieldAssociation[index_st] = association;
278 return this->ActiveFieldNames[index];
285 return this->ActiveFieldAssociation[index];
293 this->SetActiveCoordinateSystem(0, coord_idx);
299 auto index_st =
static_cast<std::size_t
>(index);
300 this->ResizeIfNeeded(index_st);
301 this->ActiveCoordinateSystemIndices[index_st] = coord_idx;
307 auto index_st =
static_cast<std::size_t
>(index);
308 return this->ActiveCoordinateSystemIndices[index_st];
318 auto index_st =
static_cast<std::size_t
>(index);
319 this->ResizeIfNeeded(index_st);
320 this->UseCoordinateSystemAsField[index] = val;
329 return this->UseCoordinateSystemAsField[index];
341 VTKM_ASSERT(this->ActiveFieldNames.size() == this->UseCoordinateSystemAsField.size());
349 VTKM_CONT virtual bool CanThread()
const;
359 return this->CanThread() && this->RunFilterWithMultipleThreads;
364 if (this->CanThread())
365 this->RunFilterWithMultipleThreads = val;
369 "Multi threaded filter not supported for " + std::string(
typeid(*this).name());
428 const std::string& resultFieldName,
432 return this->CreateResultField(
433 inDataSet,
vtkm::cont::Field{ resultFieldName, resultFieldAssociation, resultFieldArray });
452 const std::string& resultFieldName,
455 return this->CreateResultField(inDataSet,
477 const std::string& resultFieldName,
480 return this->CreateResultField(inDataSet,
516 template <
typename FieldMapper>
520 FieldMapper&& fieldMapper)
const
523 this->MapFieldsOntoOutput(input, this->GetFieldsToPass(), output, fieldMapper);
545 template <
typename FieldMapper>
548 FieldMapper&& fieldMapper)
const
552 this->MapFieldsOntoOutput(inDataSet, this->GetFieldsToPass(), outDataSet, fieldMapper);
576 template <
typename FieldMapper>
581 FieldMapper&& fieldMapper)
const
586 if (this->GetPassCoordinateSystems() || fieldSelection.
HasField(resultCoordSystem))
591 this->MapFieldsOntoOutput(inDataSet, fieldSelection, outDataSet, fieldMapper);
616 template <
typename FieldMapper>
620 const std::string& coordsName,
622 FieldMapper&& fieldMapper)
const
624 return this->CreateResultCoordinateSystem(
637 return this->GetFieldFromDataSet(0, input);
644 if (this->UseCoordinateSystemAsField[index])
649 const std::string& coordSystemName =
655 return input.
GetField(this->GetActiveFieldName(index),
656 this->GetActiveFieldAssociation(index));
674 template <
typename Functor,
typename... Args>
677 Args&&... args)
const
681 std::forward<Functor>(functor), std::forward<Args>(args)...);
684 template <
typename Functor,
typename... Args>
687 Args&&... args)
const
689 this->CastAndCallScalarField(
690 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
708 Args&&... args)
const
713 std::forward<Functor>(functor), std::forward<Args>(args)...);
719 Args&&... args)
const
721 this->CastAndCallVecField<VecSize>(
722 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
736 template <
typename Functor,
typename... Args>
739 Args&&... args)
const
755 std::forward<Args>(args)...);
759 template <
typename Functor,
typename... Args>
762 Args&&... args)
const
764 this->CastAndCallVariableVecField(
765 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
769 template <
typename FieldMapper>
773 FieldMapper&& fieldMapper)
const
781 fieldMapper(output, field);
800 if (!output.
HasPointField(coords.GetName()) && this->GetPassCoordinateSystems())
802 fieldMapper(output, coords);
812 template <
typename FieldMapper>
816 FieldMapper&& fieldMapper)
const
823 fieldMapper(output, field);
828 template <vtkm::IdComponent VecSize>
831 template <
typename T>
838 void ResizeIfNeeded(
size_t index_st);
841 bool PassCoordinateSystems =
true;
842 bool RunFilterWithMultipleThreads =
false;
const std::vector< vtkm::cont::DataSet > & GetPartitions() const
Get an STL vector of all DataSet objects stored in PartitionedDataSet.
const vtkm::cont::Field & GetFieldFromDataSet(const vtkm::cont::DataSet &input) const
Retrieve an input field from a vtkm::cont::DataSet object.
Definition: Filter.h:635
void SetUseCoordinateSystemAsField(bool val)
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:313
const std::string & GetActiveFieldName(vtkm::IdComponent index=0) const
Specifies a field to operate on.
Definition: Filter.h:274
void SetActiveCoordinateSystem(vtkm::IdComponent index, vtkm::Id coord_idx)
Specifies the coordinate system index to make active to use when processing the input vtkm::cont::Dat...
Definition: Filter.h:297
const vtkm::filter::FieldSelection & GetFieldsToPass() const
Specify which fields get passed from input to output.
Definition: Filter.h:223
bool IsBaseComponentType() const
Returns true if this array's ValueType has the provided base component type.
Definition: UnknownArrayHandle.h:540
void SetOutputFieldName(const std::string &name)
Specifies the name of the output field generated.
Definition: Filter.h:245
vtkm::Id GetActiveCoordinateSystemIndex(vtkm::IdComponent index=0) const
Specifies the coordinate system index to make active to use when processing the input vtkm::cont::Dat...
Definition: Filter.h:305
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::IdComponent GetNumberOfFields() const
Methods to Add and Get fields on a PartitionedDataSet.
Definition: PartitionedDataSet.h:90
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
A FieldSelection stores information about fields to map for input dataset to output when a filter is ...
Definition: FieldSelection.h:31
void MapFieldsOntoOutput(const vtkm::cont::DataSet &input, const vtkm::filter::FieldSelection &fieldSelection, vtkm::cont::DataSet &output, FieldMapper &&fieldMapper) const
Definition: Filter.h:770
void SetUseCoordinateSystemAsField(vtkm::IdComponent index, bool val)
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:316
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
bool HasPointField(const std::string &name) const
Definition: DataSet.h:134
vtkm::cont::Field::Association GetActiveFieldAssociation(vtkm::IdComponent index=0) const
Specifies a field to operate on.
Definition: Filter.h:282
const vtkm::cont::Field & GetField(vtkm::Id index) const
Retrieves a field by index.
Definition: DataSet.h:108
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:38
bool HasGhostCellField() const
void SetCellSet(const CellSetType &cellSet)
Definition: DataSet.h:396
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
std::vector< std::string > ActiveFieldNames
Definition: Filter.h:848
void SetActiveField(const std::string &name, vtkm::cont::Field::Association association=vtkm::cont::Field::Association::Any)
Specifies a field to operate on.
Definition: Filter.h:254
vtkm::cont::Invoker Invoke
Definition: Filter.h:381
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
void SetGhostCellFieldName(const std::string &name)
Sets the name of the field to use for cell ghost levels.
void SetThreadsPerCPU(vtkm::Id numThreads)
Definition: Filter.h:351
const vtkm::cont::Field & GetPointField(const std::string &name) const
Returns the first point field that matches the provided name.
Definition: DataSet.h:212
void CastAndCallVecField(const vtkm::cont::Field &field, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input vector field.
Definition: Filter.h:717
bool HasField(const vtkm::cont::Field &inputField) const
Returns true if the input field has been added to this selection.
Definition: FieldSelection.h:161
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
void SetFieldsToPass(const std::string &fieldname, vtkm::filter::FieldSelection::Mode mode)
Specify which fields get passed from input to output.
Definition: Filter.h:215
const std::string & GetGhostCellFieldName() const
void SetRunMultiThreadedFilter(bool val)
Definition: Filter.h:362
bool HasCellField(const std::string &name) const
Definition: DataSet.h:122
vtkm::IdComponent GetNumberOfCoordinateSystems() const
Definition: DataSet.h:412
void CastAndCallScalarField(const vtkm::cont::UnknownArrayHandle &fieldArray, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input scalar field.
Definition: Filter.h:675
const vtkm::cont::UnknownArrayHandle & GetData() const
Get the array of the data for the field.
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:30
bool GetUseCoordinateSystemAsField(vtkm::IdComponent index=0) const
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:325
void AddField(const vtkm::cont::Field &inputField)
Definition: FieldSelection.h:116
const vtkm::cont::Field & GetFieldFromDataSet(vtkm::IdComponent index, const vtkm::cont::DataSet &input) const
Retrieve an input field from a vtkm::cont::DataSet object.
Definition: Filter.h:641
vtkm::cont::DataSet CreateResultCoordinateSystem(const vtkm::cont::DataSet &inDataSet, const vtkm::cont::UnknownCellSet &resultCellSet, const std::string &coordsName, const vtkm::cont::UnknownArrayHandle &coordsData, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:617
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
std::string OutputFieldName
Definition: Filter.h:846
vtkm::cont::DataSet CreateResultField(const vtkm::cont::DataSet &inDataSet, const std::string &resultFieldName, vtkm::cont::Field::Association resultFieldAssociation, const vtkm::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:426
void CastAndCallScalarField(const vtkm::cont::Field &field, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input scalar field.
Definition: Filter.h:685
typename detail::ListTransformImpl< List, Transform >::type ListTransform
Constructs a list containing all types in a source list applied to a transform template.
Definition: List.h:598
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:31
vtkm::Id GetThreadsPerGPU() const
Definition: Filter.h:355
vtkm::IdComponent GetNumberOfActiveFields() const
Return the number of active fields currently set.
Definition: Filter.h:339
vtkm::filter::FieldSelection & GetFieldsToPass()
Specify which fields get passed from input to output.
Definition: Filter.h:226
vtkm::cont::DataSet CreateResultFieldPoint(const vtkm::cont::DataSet &inDataSet, const std::string &resultFieldName, const vtkm::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:450
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
bool GetRunMultiThreadedFilter() const
Definition: Filter.h:357
#define VTKM_FILTER_CORE_EXPORT
Definition: vtkm_filter_core_export.h:44
void CastAndCallForTypesWithFloatFallback(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type with a float cast fallback.
Definition: UnknownArrayHandle.h:1195
Base class for all filters.
Definition: Filter.h:163
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:120
@ Any
Any field regardless of the association.
void SetActiveCoordinateSystem(vtkm::Id coord_idx)
Specifies the coordinate system index to make active to use when processing the input vtkm::cont::Dat...
Definition: Filter.h:291
bool GetPassCoordinateSystems() const
Specify whether to always pass coordinate systems.
Definition: Filter.h:240
bool IsFieldSelected(const vtkm::cont::Field &inputField) const
Returns true if the input field should be mapped to the output dataset.
Definition: FieldSelection.h:104
#define VTKM_DEFAULT_STORAGE_LIST
Definition: DefaultTypes.h:50
@ Points
A field that applies to points.
#define VTKM_CONT
Definition: ExportMacros.h:57
void SetPassCoordinateSystems(bool flag)
Specify whether to always pass coordinate systems.
Definition: Filter.h:238
bool HasCoordinateSystem(const std::string &name) const
Definition: DataSet.h:374
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::cont::PartitionedDataSet CreateResult(const vtkm::cont::PartitionedDataSet &input, const vtkm::cont::PartitionedDataSet &resultPartitions, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:517
vtkm::IdComponent AddCoordinateSystem(const vtkm::cont::CoordinateSystem &cs)
Adds the given CoordinateSystem to the DataSet.
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:208
void SetActiveField(vtkm::IdComponent index, const std::string &name, vtkm::cont::Field::Association association=vtkm::cont::Field::Association::Any)
Specifies a field to operate on.
Definition: Filter.h:262
void CastAndCallVecField(const vtkm::cont::UnknownArrayHandle &fieldArray, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input vector field.
Definition: Filter.h:706
A short fixed-length array.
Definition: Types.h:357
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:236
void MapFieldsOntoOutput(const vtkm::cont::PartitionedDataSet &input, const vtkm::filter::FieldSelection &fieldSelection, vtkm::cont::PartitionedDataSet &output, FieldMapper &&fieldMapper) const
Definition: Filter.h:813
std::vector< vtkm::cont::Field::Association > ActiveFieldAssociation
Definition: Filter.h:849
vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet &inDataSet, const vtkm::cont::UnknownCellSet &resultCellSet, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:546
@ Cells
A field that applies to cells.
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
vtkm::cont::CoordinateSystem GetCoordinateSystem(vtkm::Id index=0) const
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
vtkm::cont::ArrayHandleRecombineVec< BaseComponentType > ExtractArrayFromComponents(vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On) const
Extract the array knowing only the component type of the array.
Definition: UnknownArrayHandle.h:847
vtkm::Id GetThreadsPerCPU() const
Definition: Filter.h:354
void SetThreadsPerGPU(vtkm::Id numThreads)
Definition: Filter.h:352
UnknownArrayHandle NewInstanceFloatBasic() const
Create a new ArrayHandleBasic with the base component of vtkm::FloatDefault
#define VTKM_DEPRECATED(...)
Definition: Deprecated.h:145
const std::string & GetOutputFieldName() const
Specifies the name of the output field generated.
Definition: Filter.h:248
void CastAndCallVariableVecField(const vtkm::cont::Field &field, Functor &&functor, Args &&... args) const
This method is like CastAndCallVecField except that it can be used for a field of unknown vector size...
Definition: Filter.h:760
void SetInvoker(vtkm::cont::Invoker inv)
Specify the vtkm::cont::Invoker to be used to execute worklets by this filter instance.
Definition: Filter.h:378
const std::string & GetCoordinateSystemName(vtkm::Id index=0) const
std::vector< vtkm::Id > ActiveCoordinateSystemIndices
Definition: Filter.h:851
vtkm::cont::DataSet CreateResultFieldCell(const vtkm::cont::DataSet &inDataSet, const std::string &resultFieldName, const vtkm::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:475
vtkm::IdComponent GetNumberOfFields() const
Definition: DataSet.h:409
std::vector< bool > UseCoordinateSystemAsField
Definition: Filter.h:850
vtkm::cont::DataSet CreateResultCoordinateSystem(const vtkm::cont::DataSet &inDataSet, const vtkm::cont::UnknownCellSet &resultCellSet, const vtkm::cont::CoordinateSystem &resultCoordSystem, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:577
vtkm::List< vtkm::Float32, vtkm::Float64 > TypeListFieldScalar
A list containing types used for scalar fields.
Definition: TypeList.h:47
Mode
Definition: FieldSelection.h:34
const vtkm::cont::Field & GetField(vtkm::Id index) const
Definition: PartitionedDataSet.h:152
Comprises a set of vtkm::cont::DataSet objects.
Definition: PartitionedDataSet.h:26
void CastAndCallVariableVecField(const vtkm::cont::UnknownArrayHandle &fieldArray, Functor &&functor, Args &&... args) const
This method is like CastAndCallVecField except that it can be used for a field of unknown vector size...
Definition: Filter.h:737