AGX Dynamics  2.35.0.1
agxWire/Node.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/agxPhysics_export.h>
20 
21 #include <agxStream/Serializable.h>
22 
23 #include <agx/RigidBody.h>
24 #include <agxCollide/Geometry.h>
25 
26 #include <agx/List.h>
27 
30 
31 namespace agxWire
32 {
33  // Forward declarations
34  class Node;
35  class FreeNode;
36  class BodyFixedNode;
37  class EyeNode;
38  class ConnectingNode;
39  class StopNode;
40  class ContactNode;
41  class ShapeContactNode;
42  class WireFrictionController;
43  class WireTensionController;
44  class WireFrictionConstraintImplementation;
45  class SpatialState;
46  class Wire;
47  class Link;
48 
50  // Container typedefs
59 
61 #if HASH_FOR_WIRE == HASH_NEW
63 #elif HASH_FOR_WIRE == HASH_OLD
65 #else
66  #error
67 #endif
68 
73 
75 
76  enum class WireGeometryType
77  {
78  SEGMENT,
81  };
82 
89  {
90  public:
91  enum Elements
92  {
96  ENUM_SIZE
97  };
98 
103 
108 
115 
121  const agx::Vec3& getElement( Elements element ) const;
122 
126  void transform();
127 
132  void setTranslate( const agx::Vec3& translate );
133 
141 
145  const agx::Vec3& getTranslate() const;
146 
157 
161  const agx::Vec3& getWorldPosition() const;
162 
167 
171  agx::RigidBody* getRigidBody() const;
172 
173  protected:
175  agx::Vec3 m_data[ ENUM_SIZE ];
176  };
177 
182  {
183  public:
188  {
189  NEGATIVE = 0,
191  BOTH
192  };
193 
198  {
199  GO_FORWARD = 1,
200  IS_DIRTY = (1<<1),
201  FIX_FRICTION_DIRECTION = (1<<2)
202  };
203 
208 
213  bool hasValidRestLength() const;
214 
219  bool isStick() const;
220 
225  bool isStick( Direction dir ) const;
226 
232  void setActive( bool active );
233 
238  bool getActive() const;
239 
244  void setStick( bool stick, Direction dir );
245 
250 
255 
261  void setFrictionCoefficient( agx::Real coeff, Direction dir = BOTH );
262 
269 
273  bool getEnable() const;
274 
278  bool isEnabled() const;
279 
284 
289 
293  bool isInfCoefficient( Direction dir ) const;
294 
299 
301 
302 
305  void toggleGoForward();
306 
310  bool getGoForward() const;
311 
315  bool goForwardIsDirty() const;
316 
321  void setGoForwardIsDirty();
322 
326  void resetGoForwardIsDirty();
327 
332  void updateStick( agx::Real tension );
333 
337  void setInvalidRestLength();
338 
342  void store( agxStream::OutputArchive& out ) const;
343 
347  void restore( agxStream::InputArchive& in, agxWire::Node* node );
348 
353  void reverse();
354 
359  agx::Real getRestLength() const;
360 
365  agx::Real getViolation() const;
367 
368 
369  protected:
370  friend class WireFrictionController;
371  friend class Node;
372  friend class EyeNode;
373  friend class WireFrictionConstraintImplementation;
374  friend class WireOldContactController;
375  friend class WireDistanceCompositeConstraintImplementation;
376 
381  void setRestLength( agx::Real restLength );
382 
387  void setViolation( agx::Real violation );
388 
393  void setViolationPerUnitLength( agx::Real violationPerUnitLength );
394 
398  agx::Real getViolationPerUnitLength();
399 
404  void setNormalForceMagnitude( agx::Real normalForce );
405 
406  protected:
407  enum CurrentType { VELOCITY_SCALER = 0, FRICTION_COEFFICIENT };
408 
409  protected:
410  agx::Real m_frictionCoeffs[ 2 ][ BOTH ];
413  bool m_stick[ BOTH ];
414  char m_goForward;
417  };
418 
424  {
425  public:
430 
438  void set( agx::Real startDistance, agx::Real endDistance, agx::Real nodesPerUnitDistance );
439 
443  bool isActive() const;
444 
449 
454 
459 
466  void setStartDistance( agx::Real startDistance );
467 
474  void setEndDistance( agx::Real endDistance );
475 
481  void setNodesPerUnitDistance( agx::Real nodesPerUnitDistance );
482 
486  void reverse();
487 
489 
490 
493  void store( agxStream::OutputArchive& out ) const;
494 
498  void restore( agxStream::InputArchive& in );
499 
501 
502  protected:
503  agx::Real m_startDistance;
504  agx::Real m_endDistance;
505  agx::Real m_nodesPerUnitDistance;
506  };
507 
511  class AGXPHYSICS_EXPORT Node : public agx::Referenced, public virtual agxStream::Serializable
512  {
513  public:
517  enum Type
518  {
519  NOT_DEFINED = 0,
520  EYE = (1<<0),
521  MISSING = (1<<1),
522  CONNECTING = (1<<2),
525  FREE = (1<<3),
526  CONTACT = (1<<4),
527  BODY_FIXED = (1<<5),
528  STOP = (1 << 6),
529  SHAPE_CONTACT = (1<<7)
530  };
531 
536  {
537  STANDARD = 0,
538  WAS_CONTACT = (1<< 0),
539  IS_HIGH_RES = (1<< 1),
540  IGNORE_BEND = (1<< 2),
541  NO_LUMP_NEAR = (1<< 3),
542  NO_CIRCLE_CONTACT = (1<< 4),
543  GYPSY_CONTACT = (1<< 5),
544  NO_MOVEMENT_RANGE = (1<< 6),
545  NO_FRICTION = (1<< 7),
546  SPLIT_ENABLED = (1<< 8),
547  INSIDE_OBJECT = (1<< 9),
548  WAS_CONTACT_LAST_TIMESTEP = (1<<10),
549  PERMANENT_LUMP = (1<<11),
550  REPLACE_SUPERBEND_WITH_BEND = (1<<12),
551  LUMPED_NODE = (1<<13),
552  LUMP_CONTACT = (1<<14),
553  WW_STABILIZED = (1<<15)
554  };
555 
556  public:
561 #ifndef SWIG
562  class SpatialState
563  {
564  public:
568  struct Data
569  {
573  Data();
574 
578  bool operator < ( const Data& other ) const;
579 
580  agx::Real t;
581  agx::Vec3 pos;
582  };
583 
584  typedef agx::VectorPOD< Data > DataContainer;
585 
586  public:
590  SpatialState();
591 
595  ~SpatialState();
596 
603  void store( const agx::Real t, const agxWire::Node* curr );
604 
614  agx::Real store( const agx::Real currT, const agx::Real totLen, const agxWire::Node* curr, const agxWire::Node* next );
615 
620  void onInsert( agxWire::Node* prev, agxWire::Node* curr, agxWire::Node* next );
621 
630  void onRemove( agxWire::Node* prev, agxWire::Node* curr, agxWire::Node* next );
631 
635  void sort();
636 
640  Data* local();
641 
645  const Data* local() const;
646 
650  const DataContainer& removed() const { return m_removed; }
651 
660  const Data* intermediate( agx::UInt i ) const;
661 
665  void store( agxStream::OutputArchive& out ) const;
666 
670  void restore( agxStream::InputArchive& in );
671 
672  protected:
673  Data m_local;
674  DataContainer m_removed;
675  };
676 #endif
678 
679  public:
685  static int findNodeState( const agxCollide::Geometry* geometry );
686 
687  static agx::Bool isContactType(const Node* node);
688  static agx::Bool isContactType(const Node::Type& type);
689 
693  Node::Type getType() const;
694 
699  agx::Bool isType( agx::Int typeMask ) const;
700 
707  Type getNodeType() const;
708 
712  NodeFrame* getFrame();
713 
717  const NodeFrame* getFrame() const;
718 
724  NodeFrame& getNodeFrame();
725 
730  SpatialState* getSpatialState();
731 
735  const SpatialState* getSpatialState() const;
737 
741  const agx::Vec3& getWorldPosition() const;
742 
746  const agx::Vec3& getTranslate() const;
747 
751  const agx::Vec3& getPosition() const; // support old code
752 
756  virtual void setTranslate( const agx::Vec3& translate );
757 
761  void setTranslate( agx::Real x, agx::Real y, agx::Real z );
762 
766  agx::RigidBody* getRigidBody() const;
767 
771  virtual void reverse();
772 
776  void transform();
777 
782  void setCustomData( agx::Referenced* customData );
783 
787  agx::Referenced* getCustomData() const;
788 
792  HighResolutionRange* getHighResolutionRange();
793 
797  const HighResolutionRange* getHighResolutionRange() const;
798 
806  agx::Vec3 getIntegratedPosition( agx::Real t, bool onlyTranslational = true ) const;
807 
811  virtual agx::Vec3 getVelocity() const;
812 
816  void setIgnoreBend( bool ignoreBend );
817 
821  bool getIgnoreBend() const;
822 
826  int getState() const;
827 
832  void addState( int state );
833 
838  void removeState( int state );
839 
843  NodeMaterial* getMaterial();
844 
848  const NodeMaterial* getMaterial() const;
849 
853  FreeNode* getAsFree();
854 
858  const FreeNode* getAsFree() const;
859 
863  BodyFixedNode* getAsBodyFixed();
864 
868  const BodyFixedNode* getAsBodyFixed() const;
869 
873  EyeNode* getAsEye();
874 
878  const EyeNode* getAsEye() const;
879 
884  EyeNode* getAsEyeLineNode();
885 
890  const EyeNode* getAsEyeLineNode() const;
891 
895  ConnectingNode* getAsConnecting();
896 
900  const ConnectingNode* getAsConnecting() const;
901 
905  StopNode* getAsStop();
906 
910  const StopNode* getAsStop() const;
911 
915  ContactNode* getAsContact();
916 
920  const ContactNode* getAsContact() const;
921 
925  const ShapeContactNode* getAsShapeContact() const;
926 
930  ShapeContactNode* getAsShapeContact();
931 
932 
934 
939  void setInsideObject(bool insideObject);
940 
944  bool getInsideObject() const;
945 
949  bool getWasContact() const;
950 
954  bool getWasContactLastTimestep() const;
955 
960  void setWasContact( bool wasContact );
961 
966  void setWasContactLastTimestep( bool wasContact );
967 
971  void setNoLumpNear( bool noLumpNear );
972 
976  bool getNoLumpNear() const;
977 
981  void setNoCircleContact( bool disableCircleContact );
982 
986  bool getNoCircleContact() const;
987 
992  void setGypsyContact(bool gypsyContact);
993 
998  bool getGypsyContact() const;
999 
1006  void setNoMovementRange(bool disableMovementRange);
1007 
1011  bool getNoMovementRange() const;
1012 
1017  void setNoFriction( bool noFriction );
1018 
1023  bool getNoFriction() const;
1024 
1028  void setState( int nodeState );
1029 
1034  class AGXPHYSICS_EXPORT StoreRestoreData
1035  {
1036  public:
1037  StoreRestoreData();
1038 
1039  bool& ignore();
1040  int& geometryIndex();
1041  bool& atBegin();
1042 
1043  bool getIgnored() const;
1044  int getGeometryIndex() const;
1045  bool getAtBegin() const;
1046 
1047  void reset();
1048 
1049  private:
1050  int m_geometryIndex;
1051  bool m_ignore;
1052  bool m_atBegin;
1053  };
1054 
1058  StoreRestoreData* getStoreRestoreData();
1059 
1063  const StoreRestoreData* getStoreRestoreData() const;
1064 
1065 
1068 
1070 
1071  public:
1072  struct AGXPHYSICS_EXPORT Tension
1073  {
1074  Tension() : raw( agx::Real( 0 ) ), smoothed( agx::Real( 0 ) ) {}
1075  agx::Real raw;
1076  agx::Real smoothed;
1077  };
1078 
1082  Tension* getTension();
1083 
1087  const Tension* getTension() const;
1088 
1089  struct AGXPHYSICS_EXPORT ContactForce
1090  {
1091  ContactForce() {}
1092 
1093  agx::Vec3 normalForce;
1094  agx::Vec3 frictionForce;
1095  };
1096 
1100  ContactForce* getContactForce();
1101 
1105  const ContactForce* getContactForce() const;
1106 
1110  agx::Vec3 getNormalForce() const;
1112 
1113  protected:
1117  Node( Type type );
1118 
1122  Node();
1123 
1127  virtual ~Node();
1128 
1129  protected:
1131  Type m_type;
1132  HighResolutionRange m_highResolutionRange;
1133  NodeMaterial m_material;
1134  int m_nodeState;
1135  Tension m_tension;
1136  ContactForce m_contactForce;
1137 
1138  agx::ref_ptr< agx::Referenced > m_customData;
1139 
1140  FreeNode* m_free;
1141  BodyFixedNode* m_bodyFixed;
1142  EyeNode* m_eye;
1143  ConnectingNode* m_connecting;
1144  StopNode* m_stop;
1145  ContactNode* m_contact;
1146  ShapeContactNode* m_shapeContact;
1147 
1148  StoreRestoreData m_storeRestoreData;
1149  SpatialState m_spatialState;
1150 
1151  agx::observer_ptr< Node > m_parent; // Pointer back if this is a child node.
1152 
1153  private:
1155  friend class agx::InternalData;
1160  agx::Referenced* getInternalData() const;
1161 
1166  void setInternalData( agx::Referenced* data );
1168 
1169  private:
1170  agx::ref_ptr<agx::Referenced> m_internalData;
1171  };
1172 
1178  {
1179  public:
1184  FreeNode( const agx::Vec3& position );
1185 
1193 
1195 
1196  protected:
1201 
1205  virtual ~FreeNode();
1206 
1207  protected:
1211  void create( const agx::Vec3& position );
1212  };
1213 
1215 
1226  {
1227  public:
1233  BodyFixedNode( agx::RigidBody* rb, const agx::Vec3& relativeTranslate = agx::Vec3() );
1234 
1242  BodyFixedNode( agx::RigidBody* rb, agx::Real relTranslate_x, agx::Real relTranslate_y, agx::Real relTranslate_z );
1243 
1249  void setRestLength( agx::Real restLength );
1250 
1255  void changeRestLength( agx::Real dl );
1256 
1260  agx::Real getRestLength() const;
1261 
1266  void setCurrentLength( agx::Real currentLength );
1267 
1272  void changeCurrentLength( agx::Real dl );
1273 
1277  agx::Real getCurrentLength() const;
1278 
1282  agx::Real getViolation() const;
1283 
1287  void setIsLumpedNode( bool lumpedNode );
1288 
1292  bool isLumpedNode() const;
1293 
1297  void setIsLumpContact( bool lumpContact );
1298 
1302  bool isLumpContact() const;
1303 
1308  void setSplitEnabled( bool splitEnabled );
1309 
1313  bool getSplitEnabled() const;
1314 
1319  void setIsHighRes( bool wasHighRes );
1320 
1324  bool getIsHighRes() const;
1325 
1330  void setPermanentLump( bool permantentLump );
1331 
1336  bool getPermanentLump() const;
1337 
1342  void setParent( ConnectingNode* connectingNode );
1343 
1348  ConnectingNode* getParent() const;
1349 
1351 
1353 
1354  protected:
1359 
1363  virtual ~BodyFixedNode();
1364 
1368  void create( agx::RigidBody* rb, const agx::Vec3& relativeTranslate );
1369 
1370  protected:
1371  agx::Real m_restLength;
1372  agx::Real m_currentLength;
1373  };
1374 
1375  typedef agx::ref_ptr< BodyFixedNode > BodyFixedNodeRef;
1376 
1381  {
1382  public:
1390 
1397  EyeNode( agx::RigidBody* rb, const agx::Vec3& relativeTranslate, agx::Real radius = agx::Real( 0 ) );
1398 
1409  EyeNode( agx::RigidBody* rb, const agx::Vec3& relativeTranslate, const agx::Vec3& extraEyeVector, agx::Real radius = agx::Real( 0 ) );
1410 
1423  EyeNode( agx::RigidBody* rb, agx::Real relTranslate_x, agx::Real relTranslate_y, agx::Real relTranslate_z, const agx::Vec3& extraEyeVector = agx::Vec3(), agx::Real radius = agx::Real( 0 ) );
1424 
1429  void setRadius( agx::Real radius );
1430 
1435 
1441  void setEnableReverseAddOfNormalNode( bool reverseAdd );
1443 
1450  void setReverseAdd( bool reverseAdd );
1451 
1455  bool getReverseAdd() const;
1456 
1460  EyeNode* getChildNode();
1461 
1465  const EyeNode* getChildNode() const;
1466 
1470  EyeNode* getParentNode() const;
1471 
1475  agx::Real getDistanceToChild() const;
1476 
1480  agx::Vec3 getVectorToChild() const;
1481 
1485  void setVectorToChild( const agx::Vec3& vec );
1486 
1490  virtual void reverse() override;
1491 
1499  void setFixFrictionDirection( bool fixFrictionDirection, bool goForward );
1500 
1504  bool getFixFrictionDirection() const;
1505 
1511  agx::Real findSpeedAlongWire( const agxWire::Wire* wire ) const;
1512 
1514 
1515  protected:
1520 
1526  EyeNode( Type type, agx::Real radius = agx::Real( 0 ) );
1527 
1531  virtual ~EyeNode();
1532 
1540  void create( agx::RigidBody* rb, const agx::Vec3& relativeTranslate, const agx::Vec3& extraEyeVector, agx::Real radius );
1541 
1542  protected:
1543  agx::ref_ptr< EyeNode > m_childNode; // Extra eye.
1544  bool m_reverseAdd;
1545  agx::Real m_radius;
1546  agx::Vec3 m_normal;
1547  };
1548 
1549  typedef agx::ref_ptr< EyeNode > EyeNodeRef;
1550 
1558  {
1559  public:
1565  {
1566  StabilityParameters( agx::Real youngsModulus, agx::Real damping, agx::Bool active );
1567 
1571  };
1572 
1573  public:
1580  ConnectingNode( agx::RigidBody* rb, const agx::Vec3& relativeTranslate, agx::Real radius );
1581 
1586 
1593 
1598 
1603 
1608  void setSuperBendReplacedWithBend( bool replaceSuperBend );
1609 
1613  bool getSuperBendReplacedWithBend() const;
1614 
1618  virtual void updateConnection( agxWire::Wire* /*wire*/ ) {}
1619 
1623  virtual agxWire::ConnectingNode::StabilityParameters calculateStabilityParameters( agx::Real radius, agx::Real defaultYoungsModulus, agx::Real defaultDamping, const agxWire::Node* nodes[ 3 ], const agxWire::WireTensionController* tensionController ) const;
1624 
1626 
1628 
1629  protected:
1634 
1638  virtual ~ConnectingNode();
1639 
1645  void create( agx::RigidBody* rb, const agx::Vec3& relativeTranslate );
1646 
1647  protected:
1649  };
1650 
1651  typedef agx::ref_ptr< ConnectingNode > ConnectingNodeRef;
1652 
1658  {
1659  public:
1666  StopNode( agx::RigidBody* rb, const agx::Vec3& relativeTranslate );
1667 
1672  void setNormal( agx::Vec3 normal );
1673 
1678 
1679 
1685  agx::Real getReferenceDistance() const;
1686 
1691  void setReferenceDistance( agx::Real referenceDistance );
1692 
1694 
1696 
1697  protected:
1702 
1706  virtual ~StopNode();
1707 
1713  void create( agx::RigidBody* rb, const agx::Vec3& relativeTranslate );
1714 
1715  protected:
1716  agx::Real m_referenceDistance;
1717  };
1718 
1719  typedef agx::ref_ptr< StopNode > StopNodeRef;
1720 
1726  {
1727  public:
1732  {
1733  MOVEMENT_RANGE_START = 1,
1734  MOVEMENT_RANGE_END = 2
1735  };
1736 
1741  class AGXPHYSICS_EXPORT MeshIndex
1742  {
1743  public:
1744  MeshIndex();
1745 
1746  int getMeshCurrentTriangleIndex() const;
1747  int getMeshNextTriangleIndexStart() const;
1748  int getMeshNextTriangleIndexEnd() const;
1749  int getMeshCurrentEdgeIndex() const;
1750  int getMeshNextEdgeIndexStart() const;
1751  int getMeshNextEdgeIndexEnd() const;
1752  void setMeshCurrentIndex( int meshCurrentTriangleIndex, int meshCurrentEdgeIndex );
1753  void setMeshNextIndexStart( int meshNextTriangleIndexStart, int meshNextEdgeIndexStart );
1754  void setMeshNextIndexEnd( int meshNextTriangleIndexEnd, int meshNextEdgeIndexEnd );
1755 
1756  void reset();
1757  void store( agxStream::OutputArchive& out ) const;
1758  void restore( agxStream::InputArchive& in );
1759 
1760  private:
1761  int m_meshCurrentTriangleIndex;
1762  int m_meshCurrentEdgeIndex;
1763  int m_meshNextTriangleIndexStart;
1764  int m_meshNextEdgeIndexStart;
1765  int m_meshNextTriangleIndexEnd;
1766  int m_meshNextEdgeIndexEnd;
1767  };
1768 
1770 
1771  public:
1781  ContactNode( agxCollide::Geometry* geometry, const agx::Vec3& shapeRelativeTranslate, const agx::Vec3& shapeEdgeStart, const agx::Vec3& shapeEdgeEnd, const agx::Vec3& shapeEdge );
1782 
1788 
1796  ContactNode( agxCollide::Geometry* geometry, const agx::Vec3& shapeRelativeTranslate = agx::Vec3() );
1797 
1801  agxCollide::Geometry* getGeometry() const;
1802 
1808  void setGeometry( agxCollide::Geometry* geometry );
1809 
1815  virtual void setTranslate( const agx::Vec3& shapeTranslate ) override;
1816 
1820  void setNoStickContact( bool noStickyContact );
1821 
1825  bool getNoStickContact() const;
1826 
1830  MeshIndex* getMeshIndex();
1831 
1835  const MeshIndex* getMeshIndex() const;
1836 
1837 
1839 
1844  agxCollide::Geometry* getNextGeometry() const;
1845 
1851  void setNextGeometry(agxCollide::Geometry* nextGeometry);
1852 
1856  const agx::Vec3& getShapeTranslate() const;
1857 
1861  void setShapeEdge(const agx::Vec3& shapeEdge);
1862 
1866  const agx::Vec3& getShapeEdge() const;
1867 
1871  void resetMovementRange(int direction);
1872 
1878  void setMovementRange(const agx::Vec3& start, const agx::Vec3& end);
1879 
1884  void getMovementRange(agx::Vec3& start, agx::Vec3& end) const;
1885 
1890  void getFullMovementRange(agx::Vec3& start, agx::Vec3& end) const;
1891 
1895  bool getIfOpenAngle() const;
1896 
1900  void setOpenAngle(bool openAngle);
1901 
1905  size_t getClampedRangeInformation() const;
1906 
1910  const agx::Vec3& getPreviousPosition() const;
1911 
1915  void setPreviousPosition(agx::Real t, agx::Vec3 start, agx::Vec3 edge);
1916 
1920  void resetPreviousPosition();
1921 
1925  bool clampMovementRange(const agx::Vec3& pos, MovementRange direction);
1926 
1930  void setShapeEdgeOffset(const agx::Vec3& offset);
1931 
1935  agx::Vec3 getShapeEdgeOffset() const;
1936 
1940  void setCollidedGeometry(agxCollide::Geometry* geometry, const agx::Vec3& depthVector);
1941 
1945  const GeometryRefDepthTable& getCollidedGeometries() const;
1946 
1950  void resetCollidedGeometries();
1951 
1955  agx::Vec3 getParameterizedPosition(agx::Real t) const;
1956 
1960  agx::Real findParameterizedValue(agx::Vec3 localPosition) const;
1961 
1965  agx::Real findParameterizedValueFullRange(agx::Vec3 localPosition) const;
1966 
1967 
1971  void analyzeCollidedGeometries();
1972 
1976  void copyGeometries(agxWire::ContactNode* cn);
1977 
1981  agx::Real getEdgeVelocity() const;
1982 
1987  void setEdgeVelocity(agx::Real vel);
1988 
1992  bool getCreatedFromDynamicContact() const;
1993 
1997  bool onSameGeometry( const agxWire::NodeConstIterator otherNodeIt ) const;
1998 
2002  bool onSameGeometry( const agxWire::Node* otherNode ) const;
2003 
2010  bool initialize( agx::Real wireRadius, agx::Real wireRadiusMultiplier );
2011 
2013 
2015 
2016 
2017  protected:
2022 
2026  virtual ~ContactNode();
2027 
2036  void create( agxCollide::Geometry* geometry, const agx::Vec3& shapeRelativeTranslate, const agx::Vec3& shapeEdgeStart, const agx::Vec3& shapeEdgeEnd, const agx::Vec3& shapeEdge );
2037 
2038  protected:
2039  agx::observer_ptr< agxCollide::Geometry > m_geometry;
2040  agx::observer_ptr< agxCollide::Geometry > m_nextGeometry;
2041  agx::Vec3 m_shapeTranslate;
2042  agx::Vec3 m_shapeEdgeStart;
2043  agx::Vec3 m_shapeEdgeEnd;
2044  agx::Vec3 m_shapeEdge;
2045  agx::Vec3 m_shapeFullRangeStart;
2046  agx::Vec3 m_shapeFullRangeEnd;
2047  agx::Vec3 m_shapePreviousPosition;
2048  agx::Vec3 m_edgeOffsetFromSurface;
2049  GeometryRefDepthTable m_collidedGeometries;
2050  size_t m_clamped;
2051  bool m_openAngle;
2052  agx::Real m_edgeVelocity;
2053  MeshIndex m_meshIndex;
2054  };
2055 
2056  AGX_FORCE_INLINE const agx::Vec3& NodeFrame::getWorldPosition() const
2057  {
2058  return m_data[ TRANSLATE ];
2059  }
2060 
2062  {
2063  return m_rb;
2064  }
2065 
2067  AGX_FORCE_INLINE const Node::SpatialState::Data* Node::SpatialState::intermediate( agx::UInt i ) const
2068  {
2069  return i < m_removed.size() ? m_removed.ptr() + i : i == m_removed.size() ? &m_local : nullptr;
2070  }
2071 
2072  AGX_FORCE_INLINE Node::SpatialState::Data* agxWire::Node::SpatialState::local()
2073  {
2074  return &m_local;
2075  }
2076 
2077  AGX_FORCE_INLINE const Node::SpatialState::Data* agxWire::Node::SpatialState::local() const
2078  {
2079  return &m_local;
2080  }
2081 
2082  AGX_FORCE_INLINE agxWire::Node::SpatialState* Node::getSpatialState()
2083  {
2084  return &m_spatialState;
2085  }
2086 
2087  AGX_FORCE_INLINE const agxWire::Node::SpatialState* Node::getSpatialState() const
2088  {
2089  return &m_spatialState;
2090  }
2091 
2092  inline agx::Referenced* Node::getInternalData() const
2093  {
2094  return m_internalData;
2095  }
2096 
2098 
2100  {
2101  return m_type;
2102  }
2103 
2105  {
2106  return (agx::Int( m_type ) & typeMask) != 0;
2107  }
2108 
2110  {
2111  return &m_nf;
2112  }
2113 
2115  {
2116  return &m_nf;
2117  }
2118 
2120  {
2121  return m_nf.getWorldPosition();
2122  }
2123 
2125  {
2126  return m_nf.getRigidBody();
2127  }
2128 
2130  {
2131  return m_bodyFixed;
2132  }
2133 
2135  {
2136  return m_bodyFixed;
2137  }
2138 
2140  {
2141  return m_eye;
2142  }
2143 
2145  {
2146  return m_eye;
2147  }
2148 
2150  {
2151  return m_connecting;
2152  }
2153 
2155  {
2156  return m_connecting;
2157  }
2158 
2160  {
2161  return m_stop;
2162  }
2163 
2165  {
2166  return m_stop;
2167  }
2168 
2170  {
2171  return m_contact;
2172  }
2173 
2175  {
2176  return m_contact;
2177  }
2178 
2180  {
2181  return m_shapeContact;
2182  }
2183 
2185  {
2186  return m_shapeContact;
2187  }
2188 
2190  {
2191  return &m_meshIndex;
2192  }
2193 
2194  AGX_FORCE_INLINE const ContactNode::MeshIndex* ContactNode::getMeshIndex() const
2195  {
2196  return &m_meshIndex;
2197  }
2198 
2200 
2201 }
2202 
#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
#define AGXPHYSICS_EXPORT
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
The body fixed node is attached to a body at a given offset.
BodyFixedNode(agx::RigidBody *rb, agx::Real relTranslate_x, agx::Real relTranslate_y, agx::Real relTranslate_z)
Construct a body fixed wire node given a rigid body and relative position (rigid body frame).
BodyFixedNode(agx::RigidBody *rb, const agx::Vec3 &relativeTranslate=agx::Vec3())
Construct a body fixed wire node given a rigid body and relative position (rigid body frame).
Connecting nodes contains two nodes, one at center of mass and the other at the user defined position...
ConnectingNode(agx::RigidBody *rb, const agx::Vec3 &relativeTranslate, agx::Real radius)
Construct connecting node given body, model frame offset and radius.
void fullTransform()
Transform this and (if present) the center of mass node.
agx::Real getOffsetLength() const
void setCmNode(agxWire::BodyFixedNode *cmNode)
Internal method used by serialization to assign the stored center of mass node.
BodyFixedNode * getCmNode() const
Contact node class is a node that, currently, is defined to live on an edge on a geometry (agxCollide...
MeshIndex * getMeshIndex()
MovementRange
Clamp definition.
Eye node is a type of node that can slide along a wire with or without friction.
EyeNode(agx::RigidBody *rb, agx::Real relTranslate_x, agx::Real relTranslate_y, agx::Real relTranslate_z, const agx::Vec3 &extraEyeVector=agx::Vec3(), agx::Real radius=agx::Real(0))
Construct a sliding node given a body, model center offset and a radius.
EyeNode(agx::RigidBody *rb, const agx::Vec3 &relativeTranslate, agx::Real radius=agx::Real(0))
Construct a sliding node given a body, model center offset and a radius.
void setRadius(agx::Real radius)
Set the radius of this eye node.
EyeNode(agx::RigidBody *rb, const agx::Vec3 &relativeTranslate, const agx::Vec3 &extraEyeVector, agx::Real radius=agx::Real(0))
Construct a sliding node given a body, model center offset and a radius.
agx::Real getRadius() const
EyeNode(agx::RigidBody *rb, agx::Real radius=agx::Real(0))
Construct a sliding node given a body and a radius.
Free node class used to route wires.
void create(const agx::Vec3 &position)
Create method for all constructors.
FreeNode(agx::Real x, agx::Real y, agx::Real z)
Constructs given world position.
FreeNode()
Not defined to create this node without a position.
virtual ~FreeNode()
Destructor.
FreeNode(const agx::Vec3 &position)
Constructs given world position.
Class to control variable node density along wires through routed nodes.
Definition: agxWire/Node.h:424
void set(agx::Real startDistance, agx::Real endDistance, agx::Real nodesPerUnitDistance)
Function to activate the high resolution for a node in a wire.
agx::Real getNodesPerUnitDistance() const
void setNodesPerUnitDistance(agx::Real nodesPerUnitDistance)
Assign new resolution (number of nodes per unit distance).
agx::Real getStartDistance() const
void setStartDistance(agx::Real startDistance)
Assign new start distance.
void setEndDistance(agx::Real endDistance)
Assign new end distance.
agx::Real getEndDistance() const
HighResolutionRange()
Default constructor.
void reverse()
Reverse range (distances).
Node coordinate frame in another frame.
Definition: agxWire/Node.h:89
agx::RigidBody * getRigidBody() const
const agx::Vec3 & getElement(Elements element) const
Data access.
agx::RigidBodyRef m_rb
Definition: agxWire/Node.h:174
const agx::Vec3 & getTranslate() const
agx::Vec3 calculateCmOffset(const agx::RigidBody *rb) const
Manly for writing Jacobian data to the solver.
agx::Vec3 & getElement(Elements element)
Data access.
@ ORG_TRANSLATE
Original translate.
Definition: agxWire/Node.h:93
@ TRANSLATE
Current transformed translate.
Definition: agxWire/Node.h:94
@ REL_BODY_TRANSLATE
Current transformed relative.
Definition: agxWire/Node.h:95
void transform()
Recalculates TRANSLATE and REL_BODY_TRANSLATE.
void setRigidBody(agx::RigidBody *body)
Set rigid body.
void setTranslate(agx::Real x, agx::Real y, agx::Real z)
Set original translate (world frame if this node frame doesn't have a rigid body).
~NodeFrame()
Destructor.
void setTranslate(const agx::Vec3 &translate)
Set original translate (world frame if this node frame doesn't have a rigid body).
NodeFrame()
Default constructor.
Material definition for a wire node Specifies the friction of a wire for sliding through an EyeNode.
Definition: agxWire/Node.h:182
char m_goForward
Bit mask for GO_FORWARD, IS_DIRTY...
Definition: agxWire/Node.h:414
agx::Real getFrictionCoefficient(Direction dir) const
agx::Real getKinematicContactNodeVelocityScale(Direction dir) const
agx::Real getNormalForceMagnitude() const
bool getActive() const
Internal method.
void setActive(bool active)
Internal method.
Direction
Friction direction in a wire.
Definition: agxWire/Node.h:188
@ POSITIVE
Direction towards end of the wire.
Definition: agxWire/Node.h:190
void setStick(bool stick, Direction dir)
Internal method.
agx::Real getMaxForce(Direction dir)
agx::Real m_normalForceMagnitude
Magnitude of the normal force.
Definition: agxWire/Node.h:412
bool isInfCoefficient(Direction dir) const
agx::Real m_violationPerUnitLength
Violation of the friction constraint.
Definition: agxWire/Node.h:416
Direction getActiveDirection() const
void setFrictionCoefficient(agx::Real coeff, Direction dir=BOTH)
Set stick friction coefficient in one or both directions.
agx::Real m_restLength
Rest length of the friction constraint.
Definition: agxWire/Node.h:411
bool isEnabled() const
bool hasValidRestLength() const
Internal method.
bool m_activeConstraint
Tells you if the friction constraint is active.
Definition: agxWire/Node.h:415
bool getEnable() const
bool isStick() const
Internal method.
bool isStick(Direction dir) const
Internal method.
void setKinematicContactNodeVelocityScale(agx::Real scaler, Direction dir=BOTH)
Set slide friction coefficient in one or both directions.
NodeMaterial()
Default constructor.
Class defining a node that is part of a wire.
Definition: agxWire/Node.h:512
agx::Bool isType(agx::Int typeMask) const
Test several types, e.g., node->isType( agxWire::Node::EYE | agxWire::Node::CONNECTING ).
const ShapeContactNode * getAsShapeContact() const
StateInfo
Internal state a node may have.
Definition: agxWire/Node.h:536
Type
The supported node types.
Definition: agxWire/Node.h:518
ContactNode * getAsContact()
EyeNode * getAsEye()
NodeFrame * getFrame()
ConnectingNode * getAsConnecting()
agx::RigidBody * getRigidBody() const
BodyFixedNode * getAsBodyFixed()
const agx::Vec3 & getWorldPosition() const
StopNode * getAsStop()
Stop node, wire end node used by winches.
agx::Vec3 getNormal() const
StopNode(agx::RigidBody *rb, const agx::Vec3 &relativeTranslate)
Construct a stop node (mostly used internally).
void setNormal(agx::Vec3 normal)
Assign new value for the normal.
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:62
Inheritance with partial specialization due to bug with ref_ptr containers.
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
Vector containing 'raw' data.
Definition: agx/Vector.h:246
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#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
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGXCORE_EXPORT Type * getType(const agx::String &name)
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
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
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.
agx::Vec3 AGXTERRAIN_EXPORT getContactForce(const Terrain *terrain, const Shovel *shovel)
Given geometry contacts exists and the solver has solved them - calculates total shovel contact force...
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:40
NodeRefListA NodeContainer
Definition: agxWire/Node.h:53
agx::ref_ptr< ContactNode > ContactNodeRef
WireGeometryType
Definition: agxWire/Node.h:77
NodePtrContainer::iterator NodePtrIterator
Definition: agxWire/Node.h:71
NodePtrContainer::const_iterator NodePtrConstIterator
Definition: agxWire/Node.h:72
agx::Vector< Node * > NodePtrVector
Definition: agxWire/Node.h:74
NodeContainer::const_iterator NodeConstIterator
Definition: agxWire/Node.h:57
agx::List< Node * > NodePtrListA
Definition: agxWire/Node.h:69
agx::ref_ptr< Node > NodeRef
Definition: agxWire/Node.h:51
NodePtrListA NodePtrContainer
Definition: agxWire/Node.h:70
agx::HashVector< agxCollide::GeometryRef, agx::Vec3 > GeometryRefDepthTable
Definition: agxWire/Node.h:47
NodeContainer::const_reverse_iterator NodeConstReverseIterator
Definition: agxWire/Node.h:56
NodeContainer::reverse_iterator NodeReverseIterator
Definition: agxWire/Node.h:55
agx::ref_ptr< FreeNode > FreeNodeRef
agx::Vector< NodeRef > NodeRefVector
Definition: agxWire/Node.h:58
agx::LinearProbingHashTable< Node *, NodeIterator > NodePtrNodeIterHash
Definition: agxWire/Node.h:62
agx::List< NodeRef > NodeRefListA
Definition: agxWire/Node.h:52
NodeContainer::iterator NodeIterator
Definition: agxWire/Node.h:54
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
int32_t Int
Definition: Integer.h:35
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Stability parameters object defining the behavior of the constraints associated to this connecting no...
StabilityParameters(agx::Real youngsModulus, agx::Real damping, agx::Bool active)