AGX Dynamics  2.37.3.2
StrongInteraction.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/Interaction.h>
20 
21 #if defined(_MSC_VER)
22 #pragma warning( push )
23 #pragma warning( disable : 4589 ) // Disable: 4589: Constructor of abstract class 'agx::FrictionModel' ignores initializer for virtual base class 'agxStream::Serializable'
24 #endif
25 
26 
27 namespace agxRender
28 {
29  class RenderManager;
30 }
31 
32 namespace agx
33 {
34  class SparseRangeReal;
35 
37 
43  {
44  public:
45 
46 #if (!defined SWIG ) || (!defined SWIGCSHARP && !defined SWIGJAVA)
48  {
49  MatrixData( agx::Physics::RigidBodyPtr rb ) : rb( rb ), data( nullptr ), writeTranspose( false ), leadingDimension( agx::InvalidIndex ), blockRowIndex( agx::InvalidIndex ) {}
50 
51  template< typename T >
52  void plusEqual( const T& rhs, const agx::UInt numRows, const agx::UInt numCols );
53 
57  unsigned int leadingDimension; // Argument to Sabre, has to be 'unsigned int'.
59  };
60 #endif
61 
62  public:
67  void setEnable( agx::Bool enable );
68 
72  agx::Bool getEnable() const;
73 
77  agx::Bool getValid() const;
78 
79  public:
83  virtual agx::RigidBody* getRigidBody1() const = 0;
84 
88  virtual agx::RigidBody* getRigidBody2() const = 0;
89 
93  virtual void addNotification() override;
94 
98  virtual void removeNotification() override;
99 
103  virtual void preSystemCallback( agx::DynamicsSystem* dynamicsSystem ) override;
104 
108  virtual void postSystemCallback( agx::DynamicsSystem* dynamicsSystem ) override;
109 
113  virtual void render( agxRender::RenderManager* mgr, float scale );
114 
118  virtual void prepare();
119 
120 #if (!defined SWIG ) || (!defined SWIGCSHARP && !defined SWIGJAVA)
121 
124  virtual void writeMatrixData( agx::StrongInteraction::MatrixData rb1DiagonalBlock,
125  agx::StrongInteraction::MatrixData rb2DiagonalBlock,
126  agx::StrongInteraction::MatrixData offDiagonalBlock ) = 0;
127 
136  virtual void writeRhs( agx::Physics::RigidBodyPtr rb1,
137  agx::Real* rb1Rhs,
139  agx::Real* rb2Rhs,
140  agx::Bool isRestingSolve ) = 0;
141 #endif
142 
146  virtual void addNlCallbacks( agx::SparseRangeReal& sparseRangeReal ) const;
147 
149 
150  protected:
155 
159  virtual ~StrongInteraction();
160 
165  void setValid( agx::Bool valid );
166 
170  virtual void store( agxStream::OutputArchive& out ) const override;
171 
175  virtual void restore( agxStream::InputArchive& in ) override;
176 
177  private:
178  Bool m_valid;
179  Bool m_enable;
180  };
181 
182  template< typename T >
183  void StrongInteraction::MatrixData::plusEqual( const T& rhs, const agx::UInt numRows, const agx::UInt numCols )
184  {
185  agxAssert( data != nullptr );
186  if ( writeTranspose )
187  for ( agx::UInt i = 0; i < numRows; ++i )
188  for ( agx::UInt j = 0; j < numCols; ++j )
189  data[ j * leadingDimension + i ] += rhs[ i ][ j ];
190  else
191  for ( agx::UInt i = 0; i < numRows; ++i )
192  for ( agx::UInt j = 0; j < numCols; ++j )
193  data[ i * leadingDimension + j ] += rhs[ i ][ j ];
194  }
195 }
196 
197 #if defined(_MSC_VER)
198 #pragma warning( pop ) // restoring: warning( disable : 4127 )
199 #endif
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...
bool Bool
Definition: Integer.h:48
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
#define AGXPHYSICS_EXPORT
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Namespace containing classes for handling debug rendering of collision geometries, constraints, contacts and rigid bodies.
Definition: Constraint.h:35
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
MatrixData(agx::Physics::RigidBodyPtr rb)
The base class for interactions.
Definition: Interaction.h:31
Essentially a sparse array of bounds.
Definition: SparseTypes.h:73
Pointer to a entity instance of type Physics.RigidBody.
uint32_t UInt
Definition: Integer.h:34
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
#define agxAssert(expr)
Definition: debug.h:143
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
The complete physical system with bodies, interactions, data layout, time stepper, and solver.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
agx::Physics::RigidBodyPtr rb
double Real
Definition: Real.h:42