VTK-m  2.2
FieldToColors.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 
11 #ifndef vtk_m_filter_field_transform_FieldToColors_h
12 #define vtk_m_filter_field_transform_FieldToColors_h
13 
14 #include <vtkm/cont/ColorTable.h>
15 #include <vtkm/filter/Filter.h>
17 
18 namespace vtkm
19 {
20 namespace filter
21 {
22 namespace field_transform
23 {
30 {
31 public:
32  VTKM_CONT
34 
35  // Documentation of enumerations is behaving a little weird in Doxygen (version 1.9.7).
36  // You cannot have a blank line in the documentation. Everything below it will be treated
37  // as preformatted text. Also, the first line always seem to behave like `@brief` is used
38  // even when it is not. It's easier to just document an associated method and copy the
39  // documentation
40 
42  enum struct InputMode
43  {
45  Scalar,
47  Magnitude,
49  Component,
50  };
51 
53  enum struct OutputMode
54  {
56  RGB,
58  RGBA,
59  };
60 
63  {
64  this->Table = table;
65  this->ModifiedCount = -1;
66  }
68  const vtkm::cont::ColorTable& GetColorTable() const { return this->Table; }
69 
71  void SetMappingMode(InputMode mode) { this->InputModeType = mode; }
76  void SetMappingToScalar() { this->InputModeType = InputMode::Scalar; }
81  void SetMappingToMagnitude() { this->InputModeType = InputMode::Magnitude; }
87  void SetMappingToComponent() { this->InputModeType = InputMode::Component; }
89  InputMode GetMappingMode() const { return this->InputModeType; }
91  bool IsMappingScalar() const { return this->InputModeType == InputMode::Scalar; }
93  bool IsMappingMagnitude() const { return this->InputModeType == InputMode::Magnitude; }
95  bool IsMappingComponent() const { return this->InputModeType == InputMode::Component; }
96 
101  void SetMappingComponent(vtkm::IdComponent comp) { this->Component = comp; }
103  vtkm::IdComponent GetMappingComponent() const { return this->Component; }
104 
106  void SetOutputMode(OutputMode mode) { this->OutputModeType = mode; }
111  void SetOutputToRGB() { this->OutputModeType = OutputMode::RGB; }
116  void SetOutputToRGBA() { this->OutputModeType = OutputMode::RGBA; }
118  OutputMode GetOutputMode() const { return this->OutputModeType; }
120  bool IsOutputRGB() const { return this->OutputModeType == OutputMode::RGB; }
122  bool IsOutputRGBA() const { return this->OutputModeType == OutputMode::RGBA; }
123 
129  void SetNumberOfSamplingPoints(vtkm::Int32 count);
131  vtkm::Int32 GetNumberOfSamplingPoints() const { return this->SampleCount; }
132 
133 private:
134  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
135 
137  InputMode InputModeType = InputMode::Scalar;
138  OutputMode OutputModeType = OutputMode::RGBA;
141  vtkm::IdComponent Component = 0;
142  vtkm::Int32 SampleCount = 256;
143  vtkm::Id ModifiedCount = -1;
144 };
145 
146 } // namespace field_transform
147 } // namespace filter
148 } // namespace vtkm
149 
150 #endif // vtk_m_filter_field_transform_FieldToColors_h
vtkm::filter::field_transform::FieldToColors::SetOutputToRGBA
void SetOutputToRGBA()
Write out RGBA fixed precision color values.
Definition: FieldToColors.h:116
vtkm::filter::field_transform::FieldToColors::SamplesRGBA
vtkm::cont::ColorTableSamplesRGBA SamplesRGBA
Definition: FieldToColors.h:140
vtkm::filter::field_transform::FieldToColors::SetColorTable
void SetColorTable(const vtkm::cont::ColorTable &table)
Specifies the vtkm::cont::ColorTable object to use to map field values to colors.
Definition: FieldToColors.h:62
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ColorTable
Color Table for coloring arbitrary fields.
Definition: cont/ColorTable.h:89
vtkm::filter::field_transform::FieldToColors::SamplesRGB
vtkm::cont::ColorTableSamplesRGB SamplesRGB
Definition: FieldToColors.h:139
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::filter::field_transform::FieldToColors::GetNumberOfSamplingPoints
vtkm::Int32 GetNumberOfSamplingPoints() const
Specifies how many samples to use when looking up color values.
Definition: FieldToColors.h:131
vtkm::cont::DataSet
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
vtkm::filter::field_transform::FieldToColors::SetMappingToComponent
void SetMappingToComponent()
Map a component of a vector field as if it were a scalar.
Definition: FieldToColors.h:87
ColorTable.h
vtkm_filter_field_transform_export.h
vtkm::filter::field_transform::FieldToColors::IsMappingScalar
bool IsMappingScalar() const
Returns true if this filter is in scalar mapping mode.
Definition: FieldToColors.h:91
vtkm::filter::field_transform::FieldToColors
Convert an arbitrary field to an RGB or RGBA field.
Definition: FieldToColors.h:29
vtkm::filter::field_transform::FieldToColors::Table
vtkm::cont::ColorTable Table
Definition: FieldToColors.h:136
vtkm::filter::field_transform::FieldToColors::IsMappingMagnitude
bool IsMappingMagnitude() const
Returns true if this filter is in magnitude mapping mode.
Definition: FieldToColors.h:93
vtkm::filter::field_transform::FieldToColors::SetMappingMode
void SetMappingMode(InputMode mode)
Specify the mapping mode.
Definition: FieldToColors.h:71
vtkm::filter::field_transform::FieldToColors::GetMappingComponent
vtkm::IdComponent GetMappingComponent() const
Specifies the component of the vector to use in the mapping.
Definition: FieldToColors.h:103
vtkm::filter::field_transform::FieldToColors::GetMappingMode
InputMode GetMappingMode() const
Specify the mapping mode.
Definition: FieldToColors.h:89
vtkm::cont::ColorTableSamplesRGBA
Color Sample Table used with vtkm::cont::ColorTable for fast coloring.
Definition: ColorTableSamples.h:32
vtkm::filter::field_transform::FieldToColors::OutputMode
OutputMode
Identifiers used to specify what output FieldToColors will generate.
Definition: FieldToColors.h:53
vtkm::filter::field_transform::FieldToColors::GetOutputMode
OutputMode GetOutputMode() const
Specify the output mode.
Definition: FieldToColors.h:118
vtkm::filter::Filter
Base class for all filters.
Definition: Filter.h:163
vtkm::filter::field_transform::FieldToColors::SetMappingToScalar
void SetMappingToScalar()
Treat the field as a scalar field.
Definition: FieldToColors.h:76
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::field_transform::FieldToColors::IsOutputRGB
bool IsOutputRGB() const
Returns true if this filter is in RGB output mode.
Definition: FieldToColors.h:120
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::ColorSpace::RGB
@ RGB
vtkm::filter::field_transform::FieldToColors::SetMappingToMagnitude
void SetMappingToMagnitude()
Map the magnitude of the field.
Definition: FieldToColors.h:81
vtkm::filter::field_transform::FieldToColors::SetMappingComponent
void SetMappingComponent(vtkm::IdComponent comp)
Specifies the component of the vector to use in the mapping.
Definition: FieldToColors.h:101
vtkm::Magnitude
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
vtkm::cont::ColorTableSamplesRGB
Color Sample Table used with vtkm::cont::ColorTable for fast coloring.
Definition: ColorTableSamples.h:51
vtkm::filter::field_transform::FieldToColors::SetOutputToRGB
void SetOutputToRGB()
Write out RGB fixed precision color values.
Definition: FieldToColors.h:111
vtkm::filter::field_transform::FieldToColors::IsMappingComponent
bool IsMappingComponent() const
Returns true if this filter is vector component mapping mode.
Definition: FieldToColors.h:95
vtkm::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
vtkm::filter::field_transform::FieldToColors::InputMode
InputMode
Identifiers used to specify how FieldToColors should treat its input scalars.
Definition: FieldToColors.h:42
vtkm::filter::field_transform::FieldToColors::SetOutputMode
void SetOutputMode(OutputMode mode)
Specify the output mode.
Definition: FieldToColors.h:106
VTKM_FILTER_FIELD_TRANSFORM_EXPORT
#define VTKM_FILTER_FIELD_TRANSFORM_EXPORT
Definition: vtkm_filter_field_transform_export.h:44
vtkm::filter::field_transform::FieldToColors::GetColorTable
const vtkm::cont::ColorTable & GetColorTable() const
Specifies the vtkm::cont::ColorTable object to use to map field values to colors.
Definition: FieldToColors.h:68
Filter.h
vtkm::filter::field_transform::FieldToColors::IsOutputRGBA
bool IsOutputRGBA() const
Returns true if this filter is in RGBA output mode.
Definition: FieldToColors.h:122