Merge branch 'master' into tm_builtin_pad
This commit is contained in:
commit
80fddb7aaf
25 changed files with 313 additions and 323 deletions
|
@ -240,17 +240,34 @@ if(NOT WIN32)
|
|||
set(MINIMUM_BOOST_VERSION "1.64.0")
|
||||
endif()
|
||||
find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS system filesystem thread log locale regex)
|
||||
if(Boost_FOUND)
|
||||
# message("Boost include dir: ${Boost_INCLUDE_DIRS}")
|
||||
# message("Boost library dirs: ${Boost_LIBRARY_DIRS}")
|
||||
# message("Boost libraries: ${Boost_LIBRARIES}")
|
||||
|
||||
add_library(boost_libs INTERFACE)
|
||||
add_library(boost_headeronly INTERFACE)
|
||||
|
||||
if (APPLE)
|
||||
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
|
||||
add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE)
|
||||
target_compile_definitions(boost_headeronly INTERFACE BOOST_ASIO_DISABLE_KQUEUE)
|
||||
endif()
|
||||
|
||||
if(NOT SLIC3R_STATIC)
|
||||
add_definitions(-DBOOST_LOG_DYN_LINK)
|
||||
target_compile_definitions(boost_headeronly INTERFACE BOOST_LOG_DYN_LINK)
|
||||
endif()
|
||||
|
||||
if(TARGET Boost::system)
|
||||
message(STATUS "Boost::boost exists")
|
||||
target_link_libraries(boost_headeronly INTERFACE Boost::boost)
|
||||
target_link_libraries(boost_libs INTERFACE
|
||||
boost_headeronly # includes the custom compile definitions as well
|
||||
Boost::system
|
||||
Boost::filesystem
|
||||
Boost::thread
|
||||
Boost::log
|
||||
Boost::locale
|
||||
Boost::regex
|
||||
)
|
||||
else()
|
||||
target_include_directories(boost_headeronly INTERFACE ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(boost_libs INTERFACE boost_headeronly ${Boost_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Find and configure intel-tbb
|
||||
|
|
|
@ -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.
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ if (MSVC)
|
|||
target_compile_definitions(PrusaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
|
||||
add_dependencies(PrusaSlicer_app_gui PrusaSlicer)
|
||||
set_target_properties(PrusaSlicer_app_gui PROPERTIES OUTPUT_NAME "prusa-slicer")
|
||||
target_include_directories(PrusaSlicer_app_gui SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(PrusaSlicer_app_gui PRIVATE boost_headeronly)
|
||||
|
||||
add_executable(PrusaSlicer_app_console PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
|
||||
# Generate debug symbols even in release mode.
|
||||
|
@ -147,7 +147,7 @@ if (MSVC)
|
|||
target_compile_definitions(PrusaSlicer_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE)
|
||||
add_dependencies(PrusaSlicer_app_console PrusaSlicer)
|
||||
set_target_properties(PrusaSlicer_app_console PROPERTIES OUTPUT_NAME "prusa-slicer-console")
|
||||
target_include_directories(PrusaSlicer_app_console SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(PrusaSlicer_app_console PRIVATE boost_headeronly)
|
||||
endif ()
|
||||
|
||||
# Link the resources dir to where Slic3r GUI expects it
|
||||
|
|
|
@ -11,4 +11,4 @@ add_library(admesh STATIC
|
|||
util.cpp
|
||||
)
|
||||
|
||||
target_include_directories(admesh SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(admesh PRIVATE boost_headeronly)
|
||||
|
|
|
@ -19,6 +19,6 @@ add_library(nowide STATIC
|
|||
nowide/windows.hpp
|
||||
)
|
||||
|
||||
target_include_directories(nowide SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(nowide PUBLIC boost_headeronly)
|
||||
|
||||
|
||||
|
|
|
@ -56,12 +56,12 @@ endif()
|
|||
|
||||
# Clipper backend is not enough on its own, it still needs some functions
|
||||
# from Boost geometry
|
||||
if(NOT Boost_INCLUDE_DIRS_FOUND)
|
||||
if(NOT Boost_FOUND)
|
||||
find_package(Boost 1.58 REQUIRED)
|
||||
# TODO automatic download of boost geometry headers
|
||||
endif()
|
||||
|
||||
target_include_directories(clipperBackend SYSTEM INTERFACE ${Boost_INCLUDE_DIRS} )
|
||||
target_link_libraries(clipperBackend INTERFACE Boost::boost )
|
||||
#target_sources(ClipperBackend INTERFACE
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/geometries.hpp
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/clipper_polygon.hpp
|
||||
|
|
|
@ -182,13 +182,12 @@ if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
|||
endif ()
|
||||
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB)
|
||||
target_include_directories(libslic3r SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(libslic3r
|
||||
libnest2d
|
||||
admesh
|
||||
miniz
|
||||
${Boost_LIBRARIES}
|
||||
boost_libs
|
||||
clipper
|
||||
nowide
|
||||
${EXPAT_LIBRARIES}
|
||||
|
|
|
@ -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;
|
||||
|
@ -203,7 +206,7 @@ void offset(ExPolygon& sh, coord_t distance, bool edgerounding = true) {
|
|||
auto jointype = edgerounding? jtRound : jtMiter;
|
||||
|
||||
ClipperOffset offs;
|
||||
offs.ArcTolerance = 0.01*mm(1);
|
||||
offs.ArcTolerance = 0.01*scaled(1.);
|
||||
Paths result;
|
||||
offs.AddPath(ctour, jointype, etClosedPolygon);
|
||||
offs.AddPaths(holes, jointype, etClosedPolygon);
|
||||
|
@ -253,7 +256,7 @@ void offset(Polygon& sh, coord_t distance, bool edgerounding = true) {
|
|||
}
|
||||
|
||||
ClipperOffset offs;
|
||||
offs.ArcTolerance = 0.01*mm(1);
|
||||
offs.ArcTolerance = 0.01*scaled(1.);
|
||||
Paths result;
|
||||
offs.AddPath(ctour, edgerounding ? jtRound : jtMiter, etClosedPolygon);
|
||||
offs.Execute(result, static_cast<double>(distance));
|
||||
|
@ -401,11 +404,11 @@ void breakstick_holes(ExPolygon& poly,
|
|||
out.reserve(2 * pts.size()); // output polygon points
|
||||
|
||||
// stick bottom and right edge dimensions
|
||||
double sbottom = stick_width / SCALING_FACTOR;
|
||||
double sright = (penetration + padding) / SCALING_FACTOR;
|
||||
double sbottom = scaled(stick_width);
|
||||
double sright = scaled(penetration + padding);
|
||||
|
||||
// scaled stride distance
|
||||
double sstride = stride / SCALING_FACTOR;
|
||||
double sstride = scaled(stride);
|
||||
double t = 0;
|
||||
|
||||
// process pairs of vertices as an edge, start with the last and
|
||||
|
@ -459,16 +462,6 @@ void breakstick_holes(ExPolygon& poly,
|
|||
// svg.Close();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
@ -514,7 +507,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;
|
||||
|
@ -538,7 +531,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;
|
||||
|
@ -558,41 +551,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()) {
|
||||
|
@ -640,7 +598,7 @@ Polygons concave_hull(const Polygons& polys, double max_dist_mm = 50,
|
|||
|
||||
if(polys.empty()) return Polygons();
|
||||
|
||||
const double max_dist = mm(max_dist_mm);
|
||||
const double max_dist = scaled(max_dist_mm);
|
||||
|
||||
Polygons punion = unify(polys); // could be redundant
|
||||
|
||||
|
@ -694,10 +652,10 @@ Polygons concave_hull(const Polygons& 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;
|
||||
});
|
||||
|
@ -729,15 +687,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(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(ExPolygon& o : utmp) {
|
||||
auto&& smp = o.simplify(0.1/SCALING_FACTOR); // TODO: is this important?
|
||||
for(auto& o : utmp) {
|
||||
auto&& smp = o.simplify(scaled(0.1));
|
||||
output.insert(output.end(), smp.begin(), smp.end());
|
||||
}
|
||||
}
|
||||
|
@ -768,11 +727,11 @@ Contour3D create_base_pool(const Polygons &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;
|
||||
|
||||
|
@ -902,7 +861,7 @@ Contour3D create_base_pool(const Polygons &ground_layer,
|
|||
}
|
||||
};
|
||||
|
||||
coord_t z_lo = -mm(fullheight), z_hi = -mm(wingheight);
|
||||
coord_t z_lo = -scaled(fullheight), z_hi = -scaled(wingheight);
|
||||
for (ExPolygon &ep : bttms) {
|
||||
pool.merge(triangulate_expolygon_3d(ep, -fullheight, true));
|
||||
for (auto &h : ep.holes) straight_walls(h, z_lo, z_hi);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -237,13 +237,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,7 +28,8 @@ 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)
|
||||
|
@ -703,11 +704,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
|
||||
|
@ -724,31 +725,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 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);
|
||||
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 =
|
||||
|
@ -774,7 +776,7 @@ 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++)
|
||||
|
@ -782,7 +784,7 @@ void SLAPrint::process()
|
|||
// 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);
|
||||
offset_ex(po.m_model_slices[id], float(clpr_offs));
|
||||
|
||||
mit->set_model_slice_idx(po, id); ++mit;
|
||||
}
|
||||
|
@ -1021,7 +1023,7 @@ 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)
|
||||
|
@ -1029,7 +1031,7 @@ void SLAPrint::process()
|
|||
// We apply the printer correction offset here.
|
||||
if(clpr_offs != 0)
|
||||
sd->support_slices[i] =
|
||||
offset_ex(sd->support_slices[i], clpr_offs);
|
||||
offset_ex(sd->support_slices[i], float(clpr_offs));
|
||||
|
||||
po.m_slice_index[i].set_support_slice_idx(po, i);
|
||||
}
|
||||
|
@ -1135,8 +1137,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
|
||||
|
@ -1242,13 +1244,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();
|
||||
});
|
||||
|
||||
|
@ -1336,8 +1345,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
|
||||
|
@ -1353,7 +1363,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
|
||||
|
@ -1448,11 +1458,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,
|
||||
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)
|
||||
});
|
||||
double(m_print_statistics.fast_layers_count)});
|
||||
};
|
||||
|
||||
using slaposFn = std::function<void(SLAPrintObject&)>;
|
||||
|
@ -1480,25 +1491,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 };
|
||||
// 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) {
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "Slicing object " << po->model_object()->name;
|
||||
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) {
|
||||
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);
|
||||
|
@ -1862,8 +1884,8 @@ std::vector<sla::SupportPoint> SLAPrintObject::transformed_support_points() cons
|
|||
ret.reserve(spts.size());
|
||||
|
||||
for(sla::SupportPoint& sp : spts) {
|
||||
Vec3d transformed_pos = trafo() * Vec3d(double(sp.pos(0)), double(sp.pos(1)), double(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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -19,8 +19,6 @@ wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(25 * wxGetApp().em_unit(), -
|
|||
m_user_drawn_background = false;
|
||||
#endif /*__APPLE__*/
|
||||
Bind(wxEVT_PAINT, ([this](wxPaintEvent &/* e */) { repaint(); }));
|
||||
Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent &event) { mouse_event(event); }));
|
||||
Bind(wxEVT_MOTION, ([this](wxMouseEvent &event) { mouse_event(event); }));
|
||||
Bind(wxEVT_SIZE, ([this](wxSizeEvent & /* e */) { Refresh(); }));
|
||||
}
|
||||
void Bed_2D::repaint()
|
||||
|
@ -43,22 +41,14 @@ void Bed_2D::repaint()
|
|||
dc.DrawRectangle(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
|
||||
}
|
||||
|
||||
// turn cw and ch from sizes to max coordinates
|
||||
cw--;
|
||||
ch--;
|
||||
if (m_bed_shape.empty())
|
||||
return;
|
||||
|
||||
// reduce size to have some space around the drawn shape
|
||||
cw -= (2 * Border);
|
||||
ch -= (2 * Border);
|
||||
|
||||
auto cbb = BoundingBoxf(Vec2d(0, 0),Vec2d(cw, ch));
|
||||
// leave space for origin point
|
||||
cbb.min(0) += 4;
|
||||
cbb.max -= Vec2d(4., 4.);
|
||||
|
||||
// leave space for origin label
|
||||
cbb.max(1) -= 13;
|
||||
|
||||
// read new size
|
||||
cw = cbb.size()(0);
|
||||
ch = cbb.size()(1);
|
||||
|
||||
auto ccenter = cbb.center();
|
||||
|
||||
// get bounding box of bed shape in G - code coordinates
|
||||
|
@ -76,16 +66,16 @@ void Bed_2D::repaint()
|
|||
ccenter(0) - bcenter(0) * sfactor,
|
||||
ccenter(1) - bcenter(1) * sfactor
|
||||
);
|
||||
|
||||
m_scale_factor = sfactor;
|
||||
m_shift = Vec2d(shift(0) + cbb.min(0),
|
||||
shift(1) - (cbb.max(1) - GetSize().GetHeight()));
|
||||
m_shift = Vec2d(shift(0) + cbb.min(0), shift(1) - (cbb.max(1) - ch));
|
||||
|
||||
// draw bed fill
|
||||
dc.SetBrush(wxBrush(wxColour(255, 255, 255), wxBRUSHSTYLE_SOLID));
|
||||
wxPointList pt_list;
|
||||
for (auto pt: m_bed_shape)
|
||||
{
|
||||
Point pt_pix = to_pixels(pt);
|
||||
Point pt_pix = to_pixels(pt, ch);
|
||||
pt_list.push_back(new wxPoint(pt_pix(0), pt_pix(1)));
|
||||
}
|
||||
dc.DrawPolygon(&pt_list, 0, 0);
|
||||
|
@ -105,8 +95,8 @@ void Bed_2D::repaint()
|
|||
for (auto pl : polylines)
|
||||
{
|
||||
for (size_t i = 0; i < pl.points.size()-1; i++) {
|
||||
Point pt1 = to_pixels(unscale(pl.points[i]));
|
||||
Point pt2 = to_pixels(unscale(pl.points[i+1]));
|
||||
Point pt1 = to_pixels(unscale(pl.points[i]), ch);
|
||||
Point pt2 = to_pixels(unscale(pl.points[i + 1]), ch);
|
||||
dc.DrawLine(pt1(0), pt1(1), pt2(0), pt2(1));
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +106,7 @@ void Bed_2D::repaint()
|
|||
dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxBRUSHSTYLE_TRANSPARENT));
|
||||
dc.DrawPolygon(&pt_list, 0, 0);
|
||||
|
||||
auto origin_px = to_pixels(Vec2d(0, 0));
|
||||
auto origin_px = to_pixels(Vec2d(0, 0), ch);
|
||||
|
||||
// draw axes
|
||||
auto axes_len = 50;
|
||||
|
@ -153,7 +143,7 @@ void Bed_2D::repaint()
|
|||
|
||||
// draw current position
|
||||
if (m_pos!= Vec2d(0, 0)) {
|
||||
auto pos_px = to_pixels(m_pos);
|
||||
auto pos_px = to_pixels(m_pos, ch);
|
||||
dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxPENSTYLE_SOLID));
|
||||
dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxBRUSHSTYLE_TRANSPARENT));
|
||||
dc.DrawCircle(pos_px(0), pos_px(1), 5);
|
||||
|
@ -161,35 +151,14 @@ void Bed_2D::repaint()
|
|||
dc.DrawLine(pos_px(0) - 15, pos_px(1), pos_px(0) + 15, pos_px(1));
|
||||
dc.DrawLine(pos_px(0), pos_px(1) - 15, pos_px(0), pos_px(1) + 15);
|
||||
}
|
||||
|
||||
m_painted = true;
|
||||
}
|
||||
|
||||
|
||||
// convert G - code coordinates into pixels
|
||||
Point Bed_2D::to_pixels(Vec2d point)
|
||||
Point Bed_2D::to_pixels(Vec2d point, int height)
|
||||
{
|
||||
auto p = point * m_scale_factor + m_shift;
|
||||
return Point(p(0), GetSize().GetHeight() - p(1));
|
||||
}
|
||||
|
||||
void Bed_2D::mouse_event(wxMouseEvent event)
|
||||
{
|
||||
if (!m_interactive) return;
|
||||
if (!m_painted) return;
|
||||
|
||||
auto pos = event.GetPosition();
|
||||
auto point = to_units(Point(pos.x, pos.y));
|
||||
if (event.LeftDown() || event.Dragging()) {
|
||||
if (m_on_move)
|
||||
m_on_move(point) ;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// convert pixels into G - code coordinates
|
||||
Vec2d Bed_2D::to_units(Point point)
|
||||
{
|
||||
return (Vec2d(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor);
|
||||
return Point(p(0) + Border, height - p(1) + Border);
|
||||
}
|
||||
|
||||
void Bed_2D::set_pos(Vec2d pos)
|
||||
|
|
|
@ -9,19 +9,16 @@ namespace GUI {
|
|||
|
||||
class Bed_2D : public wxPanel
|
||||
{
|
||||
static const int Border = 10;
|
||||
|
||||
bool m_user_drawn_background = true;
|
||||
|
||||
bool m_painted = false;
|
||||
bool m_interactive = false;
|
||||
double m_scale_factor;
|
||||
Vec2d m_shift = Vec2d::Zero();
|
||||
Vec2d m_pos = Vec2d::Zero();
|
||||
std::function<void(Vec2d)> m_on_move = nullptr;
|
||||
|
||||
Point to_pixels(Vec2d point);
|
||||
Vec2d to_units(Point point);
|
||||
Point to_pixels(Vec2d point, int height);
|
||||
void repaint();
|
||||
void mouse_event(wxMouseEvent event);
|
||||
void set_pos(Vec2d pos);
|
||||
|
||||
public:
|
||||
|
|
|
@ -30,10 +30,8 @@ void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt)
|
|||
SetMinSize(GetSize());
|
||||
main_sizer->SetSizeHints(this);
|
||||
|
||||
// needed to actually free memory
|
||||
this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent e) {
|
||||
EndModal(wxID_OK);
|
||||
Destroy();
|
||||
this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) {
|
||||
EndModal(wxID_CANCEL);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -135,7 +133,7 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
|
|||
|
||||
// Called from the constructor.
|
||||
// Create a panel for a rectangular / circular / custom bed shape.
|
||||
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title)
|
||||
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(const wxString& title)
|
||||
{
|
||||
|
||||
auto panel = new wxPanel(m_shape_options_book);
|
||||
|
@ -305,8 +303,9 @@ void BedShapePanel::update_shape()
|
|||
}
|
||||
m_canvas->m_bed_shape = points;
|
||||
}
|
||||
else if (page_idx == SHAPE_CUSTOM)
|
||||
m_canvas->m_bed_shape = m_loaded_bed_shape;
|
||||
|
||||
// $self->{on_change}->();
|
||||
update_preview();
|
||||
}
|
||||
|
||||
|
@ -351,8 +350,9 @@ void BedShapePanel::load_stl()
|
|||
std::vector<Vec2d> points;
|
||||
for (auto pt : polygon.points)
|
||||
points.push_back(unscale(pt));
|
||||
m_canvas->m_bed_shape = points;
|
||||
update_preview();
|
||||
|
||||
m_loaded_bed_shape = points;
|
||||
update_shape();
|
||||
}
|
||||
|
||||
} // GUI
|
||||
|
|
|
@ -17,6 +17,7 @@ using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
|
|||
class BedShapePanel : public wxPanel
|
||||
{
|
||||
Bed_2D* m_canvas;
|
||||
std::vector<Vec2d> m_loaded_bed_shape;
|
||||
|
||||
public:
|
||||
BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) {}
|
||||
|
@ -24,7 +25,7 @@ public:
|
|||
|
||||
void build_panel(ConfigOptionPoints* default_pt);
|
||||
|
||||
ConfigOptionsGroupShp init_shape_options_page(wxString title);
|
||||
ConfigOptionsGroupShp init_shape_options_page(const wxString& title);
|
||||
void set_shape(ConfigOptionPoints* points);
|
||||
void update_preview();
|
||||
void update_shape();
|
||||
|
|
|
@ -56,9 +56,9 @@ public:
|
|||
|
||||
Vec3d get_dir_right() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(0); }
|
||||
Vec3d get_dir_up() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(1); }
|
||||
Vec3d get_dir_forward() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(2); }
|
||||
Vec3d get_dir_forward() const { return -m_view_matrix.matrix().block(0, 0, 3, 3).row(2); }
|
||||
|
||||
Vec3d get_position() const { return m_view_matrix.matrix().block(0, 3, 3, 1); }
|
||||
Vec3d get_position() const { return m_view_matrix.matrix().inverse().block(0, 3, 3, 1); }
|
||||
|
||||
void apply_viewport(int x, int y, unsigned int w, unsigned int h) const;
|
||||
void apply_view_matrix() const;
|
||||
|
|
|
@ -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;
|
||||
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.
|
||||
|
|
|
@ -550,7 +550,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
const Selection& selection = m_parent.get_selection();
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
const Transform3d& instance_matrix_no_translation_no_scaling = volume->get_instance_transformation().get_matrix(true,false,true);
|
||||
Vec3f direction_to_camera = camera.get_dir_forward().cast<float>();
|
||||
Vec3f direction_to_camera = -camera.get_dir_forward().cast<float>();
|
||||
Vec3f direction_to_camera_mesh = (instance_matrix_no_translation_no_scaling.inverse().cast<float>() * direction_to_camera).normalized().eval();
|
||||
Vec3f scaling = volume->get_instance_scaling_factor().cast<float>();
|
||||
direction_to_camera_mesh = Vec3f(direction_to_camera_mesh(0)*scaling(0), direction_to_camera_mesh(1)*scaling(1), direction_to_camera_mesh(2)*scaling(2));
|
||||
|
|
|
@ -976,6 +976,7 @@ 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();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class wxTimer;
|
||||
class wxGauge;
|
||||
|
|
|
@ -296,6 +296,9 @@ void Selection::clear()
|
|||
if (!m_valid)
|
||||
return;
|
||||
|
||||
if (m_list.empty())
|
||||
return;
|
||||
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
(*m_volumes)[i]->selected = false;
|
||||
|
|
|
@ -1854,12 +1854,16 @@ void TabPrinter::build_fff()
|
|||
|
||||
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
|
||||
{
|
||||
auto dlg = new BedShapeDialog(this);
|
||||
dlg->build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
|
||||
if (dlg->ShowModal() == wxID_OK) {
|
||||
load_key_value("bed_shape", dlg->GetValue());
|
||||
BedShapeDialog dlg(this);
|
||||
dlg.build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
std::vector<Vec2d> shape = dlg.GetValue();
|
||||
if (!shape.empty())
|
||||
{
|
||||
load_key_value("bed_shape", shape);
|
||||
update_changed_ui();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return sizer;
|
||||
|
@ -2056,12 +2060,16 @@ void TabPrinter::build_sla()
|
|||
|
||||
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
|
||||
{
|
||||
auto dlg = new BedShapeDialog(this);
|
||||
dlg->build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
|
||||
if (dlg->ShowModal() == wxID_OK) {
|
||||
load_key_value("bed_shape", dlg->GetValue());
|
||||
BedShapeDialog dlg(this);
|
||||
dlg.build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
std::vector<Vec2d> shape = dlg.GetValue();
|
||||
if (!shape.empty())
|
||||
{
|
||||
load_key_value("bed_shape", shape);
|
||||
update_changed_ui();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return sizer;
|
||||
|
|
|
@ -119,8 +119,6 @@ target_include_directories(XS PRIVATE src ${LIBDIR}/libslic3r)
|
|||
target_compile_definitions(XS PRIVATE -DSLIC3RXS)
|
||||
set_target_properties(XS PROPERTIES PREFIX "") # Prevent cmake from generating libXS.so instead of XS.so
|
||||
|
||||
target_link_libraries(XS ${Boost_LIBRARIES})
|
||||
|
||||
if (APPLE)
|
||||
# -liconv: boost links to libiconv by default
|
||||
target_link_libraries(XS "-liconv -framework IOKit" "-framework CoreFoundation" -lc++)
|
||||
|
@ -156,12 +154,6 @@ if (WIN32)
|
|||
target_link_libraries(XS ${PERL_LIBRARY})
|
||||
endif()
|
||||
|
||||
target_link_libraries(XS ${Boost_LIBRARIES})
|
||||
target_link_libraries(XS ${TBB_LIBRARIES})
|
||||
# target_link_libraries(XS ${wxWidgets_LIBRARIES})
|
||||
target_link_libraries(XS ${EXPAT_LIBRARIES})
|
||||
# target_link_libraries(XS ${GLEW_LIBRARIES})
|
||||
|
||||
# Install the XS.pm and XS.{so,dll,bundle} into the local-lib directory.
|
||||
set(PERL_LOCAL_LIB_DIR "../../local-lib/lib/perl5/${PerlEmbed_ARCHNAME}")
|
||||
add_custom_command(
|
||||
|
@ -181,10 +173,6 @@ if(APPLE)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(SLIC3R_PROFILE)
|
||||
target_link_libraries(Shiny)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box.
|
||||
get_filename_component(PROPS_PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)
|
||||
|
|
Loading…
Reference in a new issue