mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-04 04:24:04 -06:00
ENH: disable arranging selected items
0. disable arranging selected 1. fix bug where brim is not correct. 2. fix bug where big circle objects are not arranged properly 3. disable default enable_rotation Change-Id: Ifc69f35d900ff63ec1e9ec8bf8638afc6ea7d54b (cherry picked from commit 2ed1b0dd8573a1e10aaf77f0d9f8896cef304427)
This commit is contained in:
parent
74e92ac51d
commit
07ae246e5f
9 changed files with 77 additions and 31 deletions
|
@ -136,6 +136,25 @@ static double fixed_overfit(const std::tuple<double, Box>& result, const Box &bi
|
|||
return score;
|
||||
}
|
||||
|
||||
// useful for arranging big circle objects
|
||||
static double fixed_overfit_topright_sliding(const std::tuple<double, Box>& result, const Box& binbb)
|
||||
{
|
||||
double score = std::get<0>(result);
|
||||
Box pilebb = std::get<1>(result);
|
||||
|
||||
auto shift = binbb.maxCorner() - pilebb.maxCorner();
|
||||
shift.x() = std::max(0, shift.x()); // do not allow left shift
|
||||
shift.y() = std::max(0, shift.y()); // do not allow bottom shift
|
||||
pilebb.minCorner() += shift;
|
||||
pilebb.maxCorner() += shift;
|
||||
|
||||
Box fullbb = sl::boundingBox(pilebb, binbb);
|
||||
auto diff = double(fullbb.area()) - binbb.area();
|
||||
if (diff > 0) score += diff;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
// A class encapsulating the libnest2d Nester class and extending it with other
|
||||
// management and spatial index structures for acceleration.
|
||||
template<class TBin>
|
||||
|
@ -503,8 +522,9 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cfg.object_function = [this, bb, starting_point](const Item& item) {
|
||||
return fixed_overfit(objfunc(item, starting_point), bb);
|
||||
return fixed_overfit_topright_sliding(objfunc(item, starting_point), bb);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -65,8 +65,7 @@ struct ArrangePolygon {
|
|||
int itemid{ 0 }; // item id in the vector, used for accessing all possible params like extrude_id
|
||||
int is_applied{ 0 }; // transform has been applied
|
||||
double height{ 0 }; // item height
|
||||
double auto_brim_width{ 0 }; // auto brim width
|
||||
double user_brim_width{ 0 }; // user defined brim width
|
||||
double brim_width{ 0 }; // brim width
|
||||
std::string name;
|
||||
|
||||
// If empty, any rotation is allowed (currently unsupported)
|
||||
|
|
|
@ -2885,6 +2885,14 @@ double getTemperatureFromExtruder(const ModelVolumePtrs objectVolumes) {
|
|||
#endif
|
||||
}
|
||||
|
||||
double ModelInstance::get_auto_brim_width() const
|
||||
{
|
||||
double adhcoeff = getadhesionCoeff(object->volumes);
|
||||
double DeltaT = getTemperatureFromExtruder(object->volumes);
|
||||
// get auto brim width (Note even if the global brim_type=btOuterBrim, we can still go into this branch)
|
||||
return get_auto_brim_width(DeltaT, adhcoeff);
|
||||
}
|
||||
|
||||
void ModelInstance::get_arrange_polygon(void* ap) const
|
||||
{
|
||||
// static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
||||
|
@ -2924,18 +2932,6 @@ void ModelInstance::get_arrange_polygon(void* ap) const
|
|||
ret.extrude_ids = volume->get_extruders();
|
||||
if (ret.extrude_ids.empty()) //the default extruder
|
||||
ret.extrude_ids.push_back(1);
|
||||
|
||||
// get user specified brim width per object
|
||||
// Note: if global brim_type=btNoBrim or brAutoBrim, user can't set individual brim_width
|
||||
if (object->config.has("brim_width"))
|
||||
ret.user_brim_width = object->config.opt_float("brim_width");
|
||||
else {
|
||||
// BBS: get DeltaT, adhcoeff before calculating brim width
|
||||
double adhcoeff = getadhesionCoeff(object->volumes);
|
||||
double DeltaT = getTemperatureFromExtruder(object->volumes);
|
||||
// get auto brim width (Note even if the global brim_type=btOuterBrim, we can still go into this branch)
|
||||
ret.auto_brim_width = get_auto_brim_width(DeltaT, adhcoeff);
|
||||
}
|
||||
}
|
||||
|
||||
indexed_triangle_set FacetsAnnotation::get_facets(const ModelVolume& mv, EnforcerBlockerType type) const
|
||||
|
|
|
@ -297,6 +297,12 @@ public:
|
|||
const Model* get_model() const { return m_model; }
|
||||
// BBS: production extension
|
||||
int get_backup_id() const;
|
||||
template<typename T> const T* get_config_value(const DynamicPrintConfig& global_config, const std::string& config_option) {
|
||||
if (config.has(config_option))
|
||||
return static_cast<const T*>(config.option(config_option));
|
||||
else
|
||||
return global_config.option<T>(config_option);
|
||||
}
|
||||
|
||||
ModelVolume* add_volume(const TriangleMesh &mesh);
|
||||
ModelVolume* add_volume(TriangleMesh &&mesh, ModelVolumeType type = ModelVolumeType::MODEL_PART);
|
||||
|
@ -1083,6 +1089,7 @@ public:
|
|||
|
||||
//BBS
|
||||
double get_auto_brim_width(double deltaT, double adhension) const;
|
||||
double get_auto_brim_width() const;
|
||||
// BBS
|
||||
Polygon convex_hull_2d();
|
||||
void invalidate_convex_hull_2d();
|
||||
|
|
|
@ -144,8 +144,22 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r::
|
|||
for (int i = 0; i < BedType::btCount; i++)
|
||||
ap.vitrify_temp += tmp * pow(100, BedType::btCount - i - 1);
|
||||
}
|
||||
ap.height = instance->get_object()->bounding_box().size().z();
|
||||
ap.name = instance->get_object()->name;
|
||||
|
||||
// get brim width
|
||||
auto obj = instance->get_object();
|
||||
ap.brim_width = instance->get_auto_brim_width();
|
||||
auto brim_type_ptr = obj->get_config_value<ConfigOptionEnum<BrimType>>(config, "brim_type");
|
||||
if (brim_type_ptr) {
|
||||
auto brim_type = brim_type_ptr->getInt();
|
||||
if (brim_type == btOuterOnly)
|
||||
ap.brim_width = obj->get_config_value<ConfigOptionFloat>(config, "brim_width")->getFloat();
|
||||
else if (brim_type == btNoBrim)
|
||||
ap.brim_width = 0;
|
||||
}
|
||||
|
||||
|
||||
ap.height = obj->bounding_box().size().z();
|
||||
ap.name = obj->name;
|
||||
return ap;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue