Commit e106bdeb authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: Re-implement computeAttachedSurfaceMesh

Was removed in 33a65d44. Now wraps extractSurfaceMesh.
parent 148efe1e
......@@ -32,11 +32,7 @@ HexahedralMesh::initialize(const std::vector<Vec3d>& vertices,
if(computeAttachedSurfaceMesh)
{
this->m_attachedSurfaceMesh = std::make_shared<imstk::SurfaceMesh>();
if (!this->extractSurfaceMesh(this->m_attachedSurfaceMesh))
{
LOG(WARNING) << "Surface mesh was not extracted!";
}
this->computeAttachedSurfaceMesh();
}
}
......@@ -109,10 +105,20 @@ HexahedralMesh::getVolume() const
return volume/6;
}
void
HexahedralMesh::computeAttachedSurfaceMesh()
{
this->m_attachedSurfaceMesh = std::make_shared<imstk::SurfaceMesh>();
if (!this->extractSurfaceMesh(this->m_attachedSurfaceMesh))
{
LOG(WARNING) << "HexahedralMesh::computeAttachedSurfaceMesh error: surface mesh was not extracted.";
}
}
bool
HexahedralMesh::extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh)
{
LOG(WARNING) << "HexahedralMesh::computeAttachedSurfaceMesh error: not implemented.";
LOG(WARNING) << "HexahedralMesh::extractSurfaceMesh error: not implemented.";
return false;
}
......
......@@ -67,9 +67,13 @@ public:
double getVolume() const override;
///
/// \brief Computes the attached surface mesh
/// \brief Compute and set the attached surface mesh
///
bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh) override;
void computeAttachedSurfaceMesh() override;
///
/// \brief Extract surface Mesh
bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh);
// Accessors
......
......@@ -32,11 +32,7 @@ TetrahedralMesh::initialize(const std::vector<Vec3d>& vertices,
if (computeAttachedSurfaceMesh)
{
this->m_attachedSurfaceMesh = std::make_shared<imstk::SurfaceMesh>();
if (!this->extractSurfaceMesh(this->m_attachedSurfaceMesh))
{
LOG(WARNING) << "Surface mesh was not extracted!";
}
this->computeAttachedSurfaceMesh();
}
}
......@@ -93,12 +89,22 @@ TetrahedralMesh::getVolume() const
return volume;
}
void
TetrahedralMesh::computeAttachedSurfaceMesh()
{
this->m_attachedSurfaceMesh = std::make_shared<imstk::SurfaceMesh>();
if (!this->extractSurfaceMesh(this->m_attachedSurfaceMesh))
{
LOG(WARNING) << "TetrahedralMesh::computeAttachedSurfaceMesh error: surface mesh was not extracted.";
}
}
bool
TetrahedralMesh::extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh)
{
if (!surfaceMesh)
{
LOG(WARNING) << "Cannot extract SurfaceMesh: The surface mesh provided is not instantiated!";
LOG(WARNING) << "TetrahedralMesh::extractSurfaceMesh error: the surface mesh provided is not instantiated.";
return false;
}
......
......@@ -69,13 +69,17 @@ public:
///
double getVolume() const override;
///
/// \brief Compute and set the attached surface mesh
///
void computeAttachedSurfaceMesh() override;
///
/// \brief This method
/// (a) Extracts the confirming triangular mesh from the tetrahedral mesh
/// (b) Checks and flips the triangle connectivity order if it is not consistent
/// (c) Renumbers the vertices
/// TODO: OPTMIZE FOR SPEED
bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh) override;
bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh);
///
/// \brief compute the barycentric weights of a given point in 3D space for a given the tetrahedra
......
......@@ -43,7 +43,7 @@ public:
///
/// \brief Computes the attached surface mesh
///
virtual bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh) = 0;
virtual void computeAttachedSurfaceMesh() = 0;
///
/// \brief Returns the attached surface mesh
......
......@@ -74,8 +74,8 @@ void testReadMesh()
auto mesh = imstk::MeshReader::read("nidus10KTet.vtk");
auto volumeMesh = std::dynamic_pointer_cast<imstk::VolumetricMesh>(mesh);
auto surfaceMesh = std::make_shared<imstk::SurfaceMesh>();
volumeMesh->extractSurfaceMesh(surfaceMesh);
volumeMesh->computeAttachedSurfaceMesh();
auto surfaceMesh = volumeMesh->getAttachedSurfaceMesh();
// Create object and add to scene
auto object = std::make_shared<imstk::VisualObject>("meshObject");
......
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