-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stock, sheet and scrap inventories #7
- Loading branch information
1 parent
1933555
commit 4f40496
Showing
4 changed files
with
197 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
namespace ta | ||
{ | ||
|
||
class cTimber; | ||
typedef std::shared_ptr< cTimber > timber_t; | ||
typedef std::vector< timber_t > timberv_t; | ||
|
||
|
||
/// A 3D object with dimension and location | ||
class cSpace | ||
{ | ||
public: | ||
int myLength, myWidth, myHeight; // dimensions | ||
int myLocL, myLocW, myLocH; | ||
|
||
|
||
cSpace( int L, int W, int H ) | ||
: myLength( L ), myWidth( W ), myHeight{ H } | ||
{ | ||
|
||
} | ||
bool fit( const cSpace& squeeze ) const | ||
{ | ||
return ( squeeze.myLength <= myLength && | ||
squeeze.myLength <= myLength && | ||
squeeze.myHeight <= myHeight ); | ||
} | ||
|
||
int size_horiz() | ||
{ | ||
return myLength * myWidth; | ||
} | ||
/// rotate so that L, W, H are in decending size order | ||
void rotateLWH(); | ||
}; | ||
|
||
class cTimber : public cSpace | ||
{ | ||
public: | ||
cTimber() | ||
: cSpace( 0, 0, 0 ) | ||
{ | ||
|
||
} | ||
cTimber( int L, int W, int H ) | ||
: cSpace( L, W, H ) | ||
{ | ||
|
||
} | ||
int ParseSpaceDelimited( | ||
const std::string& l ); | ||
|
||
|
||
std::string myUserID; | ||
int myDemand; | ||
|
||
}; | ||
class cInstance | ||
{ | ||
public: | ||
void read( const std::string& fname ); | ||
std::string text(); | ||
void sortInventory( int sheetHeight, int scrapWidth ); | ||
|
||
|
||
private: | ||
timberv_t myInventory; | ||
timberv_t myOrder; | ||
timberv_t myScrap; | ||
timberv_t mySheet; | ||
std::vector< int > ParseSpaceDelimited( | ||
const std::string& l ); | ||
void add( std::vector< int > ); | ||
void expandDemand( timberv_t& tv ); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <memory> | ||
#include <vector> | ||
#include <algorithm> | ||
#include "TimberAllocation.h" | ||
|
||
using namespace std; | ||
|
||
namespace ta | ||
{ | ||
void cSpace::rotateLWH() | ||
{ | ||
std::vector<int> vLWH { myLength, myWidth, myHeight }; | ||
std::sort( vLWH.begin(), vLWH.end(), | ||
[]( int& a, int& b) | ||
{ | ||
return a > b; | ||
}); | ||
myLength = vLWH[0]; | ||
myWidth = vLWH[1]; | ||
myHeight = vLWH[2]; | ||
|
||
// for( int i : vLWH ) | ||
// std::cout << i <<" "; | ||
// std::cout << "\n"; | ||
} | ||
} |