Go to the documentation of this file.
18 #ifndef viskores_filter_Filter_h
19 #define viskores_filter_Filter_h
208 std::initializer_list<std::string> fields,
213 std::initializer_list<std::pair<std::string, viskores::cont::Field::Association>> fields,
219 const std::string& fieldname,
264 const std::string& name,
267 this->SetActiveField(0, name, association);
273 const std::string& name,
276 auto index_st =
static_cast<std::size_t
>(index);
277 this->ResizeIfNeeded(index_st);
278 this->ActiveFieldNames[index_st] = name;
279 this->ActiveFieldAssociation[index_st] = association;
287 return this->ActiveFieldNames[index];
294 return this->ActiveFieldAssociation[index];
302 this->SetActiveCoordinateSystem(0, coord_idx);
308 auto index_st =
static_cast<std::size_t
>(index);
309 this->ResizeIfNeeded(index_st);
310 this->ActiveCoordinateSystemIndices[index_st] = coord_idx;
316 auto index_st =
static_cast<std::size_t
>(index);
317 return this->ActiveCoordinateSystemIndices[index_st];
324 SetUseCoordinateSystemAsField(0, val);
330 auto index_st =
static_cast<std::size_t
>(index);
331 this->ResizeIfNeeded(index_st);
332 this->UseCoordinateSystemAsField[index] = val;
341 return this->UseCoordinateSystemAsField[index];
353 VISKORES_ASSERT(this->ActiveFieldNames.size() == this->UseCoordinateSystemAsField.size());
365 this->NumThreadsPerCPU = numThreads;
369 this->NumThreadsPerGPU = numThreads;
377 return this->CanThread() && this->RunFilterWithMultipleThreads;
382 if (this->CanThread())
383 this->RunFilterWithMultipleThreads = val;
387 "Multi threaded filter not supported for " + std::string(
typeid(*this).name());
448 const std::string& resultFieldName,
452 return this->CreateResultField(
473 const std::string& resultFieldName,
476 return this->CreateResultField(
498 const std::string& resultFieldName,
501 return this->CreateResultField(inDataSet,
537 template <
typename FieldMapper>
541 FieldMapper&& fieldMapper)
const
544 this->MapFieldsOntoOutput(input, this->GetFieldsToPass(), output, fieldMapper);
566 template <
typename FieldMapper>
570 FieldMapper&& fieldMapper)
const
574 this->MapFieldsOntoOutput(inDataSet, this->GetFieldsToPass(), outDataSet, fieldMapper);
598 template <
typename FieldMapper>
603 FieldMapper&& fieldMapper)
const
608 if (this->GetPassCoordinateSystems() || fieldSelection.
HasField(resultCoordSystem))
613 this->MapFieldsOntoOutput(inDataSet, fieldSelection, outDataSet, fieldMapper);
638 template <
typename FieldMapper>
642 const std::string& coordsName,
644 FieldMapper&& fieldMapper)
const
646 return this->CreateResultCoordinateSystem(
660 return this->GetFieldFromDataSet(0, input);
668 if (this->UseCoordinateSystemAsField[index])
673 const std::string& coordSystemName =
679 return input.
GetField(this->GetActiveFieldName(index),
680 this->GetActiveFieldAssociation(index));
699 template <
typename Functor,
typename... Args>
702 Args&&... args)
const
706 std::forward<Functor>(functor), std::forward<Args>(args)...);
709 template <
typename Functor,
typename... Args>
712 Args&&... args)
const
714 this->CastAndCallScalarField(
715 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
733 Args&&... args)
const
738 std::forward<Functor>(functor), std::forward<Args>(args)...);
744 Args&&... args)
const
746 this->CastAndCallVecField<VecSize>(
747 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
761 template <
typename Functor,
typename... Args>
765 Args&&... args)
const
770 std::forward<Args>(args)...);
775 std::forward<Args>(args)...);
783 std::forward<Args>(args)...);
787 template <
typename Functor,
typename... Args>
790 Args&&... args)
const
792 this->CastAndCallVariableVecField(
793 field.
GetData(), std::forward<Functor>(functor), std::forward<Args>(args)...);
797 template <
typename FieldMapper>
801 FieldMapper&& fieldMapper)
const
809 fieldMapper(output, field);
829 if (!output.
HasPointField(coords.GetName()) && this->GetPassCoordinateSystems())
831 fieldMapper(output, coords);
841 template <
typename FieldMapper>
845 FieldMapper&& fieldMapper)
const
852 fieldMapper(output, field);
857 template <viskores::IdComponent VecSize>
860 template <
typename T>
867 void ResizeIfNeeded(
size_t index_st);
870 bool PassCoordinateSystems =
true;
871 bool RunFilterWithMultipleThreads =
false;
void CastAndCallScalarField(const viskores::cont::Field &field, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input scalar field.
Definition: Filter.h:710
UnknownArrayHandle NewInstanceFloatBasic() const
Create a new ArrayHandleBasic with the base component of viskores::FloatDefault
viskores::cont::CoordinateSystem GetCoordinateSystem(viskores::Id index=0) const
std::string OutputFieldName
Definition: Filter.h:875
viskores::IdComponent GetNumberOfCoordinateSystems() const
Definition: DataSet.h:431
void CastAndCallForTypesWithFloatFallback(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type with a float cast fallback.
Definition: UnknownArrayHandle.h:1231
const viskores::cont::Field & GetPointField(const std::string &name) const
Returns the first point field that matches the provided name.
Definition: DataSet.h:225
viskores::cont::Field::Association GetActiveFieldAssociation(viskores::IdComponent index=0) const
Specifies a field to operate on.
Definition: Filter.h:291
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
std::vector< viskores::cont::Field::Association > ActiveFieldAssociation
Definition: Filter.h:878
Association
Identifies what elements of a data set a field is associated with.
Definition: Field.h:46
void SetOutputFieldName(const std::string &name)
Specifies the name of the output field generated.
Definition: Filter.h:254
bool HasPointField(const std::string &name) const
Definition: DataSet.h:147
@ Any
Any field regardless of the association.
viskores::cont::DataSet CreateResultFieldCell(const viskores::cont::DataSet &inDataSet, const std::string &resultFieldName, const viskores::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:496
std::vector< bool > UseCoordinateSystemAsField
Definition: Filter.h:879
void SetPassCoordinateSystems(bool flag)
Specify whether to always pass coordinate systems.
Definition: Filter.h:247
const viskores::cont::UnknownArrayHandle & GetData() const
Get the array of the data for the field.
Base class for all filters.
Definition: Filter.h:171
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:38
void SetThreadsPerCPU(viskores::Id numThreads)
Definition: Filter.h:363
const viskores::cont::Field & GetField(viskores::Id index) const
Retrieves a field by index.
Definition: DataSet.h:117
viskores::IdComponent GetNumberOfFields() const
Definition: DataSet.h:428
void MapFieldsOntoOutput(const viskores::cont::PartitionedDataSet &input, const viskores::filter::FieldSelection &fieldSelection, viskores::cont::PartitionedDataSet &output, FieldMapper &&fieldMapper) const
Definition: Filter.h:842
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
@ Cells
A field that applies to cells.
#define VISKORES_DEFAULT_STORAGE_LIST
Definition: DefaultTypes.h:58
const viskores::filter::FieldSelection & GetFieldsToPass() const
Specify which fields get passed from input to output.
Definition: Filter.h:232
const std::string & GetActiveFieldName(viskores::IdComponent index=0) const
Specifies a field to operate on.
Definition: Filter.h:283
const viskores::cont::Field & GetField(viskores::Id index) const
Definition: PartitionedDataSet.h:168
void SetActiveField(const std::string &name, viskores::cont::Field::Association association=viskores::cont::Field::Association::Any)
Specifies a field to operate on.
Definition: Filter.h:263
viskores::IdComponent AddCoordinateSystem(const viskores::cont::CoordinateSystem &cs)
Adds the given CoordinateSystem to the DataSet.
bool HasCoordinateSystem(const std::string &name) const
Definition: DataSet.h:393
viskores::Id GetThreadsPerGPU() const
Definition: Filter.h:373
void SetActiveCoordinateSystem(viskores::Id coord_idx)
Specifies the coordinate system index to make active to use when processing the input viskores::cont:...
Definition: Filter.h:300
const std::string & GetGhostCellFieldName() const
viskores::cont::DataSet CreateResultField(const viskores::cont::DataSet &inDataSet, const std::string &resultFieldName, viskores::cont::Field::Association resultFieldAssociation, const viskores::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:446
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
const viskores::cont::Field & GetFieldFromDataSet(viskores::IdComponent index, const viskores::cont::DataSet &input) const
Retrieve an input field from a viskores::cont::DataSet object.
Definition: Filter.h:664
const std::string & GetCoordinateSystemName(viskores::Id index=0) const
viskores::cont::PartitionedDataSet CreateResult(const viskores::cont::PartitionedDataSet &input, const viskores::cont::PartitionedDataSet &resultPartitions, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:538
#define VISKORES_CONT
Definition: ExportMacros.h:65
bool IsFieldSelected(const viskores::cont::Field &inputField) const
Returns true if the input field should be mapped to the output dataset.
Definition: FieldSelection.h:112
Groups connected points that have the same field value.
Definition: Atomic.h:27
bool HasField(const viskores::cont::Field &inputField) const
Returns true if the input field has been added to this selection.
Definition: FieldSelection.h:170
void MapFieldsOntoOutput(const viskores::cont::DataSet &input, const viskores::filter::FieldSelection &fieldSelection, viskores::cont::DataSet &output, FieldMapper &&fieldMapper) const
Definition: Filter.h:798
const std::vector< viskores::cont::DataSet > & GetPartitions() const
Get an STL vector of all DataSet objects stored in PartitionedDataSet.
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:617
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:165
viskores::cont::DataSet CreateResultFieldPoint(const viskores::cont::DataSet &inDataSet, const std::string &resultFieldName, const viskores::cont::UnknownArrayHandle &resultFieldArray) const
Create the output data set for DoExecute
Definition: Filter.h:471
void SetGhostCellFieldName(const std::string &name)
Sets the name of the field to use for cell ghost levels.
viskores::filter::FieldSelection & GetFieldsToPass()
Specify which fields get passed from input to output.
Definition: Filter.h:235
#define VISKORES_DEPRECATED(...)
Definition: Deprecated.h:156
Mode
Definition: FieldSelection.h:42
bool GetUseCoordinateSystemAsField(viskores::IdComponent index=0) const
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:337
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
Comprises a set of viskores::cont::DataSet objects.
Definition: PartitionedDataSet.h:34
void CastAndCallVecField(const viskores::cont::Field &field, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input vector field.
Definition: Filter.h:742
void SetFieldsToPass(const std::string &fieldname, viskores::filter::FieldSelection::Mode mode)
Specify which fields get passed from input to output.
Definition: Filter.h:224
viskores::cont::DataSet CreateResult(const viskores::cont::DataSet &inDataSet, const viskores::cont::UnknownCellSet &resultCellSet, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:567
viskores::cont::DataSet CreateResultCoordinateSystem(const viskores::cont::DataSet &inDataSet, const viskores::cont::UnknownCellSet &resultCellSet, const viskores::cont::CoordinateSystem &resultCoordSystem, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:599
void CastAndCallVariableVecField(const viskores::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:762
void SetUseCoordinateSystemAsField(viskores::IdComponent index, bool val)
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:328
viskores::cont::DataSet CreateResultCoordinateSystem(const viskores::cont::DataSet &inDataSet, const viskores::cont::UnknownCellSet &resultCellSet, const std::string &coordsName, const viskores::cont::UnknownArrayHandle &coordsData, FieldMapper &&fieldMapper) const
Create the output data set for DoExecute.
Definition: Filter.h:639
bool GetRunMultiThreadedFilter() const
Definition: Filter.h:375
void SetUseCoordinateSystemAsField(bool val)
Specifies whether to use point coordinates as the input field.
Definition: Filter.h:322
A FieldSelection stores information about fields to map for input dataset to output when a filter is ...
Definition: FieldSelection.h:39
viskores::cont::Invoker Invoke
Definition: Filter.h:399
bool HasCellField(const std::string &name) const
Definition: DataSet.h:135
viskores::IdComponent GetNumberOfFields() const
Methods to Add and Get fields on a PartitionedDataSet.
Definition: PartitionedDataSet.h:99
A CellSet of an unknown type.
Definition: UnknownCellSet.h:56
void SetThreadsPerGPU(viskores::Id numThreads)
Definition: Filter.h:367
#define VISKORES_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:216
const viskores::cont::Field & GetFieldFromDataSet(const viskores::cont::DataSet &input) const
Retrieve an input field from a viskores::cont::DataSet object.
Definition: Filter.h:657
void CastAndCallVariableVecField(const viskores::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:788
viskores::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:244
void AddField(const viskores::cont::Field &inputField)
Definition: FieldSelection.h:124
viskores::List< viskores::Float32, viskores::Float64 > TypeListFieldScalar
A list containing types used for scalar fields.
Definition: TypeList.h:55
void SetRunMultiThreadedFilter(bool val)
Definition: Filter.h:380
viskores::cont::ArrayHandleRecombineVec< BaseComponentType > ExtractArrayFromComponents(viskores::CopyFlag allowCopy=viskores::CopyFlag::On) const
Extract the array knowing only the component type of the array.
Definition: UnknownArrayHandle.h:873
bool IsBaseComponentType() const
Returns true if this array's ValueType has the provided base component type.
Definition: UnknownArrayHandle.h:561
const std::string & GetOutputFieldName() const
Specifies the name of the output field generated.
Definition: Filter.h:257
void SetActiveCoordinateSystem(viskores::IdComponent index, viskores::Id coord_idx)
Specifies the coordinate system index to make active to use when processing the input viskores::cont:...
Definition: Filter.h:306
void SetInvoker(viskores::cont::Invoker inv)
Specify the viskores::cont::Invoker to be used to execute worklets by this filter instance.
Definition: Filter.h:396
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:49
viskores::Id GetThreadsPerCPU() const
Definition: Filter.h:372
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:129
void SetActiveField(viskores::IdComponent index, const std::string &name, viskores::cont::Field::Association association=viskores::cont::Field::Association::Any)
Specifies a field to operate on.
Definition: Filter.h:271
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::IdComponent GetNumberOfActiveFields() const
Return the number of active fields currently set.
Definition: Filter.h:351
std::vector< viskores::Id > ActiveCoordinateSystemIndices
Definition: Filter.h:880
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
bool HasGhostCellField() const
@ Points
A field that applies to points.
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:39
A short fixed-length array.
Definition: Types.h:365
void CastAndCallVecField(const viskores::cont::UnknownArrayHandle &fieldArray, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input vector field.
Definition: Filter.h:731
bool GetPassCoordinateSystems() const
Specify whether to always pass coordinate systems.
Definition: Filter.h:249
viskores::Id GetActiveCoordinateSystemIndex(viskores::IdComponent index=0) const
Specifies the coordinate system index to make active to use when processing the input viskores::cont:...
Definition: Filter.h:314
void CastAndCallScalarField(const viskores::cont::UnknownArrayHandle &fieldArray, Functor &&functor, Args &&... args) const
Convenience method to get the array from a filter's input scalar field.
Definition: Filter.h:700
std::vector< std::string > ActiveFieldNames
Definition: Filter.h:877
void SetCellSet(const CellSetType &cellSet)
Definition: DataSet.h:415