diff --git a/.vscode/launch.json b/.vscode/launch.json index f750daa..9f1afcc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/tsbp/CMakeLists.txt b/tsbp/CMakeLists.txt index 19a1ed5..420640c 100644 --- a/tsbp/CMakeLists.txt +++ b/tsbp/CMakeLists.txt @@ -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) diff --git a/tsbp/include/tsbp/Preprocess.h b/tsbp/include/tsbp/Preprocess.h index 66e309d..770226b 100644 --- a/tsbp/include/tsbp/Preprocess.h +++ b/tsbp/include/tsbp/Preprocess.h @@ -22,6 +22,8 @@ class PreprocessPacking2D Bin container; InputParameters parameters; + void InitializeInternIds(std::vector& items); + void RemoveLargeItems(std::vector& items, Bin& container); void FilterFrameConfigurations(std::vector& items, Bin& container); diff --git a/tsbp/src/Preprocess.cpp b/tsbp/src/Preprocess.cpp index 27355aa..05853ee 100644 --- a/tsbp/src/Preprocess.cpp +++ b/tsbp/src/Preprocess.cpp @@ -12,6 +12,8 @@ namespace tsbp void PreprocessPacking2D::Run() { + InitializeInternIds(this->items); + std::vector newItems = this->items; Bin newContainer = this->container; @@ -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& items) +{ + for (size_t i = 0; i < items.size(); i++) + { + Rectangle& item = items[i]; + item.InternId = i; + } +} + void PreprocessPacking2D::RemoveLargeItems(std::vector& items, Bin& container) { bool removedItem = true;