GenerateIds.h 3.42 KB
Newer Older
Kenneth Moreland's avatar
Kenneth Moreland committed
1
2
3
4
5
6
7
8
9
10
11
12
//============================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
//
//  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_GenerateIds_h
#define vtk_m_filter_GenerateIds_h

Li-Ta Lo's avatar
Li-Ta Lo committed
13
14
#include <vtkm/filter/FieldTransform/vtkm_filter_fieldtransform_export.h>
#include <vtkm/filter/NewFilter.h>
Kenneth Moreland's avatar
Kenneth Moreland committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

namespace vtkm
{
namespace filter
{

/// \brief Adds fields to a `DataSet` that give the ids for the points and cells.
///
/// This filter will add (by default) a point field named `pointids` that gives the
/// index of the associated point and likewise a cell field named `cellids` for the
/// associated cell indices. These fields are useful for tracking the provenance of
/// the elements of a `DataSet` as it gets manipulated by filters. It is also
/// convenient for adding indices to operations designed for fields and generally
/// creating test data.
///
Li-Ta Lo's avatar
Li-Ta Lo committed
30
class VTKM_FILTER_FIELDTRANSFORM_EXPORT GenerateIds : public vtkm::filter::NewFilter
Kenneth Moreland's avatar
Kenneth Moreland committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  std::string PointFieldName = "pointids";
  std::string CellFieldName = "cellids";
  bool GeneratePointIds = true;
  bool GenerateCellIds = true;
  bool UseFloat = false;

public:
  /// \{
  /// \brief The name given to the generated point field.
  ///
  /// By default, the name is `pointids`.
  ///
  const std::string& GetPointFieldName() const { return this->PointFieldName; }
  void SetPointFieldName(const std::string& name) { this->PointFieldName = name; }
  /// \}

  /// \{
  /// \brief The name given to the generated cell field.
  ///
  /// By default, the name is `cellids`.
  ///
  const std::string& GetCellFieldName() const { return this->CellFieldName; }
  void SetCellFieldName(const std::string& name) { this->CellFieldName = name; }
  /// \}

  /// \{
  /// \brief Specify whether the point id field is generated.
  ///
  /// When `GeneratePointIds` is `true` (the default), a field echoing the point
  /// indices is generated. When set to `false`, this output is not created.
  ///
  bool GetGeneratePointIds() const { return this->GeneratePointIds; }
  void SetGeneratePointIds(bool flag) { this->GeneratePointIds = flag; }
  /// \}

  /// \{
  /// \brief Specify whether the cell id field is generated.
  ///
  /// When `GenerateCellIds` is `true` (the default), a field echoing the cell
  /// indices is generated. When set to `false`, this output is not created.
  ///
  bool GetGenerateCellIds() const { return this->GenerateCellIds; }
  void SetGenerateCellIds(bool flag) { this->GenerateCellIds = flag; }
  /// \}

  /// \{
  /// \brief Specify whether the generated fields should be integer or float.
  ///
  /// When `UseFloat` is `false` (the default), then the fields generated will have
  /// type `vtkm::Id`. If it is set to `true`, then the fields will be generated
  /// with type `vtkm::FloatDefault`.
  ///
  bool GetUseFloat() const { return this->UseFloat; }
  void SetUseFloat(bool flag) { this->UseFloat = flag; }

87
  using vtkm::filter::NewFilter::Execute; // bring overloads of Execute into name lookup
Li-Ta Lo's avatar
Li-Ta Lo committed
88
  vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input) override;
Kenneth Moreland's avatar
Kenneth Moreland committed
89
90
91
92
93
94
};

} // namespace vtkm::filter
} // namespace vtkm

#endif //vtk_m_filter_GenerateIds_h