Updates will be applied - 12:30pm EDT (UTC -400). Site will be down for around 30

Commit e48e52a3 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

Merge branch 'refactorMappingClasses' into 'master'

Refactor geometry mapping classes

See merge request !338
parents 2b80a5b0 d28f3e6d
Pipeline #140699 passed with stage
in 0 seconds
......@@ -74,12 +74,7 @@ int main()
// Construct a map
// Construct one to one nodal map based on the above meshes
auto oneToOneNodalMap = std::make_shared<OneToOneMap>();
oneToOneNodalMap->setMaster(tetMesh);
oneToOneNodalMap->setSlave(surfMesh);
// Compute the map
oneToOneNodalMap->compute();
auto oneToOneNodalMap = std::make_shared<OneToOneMap>(tetMesh, surfMesh);
LOG(INFO) << "wall clock time: " << wct.getTimeElapsed() << " ms.";
LOG(INFO) << "CPU time: " << cput.getTimeElapsed() << " ms.";
......
......@@ -65,20 +65,9 @@ int main()
auto surfMeshModel = std::make_shared<VisualModel>(surfMesh);
surfMeshModel->setRenderMaterial(material);
auto deformMapP2V = std::make_shared<OneToOneMap>();
deformMapP2V->setMaster(tetMesh);
deformMapP2V->setSlave(surfMesh);
deformMapP2V->compute();
auto deformMapC2V = std::make_shared<OneToOneMap>();
deformMapC2V->setMaster(surfMesh);
deformMapC2V->setSlave(surfMesh);
deformMapC2V->compute();
auto deformMapP2C = std::make_shared<OneToOneMap>();
deformMapP2C->setMaster(tetMesh);
deformMapP2C->setSlave(surfMesh);
deformMapP2C->compute();
auto deformMapP2V = std::make_shared<OneToOneMap>(tetMesh, surfMesh);
auto deformMapC2V = std::make_shared<OneToOneMap>(surfMesh, surfMesh);
auto deformMapP2C = std::make_shared<OneToOneMap>(tetMesh, surfMesh);
auto deformableObj = std::make_shared<PbdObject>("Dragon");
deformableObj->addVisualModel(surfMeshModel);
......@@ -118,18 +107,16 @@ int main()
scene->addSceneObject(deformableObj);
bool clothTest = 0;
bool volumetric = !clothTest;
// Build floor geometry
StdVectorOfVec3d vertList;
double width = 100.0;
double height = 100.0;
size_t nRows = 2;
size_t nCols = 2;
vertList.resize(nRows * nCols);
const double width = 100.0;
const double height = 100.0;
const size_t nRows = 2;
const size_t nCols = 2;
const double dy = width / static_cast<double>(nCols - 1);
const double dx = height / static_cast<double>(nRows - 1);
StdVectorOfVec3d vertList;
vertList.resize(nRows * nCols);
for (size_t i = 0; i < nRows; ++i)
{
for (size_t j = 0; j < nCols; j++)
......@@ -162,28 +149,10 @@ int main()
auto floorMeshModel = std::make_shared<VisualModel>(floorMesh);
floorMeshModel->setRenderMaterial(materialFloor);
auto floorMapP2V = std::make_shared<OneToOneMap>();
floorMapP2V->setMaster(floorMesh);
floorMapP2V->setSlave(floorMesh);
floorMapP2V->compute();
auto floorMapP2C = std::make_shared<OneToOneMap>();
floorMapP2C->setMaster(floorMesh);
floorMapP2C->setSlave(floorMesh);
floorMapP2C->compute();
auto floorMapC2V = std::make_shared<OneToOneMap>();
floorMapC2V->setMaster(floorMesh);
floorMapC2V->setSlave(floorMesh);
floorMapC2V->compute();
auto floor = std::make_shared<PbdObject>("Floor");
floor->setCollidingGeometry(floorMesh);
floor->setVisualGeometry(floorMesh);
floor->setPhysicsGeometry(floorMesh);
floor->setPhysicsToCollidingMap(floorMapP2C);
floor->setPhysicsToVisualMap(floorMapP2V);
floor->setCollidingToVisualMap(floorMapC2V);
auto pbdModel2 = std::make_shared<PbdModel>();
pbdModel2->setModelGeometry(floorMesh);
......
......@@ -24,7 +24,6 @@
#include "imstkPbdModel.h"
#include "imstkPbdObject.h"
#include "imstkPbdSolver.h"
#include "imstkOneToOneMap.h"
#include "imstkAPIUtilities.h"
#include "imstkMeshToMeshBruteforceCD.h"
#include "imstkPBDCollisionHandling.h"
......@@ -204,28 +203,10 @@ int main()
auto floorMeshPhysics = std::make_shared<SurfaceMesh>();
floorMeshPhysics->initialize(vertList, triangles);
auto floorMapP2V = std::make_shared<OneToOneMap>();
floorMapP2V->setMaster(floorMeshPhysics);
floorMapP2V->setSlave(floorMeshVisual);
floorMapP2V->compute();
auto floorMapP2C = std::make_shared<OneToOneMap>();
floorMapP2C->setMaster(floorMeshPhysics);
floorMapP2C->setSlave(floorMeshColliding);
floorMapP2C->compute();
auto floorMapC2V = std::make_shared<OneToOneMap>();
floorMapC2V->setMaster(floorMeshColliding);
floorMapC2V->setSlave(floorMeshVisual);
floorMapC2V->compute();
auto floor = std::make_shared<PbdObject>("Floor");
floor->setCollidingGeometry(floorMeshColliding);
floor->setVisualGeometry(floorMeshVisual);
floor->setPhysicsGeometry(floorMeshPhysics);
floor->setPhysicsToCollidingMap(floorMapP2C);
floor->setPhysicsToVisualMap(floorMapP2V);
floor->setCollidingToVisualMap(floorMapC2V);
auto pbdModel2 = std::make_shared<PbdModel>();
pbdModel2->setModelGeometry(floorMeshPhysics);
......
......@@ -65,12 +65,7 @@ int main()
// Construct a map
// Construct one to one nodal map based on the above meshes
auto oneToOneNodalMap = std::make_shared<OneToOneMap>();
oneToOneNodalMap->setMaster(tetMesh);
oneToOneNodalMap->setSlave(surfMesh);
// Compute the map
oneToOneNodalMap->compute();
auto oneToOneNodalMap = std::make_shared<OneToOneMap>(tetMesh, surfMesh);
auto deformableObj = std::make_shared<PbdObject>("Beam");
auto pbdModel = std::make_shared<PbdModel>();
......
......@@ -82,8 +82,32 @@ PBDCollisionHandling::generatePBDConstraints()
{
auto c = std::make_shared<PbdEdgeEdgeConstraint>();
c->initConstraint(dynaModel1, map1->getMapIdx(colData.edgeIdA.first), map1->getMapIdx(colData.edgeIdA.second),
dynaModel2, map2->getMapIdx(colData.edgeIdB.first), map1->getMapIdx(colData.edgeIdB.second));
size_t edgeA1, edgeA2;
if (map1)
{
edgeA1 = map1->getMapIdx(colData.edgeIdA.first);
edgeA2 = map1->getMapIdx(colData.edgeIdA.second);
}
else
{
edgeA1 = colData.edgeIdA.first;
edgeA2 = colData.edgeIdA.second;
}
size_t edgeB1, edgeB2;
if (map2)
{
edgeB1 = map2->getMapIdx(colData.edgeIdB.first);
edgeB2 = map2->getMapIdx(colData.edgeIdB.second);
}
else
{
edgeB1 = colData.edgeIdB.first;
edgeB2 = colData.edgeIdB.second;
}
c->initConstraint(dynaModel1, edgeA1, edgeA2,
dynaModel2, edgeB1, edgeB2);
m_PBDConstraints.push_back(c);
}
......@@ -95,12 +119,26 @@ PBDCollisionHandling::generatePBDConstraints()
const auto c = std::make_shared<PbdPointTriangleConstraint>();
size_t v1, v2, v3;
if (map2)
{
v1 = map2->getMapIdx(triVerts[0]);
v2 = map2->getMapIdx(triVerts[1]);
v3 = map2->getMapIdx(triVerts[2]);
}
else
{
v1 = triVerts[0];
v2 = triVerts[1];
v3 = triVerts[2];
}
c->initConstraint(dynaModel1,
colData.vertexIdB,
dynaModel2,
map2->getMapIdx(triVerts[0]),
map2->getMapIdx(triVerts[1]),
map2->getMapIdx(triVerts[2]));
v1,
v2,
v3);
m_PBDConstraints.push_back(c);
}
......
......@@ -118,6 +118,17 @@ public:
/// \return index of Master corresponding to the idx of Slave
///
virtual size_t getMapIdx(const size_t&) { return 0; }
///
/// \brief Initialize the map
///
virtual void initialize()
{
LOG_IF(FATAL, (!this->isValid())) << "Map is invalid!";
this->compute();
}
protected:
///
......@@ -125,6 +136,17 @@ protected:
///
GeometryMap(Type type) : m_type(type), m_isActive(true) {}
///
/// \brief Protected constructor
///
GeometryMap(const std::shared_ptr<Geometry> master,
const std::shared_ptr<Geometry> slave,
Type type) : m_type(type), m_isActive(true)
{
this->setMaster(master);
this->setSlave(slave);
}
Type m_type; ///> type of the map
bool m_isActive; ///> true if the map us active at runtime
......
......@@ -43,6 +43,14 @@ public:
m_rigidTransform(RigidTransform3d::Identity())
{}
///
/// \brief Constructor
///
IsometricMap(std::shared_ptr<Geometry> master, std::shared_ptr<Geometry> slave) :
GeometryMap(GeometryMap::Type::Isometric),
m_rigidTransform(RigidTransform3d::Identity())
{}
///
/// \brief Destructor
///
......
......@@ -44,6 +44,16 @@ public:
///
OneToOneMap() : GeometryMap(GeometryMap::Type::OneToOne){}
///
/// \brief Constructor
///
OneToOneMap(std::shared_ptr<Geometry> master,
std::shared_ptr<Geometry> slave) : GeometryMap(GeometryMap::Type::OneToOne)
{
this->setMaster(master);
this->setSlave(slave);
}
///
/// \brief Default destructor
///
......
......@@ -44,6 +44,16 @@ public:
///
TetraTriangleMap() : GeometryMap(GeometryMap::Type::TetraTriangle){}
///
/// \brief Constructor
///
TetraTriangleMap(std::shared_ptr<Geometry> master,
std::shared_ptr<Geometry> slave) : GeometryMap(GeometryMap::Type::TetraTriangle)
{
this->setMaster(master);
this->setSlave(slave);
}
///
/// \brief Destructor
///
......
......@@ -89,6 +89,11 @@ public:
{
if (SceneObject::initialize())
{
if (m_collidingToVisualMap)
{
m_collidingToVisualMap->initialize();
}
return true;
}
else
......
......@@ -120,6 +120,16 @@ public:
{
if (CollidingObject::initialize())
{
if (m_physicsToCollidingGeomMap)
{
m_physicsToCollidingGeomMap->initialize();
}
if (m_physicsToVisualGeomMap)
{
m_physicsToVisualGeomMap->initialize();
}
return m_dynamicalModel->initialize();
}
else
......
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