AGX Dynamics  2.35.0.1
CompactionController.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 <agx/config/AGX_USE_AGXTERRAIN.h>
20 #include <agxTerrain/export.h>
21 #include <agx/Referenced.h>
23 #include <agx/Vec3.h>
24 
25 namespace agxCollide
26 {
27  class Geometry;
28 }
29 
30 namespace agxTerrain
31 {
32  class Terrain;
33  class TerrainDataAtlas;
34  class TerrainMassController;
35 
38 
41 
49  {
50  public:
52  {
54  UNIFORM_DISK
55  };
56 
58  {
60  VOID_RATIO_LN
61  };
62 
63  public:
68 
75 
79  void onPost();
80 
86 
91 
95  void setCompactionMethod(CompactionMethod compactionMethod);
96 
101 
109  bool applyCompactionFromSurfaceForce(const agx::Vec2i& voxelXY, agx::Real surfaceForce, agx::Real contactTime);
110 
116  agx::Real getStressInVoxel(const agx::Vec3i& voxelIndex) const;
117 
122 
123  public:
127 
128  protected:
130 
134  void updateCompactionFromTerrainContacts(const TerrainContactRefVector& contacts);
135 
136  // Compact the terrain using the uniform disk method
137  void handleCompactionFromTerrainContactsUniformDisk(const TerrainContactRefVector& contacts);
138 
139  // Compact the terrain using the uniform disk method
140  agx::Bool compactColumnWithPointForcesUniformDiskLoad(
141  const agx::Vec2i& voxelXY, agx::Real surfaceStress, agx::Real loadRadius, agx::Real currentContactTime);
142 
143  // Compact the terrain using the BOUSSINESQ method
144  void handleCompactionFromTerrainContactsBoussinesq(const TerrainContactRefVector& contacts);
145 
146  // Compact the terrain using the BOUSSINESQ method
147  agx::Bool compactColumnWithPointForces(const agx::Vec2i& voxelXY,
148  const TerrainContact::SurfaceForceVector& pointForces,
149  agx::Real surfaceStress,
150  bool voxelSurfacecIsInContactArea,
151  agx::Real minDepth,
152  agx::Real maxDepth,
153  agx::Real currentContactTime);
154 
155  // Calculate compaction in voxel given a compaction stress and time factor
156  bool doCompactionInVoxel(const agx::Vec3i& voxelIndex, agx::Real compactionStress, agx::Real timeFactor);
157 
158  // Calculate subsoil stress in the BOUSSINESQ method
159  agx::Real calculateTotalSubSoilStress(const agx::Vec3& voxelPoint,
160  bool voxelSurfacecIsInContactArea,
161  const TerrainContact::SurfaceForceVector& pointForces) const;
162 
163  void debugRenderStressInNode(const agx::Vec3& position, agx::Real stress) const;
164 
165  TerrainMassController* getMassController() const;
166 
167  friend class Terrain;
168 
169  private:
170  Terrain* m_terrain;
171  VoxelStressTable m_voxelIndexToStress;
172  agx::HashSet<agx::Vec2i> m_compressedTerrainIndices;
173  StressCalculationMethod m_stressMethod;
174  CompactionMethod m_compactionMethod;
175  };
176 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Controller that handles compaction in the terrain from generated terrain contacts in TerrainContactGe...
bool applyCompactionFromSurfaceForce(const agx::Vec2i &voxelXY, agx::Real surfaceForce, agx::Real contactTime)
Create compaction from an artificially applied surface force.
const agx::HashSet< agx::Vec2i > & getCompressedTerrainIndices() const
Get the indices that has been compressed this time step after the post step of the compactionControll...
void setStressMethod(StressCalculationMethod stressMethod)
Set the stress method used when calculating compaction.
void onPost()
The onPost function updates compaction from terrain contacts.
agx::Real getStressInVoxel(const agx::Vec3i &voxelIndex) const
Get the current active stress in the specified voxelIndex.
CompactionMethod getCompactionMethod() const
Get the compaction method used when calculating compaction.
CompactionController(Terrain *terrain)
Construct given terrain instance.
StressCalculationMethod getStressMethod() const
Get the stress method used when calculating compaction.
void setCompactionMethod(CompactionMethod compactionMethod)
Set the compaction method used when calculating compaction.
Class that contains information about a terrain contact between an external object and the terrain ge...
Class that handles and sanity checks the mass logic in the terrain.
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition: Referenced.h:114
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
agx::HashTable< agxCollide::Geometry *, agx::Real > GeometryContactTimeTable
agx::HashTable< agx::Vec3i, agx::Real > VoxelStressTable
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
bool Bool
Definition: Integer.h:48
Vec2T< Int > Vec2i
Definition: Vec2.h:40
Vec3T< Int > Vec3i
Definition: agx/Vec3.h:43
double Real
Definition: Real.h:42