2018-11-08 19:18:40 +00:00
|
|
|
#ifndef slic3r_SLAPrint_hpp_
|
|
|
|
#define slic3r_SLAPrint_hpp_
|
|
|
|
|
2018-11-21 14:21:57 +00:00
|
|
|
#include <mutex>
|
|
|
|
|
2018-11-08 19:18:40 +00:00
|
|
|
#include "PrintBase.hpp"
|
2018-11-13 16:33:03 +00:00
|
|
|
#include "PrintExport.hpp"
|
2018-11-08 19:18:40 +00:00
|
|
|
#include "Point.hpp"
|
2018-11-21 14:21:57 +00:00
|
|
|
#include "MTUtils.hpp"
|
2018-11-08 19:18:40 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2018-11-13 17:44:30 +00:00
|
|
|
enum SLAPrintStep : unsigned int {
|
2018-11-08 19:18:40 +00:00
|
|
|
slapsRasterize,
|
2018-11-09 11:02:42 +00:00
|
|
|
slapsValidate,
|
2018-11-08 19:18:40 +00:00
|
|
|
slapsCount
|
|
|
|
};
|
|
|
|
|
2018-11-13 17:44:30 +00:00
|
|
|
enum SLAPrintObjectStep : unsigned int {
|
2018-11-09 11:02:42 +00:00
|
|
|
slaposObjectSlice,
|
|
|
|
slaposSupportIslands,
|
2018-11-08 19:18:40 +00:00
|
|
|
slaposSupportPoints,
|
|
|
|
slaposSupportTree,
|
|
|
|
slaposBasePool,
|
2018-11-09 11:02:42 +00:00
|
|
|
slaposSliceSupports,
|
2018-11-08 19:18:40 +00:00
|
|
|
slaposCount
|
|
|
|
};
|
|
|
|
|
|
|
|
class SLAPrint;
|
2018-11-12 16:35:57 +00:00
|
|
|
class GLCanvas;
|
2018-11-08 19:18:40 +00:00
|
|
|
|
2018-11-09 17:32:35 +00:00
|
|
|
using _SLAPrintObjectBase =
|
|
|
|
PrintObjectBaseWithState<SLAPrint, SLAPrintObjectStep, slaposCount>;
|
|
|
|
|
|
|
|
class SLAPrintObject : public _SLAPrintObjectBase
|
2018-11-08 19:18:40 +00:00
|
|
|
{
|
|
|
|
private: // Prevents erroneous use by other classes.
|
2018-11-09 17:32:35 +00:00
|
|
|
using Inherited = _SLAPrintObjectBase;
|
2018-11-08 19:18:40 +00:00
|
|
|
|
|
|
|
public:
|
2018-11-13 16:45:44 +00:00
|
|
|
const Transform3d& trafo() const { return m_trafo; }
|
|
|
|
|
|
|
|
struct Instance {
|
2018-11-13 18:22:05 +00:00
|
|
|
Instance(ModelID instance_id, const Point &shift, float rotation) : instance_id(instance_id), shift(shift), rotation(rotation) {}
|
|
|
|
// ID of the corresponding ModelInstance.
|
|
|
|
ModelID instance_id;
|
|
|
|
// Slic3r::Point objects in scaled G-code coordinates
|
2018-11-13 16:45:44 +00:00
|
|
|
Point shift;
|
|
|
|
// Rotation along the Z axis, in radians.
|
|
|
|
float rotation;
|
2018-11-13 18:22:05 +00:00
|
|
|
};
|
2018-11-13 16:45:44 +00:00
|
|
|
const std::vector<Instance>& instances() const { return m_instances; }
|
|
|
|
|
2018-11-17 16:23:56 +00:00
|
|
|
bool has_mesh(SLAPrintObjectStep step) const;
|
|
|
|
TriangleMesh get_mesh(SLAPrintObjectStep step) const;
|
|
|
|
|
2018-11-13 16:45:44 +00:00
|
|
|
// Get a support mesh centered around origin in XY, and with zero rotation around Z applied.
|
|
|
|
// Support mesh is only valid if this->is_step_done(slaposSupportTree) is true.
|
2018-11-21 14:21:57 +00:00
|
|
|
const TriangleMesh& support_mesh() const;
|
2018-11-13 16:45:44 +00:00
|
|
|
// Get a pad mesh centered around origin in XY, and with zero rotation around Z applied.
|
|
|
|
// Support mesh is only valid if this->is_step_done(slaposPad) is true.
|
2018-11-21 14:21:57 +00:00
|
|
|
const TriangleMesh& pad_mesh() const;
|
2018-11-09 11:02:42 +00:00
|
|
|
|
2018-11-15 17:05:47 +00:00
|
|
|
// This will return the transformed mesh which is cached
|
|
|
|
const TriangleMesh& transformed_mesh() const;
|
|
|
|
|
2018-11-16 10:34:19 +00:00
|
|
|
std::vector<Vec3d> transformed_support_points() const;
|
|
|
|
|
2018-11-16 16:25:23 +00:00
|
|
|
// Get the needed Z elevation for the model geometry if supports should be
|
|
|
|
// displayed. This Z offset should also be applied to the support
|
|
|
|
// geometries. Note that this is not the same as the value stored in config
|
|
|
|
// as the pad height also needs to be considered.
|
|
|
|
double get_elevation() const;
|
|
|
|
|
2018-11-21 14:21:57 +00:00
|
|
|
// Should be obvious
|
|
|
|
const std::vector<ExPolygons>& get_support_slices() const;
|
|
|
|
const std::vector<ExPolygons>& get_model_slices() const;
|
2018-11-16 16:25:23 +00:00
|
|
|
|
2018-11-09 17:32:35 +00:00
|
|
|
// I refuse to grantee copying (Tamas)
|
|
|
|
SLAPrintObject(const SLAPrintObject&) = delete;
|
|
|
|
SLAPrintObject& operator=(const SLAPrintObject&) = delete;
|
|
|
|
|
2018-11-09 11:02:42 +00:00
|
|
|
protected:
|
|
|
|
// to be called from SLAPrint only.
|
|
|
|
friend class SLAPrint;
|
|
|
|
|
|
|
|
SLAPrintObject(SLAPrint* print, ModelObject* model_object);
|
2018-11-09 17:32:35 +00:00
|
|
|
~SLAPrintObject();
|
2018-11-09 11:02:42 +00:00
|
|
|
|
|
|
|
void config_apply(const ConfigBase &other, bool ignore_nonexistent = false) { this->m_config.apply(other, ignore_nonexistent); }
|
|
|
|
void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false)
|
|
|
|
{ this->m_config.apply_only(other, keys, ignore_nonexistent); }
|
2018-11-21 14:21:57 +00:00
|
|
|
|
|
|
|
void set_trafo(const Transform3d& trafo) {
|
|
|
|
m_transformed_rmesh.invalidate([this, &trafo](){ m_trafo = trafo; });
|
|
|
|
}
|
2018-11-09 11:02:42 +00:00
|
|
|
|
|
|
|
bool set_instances(const std::vector<Instance> &instances);
|
|
|
|
// Invalidates the step, and its depending steps in SLAPrintObject and SLAPrint.
|
|
|
|
bool invalidate_step(SLAPrintObjectStep step);
|
2018-11-08 19:18:40 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-20 10:59:40 +00:00
|
|
|
|
2018-11-09 11:02:42 +00:00
|
|
|
// Object specific configuration, pulled from the configuration layer.
|
|
|
|
SLAPrintObjectConfig m_config;
|
|
|
|
// Translation in Z + Rotation by Y and Z + Scaling / Mirroring.
|
|
|
|
Transform3d m_trafo = Transform3d::Identity();
|
|
|
|
std::vector<Instance> m_instances;
|
|
|
|
|
2018-11-09 17:32:35 +00:00
|
|
|
// Which steps have to be performed. Implicitly: all
|
|
|
|
std::vector<bool> m_stepmask;
|
2018-11-13 16:33:03 +00:00
|
|
|
std::vector<ExPolygons> m_model_slices;
|
2018-11-08 19:18:40 +00:00
|
|
|
|
2018-11-15 17:05:47 +00:00
|
|
|
// Caching the transformed (m_trafo) raw mesh of the object
|
2018-11-21 14:21:57 +00:00
|
|
|
mutable CachedObject<TriangleMesh> m_transformed_rmesh;
|
2018-11-15 17:05:47 +00:00
|
|
|
|
2018-11-09 17:32:35 +00:00
|
|
|
class SupportData;
|
|
|
|
std::unique_ptr<SupportData> m_supportdata;
|
2018-11-08 19:18:40 +00:00
|
|
|
};
|
|
|
|
|
2018-11-12 16:35:57 +00:00
|
|
|
using PrintObjects = std::vector<SLAPrintObject*>;
|
|
|
|
|
|
|
|
class TriangleMesh;
|
|
|
|
|
2018-11-08 19:18:40 +00:00
|
|
|
/**
|
|
|
|
* @brief This class is the high level FSM for the SLA printing process.
|
|
|
|
*
|
|
|
|
* It should support the background processing framework and contain the
|
|
|
|
* metadata for the support geometries and their slicing. It should also
|
|
|
|
* dispatch the SLA printing configuration values to the appropriate calculation
|
|
|
|
* steps.
|
|
|
|
*/
|
|
|
|
class SLAPrint : public PrintBaseWithState<SLAPrintStep, slapsCount>
|
|
|
|
{
|
|
|
|
private: // Prevents erroneous use by other classes.
|
|
|
|
typedef PrintBaseWithState<SLAPrintStep, slapsCount> Inherited;
|
|
|
|
|
|
|
|
public:
|
2018-11-13 10:53:54 +00:00
|
|
|
SLAPrint(): m_stepmask(slapsCount, true) {}
|
2018-11-13 16:33:03 +00:00
|
|
|
|
2018-11-08 19:18:40 +00:00
|
|
|
virtual ~SLAPrint() { this->clear(); }
|
|
|
|
|
|
|
|
PrinterTechnology technology() const noexcept { return ptSLA; }
|
|
|
|
|
|
|
|
void clear() override;
|
|
|
|
bool empty() const override { return false; }
|
|
|
|
ApplyStatus apply(const Model &model, const DynamicPrintConfig &config) override;
|
|
|
|
void process() override;
|
|
|
|
|
2018-11-13 16:33:03 +00:00
|
|
|
template<class Fmt> void export_raster(const std::string& fname) {
|
|
|
|
if(m_printer) m_printer->save<Fmt>(fname);
|
|
|
|
}
|
2018-11-13 16:45:44 +00:00
|
|
|
const PrintObjects& objects() const { return m_objects; }
|
|
|
|
|
2018-11-08 19:18:40 +00:00
|
|
|
private:
|
2018-11-13 16:33:03 +00:00
|
|
|
using SLAPrinter = FilePrinter<FilePrinterFormat::SLA_PNGZIP>;
|
|
|
|
using SLAPrinterPtr = std::unique_ptr<SLAPrinter>;
|
|
|
|
|
2018-11-08 19:18:40 +00:00
|
|
|
SLAPrinterConfig m_printer_config;
|
|
|
|
SLAMaterialConfig m_material_config;
|
2018-11-12 16:35:57 +00:00
|
|
|
PrintObjects m_objects;
|
2018-11-13 10:53:54 +00:00
|
|
|
std::vector<bool> m_stepmask;
|
2018-11-13 16:33:03 +00:00
|
|
|
SLAPrinterPtr m_printer;
|
2018-11-08 19:18:40 +00:00
|
|
|
|
|
|
|
friend SLAPrintObject;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif /* slic3r_SLAPrint_hpp_ */
|