VTK-m  2.0
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>
16 #include <vtkm/filter/field_transform/vtkm_filter_field_transform_export.h>
17 
18 namespace vtkm
19 {
20 namespace filter
21 {
22 namespace field_transform
23 {
26 class VTKM_FILTER_FIELD_TRANSFORM_EXPORT FieldToColors : public vtkm::filter::FilterField
27 {
28 public:
29  VTKM_CONT
31 
32  enum struct InputMode
33  {
34  Scalar,
35  Magnitude,
36  Component,
37  };
38 
39  enum struct OutputMode
40  {
41  RGB,
42  RGBA
43  };
44 
46  {
47  this->Table = table;
48  this->ModifiedCount = -1;
49  }
50  const vtkm::cont::ColorTable& GetColorTable() const { return this->Table; }
51 
52  void SetMappingMode(InputMode mode) { this->InputModeType = mode; }
53  void SetMappingToScalar() { this->InputModeType = InputMode::Scalar; }
54  void SetMappingToMagnitude() { this->InputModeType = InputMode::Magnitude; }
55  void SetMappingToComponent() { this->InputModeType = InputMode::Component; }
56  InputMode GetMappingMode() const { return this->InputModeType; }
57  bool IsMappingScalar() const { return this->InputModeType == InputMode::Scalar; }
58  bool IsMappingMagnitude() const { return this->InputModeType == InputMode::Magnitude; }
59  bool IsMappingComponent() const { return this->InputModeType == InputMode::Component; }
60 
61  void SetMappingComponent(vtkm::IdComponent comp) { this->Component = comp; }
62  vtkm::IdComponent GetMappingComponent() const { return this->Component; }
63 
64  void SetOutputMode(OutputMode mode) { this->OutputModeType = mode; }
65  void SetOutputToRGB() { this->OutputModeType = OutputMode::RGB; }
66  void SetOutputToRGBA() { this->OutputModeType = OutputMode::RGBA; }
67  OutputMode GetOutputMode() const { return this->OutputModeType; }
68  bool IsOutputRGB() const { return this->OutputModeType == OutputMode::RGB; }
69  bool IsOutputRGBA() const { return this->OutputModeType == OutputMode::RGBA; }
70 
71 
72  void SetNumberOfSamplingPoints(vtkm::Int32 count);
73  vtkm::Int32 GetNumberOfSamplingPoints() const { return this->SampleCount; }
74 
75 private:
76  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
77 
79  InputMode InputModeType = InputMode::Scalar;
80  OutputMode OutputModeType = OutputMode::RGBA;
83  vtkm::IdComponent Component = 0;
84  vtkm::Int32 SampleCount = 256;
85  vtkm::Id ModifiedCount = -1;
86 };
87 } // namespace field_transform
88 } // namespace filter
89 } // namespace vtkm
90 
91 #endif // vtk_m_filter_field_transform_FieldToColors_h
vtkm::filter::field_transform::FieldToColors::SetOutputToRGBA
void SetOutputToRGBA()
Definition: FieldToColors.h:66
vtkm::filter::field_transform::FieldToColors::SamplesRGBA
vtkm::cont::ColorTableSamplesRGBA SamplesRGBA
Definition: FieldToColors.h:82
vtkm::filter::field_transform::FieldToColors::SetColorTable
void SetColorTable(const vtkm::cont::ColorTable &table)
Definition: FieldToColors.h:45
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:81
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::Magnitude
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
vtkm::filter::field_transform::FieldToColors::GetNumberOfSamplingPoints
vtkm::Int32 GetNumberOfSamplingPoints() const
Definition: FieldToColors.h:73
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::filter::field_transform::FieldToColors::SetMappingToComponent
void SetMappingToComponent()
Definition: FieldToColors.h:55
ColorTable.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::filter::field_transform::FieldToColors::IsMappingScalar
bool IsMappingScalar() const
Definition: FieldToColors.h:57
vtkm::filter::field_transform::FieldToColors
Convert an arbitrary field to an RGB or RGBA field.
Definition: FieldToColors.h:26
vtkm::filter::field_transform::FieldToColors::Table
vtkm::cont::ColorTable Table
Definition: FieldToColors.h:78
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
vtkm::filter::field_transform::FieldToColors::IsMappingMagnitude
bool IsMappingMagnitude() const
Definition: FieldToColors.h:58
vtkm::filter::field_transform::FieldToColors::SetMappingMode
void SetMappingMode(InputMode mode)
Definition: FieldToColors.h:52
vtkm::filter::field_transform::FieldToColors::GetMappingComponent
vtkm::IdComponent GetMappingComponent() const
Definition: FieldToColors.h:62
vtkm::filter::field_transform::FieldToColors::GetMappingMode
InputMode GetMappingMode() const
Definition: FieldToColors.h:56
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
Definition: FieldToColors.h:39
vtkm::filter::field_transform::FieldToColors::GetOutputMode
OutputMode GetOutputMode() const
Definition: FieldToColors.h:67
vtkm::filter::field_transform::FieldToColors::SetMappingToScalar
void SetMappingToScalar()
Definition: FieldToColors.h:53
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::field_transform::FieldToColors::IsOutputRGB
bool IsOutputRGB() const
Definition: FieldToColors.h:68
vtkm::ColorSpace::RGB
@ RGB
vtkm::filter::field_transform::FieldToColors::SetMappingToMagnitude
void SetMappingToMagnitude()
Definition: FieldToColors.h:54
vtkm::filter::field_transform::FieldToColors::SetMappingComponent
void SetMappingComponent(vtkm::IdComponent comp)
Definition: FieldToColors.h:61
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()
Definition: FieldToColors.h:65
vtkm::filter::field_transform::FieldToColors::IsMappingComponent
bool IsMappingComponent() const
Definition: FieldToColors.h:59
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::filter::field_transform::FieldToColors::InputMode
InputMode
Definition: FieldToColors.h:32
vtkm::filter::field_transform::FieldToColors::SetOutputMode
void SetOutputMode(OutputMode mode)
Definition: FieldToColors.h:64
vtkm::filter::field_transform::FieldToColors::GetColorTable
const vtkm::cont::ColorTable & GetColorTable() const
Definition: FieldToColors.h:50
vtkm::filter::field_transform::FieldToColors::IsOutputRGBA
bool IsOutputRGBA() const
Definition: FieldToColors.h:69