mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-17 04:05:52 +08:00
Fixing slow conversion from cgal mesh format
This commit is contained in:
parent
fc3bab9063
commit
73af0ed331
@ -148,19 +148,23 @@ template<class _Mesh> TriangleMesh cgal_to_triangle_mesh(const _Mesh &cgalmesh)
|
|||||||
its.vertices.reserve(cgalmesh.num_vertices());
|
its.vertices.reserve(cgalmesh.num_vertices());
|
||||||
its.indices.reserve(cgalmesh.num_faces());
|
its.indices.reserve(cgalmesh.num_faces());
|
||||||
|
|
||||||
for (auto &vi : cgalmesh.vertices()) {
|
const auto &faces = cgalmesh.faces();
|
||||||
|
const auto &vertices = cgalmesh.vertices();
|
||||||
|
int vsize = int(vertices.size());
|
||||||
|
|
||||||
|
for (auto &vi : vertices) {
|
||||||
auto &v = cgalmesh.point(vi); // Don't ask...
|
auto &v = cgalmesh.point(vi); // Don't ask...
|
||||||
its.vertices.emplace_back(to_vec3f(v));
|
its.vertices.emplace_back(to_vec3f(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &face : cgalmesh.faces()) {
|
for (auto &face : faces) {
|
||||||
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
|
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Vec3i facet;
|
Vec3i facet;
|
||||||
for (auto v : vtc) {
|
for (auto v : vtc) {
|
||||||
int iv = v;
|
int iv = v;
|
||||||
if (i > 2 || iv < 0 || iv >= int(cgalmesh.vertices().size())) { i = 0; break; }
|
if (i > 2 || iv < 0 || iv >= vsize) { i = 0; break; }
|
||||||
facet(i++) = iv;
|
facet(i++) = iv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user