2018-07-30 14:41:35 +00:00
|
|
|
#ifndef MODELARRANGE_HPP
|
|
|
|
#define MODELARRANGE_HPP
|
|
|
|
|
|
|
|
#include "Model.hpp"
|
2018-08-03 10:37:27 +00:00
|
|
|
|
2018-07-30 14:41:35 +00:00
|
|
|
namespace Slic3r {
|
2018-08-02 11:15:30 +00:00
|
|
|
|
2018-11-12 13:52:52 +00:00
|
|
|
class Model;
|
2018-08-22 11:52:41 +00:00
|
|
|
|
2018-11-12 13:52:52 +00:00
|
|
|
namespace arr {
|
2018-07-30 14:41:35 +00:00
|
|
|
|
2018-08-03 12:49:26 +00:00
|
|
|
class Circle {
|
|
|
|
Point center_;
|
|
|
|
double radius_;
|
|
|
|
public:
|
|
|
|
|
|
|
|
inline Circle(): center_(0, 0), radius_(std::nan("")) {}
|
|
|
|
inline Circle(const Point& c, double r): center_(c), radius_(r) {}
|
|
|
|
|
|
|
|
inline double radius() const { return radius_; }
|
|
|
|
inline const Point& center() const { return center_; }
|
2018-08-06 09:30:10 +00:00
|
|
|
inline operator bool() { return !std::isnan(radius_); }
|
2018-08-03 12:49:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class BedShapeType {
|
2018-08-02 11:15:30 +00:00
|
|
|
BOX,
|
|
|
|
CIRCLE,
|
|
|
|
IRREGULAR,
|
|
|
|
WHO_KNOWS
|
|
|
|
};
|
|
|
|
|
2018-08-03 12:49:26 +00:00
|
|
|
struct BedShapeHint {
|
|
|
|
BedShapeType type;
|
|
|
|
/*union*/ struct { // I know but who cares...
|
|
|
|
Circle circ;
|
|
|
|
BoundingBox box;
|
|
|
|
Polyline polygon;
|
|
|
|
} shape;
|
|
|
|
};
|
|
|
|
|
2018-11-12 13:52:52 +00:00
|
|
|
BedShapeHint bedShape(const Polyline& bed);
|
2018-08-02 11:15:30 +00:00
|
|
|
|
2018-07-30 14:41:35 +00:00
|
|
|
/**
|
|
|
|
* \brief Arranges the model objects on the screen.
|
|
|
|
*
|
|
|
|
* The arrangement considers multiple bins (aka. print beds) for placing all
|
|
|
|
* the items provided in the model argument. If the items don't fit on one
|
|
|
|
* print bed, the remaining will be placed onto newly created print beds.
|
2018-09-19 16:02:04 +00:00
|
|
|
* The first_bin_only parameter, if set to true, disables this behavior and
|
2018-07-30 14:41:35 +00:00
|
|
|
* makes sure that only one print bed is filled and the remaining items will be
|
|
|
|
* untouched. When set to false, the items which could not fit onto the
|
|
|
|
* print bed will be placed next to the print bed so the user should see a
|
|
|
|
* pile of items on the print bed and some other piles outside the print
|
|
|
|
* area that can be dragged later onto the print bed as a group.
|
|
|
|
*
|
|
|
|
* \param model The model object with the 3D content.
|
|
|
|
* \param dist The minimum distance which is allowed for any pair of items
|
|
|
|
* on the print bed in any direction.
|
|
|
|
* \param bb The bounding box of the print bed. It corresponds to the 'bin'
|
|
|
|
* for bin packing.
|
|
|
|
* \param first_bin_only This parameter controls whether to place the
|
|
|
|
* remaining items which do not fit onto the print area next to the print
|
|
|
|
* bed or leave them untouched (let the user arrange them by hand or remove
|
|
|
|
* them).
|
2018-09-17 13:12:13 +00:00
|
|
|
* \param progressind Progress indicator callback called when an object gets
|
|
|
|
* packed. The unsigned argument is the number of items remaining to pack.
|
|
|
|
* \param stopcondition A predicate returning true if abort is needed.
|
2018-07-30 14:41:35 +00:00
|
|
|
*/
|
2018-11-12 13:52:52 +00:00
|
|
|
bool arrange(Model &model, coord_t min_obj_distance,
|
2018-08-02 11:15:30 +00:00
|
|
|
const Slic3r::Polyline& bed,
|
|
|
|
BedShapeHint bedhint,
|
2018-07-30 14:41:35 +00:00
|
|
|
bool first_bin_only,
|
2018-09-17 13:12:13 +00:00
|
|
|
std::function<void(unsigned)> progressind,
|
2018-11-12 13:52:52 +00:00
|
|
|
std::function<bool(void)> stopcondition);
|
2018-08-03 12:49:26 +00:00
|
|
|
|
2018-07-30 14:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // MODELARRANGE_HPP
|