iMSTK
Interactive Medical Simulation Toolkit
imstkPbdBaryPointToPointConstraint.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkPbdCollisionConstraint.h"
10 
11 namespace imstk
12 {
24 {
25 public:
27  ~PbdBaryPointToPointConstraint() override = default;
28 
29  IMSTK_TYPE_NAME(PbdBaryPointToPointConstraint)
30 
31  double getRestLength() const { return m_restLength; }
32  void setRestLength(const double length) { m_restLength = length; }
33 
37  Vec3d computeInterpolantDifference(PbdState& bodies) const;
38 
51  PbdState& bodies,
52  const std::vector<PbdParticleId>& ptIdsA,
53  const std::vector<double>& weightsA,
54  const std::vector<PbdParticleId>& ptIdsB,
55  const std::vector<double>& weightsB,
56  const double stiffnessA, const double stiffnessB);
57 
61  void initConstraint(
62  const std::vector<PbdParticleId>& ptIdsA,
63  const std::vector<double>& weightsA,
64  const std::vector<PbdParticleId>& ptIdsB,
65  const std::vector<double>& weightsB,
66  const double stiffnessA, const double stiffnessB,
67  const double restLength = 0.0);
68 
75  bool computeValueAndGradient(PbdState& bodies,
76  double& c, std::vector<Vec3d>& dcdx) override;
77 
81  double getRestValue() const { return m_restLength; }
82 
83 protected:
84  double m_restLength = 0.0;
85  // Bary weights A and B ordered in sequence
86  std::vector<double> m_weights;
87 };
88 } // namespace imstk
The PbdCollisionConstraint implements two sided collision. This allows the usage of differing stiffne...
Compound Geometry.
void initConstraint(const std::vector< PbdParticleId > &ptIdsA, const std::vector< double > &weightsA, const std::vector< PbdParticleId > &ptIdsB, const std::vector< double > &weightsB, const double stiffnessA, const double stiffnessB, const double restLength=0.0)
Initialize the constraint.
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.
double getRestValue() const
Return the rest configuration for the constraint.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.
Definition: imstkPbdBody.h:229
Constrains two points from two separate cells/elements given via barycentric coordinates to be coinci...
void initConstraintToRest(PbdState &bodies, const std::vector< PbdParticleId > &ptIdsA, const std::vector< double > &weightsA, const std::vector< PbdParticleId > &ptIdsB, const std::vector< double > &weightsB, const double stiffnessA, const double stiffnessB)
initialize constraint with current distance between the points as the resting length ...