diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm index f73fdf6978..00b19180a9 100644 --- a/lib/Slic3r/GUI/OptionsGroup.pm +++ b/lib/Slic3r/GUI/OptionsGroup.pm @@ -346,7 +346,8 @@ sub get_option { gui_flags => $optdef->{gui_flags}, label => ($self->full_labels && defined $optdef->{full_label}) ? $optdef->{full_label} : $optdef->{label}, sidetext => $optdef->{sidetext}, - tooltip => $optdef->{tooltip} . " (default: " . $default_value . ")", + # calling serialize() ensures we get a stringified value + tooltip => $optdef->{tooltip} . " (default: " . $self->config->serialize($opt_key) . ")", multiline => $optdef->{multiline}, width => $optdef->{width}, min => $optdef->{min}, diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 3adca46127..e5fadb652a 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -227,7 +227,6 @@ sub new { $self->object_list_changed; EVT_BUTTON($self, $self->{btn_export_gcode}, sub { $self->export_gcode; - Slic3r::thread_cleanup(); }); EVT_BUTTON($self, $self->{btn_print}, sub { $self->{print_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir()); @@ -791,7 +790,7 @@ sub rotate { $self->schedule_background_process; } -sub flip { +sub mirror { my ($self, $axis) = @_; my ($obj_idx, $object) = $self->selected_object; @@ -800,13 +799,13 @@ sub flip { my $model_object = $self->{model}->objects->[$obj_idx]; my $model_instance = $model_object->instances->[0]; - # apply Z rotation before flipping + # apply Z rotation before mirroring if ($model_instance->rotation != 0) { $model_object->rotate($model_instance->rotation, Z); $_->set_rotation(0) for @{ $model_object->instances }; } - $model_object->flip($axis); + $model_object->mirror($axis); $model_object->update_bounding_box; # realign object to Z = 0 @@ -1006,7 +1005,7 @@ sub start_background_process { $self->{print}->process; }; if ($@) { - Slic3r::debugf "Discarding background process error: $@\n"; + Slic3r::debugf "Background process error: $@\n"; Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $PROCESS_COMPLETED_EVENT, $@)); } else { Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $PROCESS_COMPLETED_EVENT, undef)); @@ -1157,6 +1156,12 @@ sub on_process_completed { $self->{process_thread}->detach if $self->{process_thread}; $self->{process_thread} = undef; + # if we're supposed to perform an explicit export let's display the error in a dialog + if ($error && $self->{export_gcode_output_file}) { + $self->{export_gcode_output_file} = undef; + Slic3r::GUI::show_error($self, $error); + } + return if $error; $self->{toolpaths2D}->reload_print if $self->{toolpaths2D}; $self->{preview3D}->reload_print if $self->{preview3D}; @@ -1721,17 +1726,17 @@ sub object_menu { $self->rotate(undef, Z); }); - my $flipMenu = Wx::Menu->new; - my $flipMenuItem = $menu->AppendSubMenu($flipMenu, "Flip", 'Mirror the selected object'); - $frame->_set_menu_item_icon($flipMenuItem, 'shape_flip_horizontal.png'); - $frame->_append_menu_item($flipMenu, "Along X axis…", 'Mirror the selected object along the X axis', sub { - $self->flip(X); + my $mirrorMenu = Wx::Menu->new; + my $mirrorMenuItem = $menu->AppendSubMenu($mirrorMenu, "Mirror", 'Mirror the selected object'); + $frame->_set_menu_item_icon($mirrorMenuItem, 'shape_flip_horizontal.png'); + $frame->_append_menu_item($mirrorMenu, "Along X axis…", 'Mirror the selected object along the X axis', sub { + $self->mirror(X); }); - $frame->_append_menu_item($flipMenu, "Along Y axis…", 'Mirror the selected object along the Y axis', sub { - $self->flip(Y); + $frame->_append_menu_item($mirrorMenu, "Along Y axis…", 'Mirror the selected object along the Y axis', sub { + $self->mirror(Y); }); - $frame->_append_menu_item($flipMenu, "Along Z axis…", 'Mirror the selected object along the Z axis', sub { - $self->flip(Z); + $frame->_append_menu_item($mirrorMenu, "Along Z axis…", 'Mirror the selected object along the Z axis', sub { + $self->mirror(Z); }); my $scaleMenu = Wx::Menu->new; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index bf4e081848..e87f9828ca 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -975,7 +975,7 @@ sub _update_description { package Slic3r::GUI::Tab::Printer; use base 'Slic3r::GUI::Tab'; -use Wx qw(wxTheApp :sizer :button :bitmap :misc :id); +use Wx qw(wxTheApp :sizer :button :bitmap :misc :id :icon :dialog); use Wx::Event qw(EVT_BUTTON); sub name { 'printer' } @@ -1360,6 +1360,22 @@ sub _update { # some options only apply when not using firmware retraction $self->get_field($_, $i)->toggle($retraction && !$config->use_firmware_retraction) for qw(retract_speed retract_restart_extra wipe); + if ($config->use_firmware_retraction && $config->get_at('wipe', $i)) { + my $dialog = Wx::MessageDialog->new($self, + "The Wipe option is not available when using the Firmware Retraction mode.\n" + . "\nShall I disable it in order to enable Firmware Retraction?", + 'Firmware Retraction', wxICON_WARNING | wxYES | wxNO); + + my $new_conf = Slic3r::Config->new; + if ($dialog->ShowModal() == wxID_YES) { + my $wipe = $config->wipe; + $wipe->[$i] = 0; + $new_conf->set("wipe", $wipe); + } else { + $new_conf->set("use_firmware_retraction", 0); + } + $self->load_config($new_conf); + } $self->get_field('retract_length_toolchange', $i)->toggle($have_multiple_extruders); diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index b16c743798..89660aefb2 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -56,7 +56,7 @@ sub make_perimeters { && $config->perimeter_speed == $other_config->perimeter_speed && $config->gap_fill_speed == $other_config->gap_fill_speed && $config->overhangs == $other_config->overhangs - && $config->perimeter_extrusion_width == $other_config->perimeter_extrusion_width + && $config->serialize('perimeter_extrusion_width') eq $other_config->serialize('perimeter_extrusion_width') && $config->thin_walls == $other_config->thin_walls && $config->external_perimeters_first == $other_config->external_perimeters_first) { push @layerms, $other_layerm; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 765fb386f4..99e692de26 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -308,7 +308,7 @@ sub slice { # remove empty layers from bottom while (@{$self->layers} && !@{$self->get_layer(0)->slices}) { - shift @{$self->layers}; + $self->delete_layer(0); for (my $i = 0; $i <= $#{$self->layers}; $i++) { $self->get_layer($i)->set_id( $self->get_layer($i)->id-1 ); } @@ -319,7 +319,7 @@ sub slice { $self->_simplify_slices(scale($self->print->config->resolution)); } - die "No layers were detected. You might want to repair your STL file(s) or check their size and retry.\n" + die "No layers were detected. You might want to repair your STL file(s) or check their size or thickness and retry.\n" if !@{$self->layers}; $self->set_typed_slices(0); diff --git a/xs/src/admesh/stlinit.c b/xs/src/admesh/stlinit.c index e6f3556f29..3a5de90525 100644 --- a/xs/src/admesh/stlinit.c +++ b/xs/src/admesh/stlinit.c @@ -69,7 +69,7 @@ stl_count_facets(stl_file *stl, char *file) { long file_size; int header_num_facets; int num_facets; - int i, j; + int i; size_t s; unsigned char chtest[128]; int num_lines = 1; diff --git a/xs/src/clipper.cpp b/xs/src/clipper.cpp index 264896e0b5..bfdcd5d981 100644 --- a/xs/src/clipper.cpp +++ b/xs/src/clipper.cpp @@ -542,8 +542,8 @@ bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range) } //------------------------------------------------------------------------------ -bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, - const IntPoint pt3, bool UseFullInt64Range) +bool SlopesEqual(const IntPoint &pt1, const IntPoint &pt2, + const IntPoint &pt3, bool UseFullInt64Range) { #ifndef use_int32 if (UseFullInt64Range) @@ -554,8 +554,8 @@ bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, } //------------------------------------------------------------------------------ -bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, - const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range) +bool SlopesEqual(const IntPoint &pt1, const IntPoint &pt2, + const IntPoint &pt3, const IntPoint &pt4, bool UseFullInt64Range) { #ifndef use_int32 if (UseFullInt64Range) @@ -572,7 +572,7 @@ inline bool IsHorizontal(TEdge &e) } //------------------------------------------------------------------------------ -inline double GetDx(const IntPoint pt1, const IntPoint pt2) +inline double GetDx(const IntPoint &pt1, const IntPoint &pt2) { return (pt1.Y == pt2.Y) ? HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y); @@ -845,8 +845,8 @@ OutPt* GetBottomPt(OutPt *pp) } //------------------------------------------------------------------------------ -bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1, - const IntPoint pt2, const IntPoint pt3) +bool Pt2IsBetweenPt1AndPt3(const IntPoint &pt1, + const IntPoint &pt2, const IntPoint &pt3) { if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2)) return false; @@ -1514,7 +1514,7 @@ void Clipper::DisposeOutRec(PolyOutList::size_type index) } //------------------------------------------------------------------------------ -void Clipper::SetWindingCount(TEdge &edge) +void Clipper::SetWindingCount(TEdge &edge) const { TEdge *e = edge.PrevInAEL; //find the edge of the same polytype that immediately preceeds 'edge' in AEL @@ -1814,7 +1814,7 @@ void Clipper::CopyAELToSEL() } //------------------------------------------------------------------------------ -void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt) +void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint &OffPt) { Join* j = new Join; j->OutPt1 = op1; @@ -1840,7 +1840,7 @@ void Clipper::ClearGhostJoins() } //------------------------------------------------------------------------------ -void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt) +void Clipper::AddGhostJoin(OutPt *op, const IntPoint &OffPt) { Join* j = new Join; j->OutPt1 = op; @@ -2180,7 +2180,7 @@ void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &Pt) } //------------------------------------------------------------------------------ -void Clipper::SetHoleState(TEdge *e, OutRec *outrec) +void Clipper::SetHoleState(TEdge *e, OutRec *outrec) const { bool IsHole = false; TEdge *e2 = e->PrevInAEL; @@ -2238,7 +2238,7 @@ OutRec* Clipper::GetOutRec(int Idx) } //------------------------------------------------------------------------------ -void Clipper::AppendPolygon(TEdge *e1, TEdge *e2) +void Clipper::AppendPolygon(TEdge *e1, TEdge *e2) const { //get the start and ends of both output polygons ... OutRec *outRec1 = m_PolyOuts[e1->OutIdx]; @@ -2588,20 +2588,20 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) MaximaList::const_iterator maxIt; MaximaList::const_reverse_iterator maxRit; - if (m_Maxima.size() > 0) + if (!m_Maxima.empty()) { //get the first maxima in range (X) ... if (dir == dLeftToRight) { maxIt = m_Maxima.begin(); - while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) maxIt++; + while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) ++maxIt; if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X) maxIt = m_Maxima.end(); } else { maxRit = m_Maxima.rbegin(); - while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) maxRit++; + while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) ++maxRit; if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X) maxRit = m_Maxima.rend(); } @@ -2620,7 +2620,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) //this code block inserts extra coords into horizontal edges (in output //polygons) whereever maxima touch these horizontal edges. This helps //'simplifying' polygons (ie if the Simplify property is set). - if (m_Maxima.size() > 0) + if (!m_Maxima.empty()) { if (dir == dLeftToRight) { @@ -2628,7 +2628,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) { if (horzEdge->OutIdx >= 0 && !IsOpen) AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y)); - maxIt++; + ++maxIt; } } else @@ -2637,7 +2637,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) { if (horzEdge->OutIdx >= 0 && !IsOpen) AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y)); - maxRit++; + ++maxRit; } } }; @@ -3323,7 +3323,7 @@ OutPt* DupOutPt(OutPt* outPt, bool InsertAfter) //------------------------------------------------------------------------------ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, - const IntPoint Pt, bool DiscardLeft) + const IntPoint &Pt, bool DiscardLeft) { Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight); Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight); @@ -3576,7 +3576,7 @@ static OutRec* ParseFirstLeft(OutRec* FirstLeft) } //------------------------------------------------------------------------------ -void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) +void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) const { //tests if NewOutRec contains the polygon before reassigning FirstLeft for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) @@ -3593,7 +3593,7 @@ void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) } //---------------------------------------------------------------------- -void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) +void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) const { //reassigns FirstLeft WITHOUT testing if NewOutRec contains the polygon for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) @@ -4462,7 +4462,7 @@ void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool p } //------------------------------------------------------------------------------ -void TranslatePath(const Path& input, Path& output, const IntPoint delta) +void TranslatePath(const Path& input, Path& output, const IntPoint& delta) { //precondition: input != output output.resize(input.size()); diff --git a/xs/src/clipper.hpp b/xs/src/clipper.hpp index c3151b51bf..c8009e64e6 100644 --- a/xs/src/clipper.hpp +++ b/xs/src/clipper.hpp @@ -224,7 +224,7 @@ public: bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed); virtual void Clear(); IntRect GetBounds(); - bool PreserveCollinear() {return m_PreserveCollinear;}; + bool PreserveCollinear() const {return m_PreserveCollinear;}; void PreserveCollinear(bool value) {m_PreserveCollinear = value;}; protected: void DisposeLocalMinimaList(); @@ -265,9 +265,9 @@ public: PolyTree &polytree, PolyFillType subjFillType, PolyFillType clipFillType); - bool ReverseSolution() { return m_ReverseOutput; }; + bool ReverseSolution() const { return m_ReverseOutput; }; void ReverseSolution(bool value) {m_ReverseOutput = value;}; - bool StrictlySimple() {return m_StrictSimple;}; + bool StrictlySimple() const {return m_StrictSimple;}; void StrictlySimple(bool value) {m_StrictSimple = value;}; //set the callback function for z value filling on intersections (otherwise Z is 0) #ifdef use_xyz @@ -297,7 +297,7 @@ private: #ifdef use_xyz ZFillCallback m_ZFill; //custom callback #endif - void SetWindingCount(TEdge& edge); + void SetWindingCount(TEdge& edge) const; bool IsEvenOddFillType(const TEdge& edge) const; bool IsEvenOddAltFillType(const TEdge& edge) const; void InsertScanbeam(const cInt Y); @@ -319,7 +319,7 @@ private: void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); OutRec* GetOutRec(int idx); - void AppendPolygon(TEdge *e1, TEdge *e2); + void AppendPolygon(TEdge *e1, TEdge *e2) const; void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt); OutRec* CreateOutRec(); OutPt* AddOutPt(TEdge *e, const IntPoint &pt); @@ -332,7 +332,7 @@ private: void ProcessEdgesAtTopOfScanbeam(const cInt topY); void BuildResult(Paths& polys); void BuildResult2(PolyTree& polytree); - void SetHoleState(TEdge *e, OutRec *outrec); + void SetHoleState(TEdge *e, OutRec *outrec) const; void DisposeIntersectNodes(); bool FixupIntersectionOrder(); void FixupOutPolygon(OutRec &outrec); @@ -340,15 +340,15 @@ private: bool IsHole(TEdge *e); bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl); void FixHoleLinkage(OutRec &outrec); - void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt); + void AddJoin(OutPt *op1, OutPt *op2, const IntPoint &offPt); void ClearJoins(); void ClearGhostJoins(); - void AddGhostJoin(OutPt *op, const IntPoint offPt); + void AddGhostJoin(OutPt *op, const IntPoint &offPt); bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2); void JoinCommonEdges(); void DoSimplePolygons(); - void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec); - void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec); + void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) const; + void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) const; #ifdef use_xyz void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2); #endif diff --git a/xs/src/libslic3r/BridgeDetector.cpp b/xs/src/libslic3r/BridgeDetector.cpp index 1dddf81ce0..24140c7b23 100644 --- a/xs/src/libslic3r/BridgeDetector.cpp +++ b/xs/src/libslic3r/BridgeDetector.cpp @@ -30,7 +30,7 @@ class BridgeDirectionComparator { BridgeDetector::BridgeDetector(const ExPolygon &_expolygon, const ExPolygonCollection &_lower_slices, coord_t _extrusion_width) : expolygon(_expolygon), lower_slices(_lower_slices), extrusion_width(_extrusion_width), - angle(-1), resolution(PI/36.0) + resolution(PI/36.0), angle(-1) { /* outset our bridge by an arbitrary amout; we'll use this outer margin for detecting anchors */ @@ -293,8 +293,8 @@ BridgeDetector::unsupported_edges(double angle, Polylines* unsupported) const TODO: angle tolerance should probably be based on segment length and flow width, so that we build supports whenever there's a chance that at least one or two bridge extrusions would be anchored within such length (i.e. a slightly non-parallel bridging - direction might still benefit from anchors if long enough) */ - double angle_tolerance = PI / 180.0 * 5.0; + direction might still benefit from anchors if long enough) + double angle_tolerance = PI / 180.0 * 5.0; */ for (Polylines::const_iterator polyline = _unsupported.begin(); polyline != _unsupported.end(); ++polyline) { Lines lines = polyline->lines(); for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) { diff --git a/xs/src/libslic3r/ClipperUtils.cpp b/xs/src/libslic3r/ClipperUtils.cpp index 3d07891b10..f186537024 100644 --- a/xs/src/libslic3r/ClipperUtils.cpp +++ b/xs/src/libslic3r/ClipperUtils.cpp @@ -685,7 +685,7 @@ SV* polynode_children_2_perl(const ClipperLib::PolyNode& node) { AV* av = newAV(); - const unsigned int len = node.ChildCount(); + const int len = node.ChildCount(); if (len > 0) av_extend(av, len-1); for (int i = 0; i < len; ++i) { av_store(av, i, polynode2perl(*node.Childs[i])); diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 741151c380..e388d8f9b3 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -8,7 +8,7 @@ namespace Slic3r { bool -ConfigBase::has(const t_config_option_key opt_key) { +ConfigBase::has(const t_config_option_key &opt_key) { return (this->option(opt_key, false) != NULL); } @@ -52,14 +52,14 @@ ConfigBase::diff(ConfigBase &other) { } std::string -ConfigBase::serialize(const t_config_option_key opt_key) { +ConfigBase::serialize(const t_config_option_key &opt_key) { ConfigOption* opt = this->option(opt_key); assert(opt != NULL); return opt->serialize(); } bool -ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) { +ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str) { if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option"; ConfigOptionDef* optdef = &(*this->def)[opt_key]; if (!optdef->shortcut.empty()) { @@ -75,7 +75,7 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) } double -ConfigBase::get_abs_value(const t_config_option_key opt_key) { +ConfigBase::get_abs_value(const t_config_option_key &opt_key) { ConfigOption* opt = this->option(opt_key, false); if (ConfigOptionFloatOrPercent* optv = dynamic_cast(opt)) { // get option definition @@ -92,7 +92,7 @@ ConfigBase::get_abs_value(const t_config_option_key opt_key) { } double -ConfigBase::get_abs_value(const t_config_option_key opt_key, double ratio_over) { +ConfigBase::get_abs_value(const t_config_option_key &opt_key, double ratio_over) { // get stored option value ConfigOptionFloatOrPercent* opt = dynamic_cast(this->option(opt_key)); assert(opt != NULL); @@ -282,7 +282,7 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) { /* This method is implemented as a workaround for this typemap bug: https://rt.cpan.org/Public/Bug/Display.html?id=94110 */ bool -ConfigBase::set_deserialize(const t_config_option_key opt_key, SV* str) { +ConfigBase::set_deserialize(const t_config_option_key &opt_key, SV* str) { size_t len; const char * c = SvPV(str, len); std::string value(c, len); @@ -328,7 +328,7 @@ DynamicConfig::DynamicConfig (const DynamicConfig& other) { } ConfigOption* -DynamicConfig::option(const t_config_option_key opt_key, bool create) { +DynamicConfig::option(const t_config_option_key &opt_key, bool create) { if (this->options.count(opt_key) == 0) { if (create) { ConfigOptionDef* optdef = &(*this->def)[opt_key]; @@ -375,16 +375,16 @@ DynamicConfig::option(const t_config_option_key opt_key, bool create) { template T* -DynamicConfig::opt(const t_config_option_key opt_key, bool create) { +DynamicConfig::opt(const t_config_option_key &opt_key, bool create) { return dynamic_cast(this->option(opt_key, create)); } -template ConfigOptionInt* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionBool* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionBools* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionPercent* DynamicConfig::opt(const t_config_option_key opt_key, bool create); +template ConfigOptionInt* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionBool* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionBools* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionPercent* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); const ConfigOption* -DynamicConfig::option(const t_config_option_key opt_key) const { +DynamicConfig::option(const t_config_option_key &opt_key) const { return const_cast(this)->option(opt_key, false); } @@ -397,7 +397,7 @@ DynamicConfig::keys() const { } void -DynamicConfig::erase(const t_config_option_key opt_key) { +DynamicConfig::erase(const t_config_option_key &opt_key) { this->options.erase(opt_key); } @@ -412,7 +412,7 @@ StaticConfig::keys() const { } const ConfigOption* -StaticConfig::option(const t_config_option_key opt_key) const +StaticConfig::option(const t_config_option_key &opt_key) const { return const_cast(this)->option(opt_key, false); } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index be433633db..49a14e2213 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -459,6 +459,7 @@ class ConfigOptionEnumGeneric : public ConfigOption }; enum ConfigOptionType { + coNone, coFloat, coFloats, coInt, @@ -500,7 +501,8 @@ class ConfigOptionDef std::vector enum_labels; t_config_enum_values enum_keys_map; - ConfigOptionDef() : multiline(false), full_width(false), readonly(false), + ConfigOptionDef() : type(coNone), + multiline(false), full_width(false), readonly(false), height(-1), width(-1), min(INT_MIN), max(INT_MAX) {}; }; @@ -512,18 +514,18 @@ class ConfigBase t_optiondef_map* def; ConfigBase() : def(NULL) {}; - bool has(const t_config_option_key opt_key); - virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0; - virtual const ConfigOption* option(const t_config_option_key opt_key) const = 0; + bool has(const t_config_option_key &opt_key); + virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; + virtual const ConfigOption* option(const t_config_option_key &opt_key) const = 0; virtual t_config_option_keys keys() const = 0; void apply(const ConfigBase &other, bool ignore_nonexistent = false); bool equals(ConfigBase &other); t_config_option_keys diff(ConfigBase &other); - std::string serialize(const t_config_option_key opt_key); - bool set_deserialize(const t_config_option_key opt_key, std::string str); + std::string serialize(const t_config_option_key &opt_key); + bool set_deserialize(const t_config_option_key &opt_key, std::string str); void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false); - double get_abs_value(const t_config_option_key opt_key); - double get_abs_value(const t_config_option_key opt_key, double ratio_over); + double get_abs_value(const t_config_option_key &opt_key); + double get_abs_value(const t_config_option_key &opt_key, double ratio_over); void setenv_(); #ifdef SLIC3RXS @@ -531,7 +533,7 @@ class ConfigBase SV* get(t_config_option_key opt_key); SV* get_at(t_config_option_key opt_key, size_t i); bool set(t_config_option_key opt_key, SV* value); - bool set_deserialize(const t_config_option_key opt_key, SV* str); + bool set_deserialize(const t_config_option_key &opt_key, SV* str); #endif }; @@ -543,11 +545,11 @@ class DynamicConfig : public ConfigBase DynamicConfig& operator= (DynamicConfig other); void swap(DynamicConfig &other); ~DynamicConfig(); - template T* opt(const t_config_option_key opt_key, bool create = false); - ConfigOption* option(const t_config_option_key opt_key, bool create = false); - const ConfigOption* option(const t_config_option_key opt_key) const; + template T* opt(const t_config_option_key &opt_key, bool create = false); + ConfigOption* option(const t_config_option_key &opt_key, bool create = false); + const ConfigOption* option(const t_config_option_key &opt_key) const; t_config_option_keys keys() const; - void erase(const t_config_option_key opt_key); + void erase(const t_config_option_key &opt_key); private: typedef std::map t_options_map; @@ -558,8 +560,8 @@ class StaticConfig : public ConfigBase { public: t_config_option_keys keys() const; - virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0; - const ConfigOption* option(const t_config_option_key opt_key) const; + virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; + const ConfigOption* option(const t_config_option_key &opt_key) const; #ifdef SLIC3RXS bool set(t_config_option_key opt_key, SV* value); diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index ee0473656c..c423c6e0a2 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -375,31 +375,29 @@ ExPolygon::triangulate_p2t(Polygons* polygons) const simplify_polygons(*this, &expp, true); for (ExPolygons::const_iterator ex = expp.begin(); ex != expp.end(); ++ex) { - p2t::CDT* cdt; - // TODO: prevent duplicate points - + // contour - { - std::vector points; - for (Points::const_iterator point = ex->contour.points.begin(); point != ex->contour.points.end(); ++point) { - points.push_back(new p2t::Point(point->x, point->y)); - } - cdt = new p2t::CDT(points); + std::vector ContourPoints; + for (Points::const_iterator point = ex->contour.points.begin(); point != ex->contour.points.end(); ++point) { + // We should delete each p2t::Point object + ContourPoints.push_back(new p2t::Point(point->x, point->y)); } - + p2t::CDT cdt(ContourPoints); + // holes for (Polygons::const_iterator hole = ex->holes.begin(); hole != ex->holes.end(); ++hole) { std::vector points; for (Points::const_iterator point = hole->points.begin(); point != hole->points.end(); ++point) { + // will be destructed in SweepContext::~SweepContext points.push_back(new p2t::Point(point->x, point->y)); } - cdt->AddHole(points); + cdt.AddHole(points); } // perform triangulation - cdt->Triangulate(); - std::vector triangles = cdt->GetTriangles(); + cdt.Triangulate(); + std::vector triangles = cdt.GetTriangles(); for (std::vector::const_iterator triangle = triangles.begin(); triangle != triangles.end(); ++triangle) { Polygon p; @@ -409,6 +407,10 @@ ExPolygon::triangulate_p2t(Polygons* polygons) const } polygons->push_back(p); } + + for(std::vector::iterator it = ContourPoints.begin(); it != ContourPoints.end(); ++it) { + delete *it; + } } } diff --git a/xs/src/libslic3r/Extruder.cpp b/xs/src/libslic3r/Extruder.cpp index 8cbd00b738..e254d6806f 100644 --- a/xs/src/libslic3r/Extruder.cpp +++ b/xs/src/libslic3r/Extruder.cpp @@ -2,7 +2,7 @@ namespace Slic3r { -Extruder::Extruder(int id, GCodeConfig *config) +Extruder::Extruder(unsigned int id, GCodeConfig *config) : id(id), config(config) { diff --git a/xs/src/libslic3r/Extruder.hpp b/xs/src/libslic3r/Extruder.hpp index 03ee7c57f3..fa91bb42f5 100644 --- a/xs/src/libslic3r/Extruder.hpp +++ b/xs/src/libslic3r/Extruder.hpp @@ -10,7 +10,7 @@ namespace Slic3r { class Extruder { public: - int id; + unsigned int id; double E; double absolute_E; double retracted; @@ -18,7 +18,7 @@ class Extruder double e_per_mm3; double retract_speed_mm_min; - Extruder(int id, GCodeConfig *config); + Extruder(unsigned int id, GCodeConfig *config); virtual ~Extruder() {} void reset(); double extrude(double dE); diff --git a/xs/src/libslic3r/ExtrusionEntity.cpp b/xs/src/libslic3r/ExtrusionEntity.cpp index 846269185e..be32519f60 100644 --- a/xs/src/libslic3r/ExtrusionEntity.cpp +++ b/xs/src/libslic3r/ExtrusionEntity.cpp @@ -283,7 +283,7 @@ ExtrusionLoop::has_overhang_point(const Point &point) const if (pos != -1) { // point belongs to this path // we consider it overhang only if it's not an endpoint - return (path->is_bridge() && pos > 0 && pos != path->polyline.points.size()-1); + return (path->is_bridge() && pos > 0 && pos != (int)(path->polyline.points.size())-1); } } return false; diff --git a/xs/src/libslic3r/ExtrusionEntityCollection.cpp b/xs/src/libslic3r/ExtrusionEntityCollection.cpp index eb77aaede3..b0f369ec86 100644 --- a/xs/src/libslic3r/ExtrusionEntityCollection.cpp +++ b/xs/src/libslic3r/ExtrusionEntityCollection.cpp @@ -6,7 +6,7 @@ namespace Slic3r { ExtrusionEntityCollection::ExtrusionEntityCollection(const ExtrusionEntityCollection& collection) - : no_sort(collection.no_sort), orig_indices(collection.orig_indices) + : orig_indices(collection.orig_indices), no_sort(collection.no_sort) { this->append(collection.entities); } diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 51093667af..8f4f98260f 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -209,9 +209,9 @@ REGISTER_CLASS(Wipe, "GCode::Wipe"); #define EXTRUDER_CONFIG(OPT) this->config.OPT.get_at(this->writer.extruder()->id) GCode::GCode() - : enable_loop_clipping(true), enable_cooling_markers(false), layer_count(0), - layer_index(-1), first_layer(false), elapsed_time(0), volumetric_speed(0), - _last_pos_defined(false), layer(NULL), placeholder_parser(NULL) + : placeholder_parser(NULL), enable_loop_clipping(true), enable_cooling_markers(false), layer_count(0), + layer_index(-1), layer(NULL), first_layer(false), elapsed_time(0), volumetric_speed(0), + _last_pos_defined(false) { } @@ -435,7 +435,6 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed) // make a little move inwards before leaving loop if (paths.back().role == erExternalPerimeter && this->layer != NULL && this->config.perimeters > 1) { - Polyline &last_path_polyline = paths.back().polyline; // detect angle between last and first segment // the side depends on the original winding order of the polygon (left for contours, right for holes) Point a = paths.front().polyline.points[1]; // second point @@ -576,7 +575,7 @@ GCode::_extrude(ExtrusionPath path, std::string description, double speed) gcode += this->writer.set_speed(F); double path_length = 0; { - std::string comment = this->config.gcode_comments ? (" ; " + description) : ""; + std::string comment = this->config.gcode_comments ? description : ""; Lines lines = path.polyline.lines(); for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) { const double line_length = line->length() * SCALING_FACTOR; diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index 801e0ebd47..4055a270ae 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -67,7 +67,7 @@ GCodeWriter::preamble() } std::string -GCodeWriter::postamble() +GCodeWriter::postamble() const { std::ostringstream gcode; if (FLAVOR_IS(gcfMachinekit)) @@ -76,7 +76,7 @@ GCodeWriter::postamble() } std::string -GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) +GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) const { if (wait && (FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish))) return ""; @@ -84,7 +84,7 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) std::string code, comment; if (wait && FLAVOR_IS_NOT(gcfTeacup)) { code = "M109"; - comment = "wait for temperature to be reached"; + comment = "set temperature and wait for it to be reached"; } else { code = "M104"; comment = "set temperature"; @@ -110,7 +110,7 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) } std::string -GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait) +GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait) const { std::string code, comment; if (wait && FLAVOR_IS_NOT(gcfTeacup)) { @@ -119,10 +119,10 @@ GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait) } else { code = "M190"; } - comment = "set bed temperature"; + comment = "set bed temperature and wait for it to be reached"; } else { code = "M140"; - comment = "wait for bed temperature to be reached"; + comment = "set bed temperature"; } std::ostringstream gcode; @@ -217,7 +217,7 @@ GCodeWriter::reset_e(bool force) } std::string -GCodeWriter::update_progress(unsigned int num, unsigned int tot, bool allow_100) +GCodeWriter::update_progress(unsigned int num, unsigned int tot, bool allow_100) const { if (FLAVOR_IS_NOT(gcfMakerWare) && FLAVOR_IS_NOT(gcfSailfish)) return ""; @@ -273,7 +273,7 @@ GCodeWriter::toolchange(unsigned int extruder_id) } std::string -GCodeWriter::set_speed(double F, const std::string &comment) +GCodeWriter::set_speed(double F, const std::string &comment) const { std::ostringstream gcode; gcode << "G1 F" << F; diff --git a/xs/src/libslic3r/GCodeWriter.hpp b/xs/src/libslic3r/GCodeWriter.hpp index dbedc17665..e7b93ac42d 100644 --- a/xs/src/libslic3r/GCodeWriter.hpp +++ b/xs/src/libslic3r/GCodeWriter.hpp @@ -24,17 +24,17 @@ class GCodeWriter { void apply_print_config(const PrintConfig &print_config); void set_extruders(const std::vector &extruder_ids); std::string preamble(); - std::string postamble(); - std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1); - std::string set_bed_temperature(unsigned int temperature, bool wait = false); + std::string postamble() const; + std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const; + std::string set_bed_temperature(unsigned int temperature, bool wait = false) const; std::string set_fan(unsigned int speed, bool dont_save = false); std::string set_acceleration(unsigned int acceleration); std::string reset_e(bool force = false); - std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false); + std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const; bool need_toolchange(unsigned int extruder_id) const; std::string set_extruder(unsigned int extruder_id); std::string toolchange(unsigned int extruder_id); - std::string set_speed(double F, const std::string &comment = std::string()); + std::string set_speed(double F, const std::string &comment = std::string()) const; std::string travel_to_xy(const Pointf &point, const std::string &comment = std::string()); std::string travel_to_xyz(const Pointf3 &point, const std::string &comment = std::string()); std::string travel_to_z(double z, const std::string &comment = std::string()); diff --git a/xs/src/libslic3r/Layer.cpp b/xs/src/libslic3r/Layer.cpp index 4d4c288052..595a5daf49 100644 --- a/xs/src/libslic3r/Layer.cpp +++ b/xs/src/libslic3r/Layer.cpp @@ -8,16 +8,16 @@ namespace Slic3r { Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) -: _id(id), - _object(object), - upper_layer(NULL), +: upper_layer(NULL), lower_layer(NULL), regions(), slicing_errors(false), slice_z(slice_z), print_z(print_z), height(height), - slices() + slices(), + _id(id), + _object(object) { } @@ -61,7 +61,7 @@ Layer::object() const size_t -Layer::region_count() +Layer::region_count() const { return this->regions.size(); } diff --git a/xs/src/libslic3r/Layer.hpp b/xs/src/libslic3r/Layer.hpp index 7adaa0fbb6..7cb643c54c 100644 --- a/xs/src/libslic3r/Layer.hpp +++ b/xs/src/libslic3r/Layer.hpp @@ -93,7 +93,7 @@ class Layer { ExPolygonCollection slices; - size_t region_count(); + size_t region_count() const; LayerRegion* get_region(int idx); LayerRegion* add_region(PrintRegion* print_region); diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 29a2f33103..01c907fada 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -162,12 +162,10 @@ Model::has_objects_with_no_instances() const bool Model::add_default_instances() { - bool added = false; // apply a default position to all objects not having one for (ModelObjectPtrs::const_iterator o = this->objects.begin(); o != this->objects.end(); ++o) { if ((*o)->instances.empty()) { (*o)->add_instance(); - added = true; } } return true; @@ -248,7 +246,7 @@ REGISTER_CLASS(Model, "Model"); ModelMaterial::ModelMaterial(Model *model) : model(model) {} ModelMaterial::ModelMaterial(Model *model, const ModelMaterial &other) - : model(model), config(other.config), attributes(other.attributes) + : attributes(other.attributes), config(other.config), model(model) {} void @@ -268,8 +266,7 @@ ModelObject::ModelObject(Model *model) {} ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes) -: model(model), - name(other.name), +: name(other.name), input_file(other.input_file), instances(), volumes(), @@ -277,7 +274,8 @@ ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volum layer_height_ranges(other.layer_height_ranges), origin_translation(other.origin_translation), _bounding_box(other._bounding_box), - _bounding_box_valid(other._bounding_box_valid) + _bounding_box_valid(other._bounding_box_valid), + model(model) { if (copy_volumes) { this->volumes.reserve(other.volumes.size()); @@ -531,10 +529,10 @@ ModelObject::rotate(float angle, const Axis &axis) } void -ModelObject::flip(const Axis &axis) +ModelObject::mirror(const Axis &axis) { for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { - (*v)->mesh.flip(axis); + (*v)->mesh.mirror(axis); } this->origin_translation = Pointf3(0,0,0); this->invalidate_bounding_box(); @@ -647,12 +645,12 @@ REGISTER_CLASS(ModelObject, "Model::Object"); ModelVolume::ModelVolume(ModelObject* object, const TriangleMesh &mesh) -: object(object), mesh(mesh), modifier(false) +: mesh(mesh), modifier(false), object(object) {} ModelVolume::ModelVolume(ModelObject* object, const ModelVolume &other) -: object(object), name(other.name), mesh(other.mesh), config(other.config), - modifier(other.modifier) +: name(other.name), mesh(other.mesh), config(other.config), + modifier(other.modifier), object(object) { this->material_id(other.material_id()); } @@ -701,11 +699,11 @@ REGISTER_CLASS(ModelVolume, "Model::Volume"); ModelInstance::ModelInstance(ModelObject *object) -: object(object), rotation(0), scaling_factor(1) +: rotation(0), scaling_factor(1), object(object) {} ModelInstance::ModelInstance(ModelObject *object, const ModelInstance &other) -: object(object), rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset) +: rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object) {} void diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index e5683cb572..d802ae8e79 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -130,7 +130,7 @@ class ModelObject void translate(coordf_t x, coordf_t y, coordf_t z); void scale(const Pointf3 &versor); void rotate(float angle, const Axis &axis); - void flip(const Axis &axis); + void mirror(const Axis &axis); size_t materials_count() const; size_t facets_count() const; bool needed_repair() const; diff --git a/xs/src/libslic3r/MotionPlanner.cpp b/xs/src/libslic3r/MotionPlanner.cpp index 124f968912..d35a89ec52 100644 --- a/xs/src/libslic3r/MotionPlanner.cpp +++ b/xs/src/libslic3r/MotionPlanner.cpp @@ -73,7 +73,7 @@ MotionPlanner::initialize() } ExPolygonCollection -MotionPlanner::get_env(size_t island_idx) const +MotionPlanner::get_env(int island_idx) const { if (island_idx == -1) { return ExPolygonCollection(this->outer); @@ -127,13 +127,12 @@ MotionPlanner::shortest_path(const Point &from, const Point &to) // Now check whether points are inside the environment. Point inner_from = from; Point inner_to = to; - bool from_is_inside, to_is_inside; - - if (!(from_is_inside = env.contains(from))) { + + if (!env.contains(from)) { // Find the closest inner point to start from. inner_from = this->nearest_env_point(env, from, to); } - if (!(to_is_inside = env.contains(to))) { + if (!env.contains(to)) { // Find the closest inner point to start from. inner_to = this->nearest_env_point(env, to, inner_from); } @@ -362,7 +361,7 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to) const std::vector &neighbors = this->adjacency_list[u]; for (std::vector::const_iterator neighbor_iter = neighbors.begin(); neighbor_iter != neighbors.end(); - neighbor_iter++) + ++neighbor_iter) { // neighbor node is v node_t v = neighbor_iter->target; diff --git a/xs/src/libslic3r/MotionPlanner.hpp b/xs/src/libslic3r/MotionPlanner.hpp index 608f016812..d49cc81986 100644 --- a/xs/src/libslic3r/MotionPlanner.hpp +++ b/xs/src/libslic3r/MotionPlanner.hpp @@ -33,7 +33,7 @@ class MotionPlanner void initialize(); MotionPlannerGraph* init_graph(int island_idx); - ExPolygonCollection get_env(size_t island_idx) const; + ExPolygonCollection get_env(int island_idx) const; Point nearest_env_point(const ExPolygonCollection &env, const Point &from, const Point &to) const; }; @@ -42,7 +42,7 @@ class MotionPlannerGraph friend class MotionPlanner; private: - typedef size_t node_t; + typedef int node_t; typedef double weight_t; struct neighbor { node_t target; diff --git a/xs/src/libslic3r/PerimeterGenerator.hpp b/xs/src/libslic3r/PerimeterGenerator.hpp index 8ce5f87d97..680790ffdd 100644 --- a/xs/src/libslic3r/PerimeterGenerator.hpp +++ b/xs/src/libslic3r/PerimeterGenerator.hpp @@ -22,7 +22,7 @@ class PerimeterGeneratorLoop { std::vector children; PerimeterGeneratorLoop(Polygon polygon, unsigned short depth) - : polygon(polygon), depth(depth), is_contour(false) + : polygon(polygon), is_contour(false), depth(depth) {}; bool is_external() const; bool is_internal_contour() const; @@ -50,8 +50,8 @@ class PerimeterGenerator { PrintConfig* print_config, ExtrusionEntityCollection* loops, ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces) : slices(slices), lower_slices(NULL), layer_height(layer_height), - perimeter_flow(flow), ext_perimeter_flow(flow), overhang_flow(flow), - solid_infill_flow(flow), layer_id(-1), + layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow), + overhang_flow(flow), solid_infill_flow(flow), config(config), object_config(object_config), print_config(print_config), loops(loops), gap_fill(gap_fill), fill_surfaces(fill_surfaces), _ext_mm3_per_mm(-1), _mm3_per_mm(-1), _mm3_per_mm_overhang(-1) diff --git a/xs/src/libslic3r/Polyline.cpp b/xs/src/libslic3r/Polyline.cpp index 22f190dbd0..c0ba0092ba 100644 --- a/xs/src/libslic3r/Polyline.cpp +++ b/xs/src/libslic3r/Polyline.cpp @@ -119,7 +119,7 @@ Polyline::equally_spaced_points(double distance) const double take = segment_length - (len - distance); // how much we take of this segment Line segment(*(it-1), *it); points.push_back(segment.point_at(take)); - it--; + --it; len = -take; } return points; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index ab8aa4a662..3f251f5238 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -335,6 +335,7 @@ PrintConfigDef::build_def() { Options["first_layer_extrusion_width"].type = coFloatOrPercent; Options["first_layer_extrusion_width"].label = "First layer"; + Options["first_layer_extrusion_width"].category = "Extrusion Width"; Options["first_layer_extrusion_width"].tooltip = "Set this to a non-zero value to set a manual extrusion width for first layer. You can use this to force fatter extrudates for better adhesion. If expressed as percentage (for example 120%) it will be computed over first layer height. If set to zero, it will use the Default Extrusion Width."; Options["first_layer_extrusion_width"].sidetext = "mm or % (leave 0 for default)"; Options["first_layer_extrusion_width"].cli = "first-layer-extrusion-width=s"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 3aa06e8d5b..b8b153715f 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -150,7 +150,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig this->xy_size_compensation.value = 0; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(dont_support_bridges); OPT_PTR(extrusion_width); OPT_PTR(first_layer_height); @@ -260,7 +260,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig this->top_solid_layers.value = 3; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(bottom_solid_layers); OPT_PTR(bridge_flow_ratio); OPT_PTR(bridge_speed); @@ -359,7 +359,7 @@ class GCodeConfig : public virtual StaticPrintConfig this->use_volumetric_e.value = false; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(before_layer_gcode); OPT_PTR(end_gcode); OPT_PTR(extrusion_axis); @@ -518,7 +518,7 @@ class PrintConfig : public GCodeConfig this->z_offset.value = 0; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(avoid_crossing_perimeters); OPT_PTR(bed_shape); OPT_PTR(bed_temperature); @@ -593,7 +593,7 @@ class HostConfig : public virtual StaticPrintConfig this->serial_speed.value = 250000; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(octoprint_host); OPT_PTR(octoprint_apikey); OPT_PTR(serial_port); @@ -607,7 +607,7 @@ class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig { public: - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* opt; if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt; if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index a405e320d0..ab25be5778 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -6,9 +6,9 @@ namespace Slic3r { PrintObject::PrintObject(Print* print, ModelObject* model_object, const BoundingBoxf3 &modobj_bbox) -: _print(print), - _model_object(model_object), - typed_slices(false) +: typed_slices(false), + _print(print), + _model_object(model_object) { // Compute the translation to be applied to our meshes so that we work with smaller coordinates { diff --git a/xs/src/libslic3r/PrintRegion.cpp b/xs/src/libslic3r/PrintRegion.cpp index e5b9092e4c..1807f84bc6 100644 --- a/xs/src/libslic3r/PrintRegion.cpp +++ b/xs/src/libslic3r/PrintRegion.cpp @@ -50,7 +50,7 @@ PrintRegion::flow(FlowRole role, double layer_height, bool bridge, bool first_la // get the configured nozzle_diameter for the extruder associated // to the flow role requested - size_t extruder; // 1-based + size_t extruder = 0; // 1-based if (role == frPerimeter || role == frExternalPerimeter) { extruder = this->config.perimeter_extruder; } else if (role == frInfill) { diff --git a/xs/src/libslic3r/SVG.cpp b/xs/src/libslic3r/SVG.cpp index f196d4713a..eacbe2e63a 100644 --- a/xs/src/libslic3r/SVG.cpp +++ b/xs/src/libslic3r/SVG.cpp @@ -6,7 +6,7 @@ namespace Slic3r { SVG::SVG(const char* filename) - : arrows(true), filename(filename), fill("grey"), stroke("black") + : arrows(true), fill("grey"), stroke("black"), filename(filename) { this->f = fopen(filename, "w"); fprintf(this->f, diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index 822d6ffb3a..6df4eba5c9 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -100,7 +100,7 @@ TriangleMesh::repair() { stl.stats.facets_w_3_bad_edge = (stl.stats.number_of_facets - stl.stats.connected_facets_1_edge); // checking nearby - int last_edges_fixed = 0; + //int last_edges_fixed = 0; float tolerance = stl.stats.shortest_edge; float increment = stl.stats.bounding_diameter / 10000.0; int iterations = 2; @@ -110,7 +110,7 @@ TriangleMesh::repair() { //printf("Checking nearby. Tolerance= %f Iteration=%d of %d...", tolerance, i + 1, iterations); stl_check_facets_nearby(&stl, tolerance); //printf(" Fixed %d edges.\n", stl.stats.edges_fixed - last_edges_fixed); - last_edges_fixed = stl.stats.edges_fixed; + //last_edges_fixed = stl.stats.edges_fixed; tolerance += increment; } else { break; @@ -230,7 +230,7 @@ void TriangleMesh::rotate_z(float angle) this->rotate(angle, Z); } -void TriangleMesh::flip(const Axis &axis) +void TriangleMesh::mirror(const Axis &axis) { if (axis == X) { stl_mirror_yz(&this->stl); @@ -242,19 +242,19 @@ void TriangleMesh::flip(const Axis &axis) stl_invalidate_shared_vertices(&this->stl); } -void TriangleMesh::flip_x() +void TriangleMesh::mirror_x() { - this->flip(X); + this->mirror(X); } -void TriangleMesh::flip_y() +void TriangleMesh::mirror_y() { - this->flip(Y); + this->mirror(Y); } -void TriangleMesh::flip_z() +void TriangleMesh::mirror_z() { - this->flip(Z); + this->mirror(Z); } void TriangleMesh::align_to_origin() @@ -316,7 +316,7 @@ TriangleMesh::split() const stl_allocate(&mesh->stl); int first = 1; - for (std::deque::const_iterator facet = facets.begin(); facet != facets.end(); facet++) { + for (std::deque::const_iterator facet = facets.begin(); facet != facets.end(); ++facet) { mesh->stl.facet_start[facet - facets.begin()] = this->stl.facet_start[*facet]; stl_facet_stats(&mesh->stl, this->stl.facet_start[*facet], first); first = 0; @@ -429,7 +429,7 @@ void TriangleMesh::ReadFromPerl(SV* vertices, SV* facets) // read geometry AV* vertices_av = (AV*)SvRV(vertices); - for (unsigned int i = 0; i < stl.stats.number_of_facets; i++) { + for (int i = 0; i < stl.stats.number_of_facets; i++) { AV* facet_av = (AV*)SvRV(*av_fetch(facets_av, i, 0)); stl_facet facet; facet.normal.x = 0; diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp index ff12e84279..8fd92863cf 100644 --- a/xs/src/libslic3r/TriangleMesh.hpp +++ b/xs/src/libslic3r/TriangleMesh.hpp @@ -36,10 +36,10 @@ class TriangleMesh void rotate_x(float angle); void rotate_y(float angle); void rotate_z(float angle); - void flip(const Axis &axis); - void flip_x(); - void flip_y(); - void flip_z(); + void mirror(const Axis &axis); + void mirror_x(); + void mirror_y(); + void mirror_z(); void align_to_origin(); void rotate(double angle, Point* center); TriangleMeshPtrs split() const; diff --git a/xs/src/poly2tri/common/shapes.cc b/xs/src/poly2tri/common/shapes.cc index d0de13e64e..54aeaba6a2 100644 --- a/xs/src/poly2tri/common/shapes.cc +++ b/xs/src/poly2tri/common/shapes.cc @@ -150,7 +150,7 @@ void Triangle::Legalize(Point& opoint, Point& npoint) } } -int Triangle::Index(const Point* p) +int Triangle::Index(const Point* p) const { if (p == points_[0]) { return 0; @@ -163,7 +163,7 @@ int Triangle::Index(const Point* p) return -1; } -int Triangle::EdgeIndex(const Point* p1, const Point* p2) +int Triangle::EdgeIndex(const Point* p1, const Point* p2) const { if (points_[0] == p1) { if (points_[1] == p2) { @@ -259,7 +259,7 @@ Triangle* Triangle::NeighborCCW(const Point& point) return neighbors_[1]; } -bool Triangle::GetConstrainedEdgeCCW(const Point& p) +bool Triangle::GetConstrainedEdgeCCW(const Point& p) const { if (&p == points_[0]) { return constrained_edge[2]; @@ -269,7 +269,7 @@ bool Triangle::GetConstrainedEdgeCCW(const Point& p) return constrained_edge[1]; } -bool Triangle::GetConstrainedEdgeCW(const Point& p) +bool Triangle::GetConstrainedEdgeCW(const Point& p) const { if (&p == points_[0]) { return constrained_edge[1]; @@ -301,7 +301,7 @@ void Triangle::SetConstrainedEdgeCW(const Point& p, bool ce) } } -bool Triangle::GetDelunayEdgeCCW(const Point& p) +bool Triangle::GetDelunayEdgeCCW(const Point& p) const { if (&p == points_[0]) { return delaunay_edge[2]; @@ -311,7 +311,7 @@ bool Triangle::GetDelunayEdgeCCW(const Point& p) return delaunay_edge[1]; } -bool Triangle::GetDelunayEdgeCW(const Point& p) +bool Triangle::GetDelunayEdgeCW(const Point& p) const { if (&p == points_[0]) { return delaunay_edge[1]; diff --git a/xs/src/poly2tri/common/shapes.h b/xs/src/poly2tri/common/shapes.h index aa582b1d80..3b8a5247ea 100644 --- a/xs/src/poly2tri/common/shapes.h +++ b/xs/src/poly2tri/common/shapes.h @@ -171,23 +171,23 @@ void MarkConstrainedEdge(int index); void MarkConstrainedEdge(Edge& edge); void MarkConstrainedEdge(Point* p, Point* q); -int Index(const Point* p); -int EdgeIndex(const Point* p1, const Point* p2); +int Index(const Point* p) const; +int EdgeIndex(const Point* p1, const Point* p2) const; Triangle* NeighborCW(const Point& point); Triangle* NeighborCCW(const Point& point); -bool GetConstrainedEdgeCCW(const Point& p); -bool GetConstrainedEdgeCW(const Point& p); +bool GetConstrainedEdgeCCW(const Point& p) const; +bool GetConstrainedEdgeCW(const Point& p) const; void SetConstrainedEdgeCCW(const Point& p, bool ce); void SetConstrainedEdgeCW(const Point& p, bool ce); -bool GetDelunayEdgeCCW(const Point& p); -bool GetDelunayEdgeCW(const Point& p); +bool GetDelunayEdgeCCW(const Point& p) const; +bool GetDelunayEdgeCW(const Point& p) const; void SetDelunayEdgeCCW(const Point& p, bool e); void SetDelunayEdgeCW(const Point& p, bool e); -bool Contains(const Point* p); -bool Contains(const Edge& e); -bool Contains(const Point* p, const Point* q); +bool Contains(const Point* p) const; +bool Contains(const Edge& e) const; +bool Contains(const Point* p, const Point* q) const; void Legalize(Point& point); void Legalize(Point& opoint, Point& npoint); /** @@ -198,7 +198,7 @@ void ClearNeighbor(const Triangle *triangle); void ClearNeighbors(); void ClearDelunayEdges(); -inline bool IsInterior(); +inline bool IsInterior() const; inline void IsInterior(bool b); Triangle& NeighborAcross(const Point& opoint); @@ -293,22 +293,22 @@ inline Triangle* Triangle::GetNeighbor(int index) return neighbors_[index]; } -inline bool Triangle::Contains(const Point* p) +inline bool Triangle::Contains(const Point* p) const { return p == points_[0] || p == points_[1] || p == points_[2]; } -inline bool Triangle::Contains(const Edge& e) +inline bool Triangle::Contains(const Edge& e) const { return Contains(e.p) && Contains(e.q); } -inline bool Triangle::Contains(const Point* p, const Point* q) +inline bool Triangle::Contains(const Point* p, const Point* q) const { return Contains(p) && Contains(q); } -inline bool Triangle::IsInterior() +inline bool Triangle::IsInterior() const { return interior_; } diff --git a/xs/src/polypartition.cpp b/xs/src/polypartition.cpp index 20de4fa68d..700cd09743 100644 --- a/xs/src/polypartition.cpp +++ b/xs/src/polypartition.cpp @@ -74,15 +74,17 @@ TPPLPoly::TPPLPoly(const TPPLPoly &src) { } TPPLPoly& TPPLPoly::operator=(const TPPLPoly &src) { - Clear(); - hole = src.hole; - numpoints = src.numpoints; - points = new TPPLPoint[numpoints]; - memcpy(points, src.points, numpoints*sizeof(TPPLPoint)); + if(&src != this) { + Clear(); + hole = src.hole; + numpoints = src.numpoints; + points = new TPPLPoint[numpoints]; + memcpy(points, src.points, numpoints*sizeof(TPPLPoint)); + } return *this; } -int TPPLPoly::GetOrientation() { +int TPPLPoly::GetOrientation() const { long i1,i2; tppl_float area = 0; for(i1=0; i1 *inpolys, list *outpolys) { list polys; list::iterator holeiter,polyiter,iter,iter2; - long i,i2,holepointindex,polypointindex; + long i,i2,holepointindex,polypointindex = 0; TPPLPoint holepoint,polypoint,bestpolypoint; TPPLPoint linep1,linep2; TPPLPoint v1,v2; @@ -181,14 +183,14 @@ int TPPLPartition::RemoveHoles(list *inpolys, list *outpolys //check for trivial case (no holes) hasholes = false; - for(iter = inpolys->begin(); iter!=inpolys->end(); iter++) { + for(iter = inpolys->begin(); iter!=inpolys->end(); ++iter) { if(iter->IsHole()) { hasholes = true; break; } } if(!hasholes) { - for(iter = inpolys->begin(); iter!=inpolys->end(); iter++) { + for(iter = inpolys->begin(); iter!=inpolys->end(); ++iter) { outpolys->push_back(*iter); } return 1; @@ -199,7 +201,7 @@ int TPPLPartition::RemoveHoles(list *inpolys, list *outpolys while(1) { //find the hole point with the largest x hasholes = false; - for(iter = polys.begin(); iter!=polys.end(); iter++) { + for(iter = polys.begin(); iter!=polys.end(); ++iter) { if(!iter->IsHole()) continue; if(!hasholes) { @@ -219,7 +221,7 @@ int TPPLPartition::RemoveHoles(list *inpolys, list *outpolys holepoint = holeiter->GetPoint(holepointindex); pointfound = false; - for(iter = polys.begin(); iter!=polys.end(); iter++) { + for(iter = polys.begin(); iter!=polys.end(); ++iter) { if(iter->IsHole()) continue; for(i=0; i < iter->GetNumPoints(); i++) { if(iter->GetPoint(i).x <= holepoint.x) continue; @@ -235,7 +237,7 @@ int TPPLPartition::RemoveHoles(list *inpolys, list *outpolys if(v2.x > v1.x) continue; } pointvisible = true; - for(iter2 = polys.begin(); iter2!=polys.end(); iter2++) { + for(iter2 = polys.begin(); iter2!=polys.end(); ++iter2) { if(iter2->IsHole()) continue; for(i2=0; i2 < iter2->GetNumPoints(); i2++) { linep1 = iter2->GetPoint(i2); @@ -278,7 +280,7 @@ int TPPLPartition::RemoveHoles(list *inpolys, list *outpolys polys.push_back(newpoly); } - for(iter = polys.begin(); iter!=polys.end(); iter++) { + for(iter = polys.begin(); iter!=polys.end(); ++iter) { outpolys->push_back(*iter); } @@ -449,7 +451,7 @@ int TPPLPartition::Triangulate_EC(list *inpolys, list *trian list::iterator iter; if(!RemoveHoles(inpolys,&outpolys)) return 0; - for(iter=outpolys.begin();iter!=outpolys.end();iter++) { + for(iter=outpolys.begin();iter!=outpolys.end();++iter) { if(!Triangulate_EC(&(*iter),triangles)) return 0; } return 1; @@ -484,7 +486,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list *parts) { if(!Triangulate_EC(poly,&triangles)) return 0; - for(iter1 = triangles.begin(); iter1 != triangles.end(); iter1++) { + for(iter1 = triangles.begin(); iter1 != triangles.end(); ++iter1) { poly1 = &(*iter1); for(i11=0;i11GetNumPoints();i11++) { d1 = poly1->GetPoint(i11); @@ -492,7 +494,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list *parts) { d2 = poly1->GetPoint(i12); isdiagonal = false; - for(iter2 = iter1; iter2 != triangles.end(); iter2++) { + for(iter2 = iter1; iter2 != triangles.end(); ++iter2) { if(iter1 == iter2) continue; poly2 = &(*iter2); @@ -548,7 +550,7 @@ int TPPLPartition::ConvexPartition_HM(TPPLPoly *poly, list *parts) { } } - for(iter1 = triangles.begin(); iter1 != triangles.end(); iter1++) { + for(iter1 = triangles.begin(); iter1 != triangles.end(); ++iter1) { parts->push_back(*iter1); } @@ -560,7 +562,7 @@ int TPPLPartition::ConvexPartition_HM(list *inpolys, list *p list::iterator iter; if(!RemoveHoles(inpolys,&outpolys)) return 0; - for(iter=outpolys.begin();iter!=outpolys.end();iter++) { + for(iter=outpolys.begin();iter!=outpolys.end();++iter) { if(!ConvexPartition_HM(&(*iter),parts)) return 0; } return 1; @@ -740,7 +742,7 @@ void TPPLPartition::TypeA(long i, long j, long k, PartitionVertex *vertices, DPS iter = pairs->end(); lastiter = pairs->end(); while(iter!=pairs->begin()) { - iter--; + --iter; if(!IsReflex(vertices[iter->index2].p,vertices[j].p,vertices[k].p)) lastiter = iter; else break; } @@ -776,7 +778,7 @@ void TPPLPartition::TypeB(long i, long j, long k, PartitionVertex *vertices, DPS while(iter!=pairs->end()) { if(!IsReflex(vertices[i].p,vertices[j].p,vertices[iter->index1].p)) { lastiter = iter; - iter++; + ++iter; } else break; } @@ -917,7 +919,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list *parts) { } if(!vertices[diagonal.index1].isConvex) { iter = pairs->end(); - iter--; + --iter; j = iter->index2; newdiagonal.index1 = j; newdiagonal.index2 = diagonal.index2; @@ -931,7 +933,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list *parts) { break; } iter2 = pairs2->end(); - iter2--; + --iter2; if(iter->index1 != iter2->index1) pairs2->pop_back(); else break; } @@ -1001,7 +1003,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list *parts) { pairs = &(dpstates[diagonal.index1][diagonal.index2].pairs); if(!vertices[diagonal.index1].isConvex) { iter = pairs->end(); - iter--; + --iter; j = iter->index2; if(iter->index1 != iter->index2) ijreal = false; } else { @@ -1032,7 +1034,7 @@ int TPPLPartition::ConvexPartition_OPT(TPPLPoly *poly, list *parts) { indices.sort(); newpoly.Init((long)indices.size()); k=0; - for(iiter = indices.begin();iiter!=indices.end();iiter++) { + for(iiter = indices.begin();iiter!=indices.end(); ++iiter) { newpoly[k] = vertices[*iiter].p; k++; } @@ -1064,7 +1066,7 @@ int TPPLPartition::MonotonePartition(list *inpolys, list *mo bool error = false; numvertices = 0; - for(iter = inpolys->begin(); iter != inpolys->end(); iter++) { + for(iter = inpolys->begin(); iter != inpolys->end(); ++iter) { numvertices += iter->GetNumPoints(); } @@ -1073,7 +1075,7 @@ int TPPLPartition::MonotonePartition(list *inpolys, list *mo newnumvertices = numvertices; polystartindex = 0; - for(iter = inpolys->begin(); iter != inpolys->end(); iter++) { + for(iter = inpolys->begin(); iter != inpolys->end(); ++iter) { poly = &(*iter); polyendindex = polystartindex + poly->GetNumPoints()-1; for(i=0;iGetNumPoints();i++) { @@ -1174,7 +1176,7 @@ int TPPLPartition::MonotonePartition(list *inpolys, list *mo error = true; break; } - edgeIter--; + --edgeIter; //Insert the diagonal connecting vi to helper(ej) in D. AddDiagonal(vertices,&newnumvertices,vindex,helpers[edgeIter->index]); vertextypes[newnumvertices-2] = vertextypes[vindex]; @@ -1220,7 +1222,7 @@ int TPPLPartition::MonotonePartition(list *inpolys, list *mo error = true; break; } - edgeIter--; + --edgeIter; //if helper(ej) is a merge vertex if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) { //Insert the diagonal connecting vi to helper(e j) in D. @@ -1270,7 +1272,7 @@ int TPPLPartition::MonotonePartition(list *inpolys, list *mo error = true; break; } - edgeIter--; + --edgeIter; //if helper(ej) is a merge vertex if(vertextypes[helpers[edgeIter->index]]==TPPL_VERTEXTYPE_MERGE) { //Insert the diagonal connecting vi to helper(e j) in D. @@ -1373,7 +1375,7 @@ bool TPPLPartition::Below(TPPLPoint &p1, TPPLPoint &p2) { } //sorts in the falling order of y values, if y is equal, x is used instead -bool TPPLPartition::VertexSorter::operator() (long index1, long index2) { +bool TPPLPartition::VertexSorter::operator() (long index1, long index2) const { if(vertices[index1].p.y > vertices[index2].p.y) return true; else if(vertices[index1].p.y == vertices[index2].p.y) { if(vertices[index1].p.x > vertices[index2].p.x) return true; @@ -1547,7 +1549,7 @@ int TPPLPartition::Triangulate_MONO(list *inpolys, list *tri list::iterator iter; if(!MonotonePartition(inpolys,&monotone)) return 0; - for(iter = monotone.begin(); iter!=monotone.end();iter++) { + for(iter = monotone.begin(); iter!=monotone.end(); ++iter) { if(!TriangulateMonotone(&(*iter),triangles)) return 0; } return 1; diff --git a/xs/src/polypartition.h b/xs/src/polypartition.h index 4e8ef1f73c..2596243ae4 100644 --- a/xs/src/polypartition.h +++ b/xs/src/polypartition.h @@ -89,11 +89,11 @@ public: TPPLPoly& operator=(const TPPLPoly &src); //getters and setters - long GetNumPoints() { + long GetNumPoints() const { return numpoints; } - bool IsHole() { + bool IsHole() const { return hole; } @@ -130,7 +130,7 @@ public: // TPPL_CCW : polygon vertices are in counter-clockwise order // TPPL_CW : polygon vertices are in clockwise order // 0 : the polygon has no (measurable) area - int GetOrientation(); + int GetOrientation() const; //sets the polygon orientation //orientation can be @@ -162,7 +162,7 @@ protected: MonotoneVertex *vertices; public: VertexSorter(MonotoneVertex *v) : vertices(v) {} - bool operator() (long index1, long index2); + bool operator() (long index1, long index2) const; }; struct Diagonal { diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t index cc140aa5a9..fd57cf8051 100644 --- a/xs/t/01_trianglemesh.t +++ b/xs/t/01_trianglemesh.t @@ -100,7 +100,7 @@ my $cube = { my $slices = $m->slice([ 5, 10 ]); is $slices->[0][0]->area, $slices->[1][0]->area, 'slicing a top tangent plane includes its area'; } - $m->flip_z; + $m->mirror_z; { # this second test also checks that performing a second slice on a mesh after # a transformation works properly (shared_vertices is correctly invalidated); diff --git a/xs/xsp/Extruder.xsp b/xs/xsp/Extruder.xsp index c244e02e4d..aac39c4139 100644 --- a/xs/xsp/Extruder.xsp +++ b/xs/xsp/Extruder.xsp @@ -6,7 +6,7 @@ %} %name{Slic3r::Extruder} class Extruder { - Extruder(int id, GCodeConfig *config); + Extruder(unsigned int id, GCodeConfig *config); ~Extruder(); void reset(); double extrude(double dE); @@ -16,7 +16,7 @@ double extruded_volume(); double used_filament(); - int id() + unsigned int id() %code%{ RETVAL = THIS->id; %}; double E() diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index cf9b974f48..1838909679 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -183,7 +183,7 @@ ModelMaterial::attributes() void scale_xyz(Pointf3* versor) %code{% THIS->scale(*versor); %}; void rotate(float angle, Axis axis); - void flip(Axis axis); + void mirror(Axis axis); Model* cut(double z) %code%{ diff --git a/xs/xsp/TriangleMesh.xsp b/xs/xsp/TriangleMesh.xsp index d870306935..c4f249f343 100644 --- a/xs/xsp/TriangleMesh.xsp +++ b/xs/xsp/TriangleMesh.xsp @@ -23,9 +23,9 @@ void rotate_x(float angle); void rotate_y(float angle); void rotate_z(float angle); - void flip_x(); - void flip_y(); - void flip_z(); + void mirror_x(); + void mirror_y(); + void mirror_z(); void align_to_origin(); void rotate(double angle, Point* center); TriangleMeshPtrs split();