AGX Dynamics  2.37.3.2
GranularFieldPostProcessor.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 # pragma once
18 
19 #include <agxModel/export.h>
20 
21 #include <agx/Frame.h>
24 
25 #include <agx/ref_ptr.h>
26 
27 namespace agxModel
28 {
30 
31  typedef std::pair<agx::Physics::GranularBodyPtr, agx::Real> ParticleWeightPair;
33 
35 
43  {
44  public:
45 
52  GranularFieldPostProcessor(agx::Physics::GranularBodySystem* gbs, const agx::Vec3u& voxelCount, const agx::Vec3& halfExtents);
53 
58  bool calculateFields();
59 
64  bool addField(agxModel::GranularField* gf);
65 
70  bool removeField(const agx::String& name);
71 
75  agx::Real getVoxelVolume();
76 
80  agx::Vec3u getVoxelCount();
81 
85  agx::Vec3 getHalfExtents();
86 
90  agx::Vec3 getVoxelSize();
91 
95  agx::Frame* getFrame();
96 
102  agxModel::GranularField* getField(const agx::String& name);
103 
107  const agxModel::GranularFieldRefVector& getFields();
108 
112  agx::Physics::GranularBodySystem* getGranularBodySystem();
113 
118  void setPosition(const agx::Vec3& pos);
119 
124  void setRotation(const agx::Quat & quat);
125 
130  void createDebugVisualization(agxSDK::Simulation* simulation);
131 
132  protected:
133  virtual ~GranularFieldPostProcessor();
134 
135  private:
136  agx::Physics::GranularBodySystemRef m_granularBodySystem;
137  agx::FrameRef m_frame;
138  agx::Vec3u m_voxelCount; // x is width, y is depth, z is height
139  agx::Vec3 m_halfExtents;
140  agx::Vec3 m_voxelSize;
141 
143 
144  public:
148 
149  private:
150  /* Sorts the particles into voxels. The result is in the particleWeightPairVector. */
151  bool sortParticlesIntoVoxels();
152  agx::Vec3i getVoxelIndexFromPosition(const agx::Vec3& position) const;
153  agx::Vec3 getPositionRelativeFirstVoxel(const agx::Vec3& position) const;
154 
155  agx::UInt getFlatIndex(const agx::Vec3i& index) const;
156 
157  void addRequiredFields(const agx::Vector<agx::String>& fields);
158 
159  };
160 
161 }
std::pair< agx::Physics::GranularBodyPtr, agx::Real > ParticleWeightPair
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Base class providing referencing counted objects.
Definition: Referenced.h:119
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
uint32_t UInt
Definition: Integer.h:34
Class for calculating different granular fields.
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:45
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::Vector< ParticleWeightPair > ParticleWeightPairVector
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
Base class for a GranularField.