diff --git a/src/slic3r/GUI/Jobs/EmbossJob.cpp b/src/slic3r/GUI/Jobs/EmbossJob.cpp
index 136399bc64..d855e84065 100644
--- a/src/slic3r/GUI/Jobs/EmbossJob.cpp
+++ b/src/slic3r/GUI/Jobs/EmbossJob.cpp
@@ -64,7 +64,7 @@ class CreateVolumeJob : public Job
TriangleMesh m_result;
public:
- CreateVolumeJob(DataCreateVolume &&input);
+ explicit CreateVolumeJob(DataCreateVolume &&input);
void process(Ctl &ctl) override;
void finalize(bool canceled, std::exception_ptr &eptr) override;
};
@@ -103,7 +103,7 @@ class CreateObjectJob : public Job
Transform3d m_transformation;
public:
- CreateObjectJob(DataCreateObject &&input);
+ explicit CreateObjectJob(DataCreateObject &&input);
void process(Ctl &ctl) override;
void finalize(bool canceled, std::exception_ptr &eptr) override;
};
@@ -136,7 +136,7 @@ class CreateSurfaceVolumeJob : public Job
TriangleMesh m_result;
public:
- CreateSurfaceVolumeJob(CreateSurfaceVolumeData &&input);
+ explicit CreateSurfaceVolumeJob(CreateSurfaceVolumeData &&input);
void process(Ctl &ctl) override;
void finalize(bool canceled, std::exception_ptr &eptr) override;
};
@@ -169,8 +169,8 @@ static bool check(const UpdateSurfaceVolumeData &input, bool is_main_thread = fa
/// NOTE: Cache glyphs is changed
/// To check if process was canceled
/// Triangle mesh model
-template static TriangleMesh try_create_mesh(DataBase &input, Fnc was_canceled);
-template static TriangleMesh create_mesh(DataBase &input, Fnc was_canceled, Job::Ctl &ctl);
+template static TriangleMesh try_create_mesh(DataBase &input, const Fnc& was_canceled);
+template static TriangleMesh create_mesh(DataBase &input, const Fnc& was_canceled, Job::Ctl &ctl);
///
/// Create default mesh for embossed text
@@ -239,7 +239,7 @@ static OrthoProject3d create_emboss_projection(bool is_outside, float emboss, Tr
/// SurfaceVolume data
/// Check to interupt execution
/// Extruded object from cuted surace
-static TriangleMesh cut_surface(/*const*/ DataBase &input1, const SurfaceVolumeData &input2, std::function was_canceled);
+static TriangleMesh cut_surface(/*const*/ DataBase &input1, const SurfaceVolumeData &input2, const std::function& was_canceled);
///
/// Copied triangles from object to be able create mesh for cut surface from
@@ -254,9 +254,8 @@ static bool process(std::exception_ptr &eptr);
static bool finalize(bool canceled, std::exception_ptr &eptr, const DataBase &input);
class JobException : public std::runtime_error {
-public: JobException(const char* message):runtime_error(message){}};
-
-auto was_canceled(Job::Ctl &ctl, DataBase &base){
+public: JobException(const char* message):runtime_error(message){}};
+static auto was_canceled(Job::Ctl &ctl, DataBase &base){
return [&ctl, &cancel = base.cancel]() -> bool {
if (cancel->load())
return true;
@@ -554,6 +553,8 @@ bool start_create_volume(Plater *plater_ptr,
const std::optional &distance,
const std::optional &angle)
{
+ if (data == nullptr)
+ return false;
if (!priv::is_valid(volume_type))
return false;
@@ -562,14 +563,13 @@ bool start_create_volume(Plater *plater_ptr,
return false;
Plater &plater = *plater_ptr;
- GLCanvas3D *canvas_ptr = plater.get_current_canvas3D();
+ const GLCanvas3D *canvas_ptr = plater.get_current_canvas3D();
assert(canvas_ptr);
if (canvas_ptr == nullptr)
return false;
- GLGizmosManager::EType gizmo_type = static_cast(gizmo);
-
- GLVolume *gl_volume = get_first_hovered_gl_volume(*canvas_ptr);
+ auto gizmo_type = static_cast(gizmo);
+ const GLVolume *gl_volume = get_first_hovered_gl_volume(*canvas_ptr);
if (gl_volume == nullptr)
// object is not under mouse position soo create object on plater
return priv::start_create_object_job(plater, std::move(data), mouse_pos, gizmo_type);
@@ -755,11 +755,11 @@ bool priv::check(const UpdateSurfaceVolumeData &input, bool is_main_thread){
}
template
-TriangleMesh priv::try_create_mesh(DataBase &base, Fnc was_canceled)
+TriangleMesh priv::try_create_mesh(DataBase &base, const Fnc& was_canceled)
{
const EmbossShape& shape = base.create_shape();
if (shape.shapes.empty()) return {};
- float depth = shape.depth / shape.scale;
+ double depth = shape.depth / shape.scale;
auto projectZ = std::make_unique(depth);
ProjectScale project(std::move(projectZ), shape.scale);
if (was_canceled()) return {};
@@ -767,7 +767,7 @@ TriangleMesh priv::try_create_mesh(DataBase &base, Fnc was_canceled)
}
template
-TriangleMesh priv::create_mesh(DataBase &input, Fnc was_canceled, Job::Ctl& ctl)
+TriangleMesh priv::create_mesh(DataBase &input, const Fnc& was_canceled, Job::Ctl& ctl)
{
// It is neccessary to create some shape
// Emboss text window is opened by creation new emboss text object
@@ -1061,7 +1061,7 @@ OrthoProject3d priv::create_emboss_projection(
}
// input can't be const - cache of font
-TriangleMesh priv::cut_surface(DataBase& base, const SurfaceVolumeData& input2, std::function was_canceled)
+TriangleMesh priv::cut_surface(DataBase& base, const SurfaceVolumeData& input2, const std::function& was_canceled)
{
EmbossShape& emboss_shape = base.create_shape();
ExPolygons& shapes = emboss_shape.shapes;
@@ -1077,7 +1077,7 @@ TriangleMesh priv::cut_surface(DataBase& base, const SurfaceVolumeData& input2,
bb.translate(-projection_center);
const SurfaceVolumeData::ModelSources &sources = input2.sources;
- const SurfaceVolumeData::ModelSource *biggest = nullptr;
+ const SurfaceVolumeData::ModelSource *biggest = &sources.front();
size_t biggest_count = 0;
// convert index from (s)ources to (i)ndexed (t)riangle (s)ets
@@ -1119,8 +1119,8 @@ TriangleMesh priv::cut_surface(DataBase& base, const SurfaceVolumeData& input2,
bool fix_reflected = true;
indexed_triangle_set &its = itss[itss_index];
its_transform(its, tr, fix_reflected);
- BoundingBoxf3 bb = bounding_box(its);
- mesh_bb.merge(bb);
+ BoundingBoxf3 its_bb = bounding_box(its);
+ mesh_bb.merge(its_bb);
}
// tr_inv = transformation of mesh inverted
@@ -1253,9 +1253,9 @@ const GLVolume * priv::find_closest(
double center_sq_distance = std::numeric_limits::max();
for (unsigned int id : indices) {
- const GLVolume *gl_volume = selection.get_volume(id);
- const ModelVolume *volume = get_model_volume(*gl_volume, objects);
- if (!volume->is_model_part())
+ const GLVolume *gl_volume = selection.get_volume(id);
+ const ModelVolume *volume = get_model_volume(*gl_volume, objects);
+ if (volume == nullptr || !volume->is_model_part())
continue;
Slic3r::Polygon hull = CameraUtils::create_hull2d(camera, *gl_volume);
Vec2d c = hull.centroid().cast();
diff --git a/src/slic3r/GUI/Jobs/EmbossJob.hpp b/src/slic3r/GUI/Jobs/EmbossJob.hpp
index 00de9b69f9..6b55e0da1f 100644
--- a/src/slic3r/GUI/Jobs/EmbossJob.hpp
+++ b/src/slic3r/GUI/Jobs/EmbossJob.hpp
@@ -32,11 +32,11 @@ namespace Slic3r::GUI::Emboss {
class DataBase
{
public:
- DataBase(std::string volume_name, std::shared_ptr> cancel) : volume_name(volume_name), cancel(std::move(cancel)) {}
- DataBase(std::string volume_name, std::shared_ptr> cancel, EmbossShape&& shape)
+ DataBase(const std::string& volume_name, std::shared_ptr> cancel) : volume_name(volume_name), cancel(std::move(cancel)) {}
+ DataBase(const std::string& volume_name, std::shared_ptr> cancel, EmbossShape&& shape)
: volume_name(volume_name), cancel(std::move(cancel)), shape(std::move(shape))
{}
- virtual ~DataBase() {}
+ virtual ~DataBase() = default;
///
/// Create shape
@@ -86,7 +86,7 @@ class UpdateJob : public Job
public:
// move params to private variable
- UpdateJob(DataUpdate &&input);
+ explicit UpdateJob(DataUpdate &&input);
///
/// Create new embossed volume by m_input data and store to m_result
@@ -148,7 +148,7 @@ class UpdateSurfaceVolumeJob : public Job
public:
// move params to private variable
- UpdateSurfaceVolumeJob(UpdateSurfaceVolumeData &&input);
+ explicit UpdateSurfaceVolumeJob(UpdateSurfaceVolumeData &&input);
void process(Ctl &ctl) override;
void finalize(bool canceled, std::exception_ptr &eptr) override;
};