Viskores  1.0
ParticleDensityBase.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_density_estimate_ParticleDensityBase_h
20 #define viskores_filter_density_estimate_ParticleDensityBase_h
21 
22 #include <viskores/filter/Filter.h>
24 
25 namespace viskores
26 {
27 namespace filter
28 {
29 namespace density_estimate
30 {
31 class VISKORES_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityBase : public viskores::filter::Filter
32 {
33 protected:
34  ParticleDensityBase() = default;
35 
36 public:
42  VISKORES_CONT void SetComputeNumberDensity(bool flag) { this->ComputeNumberDensity = flag; }
44  VISKORES_CONT bool GetComputeNumberDensity() const { return this->ComputeNumberDensity; }
45 
51  VISKORES_CONT void SetDivideByVolume(bool flag) { this->DivideByVolume = flag; }
53  VISKORES_CONT bool GetDivideByVolume() const { return this->DivideByVolume; }
54 
62  VISKORES_CONT void SetDimension(const viskores::Id3& dimension) { this->Dimension = dimension; }
64  VISKORES_CONT viskores::Id3 GetDimension() const { return this->Dimension; }
65 
68  VISKORES_CONT void SetOrigin(const viskores::Vec3f& origin) { this->Origin = origin; }
70  VISKORES_CONT viskores::Vec3f GetOrigin() const { return this->Origin; }
71 
74  VISKORES_CONT void SetSpacing(const viskores::Vec3f& spacing) { this->Spacing = spacing; }
76  VISKORES_CONT viskores::Vec3f GetSpacing() const { return this->Spacing; }
77 
88  {
89  this->Origin = { static_cast<viskores::FloatDefault>(bounds.X.Min),
90  static_cast<viskores::FloatDefault>(bounds.Y.Min),
91  static_cast<viskores::FloatDefault>(bounds.Z.Min) };
92  this->Spacing = (viskores::Vec3f{ static_cast<viskores::FloatDefault>(bounds.X.Length()),
93  static_cast<viskores::FloatDefault>(bounds.Y.Length()),
94  static_cast<viskores::FloatDefault>(bounds.Z.Length()) } /
95  Dimension);
96  }
98  {
99  return { { this->Origin[0], this->Origin[0] + (this->Spacing[0] * this->Dimension[0]) },
100  { this->Origin[1], this->Origin[1] + (this->Spacing[1] * this->Dimension[1]) },
101  { this->Origin[2], this->Origin[2] + (this->Spacing[2] * this->Dimension[2]) } };
102  }
103 
104 protected:
105  // Note: we are using the paradoxical "const ArrayHandle&" parameter whose content can actually
106  // be change by the function.
107  VISKORES_CONT void DoDivideByVolume(const viskores::cont::UnknownArrayHandle& array) const;
108 
109  viskores::Id3 Dimension = { 100, 100, 100 }; // Cell dimension
110  viskores::Vec3f Origin = { 0.0f, 0.0f, 0.0f };
111  viskores::Vec3f Spacing = { 1.0f, 1.0f, 1.0f };
112  bool ComputeNumberDensity = false;
113  bool DivideByVolume = true;
114 };
115 } // namespace density_estimate
116 } // namespace filter
117 } // namespace viskores
118 
119 #endif //viskores_filter_density_estimate_ParticleDensityBase_h
viskores::filter::density_estimate::ParticleDensityBase
Definition: ParticleDensityBase.h:31
viskores::filter::density_estimate::ParticleDensityBase::GetDimension
viskores::Id3 GetDimension() const
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:64
viskores::Range::Length
viskores::Float64 Length() const
Returns the length of the range.
Definition: Range.h:99
viskores::Bounds
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:37
viskores::filter::density_estimate::ParticleDensityBase::GetSpacing
viskores::Vec3f GetSpacing() const
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:76
viskores::Range::Min
viskores::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:42
viskores::filter::Filter
Base class for all filters.
Definition: Filter.h:171
viskores::filter::density_estimate::ParticleDensityBase::SetDimension
void SetDimension(const viskores::Id3 &dimension)
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:62
viskores::filter::density_estimate::ParticleDensityBase::SetSpacing
void SetSpacing(const viskores::Vec3f &spacing)
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:74
viskores_filter_density_estimate_export.h
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::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:51
viskores::filter::density_estimate::ParticleDensityBase::GetComputeNumberDensity
bool GetComputeNumberDensity() const
Toggles between summing mass and computing instances.
Definition: ParticleDensityBase.h:44
viskores::filter::density_estimate::ParticleDensityBase::SetOrigin
void SetOrigin(const viskores::Vec3f &origin)
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:68
viskores::Bounds::Z
viskores::Range Z
The range of values in the Z direction.
Definition: Bounds.h:47
viskores::FloatDefault
viskores::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:244
viskores::Bounds::Y
viskores::Range Y
The range of values in the Y direction.
Definition: Bounds.h:44
viskores::filter::density_estimate::ParticleDensityBase::GetOrigin
viskores::Vec3f GetOrigin() const
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:70
viskores::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:53
viskores::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::filter::density_estimate::ParticleDensityBase::SetComputeNumberDensity
void SetComputeNumberDensity(bool flag)
Toggles between summing mass and computing instances.
Definition: ParticleDensityBase.h:42
viskores::filter::density_estimate::ParticleDensityBase::SetBounds
void SetBounds(const viskores::Bounds &bounds)
The bounds of the region where density estimation occurs.
Definition: ParticleDensityBase.h:87
viskores::Vec< viskores::Id, 3 >
viskores::Bounds::X
viskores::Range X
The range of values in the X direction.
Definition: Bounds.h:41
viskores::filter::density_estimate::ParticleDensityBase::GetBounds
viskores::Bounds GetBounds() const
Definition: ParticleDensityBase.h:97
Filter.h