17 #ifndef AGX_CONSTRAINT_IMPLEMENTATION_H 18 #define AGX_CONSTRAINT_IMPLEMENTATION_H 35 # pragma warning(push) 36 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y 39 #define DEFAULT_COMPLIANCE 1.0E-8 41 #define CONSTRAINT_SUCCESS( success ) \ 43 LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \ 45 m_localState.remove( VALID ); \ 49 #define CONSTRAINT_SUCCESS_RETURN_BOOL( success ) \ 51 LOGGER_WARNING() << "Unable to create constraint. Constraint cleared." << std::endl << LOGGER_END(); \ 53 m_localState.remove( VALID ); \ 60 class ElementaryConstraint;
62 class RegularizationParameters;
63 class SparseRangeReal;
74 : m_numBlocks( 0 ), m_numRows( 0 ), m_numDynBlocks( 0 ) {}
94 BlockType m_numBlocks;
96 BlockType m_numDynBlocks;
106 DEFAULT_BINARY_TAG = NONE,
107 DEFAULT_MANY_BODY_TAG = MANY_BODY
215 agx::UInt getNumRecurrentMergedBodies()
const;
220 ConstraintRigidBodyContainer m_bodies;
223 UInt m_numRecurrentMergedBodies;
230 #if !defined(SWIGPYTHON) 273 const ConstraintRigidBodyContainer& getBodies()
const;
282 const ConstraintRigidBodyContainer& m_bodies;
345 #if !defined(SWIGPYTHON) 365 virtual bool updateValid();
373 virtual void prepare();
389 virtual int getViolation(
agx::Real* g,
int row );
396 agx::Real calculateViolationVectorAverageSize();
408 virtual void getParameters(
agx::Real* violation,
414 int8_t* indexSetState,
425 virtual int getConstraintVelocity(
agx::Real* v,
int row );
449 void onDirectComplianceMatrix(
Real* data,
unsigned int ld )
const;
463 void postSolveIndexSetCallback(
const int8_t* state );
628 virtual void setEnable(
bool enable);
652 virtual void setEnableComputeForces(
agx::Bool enable );
657 virtual agx::Bool getEnableComputeForces()
const;
745 void setEnableLinearization(
bool enable);
750 bool getEnableLinearization()
const;
802 virtual bool removeElementaryConstraint(
const agx::String& name );
809 virtual bool removeSecondaryConstraint(
const agx::String& name );
838 template<
typename T >
839 T* findSecondaryConstraintGivenType(
const agx::UInt count = 0 )
const;
893 void userAPIsetCompliance(
agx::Real compliance,
int dof );
905 void userAPIsetDamping(
agx::Real damping,
int dof );
938 agx::UInt calculateNumActiveRows()
const;
981 SUPPORTS_COMPLIANCE_MATRIX = 1 << 2
1001 void setSupportsComplianceMatrix(
Bool supportsComplianceMatrix );
1040 virtual bool updateValid()
override;
1048 virtual void prepare()
override;
1077 virtual bool rebind()
override;
1103 virtual void setEnableComputeForces(
agx::Bool enable )
override;
1108 virtual agx::Bool getEnableComputeForces()
const override;
1224 bool bodiesValid()
const;
1229 template<
typename T >
1235 template<
typename T >
1236 const T* getAttachment(
agx::UInt index )
const;
1253 return m_numDynamicBodies;
1258 return m_numDynamicBodies;
1263 return m_numNonStaticBodies;
1268 return m_numNonStaticBodies;
1273 return m_originalInfo;
1278 return m_solverInfo;
1283 return m_permutation;
1288 return m_permutation;
1293 return m_bodyIndices;
1298 return m_bodyIndices;
1305 #if !defined(SWIGPYTHON) 1326 return m_bodies.
size();
1344 :
BodyView( state.getSolverInfo(), state.getSolverBodies() ), m_state( state )
1349 :
BodyView( other.m_state.getSolverInfo(), other.m_state.getSolverBodies() ), m_state( other.m_state )
1379 template<
typename T >
1382 UInt currentNumber = 0;
1384 T* ec =
dynamic_cast< T*
>(
m_sc[ i ].get() );
1385 if ( ec !=
nullptr && currentNumber == count )
1387 currentNumber += ec !=
nullptr;
1402 template<
typename T >
1405 return m_attachmentPair[ index ] !=
nullptr ? m_attachmentPair[ index ]->as< T >() :
nullptr;
1408 template<
typename T >
1411 return m_attachmentPair[ index ] !=
nullptr ? m_attachmentPair[ index ]->as< T >() :
nullptr;
1416 return m_attachmentPair[ 0 ] !=
nullptr && !m_attachmentPair[ 0 ]->objectDeleted() &&
1417 m_attachmentPair[ 1 ] !=
nullptr && !m_attachmentPair[ 1 ]->objectDeleted();
1425 return std::atan2( c * b, c * a );
1440 # pragma warning(pop)
std::pair< Real, Real > RealPair
virtual agx::Real getAngle(agx::UInt=0) const
If the constraint supports angle calculations and 'dof' is in range, this method returns the angle of...
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...
const ConstrainedBodiesState & getState() const
agx::UInt getJacobianRowUsage() const
AGXPHYSICS_EXPORT void addSecondaryConstraints2DOF(agx::HighLevelConstraintImplementation *constraint, agx::SeparationAngle *sepAngle, agx::RotationalAngle *rotAngle)
Add secondary controllers with default name to the constraint.
agx::RigidBody * getBodyAt(agx::UInt i)
int m_tag
Tag for this constraint.
virtual void removeNotification()
Callback when this constraint is removed from Simulation.
agx::Bool(* CreateElementaryConstraintsFunction)(class HighLevelConstraintImplementation *)
agx::UInt & numNonStaticBodies()
const agx::ElementaryConstraint::RefContainer & getElementaryConstraints() const
Info with number of dynamic and non-static body counters.
virtual bool getEnable() 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...
Elementary constraint base class with interface and global constraint functionality.
UInt m_numRows
Number of rows used by this constraint.
T * findSecondaryConstraintGivenType(const agx::UInt count=0) const
virtual agx::AttachmentPair * getAttachmentPair() const
virtual agx::Attachment * userAPIgetAttachment(agx::UInt) const
bool m_enable
User controlled enable flag, constraint ignored by solver if false.
Constraint::SolveType getSolveType() const
virtual bool rebind()
The general version of rebind takes the first attachment frame and moves the other attachment frame s...
bool getSolveBoth() const
BlockType dynBlocks() const
ConstraintRigidBodyContainer m_bodies
Vector with observer pointers to bodies.
#define AGXPHYSICS_EXPORT
The base class for a constraint.
ConstrainedBodiesState m_constrainedBodiesState
State of the included bodies, updated in updateValid.
Object that holds the state seen from the user and from the solver.
BlockType getNumBlocks() const
Constraint attachment class for agx::RigidBody.
virtual void preSystemCallback(DynamicsSystem *system)
Before prepare, and before the system writes to the data buffers, this constraint gets a call with th...
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
Implementation of constraint angle ALONG an axis.
agx::ElementaryConstraint::RefContainer & getElementaryConstraints()
virtual agx::AttachmentPair * getAttachmentPair() const override
Base class providing referencing counted objects.
T * getAttachment(agx::UInt index)
const agx::ConstraintRigidBodyContainer & getSolverBodies() const
const ConstraintImplPtrVector & getSubConstraints() const
void incrementConstraintCount(RigidBody *rb) const
Increment the number of constraints connection to rb.
Constraint::SolveType m_solveType
Only for supported solvers.
const agx::ElementaryConstraint::RefContainer & getSecondaryConstraints() const
Elementary secondary constraint to keep constraint angle at a given target position.
virtual void postSystemCallback(DynamicsSystem *system)
Last in the dynamics system step forward loop, this constraint gets a call with the main system...
Essentially a sparse array of bounds.
ConstraintImplPtrVector m_subConstraints
Vector with sub-constraints.
Constraint attachment pair class.
agx::UInt getNumNonStaticBodies() const
Constraint attachment base class for any type of frame.
Elementary secondary constraint to keep constraint angle within two given values. ...
BlockType kinBlocks() const
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
agx::BitState< State, Int32 > LocalState
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
const agx::Int32Vector & getBodyIndices() const
void setNumBlocks(BlockType numBlocks)
virtual void addNotification()
Callback when this constraint is added to Simulation.
BlockStructure m_blockStructure
The block structure; number of block, rows, dynamic blocks etc.
agx::UInt & numDynamicBodies()
virtual agx::Real getCurrentSpeed(agx::UInt=0) const
If this method is implemented, a call to this method will return the current speed of the angle...
Vector< RigidBody *> ConstraintRigidBodyContainer
ConstraintImplPtrVector & getSubConstraints()
agx::ElementaryConstraint::RefContainer & getSecondaryConstraints()
Interface to the bodies, either user or solver, since these bodies can differ when e...
const agx::Int32Vector & getPermutation() const
const BodiesInfo & getSolverInfo() const
agx::UInt getBlockRowIndex() const
agx::RigidBody * getPermutedBodyAt(agx::UInt i)
const BlockStructure & getBlockStructure() const
The rigid body class, combining a geometric model and a frame of reference.
ElementaryConstraint::RefContainer m_ec
Vector of elementary constraints.
Interface to the lower triangle of the compliance matrix block in the system matrix.
virtual agx::Attachment * userAPIgetAttachment(const agx::RigidBody *) const
The complete physical system with bodies, interactions, data layout, time stepper, and solver.
const ConstraintRigidBodyContainer & getBodies() const
Abstract base class for storing/restoring a line/drums with version control.
All ghost variables have compliance and damping attributes.
SolveType
Specifies in what solvers the constraint will be solved.
void setSolveType(Constraint::SolveType type)
Set solve type, either DIRECT, ITERATIVE or DIRECT_AND_ITERATIVE.
The object defining a frame of reference and providing transformations operations.
SolverBodyView(ConstrainedBodiesState &state)
Internal, use ConstriantImplementation::getSolverView().
agx::UInt getNumBodies() const
UInt m_blockRowIndex
Start block row for this constraint in the global matrix.
AttachmentPair m_attachmentPair
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Elementary secondary constraint to drive something given target speed (translational or rotational)...
Class for writing serialized data in binary format to a stream.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Solved both in the ITERATIVE and the DIRECT solver.
void * customData
Custom data for the solvers to store data into.
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
const BodiesInfo & getOriginalInfo() const
Implementation of constraint angle ABOUT an axis.
BodyView(const ConstrainedBodiesState::BodiesInfo &info, const ConstraintRigidBodyContainer &bodies)
Internal, use ConstriantImplementation::getUserView().
void setNumRows(BlockType numRows)
Interface class used by internal objects running in parallel.
AGXPHYSICS_EXPORT void addSecondaryConstraints1DOF(agx::HighLevelConstraintImplementation *constraint, agx::Angle *angle)
Add secondary controllers with default name to the constraint.
Solved only in the ITERATIVE solver.
LocalState m_localState
Current local state, updated all the time, not serialized.
Real getAngle(const Vec3 &a, const Vec3 &b, const Vec3 &c)
a and b should be orthogonal
void setBlockRowIndex(agx::UInt blockRowIndex)
Sets the global start index for this constraint in the global, non-permuted matrix.
#define DOXYGEN_END_INTERNAL_BLOCK()
ElementaryConstraint::RefContainer m_sc
Vector of secondary constraints.
agx::UInt getNumDynamicBodies() const
#define DOXYGEN_START_INTERNAL_BLOCK()
bool m_enableLinearization
When necessary, tweak the values sent to the solver to make violation depend linearly on force or tor...
BlockType getNumRows() const
bool getSolveIterative() const
Pointer to a entity instance of type Physics.ConstraintForces.