This commit is contained in:
YuSanka 2019-01-10 11:10:01 +01:00
commit 107152b25e
30 changed files with 327 additions and 68 deletions

View file

@ -561,6 +561,12 @@ bool DynamicConfig::read_cli(int argc, char** argv, t_config_option_keys* extra)
extra->push_back(token);
continue;
}
#ifdef __APPLE__
if (boost::starts_with(token, "-psn_"))
// OSX launcher may add a "process serial number", for example "-psn_0_989382" to the command line.
// While it is supposed to be dropped since OSX 10.9, we will rather ignore it.
continue;
#endif /* __APPLE__ */
// Stop parsing tokens as options when -- is supplied.
if (token == "--") {
parse_options = false;

View file

@ -1181,22 +1181,34 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation,
Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& rotation_matrix)
{
auto y_only = [](const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& matrix) -> bool {
return (matrix(0, 1) == 0.0) && (matrix(1, 0) == 0.0) && (matrix(1, 1) == 1.0) && (matrix(1, 2) == 0.0) && (matrix(2, 1) == 0.0);
};
// see: https://www.learnopencv.com/rotation-matrix-to-euler-angles/
double sy = ::sqrt(sqr(rotation_matrix(0, 0)) + sqr(rotation_matrix(1, 0)));
double cy_abs = ::sqrt(sqr(rotation_matrix(0, 0)) + sqr(rotation_matrix(1, 0)));
Vec3d angles = Vec3d::Zero();
if (sy >= 1e-6)
if (cy_abs >= 1e-6)
{
angles(0) = ::atan2(rotation_matrix(2, 1), rotation_matrix(2, 2));
angles(1) = ::atan2(-rotation_matrix(2, 0), sy);
angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs);
angles(2) = ::atan2(rotation_matrix(1, 0), rotation_matrix(0, 0));
// this is an hack to try to avoid this function to return "strange" values due to gimbal lock
if (y_only(rotation_matrix) && (angles(0) == (double)PI) && (angles(2) == (double)PI))
{
angles(0) = 0.0;
angles(1) = ::atan2(rotation_matrix(2, 0), cy_abs) - (double)PI;
angles(2) = 0.0;
}
}
else
{
angles(0) = 0.0;
angles(1) = ::atan2(-rotation_matrix(2, 0), sy);
angles(2) = (angles(1) >-0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1));
angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs);
angles(2) = (angles(1) >= 0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1));
}
return angles;

View file

@ -2527,6 +2527,22 @@ void PrintConfigDef::init_sla_params()
def->min = 0;
def->default_value = new ConfigOptionFloat(1.0);
def = this->add("support_pillar_connection_mode", coEnum);
def->label = L("Support pillar connection mode");
def->tooltip = L("Controls the bridge type between two neigboring pillars."
" Can be zig-zag, cross (double zig-zag) or dynamic which"
" will automatically switch between the first two depending"
" on the distance of the two pillars.");
def->cli = "";
def->enum_keys_map = &ConfigOptionEnum<SLAPillarConnectionMode>::get_enum_values();
def->enum_values.push_back("zigzag");
def->enum_values.push_back("cross");
def->enum_values.push_back("dynamic");
def->enum_labels.push_back(L("Zig-Zag"));
def->enum_labels.push_back(L("Cross"));
def->enum_labels.push_back(L("Dynamic"));
def->default_value = new ConfigOptionEnum<SLAPillarConnectionMode>(slapcmDynamic);
def = this->add("support_pillar_widening_factor", coFloat);
def->label = L("Pillar widening factor");
def->category = L("Supports");
@ -3044,7 +3060,7 @@ CLIConfigDef::CLIConfigDef()
def->tooltip = L("Forces the GUI launch instead of command line slicing "
"(if you supply a model file, it will be loaded into the plater)");
def->cli = "gui";
def->default_value = new ConfigOptionBool(true);
def->default_value = new ConfigOptionBool(false);
def = this->add("info", coBool);
def->label = L("Output Model Info");

View file

@ -61,6 +61,12 @@ enum SLADisplayOrientation {
sladoPortrait
};
enum SLAPillarConnectionMode {
slapcmZigZag,
slapcmCross,
slapcmDynamic
};
template<> inline const t_config_enum_values& ConfigOptionEnum<PrinterTechnology>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {
@ -162,6 +168,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<SLADisplayOrienta
return keys_map;
}
template<> inline const t_config_enum_values& ConfigOptionEnum<SLAPillarConnectionMode>::get_enum_values() {
static const t_config_enum_values keys_map = {
{"zigzag", slapcmZigZag},
{"cross", slapcmCross},
{"dynamic", slapcmDynamic}
};
return keys_map;
}
// Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs.
// Does not store the actual values, but defines default values.
class PrintConfigDef : public ConfigDef
@ -949,6 +965,9 @@ public:
// Radius in mm of the support pillars.
ConfigOptionFloat support_pillar_diameter /*= 0.8*/;
// How the pillars are bridged together
ConfigOptionEnum<SLAPillarConnectionMode> support_pillar_connection_mode;
// TODO: unimplemented at the moment. This coefficient will have an impact
// when bridges and pillars are merged. The resulting pillar should be a bit
// thicker than the ones merging into it. How much thicker? I don't know
@ -1003,6 +1022,7 @@ protected:
OPT_PTR(support_head_penetration);
OPT_PTR(support_head_width);
OPT_PTR(support_pillar_diameter);
OPT_PTR(support_pillar_connection_mode);
OPT_PTR(support_pillar_widening_factor);
OPT_PTR(support_base_diameter);
OPT_PTR(support_base_height);

View file

@ -1249,8 +1249,13 @@ bool SLASupportTree::generate(const PointSet &points,
if(chkd >= bridge_distance) {
result.add_bridge(sj, ej, pillar.r);
auto pcm = cfg.pillar_connection_mode;
// double bridging: (crosses)
if(pillar_dist > 2*cfg.base_radius_mm) {
if( pcm == PillarConnectionMode::cross ||
(pcm == PillarConnectionMode::dynamic &&
pillar_dist > 2*cfg.base_radius_mm))
{
// If the columns are close together, no need to
// double bridge them
Vec3d bsj(ej(X), ej(Y), sj(Z));

View file

@ -28,6 +28,12 @@ using SlicedSupports = std::vector<SliceLayer>;
namespace sla {
enum class PillarConnectionMode {
zigzag,
cross,
dynamic
};
struct SupportConfig {
// Radius in mm of the pointing side of the head.
double head_front_radius_mm = 0.2;
@ -46,6 +52,9 @@ struct SupportConfig {
// headless pillars will have half of this value.
double headless_pillar_radius_mm = 0.4;
// How to connect pillars
PillarConnectionMode pillar_connection_mode = PillarConnectionMode::dynamic;
// TODO: unimplemented at the moment. This coefficient will have an impact
// when bridges and pillars are merged. The resulting pillar should be a bit
// thicker than the ones merging into it. How much thicker? I don't know

View file

@ -407,6 +407,14 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) {
scfg.tilt = c.support_critical_angle.getFloat() * PI / 180.0 ;
scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat();
scfg.headless_pillar_radius_mm = 0.375*c.support_pillar_diameter.getFloat();
switch(c.support_pillar_connection_mode.getInt()) {
case slapcmZigZag:
scfg.pillar_connection_mode = sla::PillarConnectionMode::zigzag; break;
case slapcmCross:
scfg.pillar_connection_mode = sla::PillarConnectionMode::cross; break;
case slapcmDynamic:
scfg.pillar_connection_mode = sla::PillarConnectionMode::dynamic; break;
}
scfg.pillar_widening_factor = c.support_pillar_widening_factor.getFloat();
scfg.base_radius_mm = 0.5*c.support_base_diameter.getFloat();
scfg.base_height_mm = c.support_base_height.getFloat();
@ -1058,6 +1066,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector<t_conf
|| opt_key == "support_head_penetration"
|| opt_key == "support_head_width"
|| opt_key == "support_pillar_diameter"
|| opt_key == "support_pillar_connection_mode"
|| opt_key == "support_base_diameter"
|| opt_key == "support_base_height"
|| opt_key == "support_critical_angle"