Viskores  1.0
FieldToColors.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 
19 #ifndef viskores_filter_field_transform_FieldToColors_h
20 #define viskores_filter_field_transform_FieldToColors_h
21 
23 #include <viskores/filter/Filter.h>
25 
26 namespace viskores
27 {
28 namespace filter
29 {
30 namespace field_transform
31 {
37 class VISKORES_FILTER_FIELD_TRANSFORM_EXPORT FieldToColors : public viskores::filter::Filter
38 {
39 public:
42 
43  // Documentation of enumerations is behaving a little weird in Doxygen (version 1.9.7).
44  // You cannot have a blank line in the documentation. Everything below it will be treated
45  // as preformatted text. Also, the first line always seem to behave like `@brief` is used
46  // even when it is not. It's easier to just document an associated method and copy the
47  // documentation
48 
50  enum struct InputMode
51  {
53  Scalar,
55  Magnitude,
57  Component,
58  };
59 
61  enum struct OutputMode
62  {
64  RGB,
66  RGBA,
67  };
68 
71  {
72  this->Table = table;
73  this->ModifiedCount = -1;
74  }
76  const viskores::cont::ColorTable& GetColorTable() const { return this->Table; }
77 
79  void SetMappingMode(InputMode mode) { this->InputModeType = mode; }
84  void SetMappingToScalar() { this->InputModeType = InputMode::Scalar; }
89  void SetMappingToMagnitude() { this->InputModeType = InputMode::Magnitude; }
95  void SetMappingToComponent() { this->InputModeType = InputMode::Component; }
97  InputMode GetMappingMode() const { return this->InputModeType; }
99  bool IsMappingScalar() const { return this->InputModeType == InputMode::Scalar; }
101  bool IsMappingMagnitude() const { return this->InputModeType == InputMode::Magnitude; }
103  bool IsMappingComponent() const { return this->InputModeType == InputMode::Component; }
104 
109  void SetMappingComponent(viskores::IdComponent comp) { this->Component = comp; }
111  viskores::IdComponent GetMappingComponent() const { return this->Component; }
112 
114  void SetOutputMode(OutputMode mode) { this->OutputModeType = mode; }
119  void SetOutputToRGB() { this->OutputModeType = OutputMode::RGB; }
124  void SetOutputToRGBA() { this->OutputModeType = OutputMode::RGBA; }
126  OutputMode GetOutputMode() const { return this->OutputModeType; }
128  bool IsOutputRGB() const { return this->OutputModeType == OutputMode::RGB; }
130  bool IsOutputRGBA() const { return this->OutputModeType == OutputMode::RGBA; }
131 
137  void SetNumberOfSamplingPoints(viskores::Int32 count);
139  viskores::Int32 GetNumberOfSamplingPoints() const { return this->SampleCount; }
140 
141 private:
142  VISKORES_CONT viskores::cont::DataSet DoExecute(const viskores::cont::DataSet& input) override;
143 
145  InputMode InputModeType = InputMode::Scalar;
146  OutputMode OutputModeType = OutputMode::RGBA;
149  viskores::IdComponent Component = 0;
150  viskores::Int32 SampleCount = 256;
151  viskores::Id ModifiedCount = -1;
152 };
153 
154 } // namespace field_transform
155 } // namespace filter
156 } // namespace viskores
157 
158 #endif // viskores_filter_field_transform_FieldToColors_h
viskores::filter::field_transform::FieldToColors::SetOutputMode
void SetOutputMode(OutputMode mode)
Specify the output mode.
Definition: FieldToColors.h:114
viskores::filter::field_transform::FieldToColors::SetMappingMode
void SetMappingMode(InputMode mode)
Specify the mapping mode.
Definition: FieldToColors.h:79
viskores::filter::field_transform::FieldToColors::SamplesRGBA
viskores::cont::ColorTableSamplesRGBA SamplesRGBA
Definition: FieldToColors.h:148
viskores::ColorSpace::RGB
@ RGB
viskores::filter::field_transform::FieldToColors::SetMappingToScalar
void SetMappingToScalar()
Treat the field as a scalar field.
Definition: FieldToColors.h:84
viskores::cont::DataSet
Contains and manages the geometric data structures that Viskores operates on.
Definition: DataSet.h:66
viskores::filter::field_transform::FieldToColors::IsOutputRGB
bool IsOutputRGB() const
Returns true if this filter is in RGB output mode.
Definition: FieldToColors.h:128
viskores::filter::field_transform::FieldToColors::GetOutputMode
OutputMode GetOutputMode() const
Specify the output mode.
Definition: FieldToColors.h:126
viskores::filter::Filter
Base class for all filters.
Definition: Filter.h:171
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
ColorTable.h
viskores::filter::field_transform::FieldToColors::SetMappingToComponent
void SetMappingToComponent()
Map a component of a vector field as if it were a scalar.
Definition: FieldToColors.h:95
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::filter::field_transform::FieldToColors::SetOutputToRGBA
void SetOutputToRGBA()
Write out RGBA fixed precision color values.
Definition: FieldToColors.h:124
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::filter::field_transform::FieldToColors::GetMappingMode
InputMode GetMappingMode() const
Specify the mapping mode.
Definition: FieldToColors.h:97
viskores::filter::field_transform::FieldToColors::IsOutputRGBA
bool IsOutputRGBA() const
Returns true if this filter is in RGBA output mode.
Definition: FieldToColors.h:130
viskores::cont::ColorTable
Color Table for coloring arbitrary fields.
Definition: cont/ColorTable.h:97
viskores::filter::field_transform::FieldToColors
Convert an arbitrary field to an RGB or RGBA field.
Definition: FieldToColors.h:37
viskores::filter::field_transform::FieldToColors::SetMappingComponent
void SetMappingComponent(viskores::IdComponent comp)
Specifies the component of the vector to use in the mapping.
Definition: FieldToColors.h:109
viskores::filter::field_transform::FieldToColors::IsMappingScalar
bool IsMappingScalar() const
Returns true if this filter is in scalar mapping mode.
Definition: FieldToColors.h:99
viskores::filter::field_transform::FieldToColors::IsMappingMagnitude
bool IsMappingMagnitude() const
Returns true if this filter is in magnitude mapping mode.
Definition: FieldToColors.h:101
viskores::filter::field_transform::FieldToColors::GetMappingComponent
viskores::IdComponent GetMappingComponent() const
Specifies the component of the vector to use in the mapping.
Definition: FieldToColors.h:111
viskores::filter::field_transform::FieldToColors::SetColorTable
void SetColorTable(const viskores::cont::ColorTable &table)
Specifies the viskores::cont::ColorTable object to use to map field values to colors.
Definition: FieldToColors.h:70
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::filter::field_transform::FieldToColors::SetMappingToMagnitude
void SetMappingToMagnitude()
Map the magnitude of the field.
Definition: FieldToColors.h:89
viskores::filter::field_transform::FieldToColors::IsMappingComponent
bool IsMappingComponent() const
Returns true if this filter is vector component mapping mode.
Definition: FieldToColors.h:103
viskores::filter::field_transform::FieldToColors::Table
viskores::cont::ColorTable Table
Definition: FieldToColors.h:144
viskores::Magnitude
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:108
viskores::cont::ColorTableSamplesRGBA
Color Sample Table used with viskores::cont::ColorTable for fast coloring.
Definition: ColorTableSamples.h:40
viskores::filter::field_transform::FieldToColors::InputMode
InputMode
Identifiers used to specify how FieldToColors should treat its input scalars.
Definition: FieldToColors.h:50
viskores::filter::field_transform::FieldToColors::OutputMode
OutputMode
Identifiers used to specify what output FieldToColors will generate.
Definition: FieldToColors.h:61
viskores::filter::field_transform::FieldToColors::SetOutputToRGB
void SetOutputToRGB()
Write out RGB fixed precision color values.
Definition: FieldToColors.h:119
viskores_filter_field_transform_export.h
viskores::filter::field_transform::FieldToColors::SamplesRGB
viskores::cont::ColorTableSamplesRGB SamplesRGB
Definition: FieldToColors.h:147
viskores::filter::field_transform::FieldToColors::GetColorTable
const viskores::cont::ColorTable & GetColorTable() const
Specifies the viskores::cont::ColorTable object to use to map field values to colors.
Definition: FieldToColors.h:76
viskores::cont::ColorTableSamplesRGB
Color Sample Table used with viskores::cont::ColorTable for fast coloring.
Definition: ColorTableSamples.h:60
Filter.h
viskores::filter::field_transform::FieldToColors::GetNumberOfSamplingPoints
viskores::Int32 GetNumberOfSamplingPoints() const
Specifies how many samples to use when looking up color values.
Definition: FieldToColors.h:139