Skip to content

Commit

Permalink
ENH: mcut: disable debug related logic
Browse files Browse the repository at this point in the history
found a crash in dump_mesh,
disable debug currently

Change-Id: I9f210ce074333e95233af08d3e782546107091dd
  • Loading branch information
lanewei120 committed Aug 1, 2023
1 parent f4a9eeb commit dbcfec8
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/libslic3r/MeshBoolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ using MapMatrixXiUnaligned = Eigen::Map<const Eigen::Matrix<int, Eigen::Dynami
TriangleMesh eigen_to_triangle_mesh(const EigenMesh &emesh)
{
auto &VC = emesh.first; auto &FC = emesh.second;

indexed_triangle_set its;
its.vertices.reserve(size_t(VC.rows()));
its.indices.reserve(size_t(FC.rows()));

for (Eigen::Index i = 0; i < VC.rows(); ++i)
its.vertices.emplace_back(VC.row(i).cast<float>());

for (Eigen::Index i = 0; i < FC.rows(); ++i)
its.indices.emplace_back(FC.row(i));

return TriangleMesh { std::move(its) };
}

Expand All @@ -68,12 +68,12 @@ void minus(EigenMesh &A, const EigenMesh &B)
{
auto &[VA, FA] = A;
auto &[VB, FB] = B;

Eigen::MatrixXd VC;
Eigen::MatrixXi FC;
igl::MeshBooleanType boolean_type(igl::MESH_BOOLEAN_TYPE_MINUS);
igl::copyleft::cgal::mesh_boolean(VA, FA, VB, FB, boolean_type, VC, FC);

VA = std::move(VC); FA = std::move(FC);
}

Expand All @@ -92,7 +92,7 @@ void self_union(EigenMesh &A)

igl::MeshBooleanType boolean_type(igl::MESH_BOOLEAN_TYPE_UNION);
igl::copyleft::cgal::mesh_boolean(V, F, Eigen::MatrixXd(), Eigen::MatrixXi(), boolean_type, VC, FC);

A = std::move(result);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
indexed_triangle_set its;
its.vertices.reserve(cgalmesh.num_vertices());
its.indices.reserve(cgalmesh.num_faces());

const auto &faces = cgalmesh.faces();
const auto &vertices = cgalmesh.vertices();
int vsize = int(vertices.size());
Expand All @@ -219,7 +219,7 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
if (i == 3)
its.indices.emplace_back(facet);
}

return its;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ void segment(CGALMesh& src, std::vector<CGALMesh>& dst, double smoothing_alpha =
//if (id > 2) {
// mesh_merged.join(out);
//}
//else
//else
{
dst.emplace_back(std::move(CGALMesh(out)));
}
Expand Down Expand Up @@ -401,9 +401,9 @@ template<class Op> void _mesh_boolean_do(Op &&op, indexed_triangle_set &A, const
CGALMesh meshB;
triangle_mesh_to_cgal(A.vertices, A.indices, meshA.m);
triangle_mesh_to_cgal(B.vertices, B.indices, meshB.m);

_cgal_do(op, meshA, meshB);

A = cgal_to_indexed_triangle_set(meshA.m);
}

Expand Down Expand Up @@ -617,14 +617,14 @@ void do_boolean(McutMesh &srcMesh, const McutMesh &cutMesh, const std::string &b
{
// create context
McContext context = MC_NULL_HANDLE;
McResult err = mcCreateContext(&context, static_cast<McFlags>(MC_DEBUG));
McResult err = mcCreateContext(&context, 0);
// add debug callback according to https://cutdigital.github.io/mcut.site/tutorials/debugging/
mcDebugMessageCallback(context, mcDebugOutput, nullptr);
mcDebugMessageControl(
context,
MC_DEBUG_SOURCE_ALL,
MC_DEBUG_TYPE_ALL,
MC_DEBUG_SEVERITY_ALL,
MC_DEBUG_TYPE_ERROR,
MC_DEBUG_SEVERITY_MEDIUM,
true);
// We can either let MCUT compute all possible meshes (including patches etc.), or we can
// constrain the library to compute exactly the boolean op mesh we want. This 'constrained' case
Expand Down Expand Up @@ -773,14 +773,14 @@ std::vector<TriangleMesh> make_boolean(const McutMesh &srcMesh, const McutMesh &
{
// create context
McContext context = MC_NULL_HANDLE;
McResult err = mcCreateContext(&context, static_cast<McFlags>(MC_DEBUG));
McResult err = mcCreateContext(&context, 0);
// add debug callback according to https://cutdigital.github.io/mcut.site/tutorials/debugging/
mcDebugMessageCallback(context, mcDebugOutput, nullptr);
mcDebugMessageControl(
context,
MC_DEBUG_SOURCE_ALL,
MC_DEBUG_TYPE_ALL,
MC_DEBUG_SEVERITY_ALL,
MC_DEBUG_TYPE_ERROR,
MC_DEBUG_SEVERITY_MEDIUM,
true);
// We can either let MCUT compute all possible meshes (including patches etc.), or we can
// constrain the library to compute exactly the boolean op mesh we want. This 'constrained' case
Expand Down

0 comments on commit dbcfec8

Please sign in to comment.