Merge remote-tracking branch 'origin/master' into ys_bugfixing
This commit is contained in:
commit
72479428d7
@ -15,6 +15,7 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform float object_max_z;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
@ -42,6 +43,12 @@ void main()
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Scaled to widths of the Z texture.
|
||||
object_z = (volume_world_matrix * gl_Vertex).z;
|
||||
if (object_max_z > 0.0)
|
||||
// when rendering the overlay
|
||||
object_z = object_max_z * gl_MultiTexCoord0.y;
|
||||
else
|
||||
// when rendering the volumes
|
||||
object_z = (volume_world_matrix * gl_Vertex).z;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
|
||||
// Shorthand for the vertex arrays
|
||||
auto& upoints = upper.points, &lpoints = lower.points;
|
||||
auto& rpts = ret.points; auto& rfaces = ret.indices;
|
||||
auto& rpts = ret.points; auto& ind = ret.indices;
|
||||
|
||||
// If the Z levels are flipped, or the offset difference is negative, we
|
||||
// will interpret that as the triangles normals should be inverted.
|
||||
@ -61,10 +61,11 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
|
||||
// Copy the points into the mesh, convert them from 2D to 3D
|
||||
rpts.reserve(upoints.size() + lpoints.size());
|
||||
rfaces.reserve(2*upoints.size() + 2*lpoints.size());
|
||||
const double sf = SCALING_FACTOR;
|
||||
for(auto& p : upoints) rpts.emplace_back(p.x()*sf, p.y()*sf, upper_z_mm);
|
||||
for(auto& p : lpoints) rpts.emplace_back(p.x()*sf, p.y()*sf, lower_z_mm);
|
||||
ind.reserve(2 * upoints.size() + 2 * lpoints.size());
|
||||
for (auto &p : upoints)
|
||||
rpts.emplace_back(unscaled(p.x()), unscaled(p.y()), upper_z_mm);
|
||||
for (auto &p : lpoints)
|
||||
rpts.emplace_back(unscaled(p.x()), unscaled(p.y()), lower_z_mm);
|
||||
|
||||
// Create pointing indices into vertex arrays. u-upper, l-lower
|
||||
size_t uidx = 0, lidx = offs, unextidx = 1, lnextidx = offs + 1;
|
||||
@ -121,9 +122,9 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
case Proceed::UPPER:
|
||||
if(!ustarted || uidx != uendidx) { // there are vertices remaining
|
||||
// Get the 3D vertices in order
|
||||
const Vec3d& p_up1 = rpts[size_t(uidx)];
|
||||
const Vec3d& p_low = rpts[size_t(lidx)];
|
||||
const Vec3d& p_up2 = rpts[size_t(unextidx)];
|
||||
const Vec3d& p_up1 = rpts[uidx];
|
||||
const Vec3d& p_low = rpts[lidx];
|
||||
const Vec3d& p_up2 = rpts[unextidx];
|
||||
|
||||
// Calculate fitness: the average of the two connecting edges
|
||||
double a = offsdiff2 - (distfn(p_up1, p_low) - zdiff2);
|
||||
@ -133,8 +134,9 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
if(current_fit > prev_fit) { // fit is worse than previously
|
||||
proceed = Proceed::LOWER;
|
||||
} else { // good to go, create the triangle
|
||||
inverted? rfaces.emplace_back(unextidx, lidx, uidx) :
|
||||
rfaces.emplace_back(uidx, lidx, unextidx) ;
|
||||
inverted
|
||||
? ind.emplace_back(int(unextidx), int(lidx), int(uidx))
|
||||
: ind.emplace_back(int(uidx), int(lidx), int(unextidx));
|
||||
|
||||
// Increment the iterators, rotate if necessary
|
||||
++uidx; ++unextidx;
|
||||
@ -150,9 +152,9 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
case Proceed::LOWER:
|
||||
// Mode with lower segment, upper vertex. Same structure:
|
||||
if(!lstarted || lidx != lendidx) {
|
||||
const Vec3d& p_low1 = rpts[size_t(lidx)];
|
||||
const Vec3d& p_low2 = rpts[size_t(lnextidx)];
|
||||
const Vec3d& p_up = rpts[size_t(uidx)];
|
||||
const Vec3d& p_low1 = rpts[lidx];
|
||||
const Vec3d& p_low2 = rpts[lnextidx];
|
||||
const Vec3d& p_up = rpts[uidx];
|
||||
|
||||
double a = offsdiff2 - (distfn(p_up, p_low1) - zdiff2);
|
||||
double b = offsdiff2 - (distfn(p_up, p_low2) - zdiff2);
|
||||
@ -161,8 +163,9 @@ Contour3D walls(const Polygon& lower, const Polygon& upper,
|
||||
if(current_fit > prev_fit) {
|
||||
proceed = Proceed::UPPER;
|
||||
} else {
|
||||
inverted? rfaces.emplace_back(uidx, lnextidx, lidx) :
|
||||
rfaces.emplace_back(lidx, lnextidx, uidx);
|
||||
inverted
|
||||
? ind.emplace_back(int(uidx), int(lnextidx), int(lidx))
|
||||
: ind.emplace_back(int(lidx), int(lnextidx), int(uidx));
|
||||
|
||||
++lidx; ++lnextidx;
|
||||
if(lnextidx == rpts.size()) lnextidx = offs;
|
||||
@ -200,7 +203,7 @@ void offset(ExPolygon& sh, coord_t distance) {
|
||||
}
|
||||
|
||||
ClipperOffset offs;
|
||||
offs.ArcTolerance = 0.01*mm(1);
|
||||
offs.ArcTolerance = 0.01*scaled(1.0);
|
||||
Paths result;
|
||||
offs.AddPath(ctour, jtRound, etClosedPolygon);
|
||||
offs.AddPaths(holes, jtRound, etClosedPolygon);
|
||||
@ -303,16 +306,6 @@ ExPolygons unify(const ExPolygons& shapes) {
|
||||
return retv;
|
||||
}
|
||||
|
||||
/// Only a debug function to generate top and bottom plates from a 2D shape.
|
||||
/// It is not used in the algorithm directly.
|
||||
inline Contour3D roofs(const ExPolygon& poly, coord_t z_distance) {
|
||||
auto lower = triangulate_expolygon_3d(poly);
|
||||
auto upper = triangulate_expolygon_3d(poly, z_distance*SCALING_FACTOR, true);
|
||||
Contour3D ret;
|
||||
ret.merge(lower); ret.merge(upper);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// This method will create a rounded edge around a flat polygon in 3d space.
|
||||
/// 'base_plate' parameter is the target plate.
|
||||
/// 'radius' is the radius of the edges.
|
||||
@ -358,7 +351,7 @@ Contour3D round_edges(const ExPolygon& base_plate,
|
||||
double x2 = xx*xx;
|
||||
double stepy = std::sqrt(r2 - x2);
|
||||
|
||||
offset(ob, s*mm(xx));
|
||||
offset(ob, s*scaled(xx));
|
||||
wh = ceilheight_mm - radius_mm + stepy;
|
||||
|
||||
Contour3D pwalls;
|
||||
@ -382,7 +375,7 @@ Contour3D round_edges(const ExPolygon& base_plate,
|
||||
double xx = radius_mm - i*stepx;
|
||||
double x2 = xx*xx;
|
||||
double stepy = std::sqrt(r2 - x2);
|
||||
offset(ob, s*mm(xx));
|
||||
offset(ob, s*scaled(xx));
|
||||
wh = ceilheight_mm - radius_mm - stepy;
|
||||
|
||||
Contour3D pwalls;
|
||||
@ -402,41 +395,6 @@ Contour3D round_edges(const ExPolygon& base_plate,
|
||||
return curvedwalls;
|
||||
}
|
||||
|
||||
/// Generating the concave part of the 3D pool with the bottom plate and the
|
||||
/// side walls.
|
||||
Contour3D inner_bed(const ExPolygon& poly,
|
||||
double depth_mm,
|
||||
double begin_h_mm = 0)
|
||||
{
|
||||
Contour3D bottom;
|
||||
Pointf3s triangles = triangulate_expolygon_3d(poly, -depth_mm + begin_h_mm);
|
||||
bottom.merge(triangles);
|
||||
|
||||
coord_t depth = mm(depth_mm);
|
||||
coord_t begin_h = mm(begin_h_mm);
|
||||
|
||||
auto lines = poly.lines();
|
||||
|
||||
// Generate outer walls
|
||||
auto fp = [](const Point& p, Point::coord_type z) {
|
||||
return unscale(x(p), y(p), z);
|
||||
};
|
||||
|
||||
for(auto& l : lines) {
|
||||
auto s = coord_t(bottom.points.size());
|
||||
|
||||
bottom.points.emplace_back(fp(l.a, -depth + begin_h));
|
||||
bottom.points.emplace_back(fp(l.b, -depth + begin_h));
|
||||
bottom.points.emplace_back(fp(l.a, begin_h));
|
||||
bottom.points.emplace_back(fp(l.b, begin_h));
|
||||
|
||||
bottom.indices.emplace_back(s + 3, s + 1, s);
|
||||
bottom.indices.emplace_back(s + 2, s + 3, s);
|
||||
}
|
||||
|
||||
return bottom;
|
||||
}
|
||||
|
||||
inline Point centroid(Points& pp) {
|
||||
Point c;
|
||||
switch(pp.size()) {
|
||||
@ -518,7 +476,7 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50,
|
||||
double dx = x(c) - x(cc), dy = y(c) - y(cc);
|
||||
double l = std::sqrt(dx * dx + dy * dy);
|
||||
double nx = dx / l, ny = dy / l;
|
||||
double max_dist = mm(max_dist_mm);
|
||||
double max_dist = scaled(max_dist_mm);
|
||||
|
||||
ExPolygon& expo = punion[idx++];
|
||||
BoundingBox querybb(expo);
|
||||
@ -534,10 +492,10 @@ ExPolygons concave_hull(const ExPolygons& polys, double max_dist_mm = 50,
|
||||
ctour.reserve(3);
|
||||
ctour.emplace_back(cc);
|
||||
|
||||
Point d(coord_t(mm(1)*nx), coord_t(mm(1)*ny));
|
||||
Point d(coord_t(scaled(1.)*nx), coord_t(scaled(1.)*ny));
|
||||
ctour.emplace_back(c + Point( -y(d), x(d) ));
|
||||
ctour.emplace_back(c + Point( y(d), -x(d) ));
|
||||
offset(r, mm(1));
|
||||
offset(r, scaled(1.));
|
||||
|
||||
return r;
|
||||
});
|
||||
@ -569,15 +527,16 @@ void base_plate(const TriangleMesh &mesh, ExPolygons &output, float h,
|
||||
// Now we have to unify all slice layers which can be an expensive operation
|
||||
// so we will try to simplify the polygons
|
||||
ExPolygons tmp; tmp.reserve(count);
|
||||
for(ExPolygons& o : out) for(ExPolygon& e : o) {
|
||||
auto&& exss = e.simplify(0.1/SCALING_FACTOR);
|
||||
for(ExPolygon& ep : exss) tmp.emplace_back(std::move(ep));
|
||||
}
|
||||
for(ExPolygons& o : out)
|
||||
for(ExPolygon& e : o) {
|
||||
auto&& exss = e.simplify(scaled(0.1));
|
||||
for(ExPolygon& ep : exss) tmp.emplace_back(std::move(ep));
|
||||
}
|
||||
|
||||
ExPolygons utmp = unify(tmp);
|
||||
|
||||
for(auto& o : utmp) {
|
||||
auto&& smp = o.simplify(0.1/SCALING_FACTOR);
|
||||
auto&& smp = o.simplify(scaled(0.1));
|
||||
output.insert(output.end(), smp.begin(), smp.end());
|
||||
}
|
||||
}
|
||||
@ -607,11 +566,11 @@ Contour3D create_base_pool(const ExPolygons &ground_layer,
|
||||
const double bottom_offs = (thickness + wingheight) / std::tan(slope);
|
||||
|
||||
// scaled values
|
||||
const coord_t s_thickness = mm(thickness);
|
||||
const coord_t s_eradius = mm(cfg.edge_radius_mm);
|
||||
const coord_t s_thickness = scaled(thickness);
|
||||
const coord_t s_eradius = scaled(cfg.edge_radius_mm);
|
||||
const coord_t s_safety_dist = 2*s_eradius + coord_t(0.8*s_thickness);
|
||||
const coord_t s_wingdist = mm(wingdist);
|
||||
const coord_t s_bottom_offs = mm(bottom_offs);
|
||||
const coord_t s_wingdist = scaled(wingdist);
|
||||
const coord_t s_bottom_offs = scaled(bottom_offs);
|
||||
|
||||
auto& thrcl = cfg.throw_on_cancel;
|
||||
|
||||
|
@ -11,11 +11,6 @@
|
||||
namespace Slic3r {
|
||||
namespace sla {
|
||||
|
||||
using coord_t = Point::coord_type;
|
||||
|
||||
/// get the scaled clipper units for a millimeter value
|
||||
inline coord_t mm(double v) { return coord_t(v/SCALING_FACTOR); }
|
||||
|
||||
/// Get x and y coordinates (because we are eigenizing...)
|
||||
inline coord_t x(const Point& p) { return p(0); }
|
||||
inline coord_t y(const Point& p) { return p(1); }
|
||||
@ -36,12 +31,10 @@ inline coord_t x(const Vec3crd& p) { return p(0); }
|
||||
inline coord_t y(const Vec3crd& p) { return p(1); }
|
||||
inline coord_t z(const Vec3crd& p) { return p(2); }
|
||||
|
||||
using Indices = std::vector<Vec3crd>;
|
||||
|
||||
/// Intermediate struct for a 3D mesh
|
||||
struct Contour3D {
|
||||
Pointf3s points;
|
||||
Indices indices;
|
||||
std::vector<Vec3i> indices;
|
||||
|
||||
void merge(const Contour3D& ctr) {
|
||||
auto s3 = coord_t(points.size());
|
||||
|
@ -236,13 +236,13 @@ Contour3D cylinder(double r, double h, size_t ssteps, const Vec3d sp = {0,0,0})
|
||||
// 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;
|
||||
points.emplace_back(jp); int ci = int(points.size() - 1);
|
||||
for(int i = 0; i < steps - 1; ++i)
|
||||
indices.emplace_back(i + offs + 1, i + offs, ci);
|
||||
|
||||
indices.emplace_back(offs, steps + offs - 1, ci);
|
||||
|
||||
points.emplace_back(endp); ci = points.size() - 1;
|
||||
points.emplace_back(endp); ci = int(points.size() - 1);
|
||||
for(int i = 0; i < steps - 1; ++i)
|
||||
indices.emplace_back(ci, i, i + 1);
|
||||
|
||||
|
@ -28,14 +28,16 @@ namespace Slic3r {
|
||||
|
||||
using SupportTreePtr = std::unique_ptr<sla::SLASupportTree>;
|
||||
|
||||
class SLAPrintObject::SupportData {
|
||||
class SLAPrintObject::SupportData
|
||||
{
|
||||
public:
|
||||
sla::EigenMesh3D emesh; // index-triangle representation
|
||||
std::vector<sla::SupportPoint> support_points; // all the support points (manual/auto)
|
||||
SupportTreePtr support_tree_ptr; // the supports
|
||||
SlicedSupports support_slices; // sliced supports
|
||||
sla::EigenMesh3D emesh; // index-triangle representation
|
||||
std::vector<sla::SupportPoint>
|
||||
support_points; // all the support points (manual/auto)
|
||||
SupportTreePtr support_tree_ptr; // the supports
|
||||
SlicedSupports support_slices; // sliced supports
|
||||
|
||||
inline SupportData(const TriangleMesh& trmesh): emesh(trmesh) {}
|
||||
inline SupportData(const TriangleMesh &trmesh) : emesh(trmesh) {}
|
||||
};
|
||||
|
||||
namespace {
|
||||
@ -666,11 +668,11 @@ void SLAPrint::process()
|
||||
double ilhd = m_material_config.initial_layer_height.getFloat();
|
||||
auto ilh = float(ilhd);
|
||||
|
||||
auto ilhs = coord_t(ilhd / SCALING_FACTOR);
|
||||
auto ilhs = scaled(ilhd);
|
||||
const size_t objcount = m_objects.size();
|
||||
|
||||
const unsigned min_objstatus = 0; // where the per object operations start
|
||||
const unsigned max_objstatus = 50; // where the per object operations end
|
||||
static const unsigned min_objstatus = 0; // where the per object operations start
|
||||
static const unsigned max_objstatus = 50; // where the per object operations end
|
||||
|
||||
// the coefficient that multiplies the per object status values which
|
||||
// are set up for <0, 100>. They need to be scaled into the whole process
|
||||
@ -687,31 +689,32 @@ void SLAPrint::process()
|
||||
|
||||
// Slicing the model object. This method is oversimplified and needs to
|
||||
// be compared with the fff slicing algorithm for verification
|
||||
auto slice_model = [this, ilhs, ilh, ilhd](SLAPrintObject& po) {
|
||||
auto slice_model = [this, ilhs, ilh](SLAPrintObject& po) {
|
||||
const TriangleMesh& mesh = po.transformed_mesh();
|
||||
|
||||
// We need to prepare the slice index...
|
||||
|
||||
double lhd = m_objects.front()->m_config.layer_height.getFloat();
|
||||
float lh = float(lhd);
|
||||
auto lhs = coord_t(lhd / SCALING_FACTOR);
|
||||
auto lhs = scaled(lhd);
|
||||
|
||||
auto&& bb3d = mesh.bounding_box();
|
||||
double minZ = bb3d.min(Z) - po.get_elevation();
|
||||
double maxZ = bb3d.max(Z);
|
||||
auto &&bb3d = mesh.bounding_box();
|
||||
double minZ = bb3d.min(Z) - po.get_elevation();
|
||||
double maxZ = bb3d.max(Z);
|
||||
auto minZf = float(minZ);
|
||||
|
||||
auto minZs = coord_t(minZ / SCALING_FACTOR);
|
||||
auto maxZs = coord_t(maxZ / SCALING_FACTOR);
|
||||
auto minZs = scaled(minZ);
|
||||
auto maxZs = scaled(maxZ);
|
||||
|
||||
po.m_slice_index.clear();
|
||||
|
||||
size_t cap = size_t(1 + (maxZs - minZs - ilhs) / lhs);
|
||||
po.m_slice_index.reserve(cap);
|
||||
|
||||
po.m_slice_index.emplace_back(minZs + ilhs, minZ + ilhd / 2.0, ilh);
|
||||
po.m_slice_index.emplace_back(minZs + ilhs, minZf + ilh / 2.f, ilh);
|
||||
|
||||
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
|
||||
po.m_slice_index.emplace_back(h, h*SCALING_FACTOR - lhd / 2.0, lh);
|
||||
for(coord_t h = minZs + ilhs + lhs; h <= maxZs; h += lhs)
|
||||
po.m_slice_index.emplace_back(h, unscaled<float>(h) - lh / 2.f, lh);
|
||||
|
||||
// Just get the first record that is form the model:
|
||||
auto slindex_it =
|
||||
@ -737,15 +740,15 @@ void SLAPrint::process()
|
||||
|
||||
auto mit = slindex_it;
|
||||
double doffs = m_printer_config.absolute_correction.getFloat();
|
||||
coord_t clpr_offs = coord_t(doffs / SCALING_FACTOR);
|
||||
coord_t clpr_offs = scaled(doffs);
|
||||
for(size_t id = 0;
|
||||
id < po.m_model_slices.size() && mit != po.m_slice_index.end();
|
||||
id++)
|
||||
{
|
||||
// We apply the printer correction offset here.
|
||||
if(clpr_offs != 0)
|
||||
po.m_model_slices[id] =
|
||||
offset_ex(po.m_model_slices[id], clpr_offs);
|
||||
po.m_model_slices[id] =
|
||||
offset_ex(po.m_model_slices[id], float(clpr_offs));
|
||||
|
||||
mit->set_model_slice_idx(po, id); ++mit;
|
||||
}
|
||||
@ -949,15 +952,15 @@ void SLAPrint::process()
|
||||
}
|
||||
|
||||
double doffs = m_printer_config.absolute_correction.getFloat();
|
||||
coord_t clpr_offs = coord_t(doffs / SCALING_FACTOR);
|
||||
coord_t clpr_offs = scaled(doffs);
|
||||
for(size_t i = 0;
|
||||
i < sd->support_slices.size() && i < po.m_slice_index.size();
|
||||
++i)
|
||||
{
|
||||
// We apply the printer correction offset here.
|
||||
if(clpr_offs != 0)
|
||||
sd->support_slices[i] =
|
||||
offset_ex(sd->support_slices[i], clpr_offs);
|
||||
sd->support_slices[i] =
|
||||
offset_ex(sd->support_slices[i], float(clpr_offs));
|
||||
|
||||
po.m_slice_index[i].set_support_slice_idx(po, i);
|
||||
}
|
||||
@ -1063,8 +1066,8 @@ void SLAPrint::process()
|
||||
|
||||
const int fade_layers_cnt = m_default_object_config.faded_layers.getInt();// 10 // [3;20]
|
||||
|
||||
const double width = m_printer_config.display_width.getFloat() / SCALING_FACTOR;
|
||||
const double height = m_printer_config.display_height.getFloat() / SCALING_FACTOR;
|
||||
const double width = scaled(m_printer_config.display_width.getFloat());
|
||||
const double height = scaled(m_printer_config.display_height.getFloat());
|
||||
const double display_area = width*height;
|
||||
|
||||
// get polygons for all instances in the object
|
||||
@ -1170,13 +1173,20 @@ void SLAPrint::process()
|
||||
ClipperPolygons model_polygons;
|
||||
ClipperPolygons supports_polygons;
|
||||
|
||||
size_t c = std::accumulate(layer.slices().begin(), layer.slices().end(), 0u, [](size_t a, const SliceRecord& sr) {
|
||||
return a + sr.get_slice(soModel).size();
|
||||
size_t c = std::accumulate(layer.slices().begin(),
|
||||
layer.slices().end(),
|
||||
size_t(0),
|
||||
[](size_t a, const SliceRecord &sr) {
|
||||
return a + sr.get_slice(soModel)
|
||||
.size();
|
||||
});
|
||||
|
||||
model_polygons.reserve(c);
|
||||
|
||||
c = std::accumulate(layer.slices().begin(), layer.slices().end(), 0u, [](size_t a, const SliceRecord& sr) {
|
||||
c = std::accumulate(layer.slices().begin(),
|
||||
layer.slices().end(),
|
||||
size_t(0),
|
||||
[](size_t a, const SliceRecord &sr) {
|
||||
return a + sr.get_slice(soModel).size();
|
||||
});
|
||||
|
||||
@ -1264,8 +1274,9 @@ void SLAPrint::process()
|
||||
// for(size_t i = 0; i < m_printer_input.size(); ++i) printlayerfn(i);
|
||||
tbb::parallel_for<size_t, decltype(printlayerfn)>(0, m_printer_input.size(), printlayerfn);
|
||||
|
||||
m_print_statistics.support_used_material = supports_volume * SCALING_FACTOR * SCALING_FACTOR;
|
||||
m_print_statistics.objects_used_material = models_volume * SCALING_FACTOR * SCALING_FACTOR;
|
||||
auto SCALING2 = SCALING_FACTOR * SCALING_FACTOR;
|
||||
m_print_statistics.support_used_material = supports_volume * SCALING2;
|
||||
m_print_statistics.objects_used_material = models_volume * SCALING2;
|
||||
|
||||
// Estimated printing time
|
||||
// A layers count o the highest object
|
||||
@ -1281,7 +1292,7 @@ void SLAPrint::process()
|
||||
};
|
||||
|
||||
// Rasterizing the model objects, and their supports
|
||||
auto rasterize = [this, max_objstatus]() {
|
||||
auto rasterize = [this]() {
|
||||
if(canceled()) return;
|
||||
|
||||
// collect all the keys
|
||||
@ -1376,11 +1387,12 @@ void SLAPrint::process()
|
||||
tbb::parallel_for<unsigned, decltype(lvlfn)>(0, lvlcnt, lvlfn);
|
||||
|
||||
// Set statistics values to the printer
|
||||
m_printer->set_statistics({(m_print_statistics.objects_used_material + m_print_statistics.support_used_material)/1000,
|
||||
double(m_default_object_config.faded_layers.getInt()),
|
||||
double(m_print_statistics.slow_layers_count),
|
||||
double(m_print_statistics.fast_layers_count)
|
||||
});
|
||||
m_printer->set_statistics(
|
||||
{(m_print_statistics.objects_used_material
|
||||
+ m_print_statistics.support_used_material) / 1000,
|
||||
double(m_default_object_config.faded_layers.getInt()),
|
||||
double(m_print_statistics.slow_layers_count),
|
||||
double(m_print_statistics.fast_layers_count)});
|
||||
};
|
||||
|
||||
using slaposFn = std::function<void(SLAPrintObject&)>;
|
||||
@ -1408,25 +1420,36 @@ void SLAPrint::process()
|
||||
|
||||
// TODO: this loop could run in parallel but should not exhaust all the CPU
|
||||
// power available
|
||||
// Calculate the support structures first before slicing the supports, so that the preview will get displayed ASAP for all objects.
|
||||
std::vector<SLAPrintObjectStep> step_ranges = { slaposObjectSlice, slaposSliceSupports, slaposCount };
|
||||
for (size_t idx_range = 0; idx_range + 1 < step_ranges.size(); ++ idx_range) {
|
||||
for(SLAPrintObject * po : m_objects) {
|
||||
// Calculate the support structures first before slicing the supports,
|
||||
// so that the preview will get displayed ASAP for all objects.
|
||||
std::vector<SLAPrintObjectStep> step_ranges = {slaposObjectSlice,
|
||||
slaposSliceSupports,
|
||||
slaposCount};
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Slicing object " << po->model_object()->name;
|
||||
for (size_t idx_range = 0; idx_range + 1 < step_ranges.size(); ++idx_range) {
|
||||
for (SLAPrintObject *po : m_objects) {
|
||||
|
||||
for (int s = int(step_ranges[idx_range]); s < int(step_ranges[idx_range + 1]); ++s) {
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< "Slicing object " << po->model_object()->name;
|
||||
|
||||
for (int s = int(step_ranges[idx_range]);
|
||||
s < int(step_ranges[idx_range + 1]);
|
||||
++s) {
|
||||
auto currentstep = static_cast<SLAPrintObjectStep>(s);
|
||||
|
||||
// Cancellation checking. Each step will check for cancellation
|
||||
// on its own and return earlier gracefully. Just after it returns
|
||||
// execution gets to this point and throws the canceled signal.
|
||||
// Cancellation checking. Each step will check for
|
||||
// cancellation on its own and return earlier gracefully.
|
||||
// Just after it returns execution gets to this point and
|
||||
// throws the canceled signal.
|
||||
throw_if_canceled();
|
||||
|
||||
st += incr * ostepd;
|
||||
|
||||
if(po->m_stepmask[currentstep] && po->set_started(currentstep)) {
|
||||
m_report_status(*this, st, OBJ_STEP_LABELS(currentstep));
|
||||
if (po->m_stepmask[currentstep]
|
||||
&& po->set_started(currentstep)) {
|
||||
m_report_status(*this,
|
||||
st,
|
||||
OBJ_STEP_LABELS(currentstep));
|
||||
pobj_program[currentstep](*po);
|
||||
throw_if_canceled();
|
||||
po->set_done(currentstep);
|
||||
@ -1786,8 +1809,8 @@ std::vector<sla::SupportPoint> SLAPrintObject::transformed_support_points() cons
|
||||
ret.reserve(spts.size());
|
||||
|
||||
for(sla::SupportPoint& sp : spts) {
|
||||
Vec3d transformed_pos = trafo() * Vec3d(sp.pos(0), sp.pos(1), sp.pos(2));
|
||||
ret.emplace_back(transformed_pos(0), transformed_pos(1), transformed_pos(2), sp.head_front_radius, sp.is_new_island);
|
||||
Vec3f transformed_pos = trafo().cast<float>() * sp.pos;
|
||||
ret.emplace_back(transformed_pos, sp.head_front_radius, sp.is_new_island);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -54,15 +54,15 @@ public:
|
||||
bool is_left_handed() const { return m_left_handed; }
|
||||
|
||||
struct Instance {
|
||||
Instance(ModelID instance_id, const Point &shift, float rotation) : instance_id(instance_id), shift(shift), rotation(rotation) {}
|
||||
bool operator==(const Instance &rhs) const { return this->instance_id == rhs.instance_id && this->shift == rhs.shift && this->rotation == rhs.rotation; }
|
||||
// ID of the corresponding ModelInstance.
|
||||
ModelID instance_id;
|
||||
// Slic3r::Point objects in scaled G-code coordinates
|
||||
Point shift;
|
||||
// Rotation along the Z axis, in radians.
|
||||
float rotation;
|
||||
};
|
||||
Instance(ModelID instance_id, const Point &shift, float rotation) : instance_id(instance_id), shift(shift), rotation(rotation) {}
|
||||
bool operator==(const Instance &rhs) const { return this->instance_id == rhs.instance_id && this->shift == rhs.shift && this->rotation == rhs.rotation; }
|
||||
// ID of the corresponding ModelInstance.
|
||||
ModelID instance_id;
|
||||
// Slic3r::Point objects in scaled G-code coordinates
|
||||
Point shift;
|
||||
// Rotation along the Z axis, in radians.
|
||||
float rotation;
|
||||
};
|
||||
const std::vector<Instance>& instances() const { return m_instances; }
|
||||
|
||||
bool has_mesh(SLAPrintObjectStep step) const;
|
||||
@ -142,15 +142,19 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
template <class T> inline static T level(const SliceRecord& sr) {
|
||||
template<class T> inline static T level(const SliceRecord &sr)
|
||||
{
|
||||
static_assert(std::is_arithmetic<T>::value, "Arithmetic only!");
|
||||
return std::is_integral<T>::value ? T(sr.print_level()) : T(sr.slice_level());
|
||||
return std::is_integral<T>::value ? T(sr.print_level())
|
||||
: T(sr.slice_level());
|
||||
}
|
||||
|
||||
template <class T> inline static SliceRecord create_slice_record(T val) {
|
||||
template<class T> inline static SliceRecord create_slice_record(T val)
|
||||
{
|
||||
static_assert(std::is_arithmetic<T>::value, "Arithmetic only!");
|
||||
return std::is_integral<T>::value ? SliceRecord{ coord_t(val), 0.f, 0.f } : SliceRecord{ 0, float(val), 0.f };
|
||||
return std::is_integral<T>::value
|
||||
? SliceRecord{coord_t(val), 0.f, 0.f}
|
||||
: SliceRecord{0, float(val), 0.f};
|
||||
}
|
||||
|
||||
// This is a template method for searching the slice index either by
|
||||
@ -241,11 +245,11 @@ protected:
|
||||
~SLAPrintObject();
|
||||
|
||||
void config_apply(const ConfigBase &other, bool ignore_nonexistent = false) { this->m_config.apply(other, ignore_nonexistent); }
|
||||
void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false)
|
||||
{ this->m_config.apply_only(other, keys, ignore_nonexistent); }
|
||||
void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false)
|
||||
{ this->m_config.apply_only(other, keys, ignore_nonexistent); }
|
||||
|
||||
void set_trafo(const Transform3d& trafo, bool left_handed) {
|
||||
m_transformed_rmesh.invalidate([this, &trafo, left_handed](){ m_trafo = trafo; m_left_handed = left_handed; });
|
||||
m_transformed_rmesh.invalidate([this, &trafo, left_handed](){ m_trafo = trafo; m_left_handed = left_handed; });
|
||||
}
|
||||
|
||||
template<class InstVec> inline void set_instances(InstVec&& instances) { m_instances = std::forward<InstVec>(instances); }
|
||||
@ -380,7 +384,7 @@ public:
|
||||
void set_task(const TaskParams ¶ms) override;
|
||||
void process() override;
|
||||
void finalize() override;
|
||||
// Returns true if an object step is done on all objects and there's at least one object.
|
||||
// Returns true if an object step is done on all objects and there's at least one object.
|
||||
bool is_step_done(SLAPrintObjectStep step) const;
|
||||
// Returns true if the last step was finished with success.
|
||||
bool finished() const override { return this->is_step_done(slaposSliceSupports) && this->Inherited::is_step_done(slapsRasterize); }
|
||||
|
@ -48,10 +48,33 @@ typedef double coordf_t;
|
||||
//FIXME Better to use an inline function with an explicit return type.
|
||||
//inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); }
|
||||
#define scale_(val) ((val) / SCALING_FACTOR)
|
||||
|
||||
#define SCALED_EPSILON scale_(EPSILON)
|
||||
|
||||
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define SLIC3R_CONSTEXPR
|
||||
# define SLIC3R_NOEXCEPT
|
||||
#else
|
||||
#define SLIC3R_CONSTEXPR constexpr
|
||||
#define SLIC3R_NOEXCEPT noexcept
|
||||
#endif
|
||||
|
||||
template<class Tf> inline SLIC3R_CONSTEXPR coord_t scaled(Tf val)
|
||||
{
|
||||
static_assert (std::is_floating_point<Tf>::value, "Floating point only");
|
||||
return coord_t(val / Tf(SCALING_FACTOR));
|
||||
}
|
||||
|
||||
template<class Tf = double> inline SLIC3R_CONSTEXPR Tf unscaled(coord_t val)
|
||||
{
|
||||
static_assert (std::is_floating_point<Tf>::value, "Floating point only");
|
||||
return Tf(val * Tf(SCALING_FACTOR));
|
||||
}
|
||||
|
||||
inline SLIC3R_CONSTEXPR float unscaledf(coord_t val) { return unscaled<float>(val); }
|
||||
|
||||
inline std::string debug_out_path(const char *name, ...)
|
||||
{
|
||||
char buffer[2048];
|
||||
|
@ -63,11 +63,6 @@ static const float GROUND_Z = -0.02f;
|
||||
static const float GIZMO_RESET_BUTTON_HEIGHT = 22.0f;
|
||||
static const float GIZMO_RESET_BUTTON_WIDTH = 70.f;
|
||||
|
||||
static const float UNIT_MATRIX[] = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
static const float DEFAULT_BG_DARK_COLOR[3] = { 0.478f, 0.478f, 0.478f };
|
||||
static const float DEFAULT_BG_LIGHT_COLOR[3] = { 0.753f, 0.753f, 0.753f };
|
||||
static const float ERROR_BG_DARK_COLOR[3] = { 0.478f, 0.192f, 0.039f };
|
||||
@ -452,8 +447,7 @@ void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas
|
||||
m_shader.set_uniform("z_texture_row_to_normalized", 1.0f / (float)m_layers_texture.height);
|
||||
m_shader.set_uniform("z_cursor", m_object_max_z * this->get_cursor_z_relative(canvas));
|
||||
m_shader.set_uniform("z_cursor_band_width", band_width);
|
||||
// The shader requires the original model coordinates when rendering to the texture, so we pass it the unit matrix
|
||||
m_shader.set_uniform("volume_world_matrix", UNIT_MATRIX);
|
||||
m_shader.set_uniform("object_max_z", m_object_max_z);
|
||||
|
||||
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
|
||||
@ -466,10 +460,10 @@ void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
::glNormal3f(0.0f, 0.0f, 1.0f);
|
||||
::glVertex3f(l, b, 0.0f);
|
||||
::glVertex3f(r, b, 0.0f);
|
||||
::glVertex3f(r, t, m_object_max_z);
|
||||
::glVertex3f(l, t, m_object_max_z);
|
||||
::glTexCoord2f(0.0f, 0.0f); ::glVertex2f(l, b);
|
||||
::glTexCoord2f(1.0f, 0.0f); ::glVertex2f(r, b);
|
||||
::glTexCoord2f(1.0f, 1.0f); ::glVertex2f(r, t);
|
||||
::glTexCoord2f(0.0f, 1.0f); ::glVertex2f(l, t);
|
||||
glsafe(::glEnd());
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
|
||||
|
||||
@ -522,6 +516,7 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
||||
GLint z_cursor_id = ::glGetUniformLocation(shader_id, "z_cursor");
|
||||
GLint z_cursor_band_width_id = ::glGetUniformLocation(shader_id, "z_cursor_band_width");
|
||||
GLint world_matrix_id = ::glGetUniformLocation(shader_id, "volume_world_matrix");
|
||||
GLint object_max_z_id = ::glGetUniformLocation(shader_id, "object_max_z");
|
||||
glcheck();
|
||||
|
||||
if (z_to_texture_row_id != -1 && z_texture_row_to_normalized_id != -1 && z_cursor_id != -1 && z_cursor_band_width_id != -1 && world_matrix_id != -1)
|
||||
@ -548,7 +543,10 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
||||
// Render the object using the layer editing shader and texture.
|
||||
if (! glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier)
|
||||
continue;
|
||||
glsafe(::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)glvolume->world_matrix().cast<float>().data()));
|
||||
if (world_matrix_id != -1)
|
||||
glsafe(::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)glvolume->world_matrix().cast<float>().data()));
|
||||
if (object_max_z_id != -1)
|
||||
glsafe(::glUniform1f(object_max_z_id, GLfloat(0)));
|
||||
glvolume->render();
|
||||
}
|
||||
// Revert back to the previous shader.
|
||||
|
@ -976,7 +976,8 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
|
||||
if (! boost::algorithm::ends_with(opt_key, "_settings_id"))
|
||||
tab->get_config()->option(opt_key)->set(config.option(opt_key));
|
||||
}
|
||||
wxGetApp().load_current_presets();
|
||||
|
||||
wxGetApp().load_current_presets();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user