From bba5decfad8f3c535f1506b2d9ce7aaa3cef29da Mon Sep 17 00:00:00 2001 From: Daniel Valcour <60055347+Journeyman-dev@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:22:38 -0400 Subject: [PATCH] documentation ifxes --- classmpbp_1_1Packer.html | 2 +- index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classmpbp_1_1Packer.html b/classmpbp_1_1Packer.html index b480114..7b5f3a9 100644 --- a/classmpbp_1_1Packer.html +++ b/classmpbp_1_1Packer.html @@ -446,7 +446,7 @@
To use mpbp, you must first create a mpbp::Packer object and specify the maximum width and height of each bin page. This can be done in one programming statment using its overloaded constructor.
int max_width = 32; int max_height = 16; mpbp::Packer::packer(max_width, max_height); -
In order to pack, you must provide a std::span of mpbp::Rect. An easy way to do this is to store the mpbp::Rect objects in a std::vector, which will be implicitly converted to a span when you pass it into the packing function. Construct each rect using the overloaded constructor with three arguments. For the first argument, pass in an unsigned long int
identifier value which will be used to identify this Rect later. For the second and third arguments, pass in the width and height of the Rect.
std::vector<mpbp::Rect> input_rects = { +
In order to pack, you must provide a std::span of mpbp::Rect. An easy way to do this is to store the mpbp::Rect objects in a std::vector, which will be implicitly converted to a span when you pass it into the packing function. Construct each Rect using the overloaded constructor with three arguments. For the first argument, pass in an unsigned long int
identifier value which will be used to identify this Rect later. For the second and third arguments, pass in the width and height of the Rect.
std::vector<mpbp::Rect> input_rects = { mpbp::Rect(0, 1, 1), mpbp::Rect(1, 2, 2), mpbp::Rect(2, 4, 4), mpbp::Rect(3, 5, 5), mpbp::Rect(4, 7, 7), mpbp::Rect(5, 7, 7), mpbp::Rect(6, 6, 6), mpbp::Rect(7, 9, 9), mpbp::Rect(8, 6, 6), mpbp::Rect(9, 30, 15)};
To perform a pack, pass vector of Rect objects into the mpbp::Packer::Pack() function.
packer.Pack(input_rects); -
After the Rect objects are packed, loop through them and use their getter functions to get their positions in the bin pages. You can use mpbp::Packer::GetPageCount() to get the total amount of pages that were packed. Remember that after packing, the Rect objects are no longer the same order in their container. To determine which Rect is which, check the identifier value that you set earlier, which you can get with the mpbp::Rect::GetIdentifier() function.
+After the Rect objects are packed, loop through them and use their getter functions to get their positions in the bin pages. You can use mpbp::Packer::GetPageCount() to get the total amount of pages that were packed. After packing, the Rect objects are no longer the same order in their container. To determine which Rect is which, check the identifier value that you set earlier. You can get this value from a Rect object using the mpbp::Rect::GetIdentifier() function.
If you wish to pack more Rect objects with the Packer object, you can do so by creating a new container of Rect objects and calling the Pack function again. You can do this as many times as you like, but note that the more times you call the pack algorithm, the less space efficient it will be. Alternatively, you can clear the Packer object of all state data by calling the mpbp::Packer::Clear() function, and then you can pack your Rect objects again from scratch including any new additions.
You can find a complete example of mpbp in the example folder of the GitHub repostiroy.