VTK-m  2.0
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 
15 #include <vtkm/filter/density_estimate/vtkm_filter_density_estimate_export.h>
16 
17 namespace vtkm
18 {
19 namespace filter
20 {
21 namespace density_estimate
22 {
23 class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityBase : public vtkm::filter::FilterField
24 {
25 protected:
26  ParticleDensityBase() = default;
27 
28 public:
29  VTKM_CONT void SetComputeNumberDensity(bool yes) { this->ComputeNumberDensity = yes; }
30 
31  VTKM_CONT bool GetComputeNumberDensity() const { return this->ComputeNumberDensity; }
32 
33  VTKM_CONT void SetDivideByVolume(bool yes) { this->DivideByVolume = yes; }
34 
35  VTKM_CONT bool GetDivideByVolume() const { return this->DivideByVolume; }
36 
43  VTKM_CONT void SetDimension(const vtkm::Id3& dimension) { this->Dimension = dimension; }
44  VTKM_CONT vtkm::Id3 GetDimension() const { return this->Dimension; }
46 
50  VTKM_CONT void SetOrigin(const vtkm::Vec3f& origin) { this->Origin = origin; }
51  VTKM_CONT vtkm::Vec3f GetOrigin() const { return this->Origin; }
53 
57  VTKM_CONT void SetSpacing(const vtkm::Vec3f& spacing) { this->Spacing = spacing; }
58  VTKM_CONT vtkm::Vec3f GetSpacing() const { return this->Spacing; }
60 
67  VTKM_CONT void SetBounds(const vtkm::Bounds& bounds)
68  {
69  this->Origin = { static_cast<vtkm::FloatDefault>(bounds.X.Min),
70  static_cast<vtkm::FloatDefault>(bounds.Y.Min),
71  static_cast<vtkm::FloatDefault>(bounds.Z.Min) };
72  this->Spacing = (vtkm::Vec3f{ static_cast<vtkm::FloatDefault>(bounds.X.Length()),
73  static_cast<vtkm::FloatDefault>(bounds.Y.Length()),
74  static_cast<vtkm::FloatDefault>(bounds.Z.Length()) } /
75  Dimension);
76  }
78  {
79  return { { this->Origin[0], this->Origin[0] + (this->Spacing[0] * this->Dimension[0]) },
80  { this->Origin[1], this->Origin[1] + (this->Spacing[1] * this->Dimension[1]) },
81  { this->Origin[2], this->Origin[2] + (this->Spacing[2] * this->Dimension[2]) } };
82  }
84 
85 protected:
86  // Note: we are using the paradoxical "const ArrayHandle&" parameter whose content can actually
87  // be change by the function.
88  VTKM_CONT void DoDivideByVolume(const vtkm::cont::UnknownArrayHandle& array) const;
89 
90  vtkm::Id3 Dimension = { 100, 100, 100 }; // Cell dimension
91  vtkm::Vec3f Origin = { 0.0f, 0.0f, 0.0f };
92  vtkm::Vec3f Spacing = { 1.0f, 1.0f, 1.0f };
93  bool ComputeNumberDensity = false;
94  bool DivideByVolume = true;
95 };
96 } // namespace density_estimate
97 } // namespace filter
98 } // namespace vtkm
99 
100 #endif //vtk_m_filter_density_estimate_ParticleDensityBase_h
vtkm::filter::density_estimate::ParticleDensityBase::SetOrigin
VTKM_CONT void SetOrigin(const vtkm::Vec3f &origin)
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:50
vtkm::filter::density_estimate::ParticleDensityBase::GetBounds
VTKM_CONT vtkm::Bounds GetBounds() const
The bounds of the region where density estimation occurs.
Definition: ParticleDensityBase.h:77
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::density_estimate::ParticleDensityBase::GetDivideByVolume
VTKM_CONT bool GetDivideByVolume() const
Definition: ParticleDensityBase.h:35
vtkm::filter::density_estimate::ParticleDensityBase::SetComputeNumberDensity
VTKM_CONT void SetComputeNumberDensity(bool yes)
Definition: ParticleDensityBase.h:29
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
vtkm::filter::density_estimate::ParticleDensityBase::SetDivideByVolume
VTKM_CONT void SetDivideByVolume(bool yes)
Definition: ParticleDensityBase.h:33
vtkm::Range::Length
VTKM_EXEC_CONT vtkm::Float64 Length() const
Returns the length of the range.
Definition: Range.h:87
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
vtkm::filter::density_estimate::ParticleDensityBase::GetComputeNumberDensity
VTKM_CONT bool GetComputeNumberDensity() const
Definition: ParticleDensityBase.h:31
vtkm::filter::density_estimate::ParticleDensityBase::GetSpacing
VTKM_CONT vtkm::Vec3f GetSpacing() const
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:58
vtkm::filter::density_estimate::ParticleDensityBase::SetDimension
VTKM_CONT void SetDimension(const vtkm::Id3 &dimension)
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:43
vtkm::Bounds::Z
vtkm::Range Z
Definition: Bounds.h:33
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::ParticleDensityBase::GetOrigin
VTKM_CONT vtkm::Vec3f GetOrigin() const
The lower-left (minimum) corner of the domain of density estimation.
Definition: ParticleDensityBase.h:51
vtkm::Vec< vtkm::Id, 3 >
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::filter::density_estimate::ParticleDensityBase::GetDimension
VTKM_CONT vtkm::Id3 GetDimension() const
The number of bins in the grid used as regions to estimate density.
Definition: ParticleDensityBase.h:44
vtkm::Range::Min
vtkm::Float64 Min
Definition: Range.h:33
vtkm::Bounds::X
vtkm::Range X
Definition: Bounds.h:31
vtkm::Bounds::Y
vtkm::Range Y
Definition: Bounds.h:32
vtkm::filter::density_estimate::ParticleDensityBase
Definition: ParticleDensityBase.h:23
vtkm::filter::density_estimate::ParticleDensityBase::SetSpacing
VTKM_CONT void SetSpacing(const vtkm::Vec3f &spacing)
The spacing of the grid points used to form the grid for density estimation.
Definition: ParticleDensityBase.h:57
vtkm::filter::density_estimate::ParticleDensityBase::SetBounds
VTKM_CONT void SetBounds(const vtkm::Bounds &bounds)
The bounds of the region where density estimation occurs.
Definition: ParticleDensityBase.h:67