This commit is contained in:
bubnikv 2019-01-14 19:59:33 +01:00
commit 366e8422a7
12 changed files with 108 additions and 19 deletions

View file

@ -1477,6 +1477,7 @@ namespace Slic3r {
stl_get_size(&stl);
volume->mesh.repair();
volume->center_geometry();
volume->calculate_convex_hull();
// apply volume's name and config data

View file

@ -819,14 +819,27 @@ TriangleMesh ModelObject::full_raw_mesh() const
BoundingBoxf3 ModelObject::raw_bounding_box() const
{
BoundingBoxf3 bb;
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (this->instances.empty())
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
const Transform3d& inst_matrix = this->instances.front()->get_transformation().get_matrix(true);
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
for (const ModelVolume *v : this->volumes)
if (v->is_model_part()) {
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (this->instances.empty())
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
TriangleMesh vol_mesh(v->mesh);
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
vol_mesh.transform(inst_matrix * v->get_matrix());
bb.merge(vol_mesh.bounding_box());
#else
vol_mesh.transform(v->get_matrix());
bb.merge(this->instances.front()->transform_mesh_bounding_box(vol_mesh, true));
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
}
return bb;
}
@ -835,13 +848,21 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const
BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_translate) const
{
BoundingBoxf3 bb;
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
const Transform3d& inst_matrix = this->instances[instance_idx]->get_transformation().get_matrix(dont_translate);
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
for (ModelVolume *v : this->volumes)
{
if (v->is_model_part())
{
TriangleMesh mesh(v->mesh);
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
mesh.transform(inst_matrix * v->get_matrix());
bb.merge(mesh.bounding_box());
#else
mesh.transform(v->get_matrix());
bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate));
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
}
}
return bb;

View file

@ -223,6 +223,9 @@ struct Head {
// If there is a pillar connecting to this head, then the id will be set.
long pillar_id = -1;
inline void invalidate() { id = -1; }
inline bool is_valid() const { return id >= 0; }
Head(double r_big_mm,
double r_small_mm,
double length_mm,
@ -739,8 +742,10 @@ public:
for(auto& head : heads()) {
if(m_ctl.stopcondition()) break;
auto&& m = mesh(head.mesh);
meshcache.merge(m);
if(head.is_valid()) {
auto&& m = mesh(head.mesh);
meshcache.merge(m);
}
}
for(auto& stick : pillars()) {
@ -1533,8 +1538,19 @@ bool SLASupportTree::generate(const PointSet &points,
// In this case there is no room for the base pinhead.
if(gh < head.fullwidth()) {
base_width = gh - 2 * cfg.head_front_radius_mm -
2*cfg.head_back_radius_mm + cfg.head_penetration_mm;
double min_l =
2 * cfg.head_front_radius_mm +
2 * cfg.head_back_radius_mm - cfg.head_penetration_mm;
base_width = gh - min_l;
}
if(base_width < 0) {
// There is really no space for even a reduced size head. We
// have to replace that with a small half sphere that touches
// the model surface. (TODO)
head.invalidate();
continue;
}
head.transform();
@ -1555,6 +1571,7 @@ bool SLASupportTree::generate(const PointSet &points,
// This should not happen it is against all assumptions
BOOST_LOG_TRIVIAL(warning)
<< "Ignoring invalid supports connecting to model body";
head.invalidate();
continue;
}

View file

@ -58,3 +58,5 @@
#define ENABLE_NEW_EULER_ANGLES (1 && ENABLE_1_42_0_ALPHA4)
// Added minimum threshold for click and drag movements
#define ENABLE_MOVE_MIN_THRESHOLD (1 && ENABLE_1_42_0_ALPHA4)
// Modified initial default placement of generic subparts
#define ENABLE_GENERIC_SUBPARTS_PLACEMENT (1 && ENABLE_1_42_0_ALPHA4)