@@ -64,6 +64,38 @@ void TrapezoidSet::write_svg(
6464 file << " </svg>" << std::endl;
6565}
6666
67+ namespace
68+ {
69+
70+ BranchingScheme::Direction default_direction (
71+ const Instance& instance,
72+ BinTypeId bin_type_id)
73+ {
74+ const BinType& bin_type = instance.bin_type (bin_type_id);
75+ bool lengthwise = (bin_type.x_max - bin_type.x_min ) >= (bin_type.y_max - bin_type.y_min );
76+ switch (instance.parameters ().leftover_corner ) {
77+ case Corner::BottomLeft: {
78+ return (lengthwise)?
79+ BranchingScheme::Direction::LeftToRightThenBottomToTop:
80+ BranchingScheme::Direction::BottomToTopThenLeftToRight;
81+ } case Corner::BottomRight: {
82+ return (lengthwise)?
83+ BranchingScheme::Direction::RightToLeftThenBottomToTop:
84+ BranchingScheme::Direction::BottomToTopThenRightToLeft;
85+ } case Corner::TopLeft: {
86+ return (lengthwise)?
87+ BranchingScheme::Direction::LeftToRightThenTopToBottom:
88+ BranchingScheme::Direction::TopToBottomThenLeftToRight;
89+ } case Corner::TopRight: {
90+ return (lengthwise)?
91+ BranchingScheme::Direction::RightToLeftThenTopToBottom:
92+ BranchingScheme::Direction::TopToBottomThenRightToLeft;
93+ }
94+ }
95+ }
96+
97+ }
98+
6799BranchingScheme::BranchingScheme (
68100 const Instance& instance,
69101 const Parameters& parameters):
@@ -1349,7 +1381,7 @@ void BranchingScheme::insertions(
13491381
13501382 Direction new_bin_direction = parameters_.direction ;
13511383 if (new_bin_direction == Direction::Any)
1352- new_bin_direction = Direction::LeftToRightThenBottomToTop ;
1384+ new_bin_direction = default_direction ( instance (), bin_type_id) ;
13531385
13541386 const DirectionData& direction_data = directions_data_[(int )new_bin_direction];
13551387 const std::vector<TrapezoidSet>& trapezoid_sets = direction_data.trapezoid_sets ;
0 commit comments