2018-03-02 20:49:07 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-03-02 20:49:07 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_filter_FieldSelection_h
|
|
|
|
#define vtk_m_filter_FieldSelection_h
|
|
|
|
|
2018-03-21 20:12:22 +00:00
|
|
|
#include <vtkm/Pair.h>
|
2018-03-02 20:49:07 +00:00
|
|
|
#include <vtkm/cont/Field.h>
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
#include <vtkm/filter/vtkm_filter_core_export.h>
|
|
|
|
|
|
|
|
#include <initializer_list>
|
|
|
|
#include <memory>
|
|
|
|
|
2018-03-02 20:49:07 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
/// A \c FieldSelection stores information about fields to map for input dataset to output
|
|
|
|
/// when a filter is executed. A \c FieldSelection object is passed to
|
|
|
|
/// `vtkm::filter::Filter::Execute` to execute the filter and map selected
|
|
|
|
/// fields. It is possible to easily construct \c FieldSelection that selects all or
|
|
|
|
/// none of the input fields.
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
class VTKM_FILTER_CORE_EXPORT FieldSelection
|
2018-03-02 20:49:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-17 20:36:55 +00:00
|
|
|
enum struct Mode
|
2018-03-02 20:49:07 +00:00
|
|
|
{
|
2022-03-17 20:36:55 +00:00
|
|
|
None,
|
|
|
|
All,
|
|
|
|
Select,
|
|
|
|
Exclude
|
2018-03-02 20:49:07 +00:00
|
|
|
};
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(Mode mode = Mode::Select);
|
2018-03-02 20:49:07 +00:00
|
|
|
|
2018-03-22 16:25:09 +00:00
|
|
|
/// Use this constructor to create a field selection given a single field name
|
|
|
|
/// \code{cpp}
|
|
|
|
/// FieldSelection("field_name");
|
|
|
|
/// \endcode
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(const std::string& field, Mode mode = Mode::Select);
|
2018-03-22 16:25:09 +00:00
|
|
|
|
|
|
|
/// Use this constructor to create a field selection given a single field name
|
|
|
|
/// \code{cpp}
|
|
|
|
/// FieldSelection("field_name");
|
|
|
|
/// \endcode
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(const char* field, Mode mode = Mode::Select);
|
2018-03-22 16:25:09 +00:00
|
|
|
|
|
|
|
/// Use this constructor to create a field selection given a single name and association.
|
|
|
|
/// \code{cpp}
|
2022-03-17 17:02:37 +00:00
|
|
|
/// FieldSelection("field_name", vtkm::cont::Field::Association::Points)
|
2018-03-22 16:25:09 +00:00
|
|
|
/// \endcode{cpp}
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(const std::string& field,
|
|
|
|
vtkm::cont::Field::Association association,
|
|
|
|
Mode mode = Mode::Select);
|
2018-03-22 16:25:09 +00:00
|
|
|
|
|
|
|
/// Use this constructor to create a field selection given the field names.
|
|
|
|
/// \code{cpp}
|
|
|
|
/// FieldSelection({"field_one", "field_two"});
|
|
|
|
/// \endcode
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(std::initializer_list<std::string> fields, Mode mode = Mode::Select);
|
2018-03-02 20:49:07 +00:00
|
|
|
|
|
|
|
/// Use this constructor create a field selection given the field names and
|
|
|
|
/// associations e.g.
|
|
|
|
/// @code{cpp}
|
2018-05-18 20:10:15 +00:00
|
|
|
/// using pair_type = std::pair<std::string, vtkm::cont::Field::Association>;
|
2018-03-02 20:49:07 +00:00
|
|
|
/// FieldSelection({
|
2022-03-17 17:02:37 +00:00
|
|
|
/// pair_type{"field_one", vtkm::cont::Field::Association::Points},
|
|
|
|
/// pair_type{"field_two", vtkm::cont::Field::Association::Cells} });
|
2018-03-02 20:49:07 +00:00
|
|
|
/// @endcode
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(
|
2018-05-18 20:10:15 +00:00
|
|
|
std::initializer_list<std::pair<std::string, vtkm::cont::Field::Association>> fields,
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
Mode mode = Mode::Select);
|
2018-03-02 20:49:07 +00:00
|
|
|
|
2018-03-21 20:12:22 +00:00
|
|
|
/// Use this constructor create a field selection given the field names and
|
|
|
|
/// associations e.g.
|
|
|
|
/// @code{cpp}
|
2018-05-18 20:10:15 +00:00
|
|
|
/// using pair_type = vtkm::Pair<std::string, vtkm::cont::Field::Association>;
|
2018-03-21 20:12:22 +00:00
|
|
|
/// FieldSelection({
|
2022-03-17 17:02:37 +00:00
|
|
|
/// pair_type{"field_one", vtkm::cont::Field::Association::Points},
|
|
|
|
/// pair_type{"field_two", vtkm::cont::Field::Association::Cells} });
|
2018-03-21 20:12:22 +00:00
|
|
|
/// @endcode
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(
|
2018-05-18 20:10:15 +00:00
|
|
|
std::initializer_list<vtkm::Pair<std::string, vtkm::cont::Field::Association>> fields,
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
Mode mode = Mode::Select);
|
2018-03-21 20:12:22 +00:00
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT FieldSelection(const FieldSelection& src);
|
|
|
|
VTKM_CONT FieldSelection(FieldSelection&& rhs);
|
|
|
|
VTKM_CONT FieldSelection& operator=(const FieldSelection& src);
|
|
|
|
VTKM_CONT FieldSelection& operator=(FieldSelection&& rhs);
|
|
|
|
|
|
|
|
VTKM_CONT ~FieldSelection();
|
2018-03-02 20:49:07 +00:00
|
|
|
|
|
|
|
/// Returns true if the input field should be mapped to the output
|
|
|
|
/// dataset.
|
|
|
|
VTKM_CONT
|
|
|
|
bool IsFieldSelected(const vtkm::cont::Field& inputField) const
|
|
|
|
{
|
|
|
|
return this->IsFieldSelected(inputField.GetName(), inputField.GetAssociation());
|
|
|
|
}
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT bool IsFieldSelected(
|
2018-03-02 20:49:07 +00:00
|
|
|
const std::string& name,
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const;
|
2018-03-02 20:49:07 +00:00
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
///@{
|
|
|
|
/// Add fields to select or exclude. If no mode is specified, then the mode will follow
|
|
|
|
/// that of `GetMode()`.
|
|
|
|
VTKM_CONT void AddField(const vtkm::cont::Field& inputField)
|
|
|
|
{
|
|
|
|
this->AddField(inputField.GetName(), inputField.GetAssociation(), this->GetMode());
|
2018-03-02 20:49:07 +00:00
|
|
|
}
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT void AddField(const vtkm::cont::Field& inputField, Mode mode)
|
2018-03-02 20:49:07 +00:00
|
|
|
{
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
this->AddField(inputField.GetName(), inputField.GetAssociation(), mode);
|
2018-03-02 20:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void AddField(const std::string& fieldName,
|
2022-03-17 17:02:37 +00:00
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any)
|
2018-03-02 20:49:07 +00:00
|
|
|
{
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
this->AddField(fieldName, association, this->GetMode());
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT void AddField(const std::string& fieldName, Mode mode)
|
|
|
|
{
|
|
|
|
this->AddField(fieldName, vtkm::cont::Field::Association::Any, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT void AddField(const std::string& fieldName,
|
|
|
|
vtkm::cont::Field::Association association,
|
|
|
|
Mode mode);
|
|
|
|
///@}
|
|
|
|
|
|
|
|
///@{
|
|
|
|
/// Returns the mode for a particular field. If the field as been added with `AddField`
|
|
|
|
/// (or another means), then this will return `Select` or `Exclude`. If the field has
|
|
|
|
/// not been added, `None` will be returned.
|
|
|
|
VTKM_CONT Mode GetFieldMode(const vtkm::cont::Field& inputField) const
|
|
|
|
{
|
|
|
|
return this->GetFieldMode(inputField.GetName(), inputField.GetAssociation());
|
2018-03-02 20:49:07 +00:00
|
|
|
}
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
|
|
|
|
VTKM_CONT Mode GetFieldMode(
|
|
|
|
const std::string& fieldName,
|
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const;
|
2022-09-09 02:29:48 +00:00
|
|
|
///@}
|
2018-03-02 20:49:07 +00:00
|
|
|
|
2018-03-21 20:06:12 +00:00
|
|
|
/// Returns true if the input field has been added to this selection.
|
|
|
|
/// Note that depending on the mode of this selection, the result of HasField
|
|
|
|
/// is not necessarily the same as IsFieldSelected. (If the mode is MODE_SELECT,
|
|
|
|
/// then the result of the two will be the same.)
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT bool HasField(const vtkm::cont::Field& inputField) const
|
2018-03-21 20:06:12 +00:00
|
|
|
{
|
|
|
|
return this->HasField(inputField.GetName(), inputField.GetAssociation());
|
|
|
|
}
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT bool HasField(
|
2018-05-18 20:10:15 +00:00
|
|
|
const std::string& name,
|
2022-03-17 17:02:37 +00:00
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::Any) const
|
2018-03-21 20:06:12 +00:00
|
|
|
{
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
return (this->GetFieldMode(name, association) != Mode::None);
|
2018-03-21 20:06:12 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 20:49:07 +00:00
|
|
|
/// Clear all fields added using `AddField`.
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
VTKM_CONT void ClearFields();
|
|
|
|
|
|
|
|
/// Gets the mode of the field selection. If `Select` mode is on, then only fields that have a
|
|
|
|
/// `Select` mode are considered as selected. (All others are considered unselected.) Calling
|
|
|
|
/// `AddField` in this mode will mark it as `Select`. If `Exclude` mode is on, then all fields
|
|
|
|
/// are considered selected except those fields with an `Exclude` mode. Calling `AddField` in
|
|
|
|
/// this mode will mark it as `Exclude`.
|
|
|
|
VTKM_CONT Mode GetMode() const;
|
|
|
|
|
|
|
|
/// Sets the mode of the field selection. If `Select` mode is on, then only fields that have a
|
|
|
|
/// `Select` mode are considered as selected. (All others are considered unselected.) Calling
|
|
|
|
/// `AddField` in this mode will mark it as `Select`. If `Exclude` mode is on, then all fields
|
|
|
|
/// are considered selected except those fields with an `Exclude` mode. Calling `AddField` in
|
|
|
|
/// this mode will mark it as `Exclude`.
|
|
|
|
///
|
|
|
|
/// If the mode is set to `None`, then the field modes are cleared and the overall mode is set to
|
|
|
|
/// `Select` (meaning none of the fields are initially selected). If the mode is set to `All`,
|
|
|
|
/// then the field modes are cleared and the overall mode is set to `Exclude` (meaning all of the
|
|
|
|
/// fields are initially selected).
|
|
|
|
VTKM_CONT void SetMode(Mode val);
|
2018-03-02 20:49:07 +00:00
|
|
|
|
|
|
|
private:
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
struct InternalStruct;
|
|
|
|
std::unique_ptr<InternalStruct> Internals;
|
2018-03-02 20:49:07 +00:00
|
|
|
};
|
|
|
|
|
Allow FieldSelection to simultaneously include and exclude fields
The basic use of `FieldSelection` is to construct the class with a mode
(`None`, `Any`, `Select`, `Exclude`), and then specify particular fields
based off of this mode. This works fine for basic uses where the same code
that constructs a `FieldSelection` sets all the fields.
But what happens, for example, if you have code that takes an existing
`FieldSelection` and wants to exclude the field named `foo`? If the
`FieldSelection` mode happens to be anything other than `Exclude`, the code
would have to go through several hoops to construct a new `FieldSelection`
object with this modified selection.
To make this case easier, `FieldSelection` now has the ability to specify
the mode independently for each field. The `AddField` method now has an
optional mode argument the specifies whether the mode for that field should
be `Select` or `Exclude`.
In the example above, the code can simply add the `foo` field with the
`Exclude` mode. Regardless of whatever state the `FieldSelection` was in
before, it will now report the `foo` field as not selected.
2022-11-03 18:34:58 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
2018-03-02 20:49:07 +00:00
|
|
|
|
|
|
|
#endif // vtk_m_filter_FieldSelection_h
|