AGX Dynamics  2.35.0.1
TerrainDataAtlas.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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 <agxTerrain/export.h>
20 #include <agxTerrain/Grid.h>
21 #include <agx/StackArray.h>
22 
23 namespace agxTerrain
24 {
26 
28 
29  /*
30  Atlas for holding information about terrain mass in the grid system.
31  Is active in the same index space as the regular grid.
32  */
34  {
35  static constexpr float MAX_MASS = 1.0;
36 
37  public:
38  enum MassType
39  {
42  FLUID
43  };
44  struct MassTypeHash
45  {
47  {
48  return agx::hash((agx::UInt32)key);
49  }
50  };
51 
52  public:
59  TerrainDataAtlas(agx::Real voxelSize, size_t resolutionX, size_t resolutionY, agx::Int depth);
60 
67  float getMass(const Grid::GridCoord& coord, MassType massType) const;
68 
76  void setMass(const Grid::GridCoord& coord, MassType massType, float value);
77 
86  float addMass(const Grid::GridCoord& coord, MassType massType, float value);
87 
94  void setCompaction(const Grid::GridCoord& coord, float value);
95 
101  float getCompaction(const Grid::GridCoord& coord) const;
102 
110  float getCompactedSolidMass(const Grid::GridCoord& coord) const;
111 
118 
124  bool isActiveVoxel(const Grid::GridCoord& coord, MassType massType) const;
125 
132 
133  float getTotalMassInVoxel(const Grid::GridCoord& coord) const;
134 
135  void setVelocity(const Grid::GridCoord& coord, const agx::Vec3f& value);
138 
140 
143 
144  size_t getTotalGridMemoryUsage() const;
145 
146  size_t getTotalActiveVoxels() const;
147 
148  void clearMassGrid(MassType massType);
149 
151 
153 
154  public:
158 
159  protected:
163  virtual ~TerrainDataAtlas();
164 
165  void fillGridVector();
166 
167  protected:
168  BasicGridRef m_solidMassGrid;
169  BasicGridRef m_fluidMassGrid;
170  BasicGridRef m_particleMassGrid;
171  BasicGridRef m_compactionGrid;
172 
173  VoxelToVelocityTable m_voxelToVelocityTable;
174 
175  agx::StackArray<BasicGrid*, 3> m_gridVector;
176 
177  Grid* m_rawSolidMassGrid; // alias for m_solidMassGrid
178  };
179 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXTERRAIN_STORE_RESTORE_INTERFACE
#define AGXTERRAIN_EXPORT
Pure virtual interface class for the data storage grid classes we have.
Definition: Grid.h:71
Extended pure virtual interface for Grid storage classes.
Definition: Grid.h:172
TerrainDataAtlas(agx::Real voxelSize, size_t resolutionX, size_t resolutionY, agx::Int depth)
Basic Constructor.
void setVelocity(const Grid::GridCoord &coord, const agx::Vec3f &value)
BasicGrid * getCompactionGridData() const
bool isActiveVoxel(const Grid::GridCoord &coord, MassType massType) const
Checks if a voxel is active in data grid of a specific mass type.
VoxelToVelocityTable & getVelocityTable()
float addMass(const Grid::GridCoord &coord, MassType massType, float value)
Adds occupancy mass of specific mass type in a voxel with specified 3D-coordinate in voxel index spac...
float getCompaction(const Grid::GridCoord &coord) const
Gets the compression data from a voxel in the grid.
size_t getTotalActiveVoxels() const
Grid * getSolidGridMassData() const
void setMass(const Grid::GridCoord &coord, MassType massType, float value)
Sets the occupancy mass of specific mass type in a voxel with specified 3D-coordinate in voxel index ...
agx::Vec3f getVelocity(const Grid::GridCoord &coord) const
float getCompactedSolidMass(const Grid::GridCoord &coord) const
Get the occupancy mass in a voxel modified by the compaction grid with specified 3D-coordinate in vox...
size_t getTotalGridMemoryUsage() const
float getTotalMassInVoxel(const Grid::GridCoord &coord) const
void setCompaction(const Grid::GridCoord &coord, float value)
Sets compression data in a voxel in the grid.
float getMass(const Grid::GridCoord &coord, MassType massType) const
Get the occupancy mass of specific mass type in a voxel with specified 3D-coordinate in voxel index s...
agx::Vec3iVector getIndicesWithMass(MassType massType) const
Returns the active indices in voxel index space which contains occupancy mass of a specific mass type...
float getMaximumAllowedSolidMassInVoxel(const Grid::GridCoord &coord) const
Returns the maximum allowed solid mass in the voxel.
agx::Real getMassInTerrain(MassType massType) const
BasicGrid * getGridMassData(MassType massType) const
void clearMassGrid(MassType massType)
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
agx::HashTable< agx::Vec3i, agx::Vec3f > VoxelToVelocityTable
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
int32_t Int
Definition: Integer.h:35
AGXCORE_EXPORT UInt32 hash(const T &key)
Definition: HashFunction.h:65
double Real
Definition: Real.h:42
agx::UInt32 operator()(TerrainDataAtlas::MassType key) const