Skip to content

Commit

Permalink
Update PerimeterGenerator.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
igiannakas committed Mar 4, 2024
1 parent ff4347f commit cf39ba0
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,24 @@ void PerimeterGenerator::process_classic()
this->object_config->brim_type == BrimType::btOuterOnly &&
this->object_config->brim_width.value > 0))
entities.reverse();
// SoftFever: sandwich mode
else if (this->config->wall_sequence == WallSequence::MiddleOuterInner){
if (entities.entities.size() > 1) {
entities.reverse();

int index;

for (index=0; index < entities.entities.size(); index++) {
if (entities.entities[index]->role() == erExternalPerimeter) {
if ( ( (index+1) < entities.entities.size() ) && (entities.entities[index+1]->role() == erPerimeter) ) {
std::swap(entities.entities[index], entities.entities[index+1]);
// Skip next item (which we swapped)
index++;
}
}
}
}
}
// SoftFever: sandwich mode
else if (this->config->wall_sequence == WallSequence::InnerOuterInner)
if (entities.entities.size() > 1){
int last_outer=0;
Expand Down Expand Up @@ -2582,7 +2599,6 @@ void PerimeterGenerator::process_arachne()
// perimeters in a single island
// printf("Reorder Loop. Position %d, extrusion list size: %d, Outer index %d, inner index %d, second inner index %d\n", position, reordered_extrusions.size(),outer,first_internal,second_internal);
for (arr_i = position; arr_i < reordered_extrusions.size(); ++arr_i) {
// printf("Perimeter: extrusion inset index %d, ordered extrusions array position %d\n",reordered_extrusions[arr_i].extrusion->inset_idx, arr_i);
switch (reordered_extrusions[arr_i].extrusion->inset_idx) {
case 0: // external perimeter
if (outer == -1)
Expand All @@ -2609,27 +2625,19 @@ void PerimeterGenerator::process_arachne()
// printf("Layer ID %d, Outer index %d, inner index %d, second inner index %d, maximum internal perimeter %d \n",layer_id,outer,first_internal,second_internal, max_internal);
if (outer > -1 && first_internal > -1 && second_internal > -1) { // found perimeters to re-order?
std::vector<PerimeterGeneratorArachneExtrusion> inner_outer_extrusions; // temporary array to hold extrusions for reordering
//inner_outer_extrusions.reserve(max_internal - position + 1); // reserve array containing the number of perimeters before a new island. Variables are array indexes hence need to add +1 to convert to position allocations
// printf("Allocated array size %d, max_internal index %d, start position index %d \n",max_internal-position+1,max_internal,position);

for (arr_j = max_internal; arr_j >=position; --arr_j){ // go inside out towards the external perimeter (perimeters in reverse order) and store all internal perimeters until the first one identified with inset index 2

for (arr_j = max_internal; arr_j >=position; --arr_j){ // go inside out for all perimers except any that have inset index 2 (second internal). These will be printed last
if(reordered_extrusions[arr_j].extrusion->inset_idx!=2){
//printf("Inside out loop: Mapped perimeter index %d to array position %d\n", arr_j, max_internal-arr_j);
inner_outer_extrusions.emplace_back(reordered_extrusions[arr_j]);
}
}
for (arr_j = max_internal; arr_j >=position; --arr_j){ // go inside out towards the external perimeter (perimeters in reverse order) and store all internal perimeters until the first one identified with inset index 2
for (arr_j = max_internal; arr_j >=position; --arr_j){ // print any inset index 2 perimeters that were skipped before
if(reordered_extrusions[arr_j].extrusion->inset_idx==2){
//printf("Inside out loop: Mapped perimeter index %d to array position %d\n", arr_j, max_internal-arr_j);
inner_outer_extrusions.emplace_back(reordered_extrusions[arr_j]);
}
}


/*for (arr_j = position; arr_j < second_internal; ++arr_j){ // go outside in and map the remaining perimeters (external and first internal wall(s)) using the outside in wall order
// printf("Outside in loop: Mapped perimeter index %d to array position %d\n", arr_j, current_perimeter+1);
inner_outer_extrusions[++current_perimeter] = reordered_extrusions[arr_j];
}*/

for(arr_j = position; arr_j <= max_internal; ++arr_j) // replace perimeter array with the new re-ordered array
ordered_extrusions[arr_j] = inner_outer_extrusions[arr_j-position];
Expand Down

0 comments on commit cf39ba0

Please sign in to comment.