AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Shovel.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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/BitState.h>
23 
24 #include <agxStream/Serializable.h>
25 
26 namespace agxCollide
27 {
28  class Geometry;
29  class Shape;
30 }
31 
32 namespace agxTerrain
33 {
34  class Terrain;
35  class TerrainMaterial;
36  class TerrainToolCollection;
37 
51  {
52  public:
53  class ExcavationSettings;
54 
55 
67  Shovel(agx::RigidBody* shovelBody,
68  const agx::Line& topEdge,
69  const agx::Line& cuttingEdge,
70  const agx::Vec3& cuttingDirection);
71 
87  {
88  PRIMARY = 0,
89  DEFORM_BACK = 1,
90  DEFORM_RIGHT = 2,
91  DEFORM_LEFT = 3
92  };
93 
97  agx::RigidBody* getRigidBody() const;
98 
102  ExcavationSettings& getExcavationSettings(ExcavationMode mode);
103 
107  agx::Line getTopEdge() const;
108 
112  agx::Line getTopEdgeWorld() const;
113 
117  agx::Line getCuttingEdge() const;
118 
122  agx::Line getCuttingEdgeWorld() const;
123 
127  agx::Vec3 getCuttingDirection() const;
128 
132  agx::Vec3 getCuttingDirectionWorld() const;
133 
137  agx::Real getToothLength() const;
138 
142  agx::Real getToothMinimumRadius() const;
143 
147  agx::Real getToothMaximumRadius() const;
148 
152  agx::UInt getNumberOfTeeth() const;
153 
170  void setExcavationSettings( ExcavationMode mode, ExcavationSettings excavationSettings );
171 
176  void setTopEdge(agx::Line topEdge);
177 
182  void setCuttingEdge(agx::Line cuttingEdge);
183 
187  void setCuttingDirection(agx::Vec3 cuttingDirection);
188 
192  void setToothLength(agx::Real length);
193 
197  void setToothMinimumRadius(agx::Real radius);
198 
202  void setToothMaximumRadius(agx::Real radius);
203 
207  void setNumberOfTeeth(agx::UInt count);
208 
212  void setNoMergeExtensionDistance(agx::Real extensionDistance);
213 
217  void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
218 
222  agx::Plane getCurrentSeparationPlane( Terrain* terrain, ExcavationMode mode ) const;
223 
227  agx::Real getMinimumSubmergedContactLengthFraction() const;
228 
232  agx::Real getNoMergeExtensionDistance() const;
233 
238  void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
239 
245  void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
246 
251  agx::Real getVerticalBladeSoilMergeDistance() const;
252 
264  bool getSoilPenetrationModel(agxTerrain::Terrain* terrain, agxTerrain::SoilPenetrationResistance::PenetrationModel& model) const;
265 
275  void setPenetrationDepthThreshold(agx::Real depthThreshold);
276 
288  bool setSoilPenetrationModel(agxTerrain::SoilPenetrationResistance::PenetrationModel model, agxTerrain::Terrain* terrain);
289 
299  agx::Real getPenetrationDepthThreshold() const;
300 
305  void setPenetrationForceScaling(agx::Real penetrationForceScaling);
306 
310  agx::Real getPenetrationForceScaling() const;
311 
318  void setEnableParticleFreeDeformers(bool enable);
319 
323  bool getEnableParticleFreeDeformers() const;
324 
329  void setAlwaysRemoveShovelContacts(bool enable);
330 
334  bool getAlwaysRemoveShovelContacts() const;
335 
340  void setMaxPenetrationForce(agx::Real maxPenetrationForce);
341 
346  agx::Real getMaxPenetrationForce() const;
347 
352  agx::Real getSecondarySeparationDeadloadLimit() const;
353 
357  agx::Vec3 getSecondaryCuttingDirection( Terrain* terrain ) const;
358 
362  agx::Real getSecondarySeparationAngle( Terrain* terrain ) const;
363 
369  agx::Real getDeadLoadFraction() const;
370 
377  agx::Real getInnerContactArea() const;
378 
386  void setBottomContactThreshold( agx::Real bottomContactThreshold );
387 
392  agx::Real getBottomContactThreshold() const;
393 
400  void setEnableInnerShapeCreateDynamicMass( bool enable );
401 
407  bool getEnableInnerShapeCreateDynamicMass() const;
408 
414  void setEnable(bool enable);
415 
420  bool getEnable() const;
421 
422  public:
423 
428  {
429  public:
434 
440 
445  void setEnable(bool enable);
446 
451  void setEnableCreateDynamicMass(bool enable);
452 
457  void setEnableForceFeedback(bool enable);
458 
462  bool getEnable() const;
463 
467  bool getEnableForceFeedback() const;
468 
472  bool getEnableCreateDynamicMass() const;
473 
477  agx::UInt32 getState() const;
478 
479  private:
480  enum StateFlags : agx::UInt32
481  {
482  ENABLED = 1 << 0,
483  ENABLE_CREATE_DYNAMIC_MASS = 1 << 1,
484  ENABLE_FORCE_FEEDBACK = 1 << 2,
485  };
486  using Flags = agx::BitState<StateFlags, agx::UInt32>;
487  Flags m_settings;
488  };
489 
490  public:
491 
497  agx::Bool initializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
498 
503  void uninitializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
504 
509  void onPre( TerrainToolCollection* collection );
510 
515  void onPost( TerrainToolCollection* collection );
516 
517  bool getShovelPlanes(TerrainToolCollection* collection,
518  agx::Plane& bottomPlane,
519  agx::Plane& backPlane,
520  agx::Plane& leftPlane,
521  agx::Plane& rightPlane);
522 
523  void removeTerrainShovelContacts(TerrainToolCollection* collection);
524 
525  void removeTerrainShovelContactsDeformer(TerrainToolCollection* collection);
526 
527  bool isEdgeSubmerged(const agx::Line& edge, const Terrain* terrain) const;
528 
529  bool isEdgeSubmergedInSolid(const agx::Line& edge, const Terrain* terrain) const;
530 
531  bool isEdgeSubmergedInHeightfield(const agx::Line& edge, const agxCollide::HeightField* heightfield, const Terrain* terrain) const;
532 
533  agx::Real getSubmergedEdgeLength(const agx::Line& edge, const Terrain* terrain) const;
534 
535  agx::Vec3 getCuttingEdgeVelocity();
536 
537  void calculateDeadLoadFraction( const Terrain* terrain,
538  const ActiveZone* activeZone,
539  const agx::Physics::GranularBodyPtrVector& innerParticles );
540 
541  void setInnerContactArea( agx::Real contactArea );
542 
543  void setSettingsAreDirty(bool enable);
544 
545  bool getSettingsAreDirty() const;
546 
547  agx::Real computeDefaultBottomContactThreshold() const;
548 
549  AGXSTREAM_DECLARE_SERIALIZABLE( agxTerrain::Shovel );
551 
552  protected:
556  Shovel();
557 
561  virtual ~Shovel();
562 
563  agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
564 
565  protected:
567  {
571  };
572 
574  {
575  ENABLED = 1 << 0,
576  REMOVE_SHOVEL_CONTACTS = 1 << 1,
577 
578  INNER_SHAPE_CREATE_DYNAMIC_MASS = 1 << 2,
579 
580  ENABLE_PARTICLE_FREE_DEFORMATION = 1 << 3,
581 
582  };
583  using Flags = agx::BitState<StateFlags, agx::UInt32>;
584 
599 
600  std::array< ExcavationSettings, 4 > m_excavationSettings;
601 
603 
604  // Caching of dead load
606  // Caching of inner contact area
608 
609  // Geometries used to find shovel-voxel collisions
612  };
613 }
agx::Real m_contactThreshold
Definition: Shovel.h:602
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agx::Real m_toothLength
Definition: Shovel.h:589
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
agx::Real m_secondarySeparationDeadLoadLimit
Definition: Shovel.h:596
bool Bool
Definition: Integer.h:48
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition: Shovel.h:583
agx::Real m_noMergeExtensionDistance
Definition: Shovel.h:593
PlaneT< agx::Real > Plane
Definition: Plane.h:121
bool m_settingsAreDirty
Definition: Shovel.h:611
GLenum GLuint GLenum GLsizei length
Definition: gl.h:5539
Collection of terrain tool (currently Shovel) related objects which are terrain instance specific...
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:86
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition: Shovel.h:610
agx::Real m_minimumSubmergedContactLengthFraction
Definition: Shovel.h:595
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::Real m_innerContactArea
Definition: Shovel.h:607
Class containing the settings for the different ExcavationModes for a shovel.
Definition: Shovel.h:427
agx::Vec3 m_cuttingDirection
Definition: Shovel.h:588
uint32_t UInt
Definition: Integer.h:34
SoilPenetrationParameters m_soilPenetrationParameters
Definition: Shovel.h:598
agx::UInt m_nTeeth
Definition: Shovel.h:592
std::array< ExcavationSettings, 4 > m_excavationSettings
Definition: Shovel.h:600
agx::Real m_toothMaxRadius
Definition: Shovel.h:591
agx::Line m_cuttingEdge
Definition: Shovel.h:586
#define AGXTERRAIN_EXPORT
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:52
agx::Line m_topEdge
Definition: Shovel.h:587
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:206
agx::Real m_deadLoadFraction
Definition: Shovel.h:605
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
AGX_DECLARE_VECTOR_TYPES(ActiveZone)
agx::VectorPOD< GranularBodyPtr > GranularBodyPtrVector
double Real
Definition: Real.h:42
agx::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
agx::RigidBodyObserver m_shovelBody
Definition: Shovel.h:585
agx::Real m_verticalSoilBladeMergeDistance
Definition: Shovel.h:594
LineT< Vec3 > Line
Definition: Line.h:39
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:101
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:100
agx::Real m_toothMinRadius
Definition: Shovel.h:590