AGX Dynamics  2.37.2.0
agxWire/Node.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 
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
53  typedef NodeRefListA NodeContainer;
59 
61 #if HASH_FOR_WIRE == HASH_NEW
63 #elif HASH_FOR_WIRE == HASH_OLD
65 #else
66  #error
67 #endif
68 
70  typedef NodePtrListA NodePtrContainer;
73 
75 
76  enum class WireGeometryType
77  {
78  SEGMENT,
81  };
82 
89  {
90  public:
91  enum Elements
92  {
96  ENUM_SIZE
97  };
98 
102  NodeFrame();
103 
107  ~NodeFrame();
108 
114  agx::Vec3& getElement( Elements element );
115 
121  const agx::Vec3& getElement( Elements element ) const;
122 
126  void transform();
127 
132  void setTranslate( const agx::Vec3& translate );
133 
140  void setTranslate( agx::Real x, agx::Real y, agx::Real z );
141 
145  const agx::Vec3& getTranslate() const;
146 
156  agx::Vec3 calculateCmOffset( const agx::RigidBody* rb ) const;
157 
161  const agx::Vec3& getWorldPosition() const;
162 
166  void setRigidBody( agx::RigidBody* body );
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 
207  NodeMaterial();
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 
249  agx::Real getFrictionCoefficient( Direction dir ) const;
250 
254  agx::Real getKinematicContactNodeVelocityScale( Direction dir ) const;
255 
261  void setFrictionCoefficient( agx::Real coeff, Direction dir = BOTH );
262 
268  void setKinematicContactNodeVelocityScale( agx::Real scaler, Direction dir = BOTH );
269 
273  bool getEnable() const;
274 
278  bool isEnabled() const;
279 
283  Direction getActiveDirection() const;
284 
288  agx::Real getMaxForce( Direction dir );
289 
293  bool isInfCoefficient( Direction dir ) const;
294 
298  agx::Real getNormalForceMagnitude() const;
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 
448  agx::Real getStartDistance() const;
449 
453  agx::Real getEndDistance() const;
454 
458  agx::Real getNodesPerUnitDistance() const;
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:
506  };
507 
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 
738 
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 
935 
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:
1135  Tension m_tension;
1136  ContactForce m_contactForce;
1137 
1139 
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:
1200  FreeNode();
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:
1358  BodyFixedNode();
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:
1389  EyeNode( agx::RigidBody* rb, agx::Real radius = agx::Real( 0 ) );
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 
1434  agx::Real getRadius() const;
1435 
1441  void setEnableReverseAddOfNormalNode( bool reverseAdd );
1443 
1444 
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:
1519  EyeNode();
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:
1547  };
1548 
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 
1585  BodyFixedNode* getCmNode() const;
1586 
1592  void setCmNode( agxWire::BodyFixedNode* cmNode );
1593 
1597  agx::Real getOffsetLength() const;
1598 
1602  void fullTransform();
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:
1633  ConnectingNode();
1634 
1638  virtual ~ConnectingNode();
1639 
1645  void create( agx::RigidBody* rb, const agx::Vec3& relativeTranslate );
1646 
1647  protected:
1648  BodyFixedNodeRef m_cmNode;
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 
1677  agx::Vec3 getNormal() const;
1678 
1679 
1685  agx::Real getReferenceDistance() const;
1686 
1691  void setReferenceDistance( agx::Real referenceDistance );
1692 
1694 
1696 
1697  protected:
1701  StopNode();
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 
1725  class AGXPHYSICS_EXPORT ContactNode : public Node
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 
1787  ContactNode( ContactNode* cn );
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 
1840 
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:
2021  ContactNode();
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:
2049  GeometryRefDepthTable m_collidedGeometries;
2050  size_t m_clamped;
2053  MeshIndex m_meshIndex;
2054  };
2055 
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 
2099  AGX_FORCE_INLINE Node::Type Node::getType() const
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 
2134  AGX_FORCE_INLINE const BodyFixedNode* Node::getAsBodyFixed() const
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 
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
agx::RigidBody * getRigidBody() const
Direction
Friction direction in a wire.
Definition: agxWire/Node.h:187
AGXCORE_EXPORT Type * getType(const agx::String &name)
agx::Vec3 m_normal
WireGeometryType
Definition: agxWire/Node.h:76
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
Stability parameters object defining the behavior of the constraints associated to this connecting no...
agx::ref_ptr< EyeNode > m_childNode
Type
The supported node types.
Definition: agxWire/Node.h:517
agx::Vector< NodeRef > NodeRefVector
Definition: agxWire/Node.h:58
bool m_activeConstraint
Tells you if the friction constraint is active.
Definition: agxWire/Node.h:415
Connecting nodes contains two nodes, one at center of mass and the other at the user defined position...
const agx::Vec3 & getWorldPosition() const
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...
NodeRefListA NodeContainer
Definition: agxWire/Node.h:53
MovementRange
Clamp definition.
bool Bool
Definition: Integer.h:48
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:60
NodeFrame m_nf
Node coordinate frame in another frame.
Definition: agxWire/Node.h:88
agx::Vec3 m_shapeFullRangeStart
NodeContainer::iterator NodeIterator
Definition: agxWire/Node.h:54
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
#define AGXPHYSICS_EXPORT
Inheritance with partial specialization due to bug with ref_ptr containers.
Free node class used to route wires.
int32_t Int
Definition: Integer.h:35
agx::ref_ptr< EyeNode > EyeNodeRef
agx::List< Node *> NodePtrListA
Definition: agxWire/Node.h:69
agx::Real m_violationPerUnitLength
Violation of the friction constraint.
Definition: agxWire/Node.h:416
agx::Real m_restLength
Rest length of the friction constraint.
Definition: agxWire/Node.h:411
NodeContainer::reverse_iterator NodeReverseIterator
Definition: agxWire/Node.h:55
ContactForce m_contactForce
#define AGX_FORCE_INLINE
Definition: Object.h:59
agx::HashVector< agxCollide::GeometryRef, agx::Vec3 > GeometryRefDepthTable
Definition: agxWire/Node.h:47
BodyFixedNode * m_bodyFixed
char m_goForward
Bit mask for GO_FORWARD, IS_DIRTY...
Definition: agxWire/Node.h:414
FreeNode * m_free
Material definition for a wire node Specifies the friction of a wire for sliding through an EyeNode...
Definition: agxWire/Node.h:181
agx::RigidBody * getRigidBody() const
ContactNode * m_contact
NodePtrContainer::const_iterator NodePtrConstIterator
Definition: agxWire/Node.h:72
const agx::Vec3 & getWorldPosition() const
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::Bool isType(agx::Int typeMask) const
Test several types, e.g., node->isType( agxWire::Node::EYE | agxWire::Node::CONNECTING )...
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
HighResolutionRange m_highResolutionRange
agx::Vec3 m_shapeTranslate
agx::observer_ptr< agxCollide::Geometry > m_nextGeometry
agx::ref_ptr< FreeNode > FreeNodeRef
The body fixed node is attached to a body at a given offset.
EyeNode * getAsEye()
agx::Vec3 m_shapeEdgeStart
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:61
uint32_t UInt
Definition: Integer.h:34
ContactNode * getAsContact()
Direction towards end of the wire.
Definition: agxWire/Node.h:190
agx::Vec3 m_shapeFullRangeEnd
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:39
ConnectingNode * getAsConnecting()
agx::ref_ptr< ContactNode > ContactNodeRef
agx::observer_ptr< agxCollide::Geometry > m_geometry
NodeContainer::const_reverse_iterator NodeConstReverseIterator
Definition: agxWire/Node.h:56
ShapeContactNode * m_shapeContact
Stop node, wire end node used by winches.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
ConnectingNode * m_connecting
const ShapeContactNode * getAsShapeContact() const
agx::ref_ptr< agx::Referenced > m_customData
StopNode * getAsStop()
Tension m_tension
NodePtrListA NodePtrContainer
Definition: agxWire/Node.h:70
agx::ref_ptr< Node > NodeRef
Definition: agxWire/Node.h:51
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
NodeMaterial m_material
agx::Real m_radius
agx::List< NodeRef > NodeRefListA
Definition: agxWire/Node.h:52
BodyFixedNode * getAsBodyFixed()
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
StopNode * m_stop
Class to control variable node density along wires through routed nodes.
Definition: agxWire/Node.h:423
NodePtrContainer::iterator NodePtrIterator
Definition: agxWire/Node.h:71
SpatialState m_spatialState
#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::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...
agx::Vector< Node *> NodePtrVector
Definition: agxWire/Node.h:74
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Contact node class is a node that, currently, is defined to live on an edge on a geometry (agxCollide...
MeshIndex * getMeshIndex()
GeometryRefDepthTable m_collidedGeometries
agx::Vec3 m_edgeOffsetFromSurface
NodeFrame * getFrame()
NodeContainer::const_iterator NodeConstIterator
Definition: agxWire/Node.h:57
agx::observer_ptr< Node > m_parent
Current transformed relative.
Definition: agxWire/Node.h:95
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
StateInfo
Internal state a node may have.
Definition: agxWire/Node.h:535
Class defining a node that is part of a wire.
Definition: agxWire/Node.h:511
agx::RigidBodyRef m_rb
Definition: agxWire/Node.h:174
double Real
Definition: Real.h:42
Eye node is a type of node that can slide along a wire with or without friction.
EyeNode * m_eye
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
agx::Vec3 m_shapePreviousPosition
Inheritance with partial specialization due to bug with ref_ptr containers.
Current transformed translate.
Definition: agxWire/Node.h:94
StoreRestoreData m_storeRestoreData
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
FrictionDirection
Internal.
Definition: agxWire/Node.h:197
agx::LinearProbingHashTable< Node *, NodeIterator > NodePtrNodeIterHash
Definition: agxWire/Node.h:62
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
agx::Real m_normalForceMagnitude
Magnitude of the normal force.
Definition: agxWire/Node.h:412