AGX Dynamics  2.35.0.1
ShapeContactNode.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 <agxWire/Node.h>
21 
22 namespace agxWire
23 {
24  class ShapeContactNode;
26  class ShapeContactColliderUtils;
27 
29  {
30  public:
31 
33  {
34  KEEP = 0, REMOVE, REPLACE, REMOVED
35  };
36 
38  {
39  NO_ISSUES = 0,
40  PREV_IS_CLOSE = 1 << 0,
41  NEXT_IS_CLOSE = 1 << 1,
42  PREV_HAS_SAME_NORMAL = 1 << 2,
43  NEXT_HAS_SAME_NORMAL = 1 << 3,
44  ANGLE_NOT_VALID = 1 << 4,
45  NEAR_CLAMP_POSITION = 1 << 5,
46  WORTHLESS_MIDDLE_CONTACT = 1 << 6,
47  REMOVE_IMEDIATELY = 1 << 7,
48  LEAVING_GYPSY = 1 << 8
49 
50  };
51 
52  static ShapeContactNode* createFromWorld(agxCollide::Shape* shape, const agx::Real& wireRadius, const agx::Vec3& surfacePosition, const ShapeCurvature& worldCurvature);
54  static const ShapeContactNode* getAsShapeContact(const agxWire::Node* node);
55 
56  public:
57 
60  ShapeContactNode(agxCollide::Shape* shape, const agx::Real& wireRadius, const agx::Vec3& shapeLocalPoint);
61 
75  agx::Bool initialize(const Wire* wire, const Node* prevNode, const Node* nextNode, const agx::Vec3& surfacePoint);
76 
77 
83 
92 
96  agx::Bool isNearClampPosition(const agx::Real& edgeDefaultLength) const;
97 
101  const agxCollide::Shape* getShape() const;
102 
107 
111  ShapeContactEdge& getShapeContactEdge();
112  const ShapeContactEdge& getShapeContactEdge() const;
113 
118  void setWorldPosition(const agx::Vec3& worldPosition);
119 
124 
128  virtual agx::Vec3 getVelocity() const override;
129 
133  void setVelocity( const agx::Vec3& velocity );
134 
139 
143  void setEdgeVelocity(const agx::Real& vel);
144 
149 
154 
158  void getWorldEdgeEnds(agx::Vec3& edgeStart, agx::Vec3& edgeEnd);
159 
164 
169 
176 
180  void setShapeTranslate( const agx::Vec3& localPos);
181 
186 
191  void setExtraLength(const agx::Real extraLength);
192 
196  void setShapeContactEdge(ShapeContactEdge& shapeContactEdge);
197 
201  void resetEdgeLength(agx::Real edgeHalfLength);
202 
204 
205  protected:
206  virtual ~ShapeContactNode();
207 
208  private:
209  agx::Real m_extraLength;
210 
211  agx::Vec3 m_velocity;
212 
213  ShapeContactEdge m_shapeEdge;
214 
215  };
216 
217 
219  {
221 
223 
224  agx::Real calculateMass(const Wire* wire) const;
225 
229  int state;
230 
231  };
232 
236 
239 
240 
241 }
242 
#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
Base class for a shape.
Definition: Shape.h:54
Eye node is a type of node that can slide along a wire with or without friction.
Class defining a node that is part of a wire.
Definition: agxWire/Node.h:512
agx::Real getEdgeStart() const
virtual agx::Vec3 getVelocity() const override
void setWorldPosition(const agx::Vec3 &worldPosition)
Position the node in world coordinates.
ShapeContactEdge & getShapeContactEdge()
void setExtraLength(const agx::Real extraLength)
Set the extra lenght of this node this timestep.
void setShapeTranslate(const agx::Vec3 &localPos)
Update position using a local translate.
agx::Vec3 getWorldEdgeNormal() const
agx::Bool handleCylinderContact()
Treat special cases where the node shape is a cylinder and hasCylinderContactState() return true.
void getWorldEdgeEnds(agx::Vec3 &edgeStart, agx::Vec3 &edgeEnd)
ShapeContactNode(agxCollide::Shape *shape, const agx::Real &wireRadius, const agx::Vec3 &shapeLocalPoint)
agx::Vec3 getShapeEdgeNormal() const
agx::Vec3 getWorldSurfaceNormal() const
agxCollide::Shape * getShape()
agx::Real getEdgeEnd() const
ShapeContactNode(agxCollide::Shape *shape)
agx::Real getExtraLength() const
const agxCollide::Shape * getShape() const
agx::Real getEdgeVelocity() const
const ShapeContactEdge & getShapeContactEdge() const
void setEdgeVelocity(const agx::Real &vel)
set the velocity of the node along it's edge.
void setShapeContactEdge(ShapeContactEdge &shapeContactEdge)
Set an edge to the node, containing shape etc.
static ShapeContactNode * getAsShapeContact(agxWire::Node *node)
static const ShapeContactNode * getAsShapeContact(const agxWire::Node *node)
agx::Bool initialize(const Wire *wire, const Node *prevNode, const Node *nextNode, const agx::Vec3 &surfacePoint)
Initialize the node:
agx::Bool hasCylinderContactState() const
Find out if the node is a cylinder contact.
void setVelocity(const agx::Vec3 &velocity)
Set the velocity of the node in world coordinates.
static ShapeContactNode * createFromWorld(agxCollide::Shape *shape, const agx::Real &wireRadius, const agx::Vec3 &surfacePosition, const ShapeCurvature &worldCurvature)
void resetEdgeLength(agx::Real edgeHalfLength)
Undo all clamping.
agx::Bool isNearClampPosition(const agx::Real &edgeDefaultLength) const
agx::Vec3 getShapeSurfaceNormal() const
Get data in shape coordinates.
agx::Vec3 getShapeTranslate() const
Interface and placeholder of controllers/helpers for wires.
Definition: Wire.h:62
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: agx/HashSet.h:666
Templated vector class.
Definition: agx/Vector.h:53
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
Implements a Wire model with adaptive resolution.
Definition: MergedBody.h:40
ContactNodeDataList::const_iterator ContactNodeDataListIterator
agx::HashSet< ContactNodeData * > ContactNodeDataSet
agx::List< ContactNodeDataListIterator > ContactNodeDataListIteratorList
agx::ref_ptr< ShapeContactNode > ShapeContactNodeRef
agx::List< ContactNodeData > ContactNodeDataList
agx::Vector< ContactNodeDataList > ContactNodeDataListVector
bool Bool
Definition: Integer.h:48
double Real
Definition: Real.h:42
agx::Real calculateMass(const Wire *wire) const
ShapeContactNode * contactNode
ContactNodeData(ShapeContactNode *contactNode, NodeConstIterator contactNodeIt)
ShapeContactNode::NodeExistancePolicy existancePolicy
NodeConstIterator contactNodeIt