trim_with_solid
is called:
// Trim mesh A (m_VA and m_FA) with solid B (m_VB and m_FB)
igl::copyleft::cgal::trim_with_solid(
m_VA, m_FA // input: mesh A
, m_VB, m_FB // input: solid B
, m_V, m_F, m_D, m_J // output
);
The output is processed:
// Loop over output vertex data
for (int i = 0; i < m_V.rows(); ++i) {
// Access all the vertex data
}
// Loop over output triangle (face) data
for (int i = 0; i < m_F.rows(); ++i) {
// Condition to decide if facet is inside or outside the solid B
if (m_D.coeff(i)) {
// The output face is outside the solid B
} else {
// The output face is inside the solid B
}
}
Fine result
Sometimes the trim result is fine. Like this one which is trimming a teapot model with a solid cylinder:
Bad result
But sometimes the trim result is NOT as expected:
As shown by the wire-frame view above, the intersection of teapot and cylinder is identified correctly. But for some reason, this loop is NOT able to detect triangles which are outside the cylinder:
// Loop over output triangle (face) data
for (int i = 0; i < m_F.rows(); ++i) {
// Condition to decide if facet is inside or outside the solid B
if (m_D.coeff(i)) {
// Face is outside the solid B
} else {
// Face is inside the solid B
}
}
Does anybody know what I'm possibly missing?
Previously, I was using Qt3DExtras::QCylinderMesh as solid
Header: Source:B
(VB
andFB
). But it was NOT watertight. I replaced it with the following code which creates watertight cylinders.Now the holes are created properly: