Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsupermerill <merill@fr.fr>2019-08-29 00:03:09 +0300
committersupermerill <merill@fr.fr>2019-08-29 00:03:09 +0300
commitccc05c08fdba39c99273660fbc1d50c1cbd15d59 (patch)
treee204a2b79deffe091d0b750544bd852c574ed3e3 /src/libslic3r/SLA
parentfa1274d9b10cdfd8ed310fe458fc10f4eb2d1c4f (diff)
parent85d9a165636617c76d30be54a1cd99bd4e5663b0 (diff)
Merge commit '85d9a165636617c76d30be54a1cd99bd4e5663b0'
Diffstat (limited to 'src/libslic3r/SLA')
-rw-r--r--src/libslic3r/SLA/SLAAutoSupports.cpp4
-rw-r--r--src/libslic3r/SLA/SLASupportTree.cpp52
-rw-r--r--src/libslic3r/SLA/SLASupportTreeIGL.cpp13
3 files changed, 41 insertions, 28 deletions
diff --git a/src/libslic3r/SLA/SLAAutoSupports.cpp b/src/libslic3r/SLA/SLAAutoSupports.cpp
index cbd48796d..5451c7612 100644
--- a/src/libslic3r/SLA/SLAAutoSupports.cpp
+++ b/src/libslic3r/SLA/SLAAutoSupports.cpp
@@ -1,5 +1,5 @@
-#include "igl/random_points_on_mesh.h"
-#include "igl/AABB.h"
+//#include "igl/random_points_on_mesh.h"
+//#include "igl/AABB.h"
#include <tbb/parallel_for.h>
diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp
index 48b78fcce..56be5a569 100644
--- a/src/libslic3r/SLA/SLASupportTree.cpp
+++ b/src/libslic3r/SLA/SLASupportTree.cpp
@@ -85,7 +85,7 @@ using Portion = std::tuple<double, double>;
// Set this to true to enable full parallelism in this module.
// Only the well tested parts will be concurrent if this is set to false.
-const constexpr bool USE_FULL_CONCURRENCY = false;
+const constexpr bool USE_FULL_CONCURRENCY = true;
template<bool> struct _ccr {};
@@ -713,7 +713,7 @@ struct Pad {
}
tmesh.translate(0, 0, float(zlevel));
- tmesh.require_shared_vertices();
+ if (!tmesh.empty()) tmesh.require_shared_vertices();
}
bool empty() const { return tmesh.facets_count() == 0; }
@@ -1194,7 +1194,7 @@ class SLASupportTree::Algorithm {
// Now a and b vectors are perpendicular to v and to each other.
// Together they define the plane where we have to iterate with the
// given angles in the 'phis' vector
- ccr_par::enumerate(phis.begin(), phis.end(),
+ ccr_seq::enumerate(phis.begin(), phis.end(),
[&hits, &m, sd, r_pin, r_back, s, a, b, c]
(double phi, size_t i)
{
@@ -1297,7 +1297,7 @@ class SLASupportTree::Algorithm {
// Hit results
std::array<HitResult, SAMPLES> hits;
- ccr_par::enumerate(phis.begin(), phis.end(),
+ ccr_seq::enumerate(phis.begin(), phis.end(),
[&m, a, b, sd, dir, r, s, ins_check, &hits]
(double phi, size_t i)
{
@@ -2588,7 +2588,7 @@ SLASupportTree::SLASupportTree(double gnd_lvl): m_impl(new Impl()) {
const TriangleMesh &SLASupportTree::merged_mesh() const
{
- return get().merged_mesh();
+ return m_impl->merged_mesh();
}
void SLASupportTree::merged_mesh_with_pad(TriangleMesh &outmesh) const {
@@ -2597,41 +2597,53 @@ void SLASupportTree::merged_mesh_with_pad(TriangleMesh &outmesh) const {
}
std::vector<ExPolygons> SLASupportTree::slice(
- const std::vector<float> &heights, float cr) const
+ const std::vector<float> &grid, float cr) const
{
const TriangleMesh &sup_mesh = m_impl->merged_mesh();
const TriangleMesh &pad_mesh = get_pad();
- std::vector<ExPolygons> sup_slices;
+ using Slices = std::vector<ExPolygons>;
+ auto slices = reserve_vector<Slices>(2);
+
if (!sup_mesh.empty()) {
+ slices.emplace_back();
+
TriangleMeshSlicer sup_slicer(&sup_mesh);
sup_slicer.closing_radius = cr;
- sup_slicer.slice(heights, &sup_slices, m_impl->ctl().cancelfn);
+ sup_slicer.slice(grid, &slices.back(), m_impl->ctl().cancelfn);
}
+ if (!pad_mesh.empty()) {
+ slices.emplace_back();
+
auto bb = pad_mesh.bounding_box();
- auto maxzit = std::upper_bound(heights.begin(), heights.end(), bb.max.z());
+ auto maxzit = std::upper_bound(grid.begin(), grid.end(), bb.max.z());
- auto padgrid = reserve_vector<float>(heights.end() - maxzit);
- std::copy(heights.begin(), maxzit, std::back_inserter(padgrid));
+ auto padgrid = reserve_vector<float>(grid.end() - maxzit);
+ std::copy(grid.begin(), maxzit, std::back_inserter(padgrid));
- std::vector<ExPolygons> pad_slices;
- if (!pad_mesh.empty()) {
TriangleMeshSlicer pad_slicer(&pad_mesh);
pad_slicer.closing_radius = cr;
- pad_slicer.slice(padgrid, &pad_slices, m_impl->ctl().cancelfn);
+ pad_slicer.slice(padgrid, &slices.back(), m_impl->ctl().cancelfn);
}
- size_t len = std::min(heights.size(), pad_slices.size());
- len = std::min(len, sup_slices.size());
+ size_t len = grid.size();
+ for (const Slices &slv : slices) { len = std::min(len, slv.size()); }
+ // Either the support or the pad or both has to be non empty
+ if (slices.empty()) return {};
+
+ Slices &mrg = slices.front();
+
+ for (auto it = std::next(slices.begin()); it != slices.end(); ++it) {
for (size_t i = 0; i < len; ++i) {
- std::copy(pad_slices[i].begin(), pad_slices[i].end(),
- std::back_inserter(sup_slices[i]));
- pad_slices[i] = {};
+ Slices &slv = *it;
+ std::copy(slv[i].begin(), slv[i].end(), std::back_inserter(mrg[i]));
+ slv[i] = {}; // clear and delete
+ }
}
- return sup_slices;
+ return mrg;
}
const TriangleMesh &SLASupportTree::add_pad(const ExPolygons& modelbase,
diff --git a/src/libslic3r/SLA/SLASupportTreeIGL.cpp b/src/libslic3r/SLA/SLASupportTreeIGL.cpp
index 4016b31f8..a5aede210 100644
--- a/src/libslic3r/SLA/SLASupportTreeIGL.cpp
+++ b/src/libslic3r/SLA/SLASupportTreeIGL.cpp
@@ -148,9 +148,9 @@ std::vector<BoxIndexEl> BoxIndex::query(const BoundingBox &qrbb,
BoxIndex::QueryType qt)
{
namespace bgi = boost::geometry::index;
-
+
std::vector<BoxIndexEl> ret; ret.reserve(m_impl->m_store.size());
-
+
switch (qt) {
case qtIntersects:
m_impl->m_store.query(bgi::intersects(qrbb), std::back_inserter(ret));
@@ -158,7 +158,7 @@ std::vector<BoxIndexEl> BoxIndex::query(const BoundingBox &qrbb,
case qtWithin:
m_impl->m_store.query(bgi::within(qrbb), std::back_inserter(ret));
}
-
+
return ret;
}
@@ -198,9 +198,9 @@ EigenMesh3D::EigenMesh3D(const TriangleMesh& tmesh): m_aabb(new AABBImpl()) {
F.resize(stl.stats.number_of_facets, 3);
for (unsigned int i = 0; i < stl.stats.number_of_facets; ++i) {
const stl_facet &facet = stl.facet_start[i];
- V.block<1, 3>(3 * i + 0, 0) = facet.vertex[0].cast<double>();
- V.block<1, 3>(3 * i + 1, 0) = facet.vertex[1].cast<double>();
- V.block<1, 3>(3 * i + 2, 0) = facet.vertex[2].cast<double>();
+ V.block<1, 3>(3 * i + 0, 0) = facet.vertex[0].cast<double>();
+ V.block<1, 3>(3 * i + 1, 0) = facet.vertex[1].cast<double>();
+ V.block<1, 3>(3 * i + 2, 0) = facet.vertex[2].cast<double>();
F(i, 0) = int(3*i+0);
F(i, 1) = int(3*i+1);
F(i, 2) = int(3*i+2);
@@ -306,6 +306,7 @@ PointSet normals(const PointSet& points,
PointSet ret(range.size(), 3);
+// for (size_t ridx = 0; ridx < range.size(); ++ridx)
tbb::parallel_for(size_t(0), range.size(),
[&ret, &range, &mesh, &points, thr, eps](size_t ridx)
{