VTK-m  2.2
ParticleDensityBase.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_density_estimate_ParticleDensityBase_h
12 #define vtk_m_filter_density_estimate_ParticleDensityBase_h
13 
14 #include <vtkm/filter/Filter.h>
16 
17 namespace vtkm
18 {
19 namespace filter
20 {
21 namespace density_estimate
22 {
24 {
25 protected:
26  ParticleDensityBase() = default;
27 
28 public:
34  VTKM_CONT void SetComputeNumberDensity(bool flag) { this->ComputeNumberDensity = flag; }
36  VTKM_CONT bool GetComputeNumberDensity() const { return this->ComputeNumberDensity; }
37 
43  VTKM_CONT void SetDivideByVolume(bool flag) { this->DivideByVolume = flag; }
45  VTKM_CONT bool GetDivideByVolume() const { return this->DivideByVolume; }
46 
54  VTKM_CONT void SetDimension(const vtkm::Id3& dimension) { this->Dimension = dimension; }
56  VTKM_CONT vtkm::Id3 GetDimension() const { return this->Dimension; }
57 
60  VTKM_CONT void SetOrigin(const vtkm::Vec3f& origin) { this->Origin = origin; }
62  VTKM_CONT vtkm::Vec3f GetOrigin() const { return this->Origin; }
63 
66  VTKM_CONT void SetSpacing(const vtkm::Vec3f& spacing) { this->Spacing = spacing; }
68  VTKM_CONT vtkm::Vec3f GetSpacing() const { return this->Spacing; }
69 
79  VTKM_CONT void SetBounds(const vtkm::Bounds& bounds)
80  {
81  this->Origin = { static_cast<vtkm::FloatDefault>(bounds.X.Min),
82  static_cast<vtkm::FloatDefault>(bounds.Y.Min),
83  static_cast<vtkm::FloatDefault>(bounds.Z.Min) };
84  this->Spacing = (vtkm::Vec3f{ static_cast<vtkm::FloatDefault>(bounds.X.Length()),
85  static_cast<vtkm::FloatDefault>(bounds.Y.Length()),
86  static_cast<vtkm::FloatDefault>(bounds.Z.Length()) } /
87  Dimension);
88  }
90  {
91  return { { this->Origin[0], this->Origin[0] + (this->Spacing[0] * this->Dimension[0]) },
92  { this->Origin[1], this->Origin[1] + (this->Spacing[1] * this->Dimension[1]) },
93  { this->Origin[2], this->Origin[2] + (this->Spacing[2] * this->Dimension[2]) } };
94  }
95 
96 protected:
97  // Note: we are using the paradoxical "const ArrayHandle&" parameter whose content can actually
98  // be change by the function.
99  VTKM_CONT void DoDivideByVolume(const vtkm::cont::UnknownArrayHandle& array) const;
100 
101  vtkm::Id3 Dimension = { 100, 100, 100 }; // Cell dimension
102  vtkm::Vec3f Origin = { 0.0f, 0.0f, 0.0f };
103  vtkm::Vec3f Spacing = { 1.0f, 1.0f, 1.0f };
104  bool ComputeNumberDensity = false;
105  bool DivideByVolume = true;
106 };
107 } // namespace density_estimate
108 } // namespace filter
109 } // namespace vtkm
110 
111 #endif //vtk_m_filter_density_estimate_ParticleDensityBase_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::density_estimate::ParticleDensityBase::SetBounds
void SetBounds(const vtkm::Bounds &bounds)
The bounds of the region where density estimation occurs.
Definition: ParticleDensityBase.h:79
vtkm::filter::density_estimate::ParticleDensityBase::SetDivideByVolume
void SetDivideByVolume(bool flag)
Specifies whether the accumulated mass (or count) is divided by the volume of the cell.
Definition: ParticleDensityBase.h:43
vtkm::Range::Length
vtkm::Float64 Length() const
Returns the length of the range.
Definition: Range.h:91
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
vtkm::filter::density_estimate::ParticleDensityBase::GetOrigin
vtkm::Vec3f GetOrigin() const
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:62
vtkm::filter::density_estimate::ParticleDensityBase::SetSpacing
void SetSpacing(const vtkm::Vec3f &spacing)
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:66
vtkm::filter::density_estimate::ParticleDensityBase::GetComputeNumberDensity
bool GetComputeNumberDensity() const
Toggles between summing mass and computing instances.
Definition: ParticleDensityBase.h:36
vtkm::filter::density_estimate::ParticleDensityBase::SetDimension
void SetDimension(const vtkm::Id3 &dimension)
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:54
vtkm::filter::density_estimate::ParticleDensityBase::GetDivideByVolume
bool GetDivideByVolume() const
Specifies whether the accumulated mass (or count) is divided by the volume of the cell.
Definition: ParticleDensityBase.h:45
vtkm::filter::density_estimate::ParticleDensityBase::SetComputeNumberDensity
void SetComputeNumberDensity(bool flag)
Toggles between summing mass and computing instances.
Definition: ParticleDensityBase.h:34
vtkm::filter::Filter
Base class for all filters.
Definition: Filter.h:163
vtkm::Bounds::Z
vtkm::Range Z
The range of values in the Z direction.
Definition: Bounds.h:39
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
vtkm_filter_density_estimate_export.h
vtkm::Vec< vtkm::Id, 3 >
vtkm::filter::density_estimate::ParticleDensityBase::SetOrigin
void SetOrigin(const vtkm::Vec3f &origin)
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:60
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:236
vtkm::Range::Min
vtkm::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:34
vtkm::filter::density_estimate::ParticleDensityBase::GetBounds
vtkm::Bounds GetBounds() const
Definition: ParticleDensityBase.h:89
vtkm::Bounds::X
vtkm::Range X
The range of values in the X direction.
Definition: Bounds.h:33
vtkm::Bounds::Y
vtkm::Range Y
The range of values in the Y direction.
Definition: Bounds.h:36
vtkm::filter::density_estimate::ParticleDensityBase
Definition: ParticleDensityBase.h:23
vtkm::filter::density_estimate::ParticleDensityBase::GetDimension
vtkm::Id3 GetDimension() const
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:56
VTKM_FILTER_DENSITY_ESTIMATE_EXPORT
#define VTKM_FILTER_DENSITY_ESTIMATE_EXPORT
Definition: vtkm_filter_density_estimate_export.h:44
vtkm::filter::density_estimate::ParticleDensityBase::GetSpacing
vtkm::Vec3f GetSpacing() const
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:68
Filter.h