diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 1d186d3ab..b40430fec 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -463,7 +463,7 @@ Print::apply_config(DynamicPrintConfig config) std::vector ®ion_volumes = object->region_volumes[region_id]; for (std::vector::const_iterator volume_id = region_volumes.begin(); volume_id != region_volumes.end(); ++volume_id) { - ModelVolume* volume = object->model_object()->volumes[*volume_id]; + ModelVolume* volume = object->model_object()->volumes.at(*volume_id); PrintRegionConfig new_config = this->_region_config_from_model_volume(*volume); diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index f0c1454fc..0e7334eaf 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -76,8 +76,10 @@ class PrintObject friend class Print; public: - // vector of (vectors of volume ids), indexed by region_id - std::vector > region_volumes; + // map of (vectors of volume ids), indexed by region_id + /* (we use map instead of vector so that we don't have to worry about + resizing it and the [] operator adds new items automagically) */ + std::map< size_t,std::vector > region_volumes; PrintObjectConfig config; t_layer_height_ranges layer_height_ranges; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 5fbca0c6d..1d33fbc00 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -10,8 +10,6 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding _model_object(model_object), typed_slices(false) { - region_volumes.resize(this->_print->regions.size()); - // Compute the translation to be applied to our meshes so that we work with smaller coordinates { // Translate meshes so that our toolpath generation algorithms work with smaller @@ -125,10 +123,6 @@ PrintObject::bounding_box(BoundingBox* bb) const void PrintObject::add_region_volume(int region_id, int volume_id) { - if (region_id >= region_volumes.size()) { - region_volumes.resize(region_id + 1); - } - region_volumes[region_id].push_back(volume_id); } @@ -369,7 +363,7 @@ PrintObject::bridge_over_infill() diff(internal_solid, to_bridge, ¬_to_bridge, true); #ifdef SLIC3R_DEBUG - printf "Bridging %d internal areas at layer %d\n", scalar(@$to_bridge), $layer_id; + printf("Bridging %zu internal areas at layer %d\n", to_bridge.size(), layer->id()); #endif // build the new collection of fill_surfaces