Commit 3223d275 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Merge branch 'marching-squares-bug' into 'master'

Fixing states 5 and 10 to ensure clock-wise walk.

See merge request !40
parents 2f73167c 3e696274
Pipeline #13844 failed with stages
in 7 minutes and 5 seconds
......@@ -97,8 +97,6 @@ std::vector<std::pair<int, int>> MarchingSquares<data_type>::march(
// of rows and columns to allow for traveling the boundaries
if (column >= 0 && column <= mColumns && row >= 0 && row <= mRows)
{
radix_tagged_line("(" << row << ", " << column
<< ") =" << int(next_step));
out.push_back({row, column});
}
......@@ -206,10 +204,7 @@ void MarchingSquares<data_type>::step(size_t r, size_t c)
next_step = StepDirection::Left;
break;
case 2:
if (prev_step == StepDirection::Left)
next_step = StepDirection::Up;
else
next_step = StepDirection::Right;
next_step = StepDirection::Up;
break;
case 3:
next_step = StepDirection::Left;
......@@ -218,57 +213,54 @@ void MarchingSquares<data_type>::step(size_t r, size_t c)
next_step = StepDirection::Right;
break;
case 5:
next_step = StepDirection::Up;
break;
case 6:
if (prev_step == StepDirection::Down)
next_step = StepDirection::Down;
next_step = StepDirection::Right;
else
next_step = StepDirection::Up;
next_step = StepDirection::Left;
break;
case 6:
next_step = StepDirection::Up;
break;
case 7:
if (prev_step == StepDirection::Up)
next_step = StepDirection::Left;
else
next_step = StepDirection::Down;
next_step = StepDirection::Left;
break;
case 8:
next_step = StepDirection::Down;
break;
case 9:
if (prev_step == StepDirection::Down)
next_step = StepDirection::Down;
else
next_step = StepDirection::Up;
break;
case 10:
next_step = StepDirection::Down;
break;
case 11:
case 10:
if (prev_step == StepDirection::Left)
next_step = StepDirection::Down;
else
next_step = StepDirection::Right;
next_step = StepDirection::Up;
break;
case 11:
next_step = StepDirection::Down;
break;
case 12:
next_step = StepDirection::Right;
break;
case 13:
if (prev_step == StepDirection::Down)
next_step = StepDirection::Right;
else
next_step == StepDirection::Up;
next_step = StepDirection::Right;
break;
case 14:
if (prev_step == StepDirection::Down)
next_step = StepDirection::Left;
else
next_step = StepDirection::Up;
next_step = StepDirection::Up;
break;
default:
next_step = StepDirection::None;
break;
}
radix_tagged_line(
"(" << r << ", " << c << ") =" << state << " "
<< ((next_step == StepDirection::Up)
? "Up"
: ((next_step == StepDirection::Down)
? "Down"
: (next_step == StepDirection::Left) ? "Left"
: "Right")));
}
} // namespace radix
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment