Commit 011294e2 authored by Rachel Clipp's avatar Rachel Clipp Committed by Sreekanth Arikatla
Browse files

ENH: Integrate the constant density constraint with rest of PBD workflow

parent 1620d23e
......@@ -45,6 +45,7 @@ public:
Volume,
FEMTet,
FEMHex,
ConstantDensity,
none
};
......
......@@ -28,6 +28,7 @@
#include "imstkPbdAreaConstraint.h"
#include "imstkPbdFETetConstraint.h"
#include "imstkPbdFEHexConstraint.h"
#include "imstkPbdConstantDensityConstraint.h"
#include <g3log/g3log.hpp>
......@@ -395,6 +396,24 @@ PbdModel::initializeDihedralConstraints(const double& stiffness)
return true;
}
bool
PbdModel::initializeConstantDensityConstraint(const double& stiffness)
{
// check if constraint type matches the mesh type
if (m_mesh->getType() != Geometry::Type::SurfaceMesh && m_mesh->getType() != Geometry::Type::TetrahedralMesh && m_mesh->getType() != Geometry::Type::LineMesh &&
m_mesh->getType() != Geometry::Type::HexahedralMesh)
{
LOG(WARNING) << "Constant constraint should come with a mesh"; //TODO: Really only need a point cloud, so may need to change this.
return false;
}
auto c = std::make_shared<PbdConstantDensityConstraint>();
c->initConstraint(*this, stiffness);
m_constraints.push_back(c);
return true;
}
void
PbdModel::projectConstraints()
{
......
......@@ -125,6 +125,13 @@ public:
/// \brief addConstraint add elastic constraint
/// \param constraint
///
bool initializeConstantDensityConstraint(const double& stiffness);
///
/// \todo: add the initialization parameters for the constraint
/// \param...
///
inline void addConstraint(std::shared_ptr<PbdConstraint> constraint) { m_constraints.push_back(constraint); }
///
......
......@@ -118,6 +118,13 @@ PbdObject::initialize(int nCons, ...)
LOG(INFO) << "Creating Dihedral constraints " << stiffness;
m_pbdModel->initializeDihedralConstraints(stiffness);
}
else if (strncmp("ConstantDensity", &s[0], len) == 0)
{
float stiffness;
sscanf(&s[len + 1], "%f", &stiffness);
LOG(INFO) << "Creating Constant Density constraints ";
m_pbdModel->initializeConstantDensityConstraint(stiffness);
}
else
{
exit(0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment