Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesBremner committed Jun 30, 2020
1 parent 460c112 commit 8a42a48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/TimberAllocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ bool CS2Pack2(
cInstance& I,
cLevel& level, int h );

/** Record a cut for an order in the instance
/** Allocate an order
@param[in] I the instance
@param[in] stock order is cut from
@param[in] order being cut
@param[in] stock order is allocated to
@param[in] order being allocated
@param[[in] length position
@param[[in] width position
@param[[in] height position
*/
void CutOrder(
void AllocateOrder(
cInstance& I,
timber_t& stock,
timber_t& order,
Expand Down
18 changes: 11 additions & 7 deletions src/taCutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ bool CS2Pack2(
// std::cout << pack2::CSV( E );


// loop over items in level, allocating orders that fit
int packedCount = 0;
for( pack2::item_t item : E.items() )
{
Expand All @@ -297,18 +298,16 @@ bool CS2Pack2(
so record the level cut in the instance
unless at top of stock
*/
if( level.height() != level.myStock->myHeight )
CutLevel(
I,
level );
CutLevel(
I,
level );
}

CutOrder(
AllocateOrder(
I,
level.myStock,
level.myOrder[ atoi( item->userID().c_str() ) ],
item->locX(), item->locY(), h );

}

// check for nothing packed
Expand Down Expand Up @@ -362,7 +361,7 @@ bool CS2Pack2(
return ( packedCount == level.size() );
}

void CutOrder(
void AllocateOrder(
cInstance& I,
timber_t& stock,
timber_t& order,
Expand All @@ -375,6 +374,11 @@ void CutLevel(
cInstance& I,
cLevel& level )
{
if( level.height() == level.myStock->myHeight )
{
//no need for a cut, we are at the top of the stock
return;
}
I.myCut.push_back( cCut(
level.myStock,
'H',
Expand Down

0 comments on commit 8a42a48

Please sign in to comment.