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_source_Wavelet_h 12 #define vtk_m_source_Wavelet_h 13 14 #include <vtkm/source/Source.h> 15 16 namespace vtkm 17 { 18 namespace source 19 { 20 /** 21 * @brief The Wavelet source creates a dataset similar to VTK's 22 * vtkRTAnalyticSource. 23 * 24 * This class generates a predictable structured dataset with a smooth yet 25 * interesting set of scalars, which is useful for testing and benchmarking. 26 * 27 * The Execute method creates a complete structured dataset that have a 28 * point field names 'scalars' 29 * 30 * The scalars are computed as: 31 * 32 * ``` 33 * MaxVal * Gauss + MagX * sin(FrqX*x) + MagY * sin(FrqY*y) + MagZ * cos(FrqZ*z) 34 * ``` 35 * 36 * The dataset properties are determined by: 37 * - `Minimum/MaximumExtent`: The logical point extents of the dataset. 38 * - `Spacing`: The distance between points of the dataset. 39 * - `Center`: The center of the dataset. 40 * 41 * The scalar functions is control via: 42 * - `Center`: The center of a Gaussian contribution to the scalars. 43 * - `StandardDeviation`: The unscaled width of a Gaussian contribution. 44 * - `MaximumValue`: Upper limit of the scalar range. 45 * - `Frequency`: The Frq[XYZ] parameters of the periodic contributions. 46 * - `Magnitude`: The Mag[XYZ] parameters of the periodic contributions. 47 * 48 * By default, the following parameters are used: 49 * - `Extents`: { -10, -10, -10 } `-->` { 10, 10, 10 } 50 * - `Spacing`: { 1, 1, 1 } 51 * - `Center`: { 0, 0, 0 } 52 * - `StandardDeviation`: 0.5 53 * - `MaximumValue`: 255 54 * - `Frequency`: { 60, 30, 40 } 55 * - `Magnitude`: { 10, 18, 5 } 56 */ 57 class VTKM_SOURCE_EXPORT Wavelet final : public vtkm::source::Source 58 { 59 public: 60 VTKM_CONT 61 Wavelet(vtkm::Id3 minExtent = { -10 }, vtkm::Id3 maxExtent = { 10 }); 62 SetCenter(const vtkm::Vec<FloatDefault,3> & center)63 VTKM_CONT void SetCenter(const vtkm::Vec<FloatDefault, 3>& center) { this->Center = center; } 64 SetSpacing(const vtkm::Vec<FloatDefault,3> & spacing)65 VTKM_CONT void SetSpacing(const vtkm::Vec<FloatDefault, 3>& spacing) { this->Spacing = spacing; } 66 SetFrequency(const vtkm::Vec<FloatDefault,3> & frequency)67 VTKM_CONT void SetFrequency(const vtkm::Vec<FloatDefault, 3>& frequency) 68 { 69 this->Frequency = frequency; 70 } 71 SetMagnitude(const vtkm::Vec<FloatDefault,3> & magnitude)72 VTKM_CONT void SetMagnitude(const vtkm::Vec<FloatDefault, 3>& magnitude) 73 { 74 this->Magnitude = magnitude; 75 } 76 SetMinimumExtent(const vtkm::Id3 & minExtent)77 VTKM_CONT void SetMinimumExtent(const vtkm::Id3& minExtent) { this->MinimumExtent = minExtent; } 78 SetMaximumExtent(const vtkm::Id3 & maxExtent)79 VTKM_CONT void SetMaximumExtent(const vtkm::Id3& maxExtent) { this->MaximumExtent = maxExtent; } 80 SetExtent(const vtkm::Id3 & minExtent,const vtkm::Id3 & maxExtent)81 VTKM_CONT void SetExtent(const vtkm::Id3& minExtent, const vtkm::Id3& maxExtent) 82 { 83 this->MinimumExtent = minExtent; 84 this->MaximumExtent = maxExtent; 85 } 86 SetMaximumValue(const vtkm::FloatDefault & maxVal)87 VTKM_CONT void SetMaximumValue(const vtkm::FloatDefault& maxVal) { this->MaximumValue = maxVal; } 88 SetStandardDeviation(const vtkm::FloatDefault & stdev)89 VTKM_CONT void SetStandardDeviation(const vtkm::FloatDefault& stdev) 90 { 91 this->StandardDeviation = stdev; 92 } 93 94 vtkm::cont::DataSet Execute() const; 95 96 private: 97 vtkm::cont::Field GeneratePointField(const vtkm::cont::CellSetStructured<3>& cellset, 98 const std::string& name) const; 99 100 vtkm::Vec3f Center; 101 vtkm::Vec3f Spacing; 102 vtkm::Vec3f Frequency; 103 vtkm::Vec3f Magnitude; 104 vtkm::Id3 MinimumExtent; 105 vtkm::Id3 MaximumExtent; 106 vtkm::FloatDefault MaximumValue; 107 vtkm::FloatDefault StandardDeviation; 108 }; 109 } //namespace source 110 } //namespace vtkm 111 112 #endif //vtk_m_source_Wavelet_h 113