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
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2019-01-28 16:20:42 +0300
committertamasmeszaros <meszaros.q@gmail.com>2019-01-28 16:20:42 +0300
commita32839260f76c9f97190bae29ae2b56fda19d685 (patch)
tree2ecc46603e3b7ae923e35481d4b28511c5529d24
parentcdd415bb0c7584d5bb278bfaa572ca7ee38ff146 (diff)
Remove duplicate code from support generation.version_1.44.0-alpha4version_1.42.0-alpha4delete
-rw-r--r--src/libslic3r/SLA/SLASupportTree.cpp67
1 files changed, 16 insertions, 51 deletions
diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp
index b7ae95fda..1127454c6 100644
--- a/src/libslic3r/SLA/SLASupportTree.cpp
+++ b/src/libslic3r/SLA/SLASupportTree.cpp
@@ -164,7 +164,13 @@ Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
return ret;
}
-Contour3D cylinder(double r, double h, size_t ssteps) {
+// Down facing cylinder in Z direction with arguments:
+// r: radius
+// h: Height
+// ssteps: how many edges will create the base circle
+// sp: starting point
+Contour3D cylinder(double r, double h, size_t ssteps, const Vec3d sp = {0,0,0})
+{
Contour3D ret;
auto steps = int(ssteps);
@@ -173,8 +179,8 @@ Contour3D cylinder(double r, double h, size_t ssteps) {
points.reserve(2*ssteps);
double a = 2*PI/steps;
- Vec3d jp = {0, 0, 0};
- Vec3d endp = {0, 0, h};
+ Vec3d jp = sp;
+ Vec3d endp = {sp(X), sp(Y), sp(Z) + h};
// Upper circle points
for(int i = 0; i < steps; ++i) {
@@ -371,54 +377,15 @@ struct Pillar {
r(radius), steps(st), endpoint(endp), starts_from_head(false)
{
assert(steps > 0);
- assert(jp(Z) > endp(Z)); // Endpoint is below the starting point
-
- int steps_1 = int(steps - 1);
-
- auto& points = mesh.points;
- auto& indices = mesh.indices;
- points.reserve(2*steps);
- double a = 2*PI/steps;
-
- for(size_t i = 0; i < steps; ++i) {
- double phi = i*a;
- double x = jp(X) + r*std::cos(phi);
- double y = jp(Y) + r*std::sin(phi);
- points.emplace_back(x, y, jp(Z));
- }
-
- for(size_t i = 0; i < steps; ++i) {
- double phi = i*a;
- double ex = endp(X) + r*std::cos(phi);
- double ey = endp(Y) + r*std::sin(phi);
- points.emplace_back(ex, ey, endp(Z));
- }
-
- indices.reserve(2*steps);
- int offs = int(steps);
- for(int i = 0; i < steps_1 ; ++i) {
- indices.emplace_back(i, i + offs, offs + i + 1);
- indices.emplace_back(i, offs + i + 1, i + 1);
- }
-
- indices.emplace_back(0, steps_1, offs);
- indices.emplace_back(steps_1, offs + steps_1, offs);
-
- // According to the slicing algorithms, we need to aid them with
- // generating a watertight body. So we create a triangle fan for the
- // upper and lower ending of the cylinder to close the geometry.
- points.emplace_back(jp); size_t ci = points.size() - 1;
- int stepsi = int(steps);
- for(int i = 0; i < stepsi - 1; ++i)
- indices.emplace_back(ci, i, i + 1);
- indices.emplace_back(stepsi - 1, 0, ci);
+ double h = jp(Z) - endp(Z);
+ assert(h > 0); // Endpoint is below the starting point
- points.emplace_back(endp); ci = points.size() - 1;
- for(int i = 0; i < stepsi - 1; ++i)
- indices.emplace_back(i + offs + 1, i + offs, ci);
-
- indices.emplace_back(offs, stepsi + offs - 1, ci);
+ // We just create a bridge geometry with the pillar parameters and
+ // move the data.
+ Contour3D body = cylinder(radius, h, st, endp);
+ mesh.points.swap(body.points);
+ mesh.indices.swap(body.indices);
}
Pillar(const Junction& junc, const Vec3d& endp):
@@ -498,8 +465,6 @@ struct Bridge {
Vec3d dir = (j2 - j1).normalized();
double d = distance(j2, j1);
- assert(d > 0);
-
mesh = cylinder(r, d, steps);
auto quater = Quaternion::FromTwoVectors(Vec3d{0,0,1}, dir);