Skip to content

Commit

Permalink
fix indices after bug introduced by refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ktnr committed May 15, 2022
1 parent 01797ba commit 2fa7152
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
"environment": [],
"console": "externalTerminal"
},
{
"name": "Launch Release (Windows)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/tsbp-cli/Release/tsbp.exe",
"args": [
"-i",
"${workspaceFolder}/data/input/CJCM08/",
"-f",
"E00N10.json",
"-o",
"${workspaceFolder}/data/output/"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal"
},
{
"name": "Launch Test Debug (Windows)",
"type": "cppvsdbg",
Expand Down
1 change: 1 addition & 0 deletions tsbp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ add_library(tsbp-lib
"include/tsbp/OrthogonalPackingSolver2D.h"
"include/tsbp/Serialization.h"
"include/tsbp/Preprocess.h"
"${CMAKE_SOURCE_DIR}/external/ltalloc/ltalloc.cc"
)

if(UNIX)
Expand Down
2 changes: 2 additions & 0 deletions tsbp/include/tsbp/Preprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class PreprocessPacking2D
Bin container;
InputParameters parameters;

void InitializeInternIds(std::vector<Rectangle>& items);

void RemoveLargeItems(std::vector<Rectangle>& items, Bin& container);
void FilterFrameConfigurations(std::vector<Rectangle>& items, Bin& container);

Expand Down
13 changes: 13 additions & 0 deletions tsbp/src/Preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace tsbp

void PreprocessPacking2D::Run()
{
InitializeInternIds(this->items);

std::vector<Rectangle> newItems = this->items;
Bin newContainer = this->container;

Expand All @@ -25,10 +27,21 @@ void PreprocessPacking2D::Run()
std::cout << "Preprocess removed " << this->items.size() - newItems.size() << " items "
<< "and reduced container area by " << this->container.Area - newContainer.Area << ".\n";

InitializeInternIds(newItems);

PreprocessedContainer = newContainer;
ProcessedItems = newItems;
}

void PreprocessPacking2D::InitializeInternIds(std::vector<Rectangle>& items)
{
for (size_t i = 0; i < items.size(); i++)
{
Rectangle& item = items[i];
item.InternId = i;
}
}

void PreprocessPacking2D::RemoveLargeItems(std::vector<Rectangle>& items, Bin& container)
{
bool removedItem = true;
Expand Down

0 comments on commit 2fa7152

Please sign in to comment.