iMSTK
Interactive Medical Simulation Toolkit
imstkPbdEdgeEdgeCCDConstraint.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 {
19 {
20 public:
22  ~PbdEdgeEdgeCCDConstraint() override = default;
23 
24  IMSTK_TYPE_NAME(PbdEdgeEdgeCCDConstraint)
25 
26 public:
30  void initConstraint(
31  Vec3d* prevPtA0, Vec3d* prevPtA1,
32  Vec3d* prevPtB0, Vec3d* prevPtB1,
33  const PbdParticleId& ptA0, const PbdParticleId& ptA1,
34  const PbdParticleId& ptB0, const PbdParticleId& ptB1,
35  double stiffnessA, double stiffnessB,
36  int ccdSubsteps = 25);
37 
38  void projectConstraint(PbdState& bodies,
39  const double dt, const SolverType& type) override;
40 
47  bool computeValueAndGradient(PbdState& bodies,
48  double& c, std::vector<Vec3d>& dcdx) override;
49 
50 protected:
51  // Extra particles used but not solved for
52  std::array<Vec3d*, 2> m_prevEdgeA = { nullptr, nullptr };
53  std::array<Vec3d*, 2> m_prevEdgeB = { nullptr, nullptr };
54  int m_ccdSubsteps = 25;
55 };
56 } // namespace imstk
The PbdCollisionConstraint implements two sided collision. This allows the usage of differing stiffne...
std::pair< int, int > PbdParticleId
Index pair that refers to a particle in a PbdState. Index 0 is the body id, Index 1 is the particle i...
Compound Geometry.
void initConstraint(Vec3d *prevPtA0, Vec3d *prevPtA1, Vec3d *prevPtB0, Vec3d *prevPtB1, const PbdParticleId &ptA0, const PbdParticleId &ptA1, const PbdParticleId &ptB0, const PbdParticleId &ptB1, double stiffnessA, double stiffnessB, int ccdSubsteps=25)
Initialize constraint.
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.
SolverType
Type of solvers.
void projectConstraint(PbdState &bodies, const double dt, const SolverType &type) override
Performs the actual positional solve.
Pushes an edge "outside" the other edge.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.
Definition: imstkPbdBody.h:229