src
fields2cover
route_planning
spiral_order.cpp
Go to the documentation of this file.
1
#include "
fields2cover/route_planning/spiral_order.h
"
2
3
namespace
f2c::rp
{
4
5
6
SpiralOrder::SpiralOrder
(
size_t
sp_size) {
7
setSpiralSize
(
static_cast<
size_t
>
(std::max(2,
static_cast<
int
>
(sp_size))));
8
}
9
10
SpiralOrder::~SpiralOrder
() =
default
;
11
12
void
SpiralOrder::setSpiralSize
(
size_t
sp_size) {
13
this->
spiral_size
= sp_size;
14
}
15
16
void
SpiralOrder::sortSwaths
(
F2CSwaths
&
swaths
)
const
{
17
size_t
spiral_count =
swaths
.size() /
spiral_size
;
18
for
(
size_t
i = 0; i < spiral_count; i++) {
19
spiral
(
swaths
, i *
spiral_size
,
spiral_size
);
20
}
21
22
int
swaths_left =
swaths
.size() - spiral_count *
spiral_size
;
23
if
(swaths_left > 1) {
24
spiral
(
swaths
, spiral_count *
spiral_size
, swaths_left);
25
}
26
}
27
28
void
SpiralOrder::spiral
(
F2CSwaths
&
swaths
,
size_t
offset,
size_t
size)
const
{
29
for
(
size_t
j = (offset + 1) % 2; j < size; j += 2) {
30
std::rotate(
swaths
.begin() + offset + j,
31
swaths
.begin() + offset + size - 1,
32
swaths
.begin() + offset + size);
33
}
34
}
35
36
}
// namespace f2c::rp
37
5_route_planning.swaths
swaths
Definition:
5_route_planning.py:58
f2c::rp::SpiralOrder::~SpiralOrder
~SpiralOrder()
spiral_order.h
f2c::rp::SpiralOrder::spiral_size
size_t spiral_size
Definition:
spiral_order.h:20
f2c::rp::SpiralOrder::SpiralOrder
SpiralOrder(size_t sp_size=2)
Definition:
spiral_order.cpp:6
f2c::rp::SpiralOrder::spiral
void spiral(F2CSwaths &swaths, size_t offset, size_t size) const
Definition:
spiral_order.cpp:28
f2c::rp
Route planning algorithms' namespace.
Definition:
boustrophedon_order.h:14
f2c::rp::SpiralOrder::sortSwaths
void sortSwaths(F2CSwaths &swaths) const override
Definition:
spiral_order.cpp:16
f2c::rp::SpiralOrder::setSpiralSize
void setSpiralSize(size_t sp_size)
Definition:
spiral_order.cpp:12
f2c::types::Swaths
Definition:
Swaths.h:20
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31