Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
documentation ifxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Journeyman1337 committed Aug 11, 2022
1 parent 4a6a224 commit bba5dec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion classmpbp_1_1Packer.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ <h2 class="memtitle"><span class="permalink"><a href="#a2a6a069cd974978f44cea2b6
<p>Run the pack algorithm with the given span of <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">Rect</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">The</td><td>span of <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">Rect</a> to pack. </td></tr>
<tr><td class="paramname">rects</td><td>The span of <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">Rect</a> to pack. </td></tr>
</table>
</dd>
</dl>
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ <h1><a class="anchor" id="Usage"></a>
<p >To use mpbp, you must first create a <a class="el" href="classmpbp_1_1Packer.html" title="A bin packing algorithm runner and state machine.">mpbp::Packer</a> object and specify the maximum width and height of each bin page. This can be done in one programming statment using its overloaded constructor. </p><pre class="fragment">int max_width = 32;
int max_height = 16;
mpbp::Packer::packer(max_width, max_height);
</pre><p> In order to pack, you must provide a <a href="https://en.cppreference.com/w/cpp/container/span">std::span</a> of <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">mpbp::Rect</a>. An easy way to do this is to store the <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">mpbp::Rect</a> objects in a <a href="https://en.cppreference.com/w/cpp/container/vector">std::vector</a>, 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 <code>unsigned long int</code> 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. </p><pre class="fragment"> std::vector&lt;mpbp::Rect&gt; input_rects = {
</pre><p> In order to pack, you must provide a <a href="https://en.cppreference.com/w/cpp/container/span">std::span</a> of <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">mpbp::Rect</a>. An easy way to do this is to store the <a class="el" href="classmpbp_1_1Rect.html" title="A bin packable axis-alligned rectangle.">mpbp::Rect</a> objects in a <a href="https://en.cppreference.com/w/cpp/container/vector">std::vector</a>, 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 <code>unsigned long int</code> 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. </p><pre class="fragment"> std::vector&lt;mpbp::Rect&gt; 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)};
</pre><p> To perform a pack, pass vector of Rect objects into the <a class="el" href="classmpbp_1_1Packer.html#a2a6a069cd974978f44cea2b6ccbb3761" title="Run the pack algorithm with the given span of Rect.">mpbp::Packer::Pack()</a> function. </p><pre class="fragment">packer.Pack(input_rects);
</pre><p> 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 <a class="el" href="classmpbp_1_1Packer.html#a7706c5044bdaaa0b764b8e54f093ee03" title="Get the amount of bin pages from all previous packs.">mpbp::Packer::GetPageCount()</a> 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 <a class="el" href="classmpbp_1_1Rect.html#ac7632e2cf65c74a1e569b4fa37bdf5cc" title="Get the value used to idenitfy this Rect.">mpbp::Rect::GetIdentifier()</a> function.</p>
</pre><p> 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 <a class="el" href="classmpbp_1_1Packer.html#a7706c5044bdaaa0b764b8e54f093ee03" title="Get the amount of bin pages from all previous packs.">mpbp::Packer::GetPageCount()</a> 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 <a class="el" href="classmpbp_1_1Rect.html#ac7632e2cf65c74a1e569b4fa37bdf5cc" title="Get the value used to idenitfy this Rect.">mpbp::Rect::GetIdentifier()</a> function.</p>
<p >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 <a class="el" href="classmpbp_1_1Packer.html#a0ea3bf433ee29ae0c31f8f3360039277" title="Clear the Packer of data from all previous packs.">mpbp::Packer::Clear()</a> function, and then you can pack your Rect objects again from scratch including any new additions.</p>
<p >You can find a complete example of mpbp in the example folder of the GitHub repostiroy. </p>
</div></div><!-- PageDoc -->
Expand Down

0 comments on commit bba5dec

Please sign in to comment.