AGXDynamics  2.35.0.2
Shovel.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/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 
157  agx::Real computeCuttingEdgeLength() const;
158 
175  void setExcavationSettings( ExcavationMode mode, ExcavationSettings excavationSettings );
176 
181  void setTopEdge(agx::Line topEdge);
182 
187  void setCuttingEdge(agx::Line cuttingEdge);
188 
192  void setCuttingDirection(agx::Vec3 cuttingDirection);
193 
197  void setToothLength(agx::Real length);
198 
202  void setToothMinimumRadius(agx::Real radius);
203 
207  void setToothMaximumRadius(agx::Real radius);
208 
212  void setNumberOfTeeth(agx::UInt count);
213 
217  void setNoMergeExtensionDistance(agx::Real extensionDistance);
218 
222  void setMinimumSubmergedContactLengthFraction(agx::Real minimumSubmergedContactLengthFraction);
223 
227  agx::Plane getCurrentSeparationPlane( Terrain* terrain, ExcavationMode mode ) const;
228 
232  agx::Real getMinimumSubmergedContactLengthFraction() const;
233 
237  agx::Real getNoMergeExtensionDistance() const;
238 
243  void setVerticalBladeSoilMergeDistance(agx::Real verticalSoilBladeMergeDistance);
244 
250  void setSecondarySeparationDeadloadLimit( agx::Real secondarySeparationLimit );
251 
256  agx::Real getVerticalBladeSoilMergeDistance() const;
257 
269  bool getSoilPenetrationModel(agxTerrain::Terrain* terrain, agxTerrain::SoilPenetrationResistance::PenetrationModel& model) const;
270 
280  void setPenetrationDepthThreshold(agx::Real depthThreshold);
281 
293  bool setSoilPenetrationModel(agxTerrain::SoilPenetrationResistance::PenetrationModel model, agxTerrain::Terrain* terrain);
294 
304  agx::Real getPenetrationDepthThreshold() const;
305 
310  void setPenetrationForceScaling(agx::Real penetrationForceScaling);
311 
315  agx::Real getPenetrationForceScaling() const;
316 
323  void setEnableParticleFreeDeformers(bool enable);
324 
328  bool getEnableParticleFreeDeformers() const;
329 
334  void setAlwaysRemoveShovelContacts(bool enable);
335 
339  bool getAlwaysRemoveShovelContacts() const;
340 
345  void setMaxPenetrationForce(agx::Real maxPenetrationForce);
346 
351  agx::Real getMaxPenetrationForce() const;
352 
357  agx::Real getSecondarySeparationDeadloadLimit() const;
358 
362  agx::Vec3 getSecondaryCuttingDirection( Terrain* terrain ) const;
363 
367  agx::Real getSecondarySeparationAngle( Terrain* terrain ) const;
368 
374  agx::Real getDeadLoadFraction() const;
375 
382  agx::Real getInnerContactArea() const;
383 
391  void setBottomContactThreshold( agx::Real bottomContactThreshold );
392 
397  agx::Real getBottomContactThreshold() const;
398 
405  void setEnableInnerShapeCreateDynamicMass( bool enable );
406 
412  bool getEnableInnerShapeCreateDynamicMass() const;
413 
419  void setEnable(bool enable);
420 
425  bool getEnable() const;
426 
427  public:
428 
433  {
434  public:
439 
445 
450  void setEnable(bool enable);
451 
456  void setEnableCreateDynamicMass(bool enable);
457 
462  void setEnableForceFeedback(bool enable);
463 
467  bool getEnable() const;
468 
472  bool getEnableForceFeedback() const;
473 
477  bool getEnableCreateDynamicMass() const;
478 
482  agx::UInt32 getState() const;
483 
484  void store( agxStream::OutputArchive& out ) const { m_settings.store( out ); }
485  void restore( agxStream::InputArchive& in ) { m_settings.restore( in ); }
486 
487  private:
488  enum StateFlags : agx::UInt32
489  {
490  ENABLED = 1 << 0,
491  ENABLE_CREATE_DYNAMIC_MASS = 1 << 1,
492  ENABLE_FORCE_FEEDBACK = 1 << 2,
493  };
494  using Flags = agx::BitState<StateFlags, agx::UInt32>;
495  Flags m_settings;
496  };
497 
498  public:
499 
505  agx::Bool initializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
506 
511  void uninitializeCollection( TerrainToolCollection* collection, agxSDK::Simulation* simulation );
512 
517  void onPre( TerrainToolCollection* collection );
518 
523  void onPost( TerrainToolCollection* collection );
524 
525  bool getShovelPlanes(TerrainToolCollection* collection,
526  agx::Plane& bottomPlane,
527  agx::Plane& backPlane,
528  agx::Plane& leftPlane,
529  agx::Plane& rightPlane);
530 
531  void removeTerrainShovelContacts(TerrainToolCollection* collection);
532 
533  void removeTerrainShovelContactsDeformer(TerrainToolCollection* collection);
534 
535  bool isEdgeSubmerged(const agx::Line& edge, const Terrain* terrain) const;
536 
537  bool isEdgeSubmergedInSolid(const agx::Line& edge, const Terrain* terrain) const;
538 
539  bool isEdgeSubmergedInHeightfield(const agx::Line& edge, const agxCollide::HeightField* heightfield, const Terrain* terrain) const;
540 
541  agx::Real getSubmergedEdgeLength(const agx::Line& edge, const Terrain* terrain) const;
542 
543  agx::Vec3 getCuttingEdgeVelocity();
544 
545  void correctShovelVectors();
546 
547  void calculateDeadLoadFraction( const Terrain* terrain,
548  const ActiveZone* activeZone,
549  const agx::Physics::GranularBodyPtrVector& innerParticles );
550 
551  void setInnerContactArea( agx::Real contactArea );
552 
553  void setSettingsAreDirty(bool enable);
554 
555  bool getSettingsAreDirty() const;
556 
557  agx::Real computeDefaultBottomContactThreshold() const;
558 
561 
562  protected:
566  Shovel();
567 
571  virtual ~Shovel();
572 
573  agxCollide::GeometryRefVector createVoxelCollisionGeometries( agx::Real tessellationLevel ) const;
574 
575  protected:
577  {
581  };
582 
584  {
585  ENABLED = 1 << 0,
586  REMOVE_SHOVEL_CONTACTS = 1 << 1,
587 
588  INNER_SHAPE_CREATE_DYNAMIC_MASS = 1 << 2,
589 
590  ENABLE_PARTICLE_FREE_DEFORMATION = 1 << 3,
591 
592  };
593  using Flags = agx::BitState<StateFlags, agx::UInt32>;
594 
609 
610  std::array< ExcavationSettings, 4 > m_excavationSettings;
611 
613 
614  // Caching of dead load
616  // Caching of inner contact area
618 
619  // Geometries used to find shovel-voxel collisions
622  };
623 }
agxTerrain::Shovel::SoilPenetrationParameters::maxForce
agx::Real maxForce
Definition: Shovel.h:580
agxTerrain::Shovel::SoilPenetrationParameters::forceScaling
agx::Real forceScaling
Definition: Shovel.h:579
agxTerrain::Terrain
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: agxTerrain/Terrain.h:85
agx::Real
double Real
Definition: Real.h:42
agxTerrain::Shovel::m_flags
Flags m_flags
Definition: Shovel.h:607
agx::Physics::GranularBodyPtrVector
agx::VectorPOD< GranularBodyPtr > GranularBodyPtrVector
Definition: GranularBodyEntity.h:321
agx::Vector< agx::ref_ptr< Geometry > >
PrimaryActiveZone.h
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
BitState.h
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agxRender::Flags
Flags
Flags for specifying what is enabled in the debug rendering system.
Definition: RenderManager.h:58
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agxTerrain::Shovel
Definition: Shovel.h:50
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxTerrain::Shovel::m_nTeeth
agx::UInt m_nTeeth
Definition: Shovel.h:602
agxTerrain::Shovel::m_noMergeExtensionDistance
agx::Real m_noMergeExtensionDistance
Definition: Shovel.h:603
SoilPenetrationResistance.h
agxTerrain::Shovel::ExcavationMode
ExcavationMode
Enum for describing the different excavation modes of a shovel: PRIMARY - The primary mode of excavat...
Definition: Shovel.h:86
agxTerrain::Shovel::m_voxelCollisionGeometries
agxCollide::GeometryRefVector m_voxelCollisionGeometries
Definition: Shovel.h:620
AGXSTREAM_DECLARE_SERIALIZABLE
#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:207
agx::observer_ptr< RigidBody >
agxTerrain::Shovel::m_toothMinRadius
agx::Real m_toothMinRadius
Definition: Shovel.h:600
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxTerrain::Shovel::ExcavationSettings::store
void store(agxStream::OutputArchive &out) const
Definition: Shovel.h:484
agxTerrain::Shovel::ExcavationSettings::restore
void restore(agxStream::InputArchive &in)
Definition: Shovel.h:485
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
agxTerrain::Shovel::m_contactThreshold
agx::Real m_contactThreshold
Definition: Shovel.h:612
agx::PlaneT
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agxTerrain::Shovel::SoilPenetrationParameters::depthThreshold
agx::Real depthThreshold
Definition: Shovel.h:578
agx::Vec3
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agxTerrain::Shovel::m_cuttingDirection
agx::Vec3 m_cuttingDirection
Definition: Shovel.h:598
agxTerrain::Shovel::Flags
agx::BitState< StateFlags, agx::UInt32 > Flags
Definition: Shovel.h:593
agxTerrain::SoilPenetrationResistance::PenetrationModel
PenetrationModel
Definition: SoilPenetrationResistance.h:35
agxTerrain::Shovel::m_soilPenetrationParameters
SoilPenetrationParameters m_soilPenetrationParameters
Definition: Shovel.h:608
agxTerrain::Shovel::ExcavationSettings
Class containing the settings for the different ExcavationModes for a shovel.
Definition: Shovel.h:432
agxTerrain::Shovel::m_toothMaxRadius
agx::Real m_toothMaxRadius
Definition: Shovel.h:601
agxTerrain::Shovel::m_minimumSubmergedContactLengthFraction
agx::Real m_minimumSubmergedContactLengthFraction
Definition: Shovel.h:605
agx::LineT
Definition: Line.h:25
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::Line
LineT< Vec3 > Line
Definition: Line.h:39
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agxTerrain::Shovel::StateFlags
StateFlags
Definition: Shovel.h:583
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition: agxTerrain/export.h:41
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxTerrain::Shovel::m_cuttingEdge
agx::Line m_cuttingEdge
Definition: Shovel.h:596
agx::Bool
bool Bool
Definition: Integer.h:48
agxTerrain::Shovel::m_settingsAreDirty
bool m_settingsAreDirty
Definition: Shovel.h:621
agxTerrain::Shovel::SoilPenetrationParameters
Definition: Shovel.h:576
agxTerrain::Shovel::m_topEdge
agx::Line m_topEdge
Definition: Shovel.h:597
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agxTerrain::Shovel::m_shovelBody
agx::RigidBodyObserver m_shovelBody
Definition: Shovel.h:595
agx::Vec3T< Real >
SoilParticleAggregate.h
agxTerrain::Shovel::m_excavationSettings
std::array< ExcavationSettings, 4 > m_excavationSettings
Definition: Shovel.h:610
agx::UInt32
uint32_t UInt32
Definition: Integer.h:40
agxCollide::GeometryRefVector
agx::Vector< agx::ref_ptr< Geometry > > GeometryRefVector
Definition: agxcollide_vector_types.h:38
agxTerrain::Shovel::m_toothLength
agx::Real m_toothLength
Definition: Shovel.h:599
agxTerrain::Shovel::m_secondarySeparationDeadLoadLimit
agx::Real m_secondarySeparationDeadLoadLimit
Definition: Shovel.h:606
agxTerrain::Shovel::m_innerContactArea
agx::Real m_innerContactArea
Definition: Shovel.h:617
agx::Plane
PlaneT< agx::Real > Plane
Definition: Plane.h:121
agxTerrain::Shovel::m_verticalSoilBladeMergeDistance
agx::Real m_verticalSoilBladeMergeDistance
Definition: Shovel.h:604
agxTerrain::Shovel::m_deadLoadFraction
agx::Real m_deadLoadFraction
Definition: Shovel.h:615