mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 05:07:51 -06:00
TriangleMeshSlicer: Got rid of admesh!
This commit is contained in:
parent
1256aebd88
commit
70b4915f9c
18 changed files with 443 additions and 452 deletions
|
@ -29,7 +29,6 @@ void MeshClipper::set_mesh(const TriangleMesh& mesh)
|
|||
m_mesh = &mesh;
|
||||
m_triangles_valid = false;
|
||||
m_triangles2d.resize(0);
|
||||
m_tms.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,11 +67,6 @@ void MeshClipper::render_cut()
|
|||
|
||||
void MeshClipper::recalculate_triangles()
|
||||
{
|
||||
if (! m_tms) {
|
||||
m_tms.reset(new TriangleMeshSlicer);
|
||||
m_tms->init(m_mesh, [](){});
|
||||
}
|
||||
|
||||
const Transform3f& instance_matrix_no_translation_no_scaling = m_trafo.get_matrix(true,false,true).cast<float>();
|
||||
const Vec3f& scaling = m_trafo.get_scaling_factor().cast<float>();
|
||||
// Calculate clipping plane normal in mesh coordinates.
|
||||
|
@ -82,16 +76,15 @@ void MeshClipper::recalculate_triangles()
|
|||
float height_mesh = m_plane.distance(m_trafo.get_offset()) * (up_noscale.norm()/up.norm());
|
||||
|
||||
// Now do the cutting
|
||||
std::vector<ExPolygons> list_of_expolys;
|
||||
m_tms->set_up_direction(up.cast<float>());
|
||||
m_tms->slice(std::vector<float>{height_mesh}, MeshSlicingParamsExtended{}, &list_of_expolys);
|
||||
MeshSlicingParamsEx slicing_params;
|
||||
slicing_params.trafo.rotate(Eigen::Quaternion<double, Eigen::DontAlign>::FromTwoVectors(up, Vec3d::UnitZ()).cast<float>());
|
||||
|
||||
assert(m_mesh->has_shared_vertices());
|
||||
std::vector<ExPolygons> list_of_expolys = slice_mesh_ex(m_mesh->its, std::vector<float>{height_mesh}, slicing_params);
|
||||
|
||||
if (m_negative_mesh && !m_negative_mesh->empty()) {
|
||||
TriangleMeshSlicer negative_tms{m_negative_mesh};
|
||||
negative_tms.set_up_direction(up.cast<float>());
|
||||
|
||||
std::vector<ExPolygons> neg_polys;
|
||||
negative_tms.slice(std::vector<float>{height_mesh}, MeshSlicingParamsExtended{}, &neg_polys);
|
||||
assert(m_negative_mesh->has_shared_vertices());
|
||||
std::vector<ExPolygons> neg_polys = slice_mesh_ex(m_negative_mesh->its, std::vector<float>{height_mesh}, slicing_params);
|
||||
list_of_expolys.front() = diff_ex(list_of_expolys.front(), neg_polys.front());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue