Little optimization when creating a SLA support mesh for preview.

This commit is contained in:
bubnikv 2019-01-23 14:22:33 +01:00
parent fc97ec9cd9
commit 5ed475a730

View file

@ -738,45 +738,46 @@ public:
const TriangleMesh& merged_mesh() const { const TriangleMesh& merged_mesh() const {
if(meshcache_valid) return meshcache; if(meshcache_valid) return meshcache;
meshcache = TriangleMesh(); Contour3D merged;
for(auto& head : heads()) { for(auto& head : heads()) {
if(m_ctl.stopcondition()) break; if(m_ctl.stopcondition()) break;
if(head.is_valid()) { if(head.is_valid())
auto&& m = mesh(head.mesh); merged.merge(head.mesh);
meshcache.merge(m);
}
} }
for(auto& stick : pillars()) { for(auto& stick : pillars()) {
if(m_ctl.stopcondition()) break; if(m_ctl.stopcondition()) break;
meshcache.merge(mesh(stick.mesh)); merged.merge(stick.mesh);
meshcache.merge(mesh(stick.base)); merged.merge(stick.base);
} }
for(auto& j : junctions()) { for(auto& j : junctions()) {
if(m_ctl.stopcondition()) break; if(m_ctl.stopcondition()) break;
meshcache.merge(mesh(j.mesh)); merged.merge(j.mesh);
} }
for(auto& cb : compact_bridges()) { for(auto& cb : compact_bridges()) {
if(m_ctl.stopcondition()) break; if(m_ctl.stopcondition()) break;
meshcache.merge(mesh(cb.mesh)); merged.merge(cb.mesh);
} }
for(auto& bs : bridges()) { for(auto& bs : bridges()) {
if(m_ctl.stopcondition()) break; if(m_ctl.stopcondition()) break;
meshcache.merge(mesh(bs.mesh)); merged.merge(bs.mesh);
} }
if(m_ctl.stopcondition()) { if(m_ctl.stopcondition()) {
// In case of failure we have to return an empty mesh // In case of failure we have to return an empty mesh
meshcache = TriangleMesh(); meshcache = TriangleMesh();
return meshcache; return meshcache;
} }
meshcache = mesh(merged);
// TODO: Is this necessary? // TODO: Is this necessary?
meshcache.repair(); //meshcache.repair();
BoundingBoxf3&& bb = meshcache.bounding_box(); BoundingBoxf3&& bb = meshcache.bounding_box();
model_height = bb.max(Z) - bb.min(Z); model_height = bb.max(Z) - bb.min(Z);