Commit f911c88d authored by Nghia Truong's avatar Nghia Truong

COMP: Fix miscellaneous compiling errors due to previous changes

parent 700011a0
......@@ -50,7 +50,7 @@
#include <g3log/g3log.hpp>
#define IMSTK_CHECK_GEOMETRIES(obj1, obj2) \
#define IMSTK_CHECK_FOR_VALID_GEOMETRIES(obj1, obj2) \
LOG_IF(FATAL, (obj1 == nullptr || obj2 == nullptr)) << \
"CollisionDetection::makeCollisionDetectionObject() error: " << \
"Invalid object geometries were provided for the given collision detection type.\n" << \
......@@ -71,35 +71,35 @@ CollisionDetection::makeCollisionDetectionObject(const Type
{
auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry());
auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(pointset, sphere)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, sphere)
return std::make_shared<PointSetToSphereCD>(pointset, sphere, colData);
}
case Type::PointSetToPlane:
{
auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry());
auto plane = std::dynamic_pointer_cast<Plane>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(pointset, plane)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, plane)
return std::make_shared<PointSetToPlaneCD>(pointset, plane, colData);
}
case Type::PointSetToCapsule:
{
auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry());
auto capsule = std::dynamic_pointer_cast<Capsule>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(pointset, capsule)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, capsule)
return std::make_shared<PointSetToCapsuleCD>(pointset, capsule, colData);
}
case Type::PointSetToSpherePicking:
{
auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry());
auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(pointset, sphere)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, sphere)
return std::make_shared<PointSetToSpherePickingCD>(pointset, sphere, colData);
}
case Type::PointSetToVolumeMesh:
{
auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry());
auto triMesh = std::dynamic_pointer_cast<SurfaceMesh>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(pointset, triMesh)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, triMesh)
return std::make_shared<PointSetToVolumeMeshCD>(pointset, triMesh, colData);
}
// Mesh to mesh
......@@ -107,14 +107,14 @@ CollisionDetection::makeCollisionDetectionObject(const Type
{
auto meshA = std::dynamic_pointer_cast<SurfaceMesh>(objA->getCollidingGeometry());
auto meshB = std::dynamic_pointer_cast<SurfaceMesh>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(meshA, meshB)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(meshA, meshB)
return std::make_shared<SurfaceMeshToSurfaceMeshCD>(meshA, meshB, colData);
}
case Type::SurfaceMeshToSurfaceMeshCCD:
{
auto meshA = std::dynamic_pointer_cast<SurfaceMesh>(objA->getCollidingGeometry());
auto meshB = std::dynamic_pointer_cast<SurfaceMesh>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(meshA, meshB)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(meshA, meshB)
return std::make_shared<SurfaceMeshToSurfaceMeshCCD>(meshA, meshB, colData);
}
......@@ -122,7 +122,7 @@ CollisionDetection::makeCollisionDetectionObject(const Type
{
auto tet1 = std::dynamic_pointer_cast<TetrahedralMesh>(objA->getCollidingGeometry());
auto tet2 = std::dynamic_pointer_cast<TetrahedralMesh>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(tet1, tet2)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(tet1, tet2)
return std::make_shared<TetraToTetraCD>(tet1, tet2, colData);
}
......@@ -131,28 +131,28 @@ CollisionDetection::makeCollisionDetectionObject(const Type
{
auto plane = std::dynamic_pointer_cast<Plane>(objA->getCollidingGeometry());
auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(plane, sphere)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(plane, sphere)
return std::make_shared<UnidirectionalPlaneToSphereCD>(plane, sphere, colData);
}
case Type::BidirectionalPlaneToSphere:
{
auto plane = std::dynamic_pointer_cast<Plane>(objA->getCollidingGeometry());
auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(plane, sphere)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(plane, sphere)
return std::make_shared<BidirectionalPlaneToSphereCD>(plane, sphere, colData);
}
case Type::SphereToSphere:
{
auto sphereA = std::dynamic_pointer_cast<Sphere>(objA->getCollidingGeometry());
auto sphereB = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(sphereA, sphereB)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(sphereA, sphereB)
return std::make_shared<SphereToSphereCD>(sphereA, sphereB, colData);
}
case Type::SphereToCylinder:
{
auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry());
auto cylinder = std::dynamic_pointer_cast<Cylinder>(objA->getCollidingGeometry());
IMSTK_CHECK_GEOMETRIES(sphere, cylinder)
IMSTK_CHECK_FOR_VALID_GEOMETRIES(sphere, cylinder)
return std::make_shared<SphereToCylinderCD>(sphere, cylinder, colData);
}
......
......@@ -38,11 +38,7 @@ struct CollisionData;
///
class PointSetToVolumeMeshCD : public CollisionDetection
{
friend class SurfaceMeshToSurfaceMeshCD;
friend class SurfaceMeshToVolumeMeshCD;
friend class VolumeMeshToVolumeMeshCD;
public:
///
/// \brief Constructor
///
......
......@@ -52,7 +52,6 @@ TetraToTetraCD::findCollisionsForMeshWithinHashTable(const std::shared_ptr<Tetra
auto nodesMeshA = m_meshA->getVertexPositions();
auto nodesMeshB = m_meshB->getVertexPositions();
ParallelUtils::SpinLock lock;
ParallelUtils::parallelFor(mesh->getNumTetrahedra(),
[&](const size_t tId)
{
......@@ -100,12 +99,7 @@ TetraToTetraCD::findCollisionsForMeshWithinHashTable(const std::shared_ptr<Tetra
{
auto coordSum = bCoord[0] + bCoord[1] + bCoord[2] + bCoord[3];
assert(coordSum <= 1.0 + eps2 && coordSum >= 1.0 - eps2);
lock.lock();
LOG(FATAL) << "UNIMPLEMENTED";
//todo
// m_colData->PTColData.safeAppend({ cType, vId, tId, bCoord });
lock.unlock();
m_colData->PTColData.safeAppend({ cType, static_cast<uint32_t>(vId), static_cast<uint32_t>(tId), bCoord });
}
} //if not this tetrahedron
} //for vertices
......
......@@ -86,23 +86,23 @@ BoneDrillingCH::erodeBone()
[&](const size_t idx)
{
auto& cd = m_colData->MAColData[idx];
if (m_nodeRemovalStatus[cd.nodeId])
if (m_nodeRemovalStatus[cd.nodeIdx])
{
return;
}
m_nodalDensity[cd.nodeId] -= 0.001 * (m_angularSpeed / m_BoneHardness) * m_stiffness * cd.penetrationVector.norm() * 0.001;
m_nodalDensity[cd.nodeIdx] -= 0.001 * (m_angularSpeed / m_BoneHardness) * m_stiffness * cd.penetrationVector.norm() * 0.001;
if (m_nodalDensity[cd.nodeId] <= 0.)
if (m_nodalDensity[cd.nodeIdx] <= 0.)
{
// TODO: Unused variable, maybe used in furture?
// lock.lock();
// m_erodedNodes.push_back(cd.nodeId);
// lock.unlock();
m_nodeRemovalStatus[cd.nodeId] = true;
m_nodeRemovalStatus[cd.nodeIdx] = true;
// tag the tetra that will be removed
for (auto& tetId : m_nodalCardinalSet[cd.nodeId])
for (auto& tetId : m_nodalCardinalSet[cd.nodeIdx])
{
boneTetMesh->setTetrahedraAsRemoved(static_cast<unsigned int>(tetId));
boneTetMesh->setTopologyChangedFlag(true);
......
......@@ -27,8 +27,8 @@
namespace imstk
{
class CollidingObject;
class CollisionData;
class DeviceTracker;
struct CollisionData;
///
/// \class BoneDrillingCH
......
......@@ -146,4 +146,4 @@ PBDCollisionHandling::generatePBDConstraints()
}
//TODO: generating PbdPointTriangleConstraint from the VTColData should be added
}
}
\ No newline at end of file
}
......@@ -30,10 +30,10 @@
namespace imstk
{
class CollidingObject;
class CollisionData;
class PbdObject;
class PbdCollisionConstraint;
class PbdSolver;
struct CollisionData;
///
/// \class PBDCollisionHandling
......
......@@ -116,9 +116,9 @@ PenaltyCH::computeContactForcesDiscreteDeformable(const std::shared_ptr<Deformab
ParallelUtils::SpinLock lock;
ParallelUtils::parallelFor(m_colData->MAColData.getSize(),
[&](const size_t idx) {
const auto& cd = m_colData->MAColData[idx];
const auto nodeDofID = static_cast<Eigen::Index>(3 * cd.nodeId);
const auto unit = cd.penetrationVector / cd.penetrationVector.norm();
const auto& cd = m_colData->MAColData[idx];
const auto nodeDofID = static_cast<Eigen::Index>(3 * cd.nodeIdx);
const auto unit = cd.penetrationVector / cd.penetrationVector.norm();
auto velocityProjection = Vec3d(velVector(nodeDofID),
velVector(nodeDofID + 1),
......@@ -128,7 +128,7 @@ PenaltyCH::computeContactForcesDiscreteDeformable(const std::shared_ptr<Deformab
const auto nodalForce = -m_stiffness * cd.penetrationVector - m_damping * velocityProjection;
lock.lock();
force(nodeDofID) += nodalForce.x();
force(nodeDofID) += nodalForce.x();
force(nodeDofID + 1) += nodalForce.y();
force(nodeDofID + 2) += nodalForce.z();
lock.unlock();
......
......@@ -31,7 +31,7 @@ namespace imstk
{
class CollidingObject;
class DeformableObject;
class CollisionData;
struct CollisionData;
///
/// \class PenaltyCH
......
......@@ -74,15 +74,15 @@ PickingCH::addPickConstraints(std::shared_ptr<DeformableObject> deformableObj)
ParallelUtils::SpinLock lock;
ParallelUtils::parallelFor(m_colData->NodePickData.getSize(),
[&](const size_t idx) {
const auto& cd = m_colData->NodePickData[idx];
const auto nodeDof = static_cast<Eigen::Index>(3 * cd.nodeId);
const auto vprev = Vec3d(Vprev(nodeDof), Vprev(nodeDof + 1), Vprev(nodeDof + 2));
const auto uprev = Vec3d(Uprev(nodeDof), Uprev(nodeDof + 1), Uprev(nodeDof + 2));
const auto x = (cd.ptPos + PhysTetMesh->getVertexPosition(cd.nodeId) -
PhysTetMesh->getInitialVertexPosition(cd.nodeId) - uprev) / dT - vprev;
auto pickProjector = LinearProjectionConstraint(cd.nodeId, true);
pickProjector.setProjectorToDirichlet(static_cast<unsigned int>(cd.nodeId), x);
const auto& cd = m_colData->NodePickData[idx];
const auto nodeDof = static_cast<Eigen::Index>(3 * cd.nodeIdx);
const auto vprev = Vec3d(Vprev(nodeDof), Vprev(nodeDof + 1), Vprev(nodeDof + 2));
const auto uprev = Vec3d(Uprev(nodeDof), Uprev(nodeDof + 1), Uprev(nodeDof + 2));
const auto x = (cd.ptPos + PhysTetMesh->getVertexPosition(cd.nodeIdx) -
PhysTetMesh->getInitialVertexPosition(cd.nodeIdx) - uprev) / dT - vprev;
auto pickProjector = LinearProjectionConstraint(cd.nodeIdx, true);
pickProjector.setProjectorToDirichlet(static_cast<unsigned int>(cd.nodeIdx), x);
lock.lock();
m_DynamicLinearProjConstraints->push_back(std::move(pickProjector));
......
......@@ -32,7 +32,7 @@ namespace imstk
{
class CollidingObject;
class DeformableObject;
class CollisionData;
struct CollisionData;
///
/// \class PickingCH
......
......@@ -53,7 +53,7 @@ SPHCollisionHandling::processCollisionData()
[&](const size_t idx)
{
const auto& cd = m_colData->MAColData[idx];
const auto pidx = cd.nodeId; // Fluid particle index
const auto pidx = cd.nodeIdx; // Fluid particle index
auto n = cd.penetrationVector; // This vector should point into solid object
// Correct particle position
......
......@@ -27,7 +27,7 @@
namespace imstk
{
class CollidingObject;
class CollisionData;
struct CollisionData;
///
/// \class VirtualCouplingCH
......
......@@ -39,8 +39,7 @@ public:
///
/// \brief Constructor
///
PbdInteractionPair(std::shared_ptr<PbdObject> A, std::shared_ptr<PbdObject> B) :
first(A), second(B) {}
PbdInteractionPair(const std::shared_ptr<PbdObject>& A, const std::shared_ptr<PbdObject>& B);
///
/// \brief Clear the collisions from previous step
......@@ -75,8 +74,12 @@ public:
private:
std::vector<std::shared_ptr<PbdCollisionConstraint>> m_collisionConstraints;
std::shared_ptr<PbdObject> first;
std::shared_ptr<PbdObject> second;
std::shared_ptr<PbdObject> m_firstObj;
std::shared_ptr<PbdObject> m_secondObj;
double m_firstObjProximity;
double m_secondObjProximity;
unsigned int maxIter;
};
}
......@@ -47,6 +47,10 @@ public:
MaxL2NormFunctor(const StdVectorOfVec3r& data) : m_Data(data) {}
MaxL2NormFunctor(MaxL2NormFunctor& pObj, tbb::split) : m_Data(pObj.m_Data) {}
// Prohibit copying
MaxL2NormFunctor() = delete;
MaxL2NormFunctor& operator=(const MaxL2NormFunctor&) = delete;
void operator()(const tbb::blocked_range<size_t>& r)
{
for (size_t i = r.begin(); i != r.end(); ++i)
......@@ -74,6 +78,10 @@ public:
AABBFunctor(const StdVectorOfVec3r& data) : m_Data(data) { if (data.size() > 0) { m_UpperCorner = data[0]; } }
AABBFunctor(AABBFunctor& pObj, tbb::split) : m_Data(pObj.m_Data) {}
// Prohibit copying
AABBFunctor() = delete;
AABBFunctor& operator=(const AABBFunctor&) = delete;
void operator()(const tbb::blocked_range<size_t>& r)
{
for (size_t i = r.begin(); i != r.end(); ++i)
......
Markdown is supported
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