Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-02-07 20:17:12 +0300
committerbubnikv <bubnikv@gmail.com>2017-02-07 20:17:12 +0300
commit43ac693900ff7f6ff46a93f19b18b1fdb8a7b19f (patch)
treef3371588d7a64bc6c7ca7063342f621e6c4256ba /xs
parentaceb87d18868dd7c207e4a97ff451762086d91d6 (diff)
Added a tooltip overlay for the variable layer height edit tool.
Short methods of PrintState made inline. Added layer height profile to a Model class.
Diffstat (limited to 'xs')
-rw-r--r--xs/src/libslic3r/Model.hpp3
-rw-r--r--xs/src/libslic3r/Print.cpp37
-rw-r--r--xs/src/libslic3r/Print.hpp18
-rw-r--r--xs/src/libslic3r/PrintObject.cpp6
-rw-r--r--xs/xsp/Model.xsp2
-rw-r--r--xs/xsp/Print.xsp3
6 files changed, 23 insertions, 46 deletions
diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp
index 963bd7c85..e6e98bc01 100644
--- a/xs/src/libslic3r/Model.hpp
+++ b/xs/src/libslic3r/Model.hpp
@@ -114,6 +114,9 @@ public:
DynamicPrintConfig config;
// Variation of a layer thickness for spans of Z coordinates.
t_layer_height_ranges layer_height_ranges;
+ // Profile of increasing z to a layer height, to be linearly interpolated when calculating the layers.
+ // The pairs of <z, layer_height> are packed into a 1D array to simplify handling by the Perl XS.
+ std::vector<coordf_t> layer_height_profile;
/* This vector accumulates the total translation applied to the object by the
center_around_origin() method. Callers might want to apply the same translation
diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp
index 6e2fdb4f3..539562a16 100644
--- a/xs/src/libslic3r/Print.cpp
+++ b/xs/src/libslic3r/Print.cpp
@@ -8,43 +8,6 @@
namespace Slic3r {
-template <class StepClass>
-bool
-PrintState<StepClass>::is_started(StepClass step) const
-{
- return this->started.find(step) != this->started.end();
-}
-
-template <class StepClass>
-bool
-PrintState<StepClass>::is_done(StepClass step) const
-{
- return this->done.find(step) != this->done.end();
-}
-
-template <class StepClass>
-void
-PrintState<StepClass>::set_started(StepClass step)
-{
- this->started.insert(step);
-}
-
-template <class StepClass>
-void
-PrintState<StepClass>::set_done(StepClass step)
-{
- this->done.insert(step);
-}
-
-template <class StepClass>
-bool
-PrintState<StepClass>::invalidate(StepClass step)
-{
- bool invalidated = this->started.erase(step) > 0;
- this->done.erase(step);
- return invalidated;
-}
-
template class PrintState<PrintStep>;
template class PrintState<PrintObjectStep>;
diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp
index a0392290d..99582d65d 100644
--- a/xs/src/libslic3r/Print.hpp
+++ b/xs/src/libslic3r/Print.hpp
@@ -33,14 +33,18 @@ enum PrintObjectStep {
template <class StepType>
class PrintState
{
- public:
+public:
std::set<StepType> started, done;
- bool is_started(StepType step) const;
- bool is_done(StepType step) const;
- void set_started(StepType step);
- void set_done(StepType step);
- bool invalidate(StepType step);
+ bool is_started(StepType step) const { return this->started.find(step) != this->started.end(); }
+ bool is_done(StepType step) const { return this->done.find(step) != this->done.end(); }
+ void set_started(StepType step) { this->started.insert(step); }
+ void set_done(StepType step) { this->done.insert(step); }
+ bool invalidate(StepType step) {
+ bool invalidated = this->started.erase(step) > 0;
+ this->done.erase(step);
+ return invalidated;
+ }
};
// A PrintRegion object represents a group of volumes to print
@@ -143,7 +147,7 @@ public:
// Process layer_height_ranges, the raft layers and first layer thickness into layer_height_profile.
// The layer_height_profile may be later modified interactively by the user to refine layers at sloping surfaces.
- void update_layer_height_profile();
+ bool update_layer_height_profile();
// Collect the slicing parameters, to be used by variable layer thickness algorithm,
// by the interactive layer height editor and by the printing process itself.
diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp
index 94001cb38..8091db973 100644
--- a/xs/src/libslic3r/PrintObject.cpp
+++ b/xs/src/libslic3r/PrintObject.cpp
@@ -49,6 +49,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
this->reload_model_instances();
this->layer_height_ranges = model_object->layer_height_ranges;
+ this->layer_height_profile = model_object->layer_height_profile;
}
bool
@@ -949,8 +950,9 @@ SlicingParameters PrintObject::slicing_parameters() const
unscale(this->size.z), this->print()->object_extruders());
}
-void PrintObject::update_layer_height_profile()
+bool PrintObject::update_layer_height_profile()
{
+ bool updated = false;
if (this->layer_height_profile.empty()) {
if (0)
// if (this->layer_height_profile.empty())
@@ -958,7 +960,9 @@ void PrintObject::update_layer_height_profile()
this->model_object()->volumes);
else
this->layer_height_profile = layer_height_profile_from_ranges(this->slicing_parameters(), this->layer_height_ranges);
+ updated = true;
}
+ return updated;
}
// 1) Decides Z positions of the layers,
diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp
index aedc1f7dc..1859779b9 100644
--- a/xs/xsp/Model.xsp
+++ b/xs/xsp/Model.xsp
@@ -4,6 +4,7 @@
#include <xsinit.h>
#include "libslic3r/Model.hpp"
#include "libslic3r/PrintConfig.hpp"
+#include "libslic3r/Slicing.hpp"
%}
%name{Slic3r::Model} class Model {
@@ -169,6 +170,7 @@ ModelMaterial::attributes()
void set_layer_height_ranges(t_layer_height_ranges ranges)
%code%{ THIS->layer_height_ranges = ranges; %};
+
Ref<Pointf3> origin_translation()
%code%{ RETVAL = &THIS->origin_translation; %};
void set_origin_translation(Pointf3* point)
diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp
index d2fca6105..f7a3fa118 100644
--- a/xs/xsp/Print.xsp
+++ b/xs/xsp/Print.xsp
@@ -3,7 +3,6 @@
%{
#include <xsinit.h>
#include "libslic3r/Print.hpp"
-#include "libslic3r/Slicing.hpp"
#include "libslic3r/PlaceholderParser.hpp"
%}
@@ -121,6 +120,8 @@ _constant()
void _infill();
void _generate_support_material();
+ bool update_layer_height_profile();
+
void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action)
%code%{
THIS->update_layer_height_profile();