AGX Dynamics  2.37.3.2
Wire.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 
20 
30 
32 #include <agxWire/RenderIterator.h>
33 
34 #include <agx/ICloneable.h>
35 
36 namespace agxUtil
37 {
38  class SmoothingFilter;
39 }
40 
41 namespace agx
42 {
43  class SolveIslandSplitAlgorithm;
44 
45  namespace Physics
46  {
47  class GraphNodeData;
48  }
49 }
50 
52 namespace agxWire
53 {
54  class Winch;
57 
61  class AGXPHYSICS_EXPORT Wire : public SimulationProxyT< agxSDK::StepEventListener >
62  {
63  public:
64  typedef SimulationProxyT< agxSDK::StepEventListener > base;
65 
66  public:
71  {
72  TensionData();
73  TensionData( agx::Real rawTension, agx::Real smoothedTension );
74  TensionData( const agxWire::Node::Tension* tension );
75 
78  };
79 
80  public:
81 
82  agx::Real getContactNodeMomentum() const;
83 
88  static agx::Bool isLumpedNode( const agx::RigidBody* rb );
89 
94  static agxWire::BodyFixedNode* getLumpedNode( agx::RigidBody* rb );
95 
100  static const agxWire::BodyFixedNode* getLumpedNode( const agx::RigidBody* rb );
101 
106  static agxWire::Wire* getWire( agx::RigidBody* rb );
107 
112  static const agxWire::Wire* getWire( const agx::RigidBody* rb );
113 
118  static agxWire::Wire* getWire( agxCollide::Geometry* geometry );
119 
124  static const agxWire::Wire* getWire( const agxCollide::Geometry* geometry );
125 
132  static agxWire::Wire* find( agxSDK::Simulation* simulation, const agx::Name& name );
133 
140  static agxWire::Wire* find( agxSDK::Simulation* simulation, const agx::Uuid& uuid );
141 
147  static agxWire::WirePtrVector findAll( const agxSDK::Simulation* simulation );
148 
155  static agxWire::WirePtrVector findAll( const agxSDK::Simulation* simulation, const agx::Name& name );
156 
157  public:
164  Wire( agx::Real radius, agx::Real resolutionPerUnitLength, bool enableCollisions = true );
165 
171  virtual agxWire::Wire* clone( agxWire::Wire* newWire = nullptr );
172 
179  virtual bool add( agxWire::Node* node );
180 
187  virtual bool add( agxWire::WireWinchController* winchController );
188 
196  virtual bool add( agxWire::WireWinchController* winchController, agx::Real pulledInLength );
197 
206  virtual bool add( agxWire::Link* link, bool updateConnectionType = true );
207 
218  virtual bool add( agxWire::Link* link, const agx::Vec3& relativeTranslate );
219 
225  virtual bool remove( agxWire::Node* node );
226 
233  virtual bool remove( agxWire::WireWinchController* winchController );
234 
245  bool insert( agxWire::Node* node, agx::Real distanceFromStart, bool includeWinchPulledInLength = true );
246 
254  bool insert( agxWire::Node* node, const agx::Vec3& worldPoint );
255 
260  bool reverse();
261 
272  bool merge( agxWire::WireRef other );
273 
283  agxWire::WireRef cut(agx::Real distanceAlongWire, size_t minimumResolution, bool includeWinchPulledInLength = true);
284 
293  agxWire::WireRef cut( const agx::Vec3& worldPoint, size_t minimumResolution );
294 
304  virtual bool attach( agxWire::Node* node, bool begin );
305 
313  virtual bool attach( agxWire::WireWinchController* winchController, bool begin );
314 
320  virtual bool detach( bool begin );
321 
326  const agxWire::WireAttachmentController* getBeginAttachment() const;
327 
332  const agxWire::WireAttachmentController* getEndAttachment() const;
333 
337  bool initialized() const;
338 
344  void setInitializationController( agxWire::WireInitializationController* initializationController );
345 
355  bool setRouteController( agxWire::WireRouteController* routeController, bool copyCurrentRouteToNew = false );
356 
360  agxWire::WireRouteController* getRouteController() const;
361 
365  agxWire::WireParameterController* getParameterController() const;
366 
370  agxWire::WireStabilityController* getStabilityController() const;
371 
375  agxWire::WireMaterialController* getMaterialController() const;
376 
380  agxWire::WireGeometryController* getGeometryController() const;
381 
385  agxWire::WireContactController* getActiveContactController() const;
386 
393  virtual agx::Real getRestLength( bool includeWinches = true ) const;
394 
405  agx::Real getRestLength( const agxWire::Node* node1, const agxWire::Node* node2 ) const;
406 
417  agx::Real findRestLength( bool includeWinches = true ) const;
418 
425  agx::Real getCurrentLength( bool includeWinches = true ) const;
426 
435  agx::Real getCurrentLength( const agxWire::Node* node1, const agxWire::Node* node2 ) const;
436 
443  agx::Real scaleToRestlength( agx::Real currentLength, const agxWire::Node* node ) const;
444 
450  agx::Real getRestLengthScaler( const agxWire::Node* node ) const;
451 
458  agx::Real scaleToCurrentlength( agx::Real restLength, const agxWire::Node* node ) const;
459 
465  agx::Real getCurrentLengthScaler( const agxWire::Node* node ) const;
466 
471  agxWire::WireWinchController* getWinchController( size_t i ) const;
472 
476  agx::Real getMass() const;
477 
478 
484  agxWire::RenderIterator getRenderBeginIterator() const;
485 
491  agxWire::RenderIterator getRenderEndIterator() const;
492 
496  bool getRenderListEmpty() const;
497 
504  agx::Real findRestLengthFromStart( const agx::Vec3& point, bool includeWinchesPulledInLength = true ) const;
505 
513  agx::Vec3 findPoint( agx::Real distanceFromStart ) const;
514 
525  agx::Vec3 findPoint( agx::Real distanceFromStart, bool includesWinchesPulledInLength ) const;
526 
532  agx::Vec3 findPoint( const agx::Vec3& point ) const;
533 
540  agxWire::WireSegmentTensionData getTension( const agx::Vec3& point ) const;
541 
549  agxWire::WireSegmentTensionData getTension( agx::Real distanceFromStart ) const;
550 
554  agxWire::WireNodeTensionData getTension( const agxWire::Node* node ) const;
555 
559  agx::Material* getMaterial() const;
560 
565  virtual void setMaterial( agx::Material* material );
566 
571  void setIsBendResistent( bool isBendResistant );
572 
577  void setPropertyContainer( agx::PropertyContainer* propertyContainer );
578 
580  agx::PropertyContainer* getPropertyContainer();
581 
583  const agx::PropertyContainer* getPropertyContainer() const;
584 
586  bool hasPropertyContainer() const;
587 
591  agx::Real getRadius() const;
592 
596  agx::Real getRadiusIncludingContactNodeOffsetDistanceMultiplier() const;
597 
602  virtual void setRadius( agx::Real radius );
603 
611  void setResolutionPerUnitLength( agx::Real resolutionPerUnitLength );
612 
616  agx::Real getResolutionPerUnitLength() const;
617 
623  void setEnableCollisions( agxCollide::Geometry* geometry, bool enable );
624 
630  void setEnableCollisions( agx::RigidBody* rb, bool enable );
631 
636  void setEnableCollisions( bool enable );
637 
643  void setActiveContactControllerType(const WireContactControllerType type);
644  WireContactControllerType getActiveContactControllerType() const;
645 
649  bool getEnableCollisions() const;
650 
654  bool getEnableCollisions( const agxCollide::Geometry* geometry ) const;
655 
659  bool getEnableCollisions( const agx::RigidBody* rb ) const;
660 
664  static void setEnableGroupWireCollision(agxCollide::Space* space,const agx::UInt32 group, bool enable);
665 
672  void setEnableSplitting( bool splitting );
673 
677  bool getEnableSplitting() const;
678 
683  void addGroup( uint32_t id );
684 
689  void addGroup( const agx::Name& name );
690 
694  bool hasGroup( const uint32_t id ) const;
695 
699  bool hasGroup( const agx::Name& name ) const;
700 
705  void removeGroup( uint32_t id );
706 
711  void removeGroup( const agx::Name& name );
712 
716  bool hasGeometry( const agxCollide::Geometry* geometry ) const;
717 
721  bool hasNode( const agxWire::Node* node ) const;
722 
726  agxWire::Node* getFirstNode() const;
727 
731  agxWire::Node* getLastNode() const;
732 
736  agxWire::WireDistanceCompositeConstraint* getConstraint() const;
737 
742  void getGeometries( agxCollide::GeometryPtrVector& geoms ) const;
743 
747  void removeGeometries();
748 
752  void updateNodeTransforms();
753 
758  agx::Frame* getFrame() const;
759 
763  void setFrame( agx::Frame* frame );
764 
770  void setLinearVelocityDamping( agx::Real linearVelocityDamping );
771 
775  agx::Real getLinearVelocityDamping() const;
776 
780  bool hasContactNodesOn( const agx::RigidBody* rb ) const;
781 
785  bool hasContactNodesOn( const agxCollide::Geometry* geometry ) const;
786 
795  bool replaceBodyInNodes( agx::RigidBody* currentBody, agx::RigidBody* newBody, agxCollide::Geometry* geometry = nullptr );
796 
812  bool changeRigidBody( agxWire::Node* node, agx::RigidBody* newRigidBody ) const;
813 
818  void setSmoothedTension( agx::Real newSmoothedTension );
819 
826  void setSmoothedTension( agx::Real newSmoothedTension, agxWire::NodeIterator from, agxWire::NodeIterator to );
827 
833  void setSmoothingFilter( agxUtil::SmoothingFilter *filter );
834 
838  const agxUtil::SmoothingFilter* getSmoothingFilter() const;
839 
843  virtual void preCollide( const agx::TimeStamp& ) override;
844 
848  virtual void pre( const agx::TimeStamp& t ) override;
849 
853  virtual void post( const agx::TimeStamp& t ) override;
854 
859  bool simplify( const agx::Frame* parentFrame = nullptr );
860 
865  bool unsimplify();
866 
870  bool isSimplified() const;
871 
875  agxWire::WireSimplifyController* getSimplifyController() const;
876 
880  void setSolveType( agx::Constraint::SolveType solveType);
881 
885  agx::SolveIslandSplitAlgorithm* getSplitAlgorithm() const;
886 
895  bool shorten( const agxWire::Node* toNode, bool fromBegin );
896 
900  void replaceContactNodesWithShapeContacts();
901 
903 
904 
908  void uninitializeConstraint();
909 
916  bool isStatic() const;
917 
921  agx::UInt getNumNodes() const;
922 
933  bool explicitReplaceWinchController( agxWire::ConnectingNode* connectingNode, bool begin );
934 
939  void onCreateMergeSplitProperties();
940 
945  agxWire::WirePropertyController* getPropertyController() const;
946 
949 
950  protected:
954  Wire();
955 
959  virtual ~Wire();
960 
965  virtual void addNotification() override;
966  using SimulationProxyT< agxSDK::StepEventListener >::addNotification;
967 
971  virtual void removeNotification() override;
972  using SimulationProxyT< agxSDK::StepEventListener >::removeNotification;
973 
977  void updateMaterial();
978 
982 #ifndef SWIG
984 #endif
985 
986  friend class agxWire::Winch;
992  virtual void setWinchController( agxWire::WireWinchController* winchController, bool begin );
993 
998  agxWire::WireAttachmentController* getBeginAttachment();
999 
1004  agxWire::WireAttachmentController* getEndAttachment();
1005 
1006  protected:
1007  WireDistanceCompositeConstraintRef m_constraint;
1008 
1009  // Controllers
1010  WireRouteControllerRef m_routeController;
1011  WireInitializationControllerRef m_initializationController;
1014  WireMaterialControllerRef m_materialController;
1015  WireStabilityControllerRef m_stabilityController;
1016  WireGeometryControllerRef m_geometryController;
1017  WireFrictionControllerRef m_frictionController;
1018  WireSimplifyControllerRef m_simplifyController;
1019 
1026 
1031 
1032  private:
1034  friend class agx::InternalData;
1039  agx::Referenced* getInternalData() const;
1040 
1045  void setInternalData( agx::Referenced* data );
1047  };
1048 
1049  // Inline methods *******************************************************************************************
1050 
1051  inline bool Wire::initialized() const
1052  {
1053  return m_initialized;
1054  }
1055 
1057  {
1058  return const_cast< WireParameterController* >( &m_parameterController );
1059  }
1060 
1062  {
1063  return m_routeController;
1064  }
1065 
1066  inline WireStabilityController* Wire::getStabilityController() const
1067  {
1068  return m_stabilityController;
1069  }
1070 
1071  inline WireMaterialController* Wire::getMaterialController() const
1072  {
1073  return m_materialController;
1074  }
1075 
1076  inline WireGeometryController* Wire::getGeometryController() const
1077  {
1078  return m_geometryController;
1079  }
1080 
1081  inline WireDistanceCompositeConstraint* Wire::getConstraint() const
1082  {
1083  return m_constraint;
1084  }
1085 
1086  inline agx::Referenced* Wire::getInternalData() const
1087  {
1088  return m_internalData;
1089  }
1090 
1092  {
1093  if (!m_propertyContainer)
1094  m_propertyContainer = new agx::PropertyContainer;
1095  return m_propertyContainer;
1096  }
1097 
1099  {
1100  return (m_propertyContainer.isValid());
1101  }
1102 
1104  {
1105  if (!m_propertyContainer)
1106  m_propertyContainer = new agx::PropertyContainer;
1107 
1108  return m_propertyContainer;
1109  }
1110 
1111  // **********************************************************************************************************
1112 
1113  // Static utility functions *********************************************************************************
1119  AGXPHYSICS_EXPORT void extractNodes( NodePtrVector& nodes, const Wire* wire );
1120  // **********************************************************************************************************
1121 }
1122 
SimulationProxyT< agxSDK::StepEventListener > base
Definition: Wire.h:64
AGXCORE_EXPORT Type * getType(const agx::String &name)
Winch object which works like agxWire::WireWinchController but enables the features of having stored...
Definition: Winch.h:30
WireMaterialControllerRef m_materialController
Definition: Wire.h:1014
Connecting nodes contains two nodes, one at center of mass and the other at the user defined position...
agx::ref_ptr< agx::Referenced > m_propertyController
Definition: Wire.h:1029
agx::Real smoothed
Definition: Wire.h:77
Proxy class for wire iterators.
Type
Type of EventListener.
Definition: EventListener.h:45
agxWire::WireGeometryController * getGeometryController() const
Definition: Wire.h:1076
bool Bool
Definition: Integer.h:48
agx::ref_ptr< agx::Referenced > m_splitAlgorithm
Definition: Wire.h:1027
agxWire::WireStabilityController * getStabilityController() const
Definition: Wire.h:1066
agxUtil::SmoothingFilterRef m_smoothingFilter
Definition: Wire.h:1020
WireGeometryControllerRef m_geometryController
Definition: Wire.h:1016
#define AGXPHYSICS_EXPORT
Structure containing relevant tension data for a wire element/segment.
WireDistanceCompositeConstraintRef m_constraint
Definition: Wire.h:1007
agxWire::WireMaterialController * getMaterialController() const
Definition: Wire.h:1071
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
bool m_initialized
Definition: Wire.h:1021
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:59
agx::Real TimeStamp
Definition: TimeStamp.h:26
bool hasPropertyContainer() const
Definition: Wire.h:1098
WireInitializationControllerRef m_initializationController
Definition: Wire.h:1011
Structure containing relevant tension data for a node.
Base class providing referencing counted objects.
Definition: Referenced.h:119
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
WireFrictionControllerRef m_frictionController
Definition: Wire.h:1017
The rigid body class, combining a geometric model and a frame of reference.
AGXPHYSICS_EXPORT void addGroup(const agx::RigidBody *body, unsigned id)
For the specified body, add the collision group ID to its geometries.
The body fixed node is attached to a body at a given offset.
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:61
agx::PropertyContainer * getPropertyContainer()
Definition: Wire.h:1091
uint32_t UInt
Definition: Integer.h:34
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
Class that is a container of named properties.
Definition: Property.h:158
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:81
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
agx::ref_ptr< agx::Referenced > m_internalData
Definition: Wire.h:1028
WireStabilityControllerRef m_stabilityController
Definition: Wire.h:1015
bool m_splitEnabled
Definition: Wire.h:1024
Class to hold specific parameters for the wire - this makes the wires highly configurable.
AGXPHYSICS_EXPORT void extractNodes(NodePtrVector &nodes, const Wire *wire)
Extracts all the nodes given the render list in the wire.
WireParameterController m_parameterController
Definition: Wire.h:1012
WireSimplifyControllerRef m_simplifyController
Definition: Wire.h:1018
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
agxWire::WireRouteController * getRouteController() const
Definition: Wire.h:1061
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:375
agx::PropertyContainerRef m_propertyContainer
Definition: Wire.h:1030
AGXPHYSICS_EXPORT bool setEnableCollisions(agx::RigidBody *rb1, agx::RigidBody *rb2, bool enable)
Enable or disable the collision between all geometries in RigidBody rb1 and RigidBody rb2...
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
SolveType
Specifies in what solvers the constraint will be solved.
Definition: Constraint.h:92
agxWire::WireParameterController * getParameterController() const
Definition: Wire.h:1056
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
#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
AGXPHYSICS_EXPORT void removeGroup(const agx::RigidBody *body, unsigned id)
For the specified body, remove the collision group ID to its geometries.
WireRouteControllerRef m_routeController
Definition: Wire.h:1010
WireWinchControllerRefVector m_winchControllers
Winch controller vector, always of size 2, default both 0.
Definition: Wire.h:1013
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agx::FrameRef m_frame
Definition: Wire.h:1022
agxWire::WireDistanceCompositeConstraint * getConstraint() const
Definition: Wire.h:1081
Structure containing relevant tension data given one look-up.
Definition: Wire.h:70
agx::observer_ptr< WireStabilityController > m_stabilityController
If by the initialization controller, this winch can merge segments and change mass of the lumps via t...
Class defining a node that is part of a wire.
Definition: agxWire/Node.h:511
agx::Constraint::SolveType m_solveType
Definition: Wire.h:1025
Winch class for handling in and out hauling of wires.
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
bool isValid() const
Definition: ref_ptr.h:268
agx::Real m_linearVelocityDamping
Only linear velocity damping as real is defined for lumped nodes.
Definition: Wire.h:1023
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
uint32_t UInt32
Definition: Integer.h:40
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
The agxUtil namespace contain classes and methods for utility functionality.
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97