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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Matena <lukasmatena@seznam.cz>2020-04-16 17:59:06 +0300
committerLukas Matena <lukasmatena@seznam.cz>2020-04-17 14:15:26 +0300
commitc570fc40de709d097afa1c763b3b5efbdc794ba7 (patch)
treeb7f1f580af680e64a79a96f55e91a0f87008d702 /src
parent546b0702f901cf24768ccf9df2022d1505957777 (diff)
First partially working implementation of custom supports at the backend
The solution is temporary and should be improved and moved elsewhere - see comments in the code.
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/SupportMaterial.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp
index 1d98bb0e6..dccc8616b 100644
--- a/src/libslic3r/SupportMaterial.cpp
+++ b/src/libslic3r/SupportMaterial.cpp
@@ -971,6 +971,77 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
std::vector<ExPolygons> enforcers = object.slice_support_enforcers();
std::vector<ExPolygons> blockers = object.slice_support_blockers();
+
+
+
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ /// TEMPORARY INLINE DRAFT PROJECTING CUSTOM SUPPORTS ON SLICES ///
+ /// ///////////////////////////////////////////////////////////////////////
+ const auto& data = object.model_object()->volumes.front()->m_supported_facets;
+ const auto& custom_enf = data.get_facets(FacetSupportType::ENFORCER);
+ const TriangleMesh& mesh = object.model_object()->volumes.front()->mesh();
+ const Transform3f& tr1 = object.model_object()->volumes.front()->get_matrix().cast<float>();
+ const Transform3f& tr2 = object.trafo().cast<float>();
+
+ // Make a list of all layers.
+ const LayerPtrs& layers = object.layers();
+
+ // Make sure that enforcers vector can be used.
+ if (! custom_enf.empty())
+ enforcers.resize(layers.size());
+
+ // Iterate over all triangles.
+ for (int facet_idx : custom_enf) {
+
+ ExPolygon triangle; // To store horizontal projection of the triangle.
+
+ // Min and max z-coord of the triangle.
+ float max_z = std::numeric_limits<float>::min();
+ float min_z = std::numeric_limits<float>::max();
+
+ // This block transforms the triangle into worlds coords and
+ // calculates the projection and z-bounds.
+ {
+ std::array<Vec3f, 3> facet;
+ Points projection(3);
+ for (int i=0; i<3; ++i) {
+ facet[i] = tr2 * tr1 * mesh.its.vertices[mesh.its.indices[facet_idx](i)];
+ max_z = std::max(max_z, facet[i].z());
+ min_z = std::min(min_z, facet[i].z());
+ projection[i] = Point(scale_(facet[i].x()), scale_(facet[i].y()));
+ projection[i] = projection[i] - object.center_offset();
+ }
+ triangle = ExPolygon(projection);
+ }
+
+ // We now have the projection of the triangle.
+ // Find lowest slice not below the triangle.
+ auto it = std::lower_bound(layers.begin(), layers.end(), min_z,
+ [](const Layer* l1, float z) {
+ return l1->slice_z < z;
+ });
+
+ // Project the triangles on all slices intersecting the triangle.
+ // FIXME: This ignores horizontal triangles and does not project
+ // anything to the slice above max_z.
+ // FIXME: Each part of the projection should be assigned to one slice only.
+ // FIXME: The speed of the algorithm might be improved.
+ while (it != layers.end() && (*it)->slice_z < max_z) {
+ enforcers[it-layers.begin()].emplace_back(triangle);
+ ++it;
+ }
+ }
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+
+
+
+
+
+
// Output layers, sorted by top Z.
MyLayersPtr contact_out;