mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-03 12:04:05 -06:00
Merge branch 'master' into vb_wold_object_manipulation
This commit is contained in:
commit
31e724abac
15 changed files with 1288 additions and 1207 deletions
|
@ -1473,7 +1473,7 @@ void Print::process()
|
|||
BOOST_LOG_TRIVIAL(info) << "Staring the slicing process." << log_memory_info();
|
||||
for (PrintObject *obj : m_objects)
|
||||
obj->make_perimeters();
|
||||
this->set_status(70, "Infilling layers");
|
||||
this->set_status(70, L("Infilling layers"));
|
||||
for (PrintObject *obj : m_objects)
|
||||
obj->infill();
|
||||
for (PrintObject *obj : m_objects)
|
||||
|
@ -1481,7 +1481,7 @@ void Print::process()
|
|||
if (this->set_started(psSkirt)) {
|
||||
m_skirt.clear();
|
||||
if (this->has_skirt()) {
|
||||
this->set_status(88, "Generating skirt");
|
||||
this->set_status(88, L("Generating skirt"));
|
||||
this->_make_skirt();
|
||||
}
|
||||
this->set_done(psSkirt);
|
||||
|
@ -1489,7 +1489,7 @@ void Print::process()
|
|||
if (this->set_started(psBrim)) {
|
||||
m_brim.clear();
|
||||
if (m_config.brim_width > 0) {
|
||||
this->set_status(88, "Generating brim");
|
||||
this->set_status(88, L("Generating brim"));
|
||||
this->_make_brim();
|
||||
}
|
||||
this->set_done(psBrim);
|
||||
|
@ -1497,7 +1497,7 @@ void Print::process()
|
|||
if (this->set_started(psWipeTower)) {
|
||||
m_wipe_tower_data.clear();
|
||||
if (this->has_wipe_tower()) {
|
||||
//this->set_status(95, "Generating wipe tower");
|
||||
//this->set_status(95, L("Generating wipe tower"));
|
||||
this->_make_wipe_tower();
|
||||
}
|
||||
this->set_done(psWipeTower);
|
||||
|
@ -1514,7 +1514,8 @@ std::string Print::export_gcode(const std::string &path_template, GCodePreviewDa
|
|||
// output everything to a G-code file
|
||||
// The following call may die if the output_filename_format template substitution fails.
|
||||
std::string path = this->output_filepath(path_template);
|
||||
std::string message = "Exporting G-code";
|
||||
std::string message = L("Exporting G-code");
|
||||
// #ys_FIXME_localization
|
||||
if (! path.empty() && preview_data == nullptr) {
|
||||
// Only show the path if preview_data is not set -> running from command line.
|
||||
message += " to ";
|
||||
|
|
|
@ -92,9 +92,9 @@ void PrintConfigDef::init_common_params()
|
|||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
def = this->add("printhost_cafile", coString);
|
||||
def->label = "HTTPS CA File";
|
||||
def->tooltip = "Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. "
|
||||
"If left blank, the default OS CA certificate repository is used.";
|
||||
def->label = L("HTTPS CA File");
|
||||
def->tooltip = L("Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. "
|
||||
"If left blank, the default OS CA certificate repository is used.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
}
|
||||
|
@ -145,6 +145,7 @@ void PrintConfigDef::init_fff_params()
|
|||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
def = this->add("bottom_solid_layers", coInt);
|
||||
//TRN To be shown in Print Settings "Bottom solid layers"
|
||||
def->label = L("Bottom");
|
||||
def->category = L("Layers and Perimeters");
|
||||
def->tooltip = L("Number of solid layers to generate on bottom surfaces.");
|
||||
|
@ -913,10 +914,10 @@ void PrintConfigDef::init_fff_params()
|
|||
def->set_default_value(new ConfigOptionEnum<GCodeFlavor>(gcfRepRap));
|
||||
|
||||
def = this->add("gcode_label_objects", coBool);
|
||||
def->label = "Label objects";
|
||||
def->tooltip = "Enable this to add comments into the G-Code labeling print moves with what object they belong to,"
|
||||
def->label = L("Label objects");
|
||||
def->tooltip = L("Enable this to add comments into the G-Code labeling print moves with what object they belong to,"
|
||||
" which is useful for the Octoprint CancelObject plugin. This settings is NOT compatible with "
|
||||
"Single Extruder Multi Material setup and Wipe into Object / Wipe into Infill.";
|
||||
"Single Extruder Multi Material setup and Wipe into Object / Wipe into Infill.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(0));
|
||||
|
||||
|
@ -2038,6 +2039,7 @@ void PrintConfigDef::init_fff_params()
|
|||
def->set_default_value(new ConfigOptionFloatOrPercent(15, false));
|
||||
|
||||
def = this->add("top_solid_layers", coInt);
|
||||
//TRN To be shown in Print Settings "Top solid layers"
|
||||
def->label = L("Top");
|
||||
def->category = L("Layers and Perimeters");
|
||||
def->tooltip = L("Number of solid layers to generate on top surfaces.");
|
||||
|
@ -2141,7 +2143,7 @@ void PrintConfigDef::init_fff_params()
|
|||
def = this->add("wipe_tower_rotation_angle", coFloat);
|
||||
def->label = L("Wipe tower rotation angle");
|
||||
def->tooltip = L("Wipe tower rotation angle with respect to x-axis ");
|
||||
def->sidetext = L("degrees");
|
||||
def->sidetext = L("°");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(0.));
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "BoundingBox.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Geometry.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "SupportMaterial.hpp"
|
||||
#include "Surface.hpp"
|
||||
#include "Slicing.hpp"
|
||||
|
@ -17,6 +18,10 @@
|
|||
|
||||
#include <Shiny/Shiny.h>
|
||||
|
||||
//! macro used to mark string used at localization,
|
||||
//! return same string
|
||||
#define L(s) Slic3r::I18N::translate(s)
|
||||
|
||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||
#define SLIC3R_DEBUG
|
||||
#endif
|
||||
|
@ -102,7 +107,7 @@ void PrintObject::slice()
|
|||
{
|
||||
if (! this->set_started(posSlice))
|
||||
return;
|
||||
m_print->set_status(10, "Processing triangulated mesh");
|
||||
m_print->set_status(10, L("Processing triangulated mesh"));
|
||||
std::vector<coordf_t> layer_height_profile;
|
||||
this->update_layer_height_profile(*this->model_object(), m_slicing_params, layer_height_profile);
|
||||
m_print->throw_if_canceled();
|
||||
|
@ -133,7 +138,7 @@ void PrintObject::make_perimeters()
|
|||
if (! this->set_started(posPerimeters))
|
||||
return;
|
||||
|
||||
m_print->set_status(20, "Generating perimeters");
|
||||
m_print->set_status(20, L("Generating perimeters"));
|
||||
BOOST_LOG_TRIVIAL(info) << "Generating perimeters..." << log_memory_info();
|
||||
|
||||
// merge slices if they were split into types
|
||||
|
@ -243,7 +248,7 @@ void PrintObject::prepare_infill()
|
|||
if (! this->set_started(posPrepareInfill))
|
||||
return;
|
||||
|
||||
m_print->set_status(30, "Preparing infill");
|
||||
m_print->set_status(30, L("Preparing infill"));
|
||||
|
||||
// This will assign a type (top/bottom/internal) to $layerm->slices.
|
||||
// Then the classifcation of $layerm->slices is transfered onto
|
||||
|
@ -383,7 +388,7 @@ void PrintObject::generate_support_material()
|
|||
if (this->set_started(posSupportMaterial)) {
|
||||
this->clear_support_layers();
|
||||
if ((m_config.support_material || m_config.raft_layers > 0) && m_layers.size() > 1) {
|
||||
m_print->set_status(85, "Generating support material");
|
||||
m_print->set_status(85, L("Generating support material"));
|
||||
this->_generate_support_material();
|
||||
m_print->throw_if_canceled();
|
||||
} else {
|
||||
|
|
|
@ -1858,116 +1858,101 @@ TriangleMesh make_cube(double x, double y, double z) {
|
|||
// Generate the mesh for a cylinder and return it, using
|
||||
// the generated angle to calculate the top mesh triangles.
|
||||
// Default is 360 sides, angle fa is in radians.
|
||||
TriangleMesh make_cylinder(double r, double h, double fa) {
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> facets;
|
||||
TriangleMesh make_cylinder(double r, double h, double fa)
|
||||
{
|
||||
size_t n_steps = (size_t)ceil(2. * PI / fa);
|
||||
double angle_step = 2. * PI / n_steps;
|
||||
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> facets;
|
||||
vertices.reserve(2 * n_steps + 2);
|
||||
facets.reserve(4 * n_steps);
|
||||
|
||||
// 2 special vertices, top and bottom center, rest are relative to this
|
||||
vertices.emplace_back(Vec3d(0.0, 0.0, 0.0));
|
||||
vertices.emplace_back(Vec3d(0.0, 0.0, h));
|
||||
|
||||
// adjust via rounding to get an even multiple for any provided angle.
|
||||
double angle = (2*PI / floor(2*PI / fa));
|
||||
|
||||
// for each line along the polygon approximating the top/bottom of the
|
||||
// circle, generate four points and four facets (2 for the wall, 2 for the
|
||||
// top and bottom.
|
||||
// Special case: Last line shares 2 vertices with the first line.
|
||||
unsigned id = vertices.size() - 1;
|
||||
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, 0));
|
||||
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, h));
|
||||
for (double i = 0; i < 2*PI; i+=angle) {
|
||||
Vec2d p = Eigen::Rotation2Dd(i) * Eigen::Vector2d(0, r);
|
||||
Vec2d p = Eigen::Rotation2Dd(0.) * Eigen::Vector2d(0, r);
|
||||
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
||||
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
||||
for (size_t i = 1; i < n_steps; ++i) {
|
||||
p = Eigen::Rotation2Dd(angle_step * i) * Eigen::Vector2d(0, r);
|
||||
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
||||
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
||||
id = vertices.size() - 1;
|
||||
int id = (int)vertices.size() - 1;
|
||||
facets.emplace_back(Vec3crd( 0, id - 1, id - 3)); // top
|
||||
facets.emplace_back(Vec3crd(id, 1, id - 2)); // bottom
|
||||
facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side
|
||||
facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side
|
||||
facets.emplace_back(Vec3crd(id, id - 3, id - 1)); // bottom-left of side
|
||||
}
|
||||
// Connect the last set of vertices with the first.
|
||||
facets.emplace_back(Vec3crd( 2, 0, id - 1));
|
||||
facets.emplace_back(Vec3crd( 1, 3, id));
|
||||
facets.emplace_back(Vec3crd(id, 3, 2));
|
||||
facets.emplace_back(Vec3crd(id, 2, id - 1));
|
||||
int id = (int)vertices.size() - 1;
|
||||
facets.emplace_back(Vec3crd( 0, 2, id - 1));
|
||||
facets.emplace_back(Vec3crd( 3, 1, id));
|
||||
facets.emplace_back(Vec3crd(id, 2, 3));
|
||||
facets.emplace_back(Vec3crd(id, id - 1, 2));
|
||||
|
||||
TriangleMesh mesh(vertices, facets);
|
||||
return mesh;
|
||||
return TriangleMesh(std::move(vertices), std::move(facets));
|
||||
}
|
||||
|
||||
// Generates mesh for a sphere centered about the origin, using the generated angle
|
||||
// to determine the granularity.
|
||||
// Default angle is 1 degree.
|
||||
TriangleMesh make_sphere(double rho, double fa) {
|
||||
Pointf3s vertices;
|
||||
std::vector<Vec3crd> facets;
|
||||
//FIXME better to discretize an Icosahedron recursively http://www.songho.ca/opengl/gl_sphere.html
|
||||
TriangleMesh make_sphere(double radius, double fa)
|
||||
{
|
||||
int sectorCount = ceil(2. * M_PI / fa);
|
||||
int stackCount = ceil(M_PI / fa);
|
||||
float sectorStep = 2. * M_PI / sectorCount;
|
||||
float stackStep = M_PI / stackCount;
|
||||
|
||||
// Algorithm:
|
||||
// Add points one-by-one to the sphere grid and form facets using relative coordinates.
|
||||
// Sphere is composed effectively of a mesh of stacked circles.
|
||||
Pointf3s vertices;
|
||||
vertices.reserve((stackCount - 1) * sectorCount + 2);
|
||||
for (int i = 0; i <= stackCount; ++ i) {
|
||||
// from pi/2 to -pi/2
|
||||
double stackAngle = 0.5 * M_PI - stackStep * i;
|
||||
double xy = radius * cos(stackAngle);
|
||||
double z = radius * sin(stackAngle);
|
||||
if (i == 0 || i == stackCount)
|
||||
vertices.emplace_back(Vec3d(xy, 0., z));
|
||||
else
|
||||
for (int j = 0; j < sectorCount; ++ j) {
|
||||
// from 0 to 2pi
|
||||
double sectorAngle = sectorStep * j;
|
||||
vertices.emplace_back(Vec3d(xy * cos(sectorAngle), xy * sin(sectorAngle), z));
|
||||
}
|
||||
}
|
||||
|
||||
// adjust via rounding to get an even multiple for any provided angle.
|
||||
double angle = (2*PI / floor(2*PI / fa));
|
||||
|
||||
// Ring to be scaled to generate the steps of the sphere
|
||||
std::vector<double> ring;
|
||||
for (double i = 0; i < 2*PI; i+=angle) {
|
||||
ring.emplace_back(i);
|
||||
}
|
||||
const size_t steps = ring.size();
|
||||
const double increment = (double)(1.0 / (double)steps);
|
||||
|
||||
// special case: first ring connects to 0,0,0
|
||||
// insert and form facets.
|
||||
vertices.emplace_back(Vec3d(0.0, 0.0, -rho));
|
||||
size_t id = vertices.size();
|
||||
for (size_t i = 0; i < ring.size(); i++) {
|
||||
// Fixed scaling
|
||||
const double z = -rho + increment*rho*2.0;
|
||||
// radius of the circle for this step.
|
||||
const double r = sqrt(abs(rho*rho - z*z));
|
||||
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||
facets.emplace_back((i == 0) ? Vec3crd(1, 0, ring.size()) : Vec3crd(id, 0, id - 1));
|
||||
++ id;
|
||||
}
|
||||
|
||||
// General case: insert and form facets for each step, joining it to the ring below it.
|
||||
for (size_t s = 2; s < steps - 1; s++) {
|
||||
const double z = -rho + increment*(double)s*2.0*rho;
|
||||
const double r = sqrt(abs(rho*rho - z*z));
|
||||
|
||||
for (size_t i = 0; i < ring.size(); i++) {
|
||||
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||
if (i == 0) {
|
||||
// wrap around
|
||||
facets.emplace_back(Vec3crd(id + ring.size() - 1 , id, id - 1));
|
||||
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1));
|
||||
} else {
|
||||
facets.emplace_back(Vec3crd(id , id - ring.size(), (id - 1) - ring.size()));
|
||||
facets.emplace_back(Vec3crd(id, id - 1 - ring.size() , id - 1));
|
||||
}
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// special case: last ring connects to 0,0,rho*2.0
|
||||
// only form facets.
|
||||
vertices.emplace_back(Vec3d(0.0, 0.0, rho));
|
||||
for (size_t i = 0; i < ring.size(); i++) {
|
||||
if (i == 0) {
|
||||
// third vertex is on the other side of the ring.
|
||||
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1));
|
||||
} else {
|
||||
facets.emplace_back(Vec3crd(id, id - ring.size() + i, id - ring.size() + (i - 1)));
|
||||
}
|
||||
}
|
||||
id++;
|
||||
TriangleMesh mesh(vertices, facets);
|
||||
return mesh;
|
||||
std::vector<Vec3crd> facets;
|
||||
facets.reserve(2 * (stackCount - 1) * sectorCount);
|
||||
for (int i = 0; i < stackCount; ++ i) {
|
||||
// Beginning of current stack.
|
||||
int k1 = (i == 0) ? 0 : (1 + (i - 1) * sectorCount);
|
||||
int k1_first = k1;
|
||||
// Beginning of next stack.
|
||||
int k2 = (i == 0) ? 1 : (k1 + sectorCount);
|
||||
int k2_first = k2;
|
||||
for (int j = 0; j < sectorCount; ++ j) {
|
||||
// 2 triangles per sector excluding first and last stacks
|
||||
int k1_next = k1;
|
||||
int k2_next = k2;
|
||||
if (i != 0) {
|
||||
k1_next = (j + 1 == sectorCount) ? k1_first : (k1 + 1);
|
||||
facets.emplace_back(Vec3crd(k1, k2, k1_next));
|
||||
}
|
||||
if (i + 1 != stackCount) {
|
||||
k2_next = (j + 1 == sectorCount) ? k2_first : (k2 + 1);
|
||||
facets.emplace_back(Vec3crd(k1_next, k2, k2_next));
|
||||
}
|
||||
k1 = k1_next;
|
||||
k2 = k2_next;
|
||||
}
|
||||
}
|
||||
return TriangleMesh(std::move(vertices), std::move(facets));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue