swath_generator_base.cpp
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 // Author: Gonzalo Mier
4 // BSD-3 License
5 //=============================================================================
6 
8 
9 namespace f2c::sg {
10 
12  return this->allow_overlap;
13 }
14 
16  this->allow_overlap = value;
17 }
18 
20  f2c::obj::SGObjective& obj, double op_width, const F2CCell& poly) {
21  return generateSwaths(computeBestAngle(obj, op_width, poly), op_width, poly);
22 }
23 
25  f2c::obj::SGObjective& obj, double op_width, const F2CCells& polys) {
27  for (auto&& p : polys) {
28  swaths.emplace_back(generateBestSwaths(obj, op_width, p));
29  }
30  return swaths;
31 }
32 
34  double op_width, const F2CCells& polys) {
36  for (auto&& p : polys) {
37  swaths.emplace_back(generateSwaths(angle, op_width, p));
38  }
39  return swaths;
40 }
41 
42 
44  double op_width, const F2CCell& poly) {
45  auto rot_poly {F2CPoint(0.0, 0.0).rotateFromPoint(-angle, poly)};
46 
47  double field_height {rot_poly.getHeight()};
48  F2CPoint min_point(rot_poly.getDimMinX(), rot_poly.getDimMinY());
49  auto seed_curve = rot_poly.createStraightLongLine(min_point, 0.0);
50 
51  double curve_y {-0.5 * op_width};
52  F2CMultiLineString paths;
53  while (field_height > curve_y + (allow_overlap ? 0.0 : 0.5 * op_width)) {
54  curve_y += op_width;
55  paths.addGeometry(F2CPoint(0.0, 0.0).rotateFromPoint(angle,
56  seed_curve + F2CPoint(0.0, curve_y)));
57  }
58 
60  swaths.append(paths, poly, op_width, f2c::types::SwathType::MAINLAND);
61  return swaths;
62 }
63 
64 
66  double ang, double op_width, const F2CCell& poly) {
67  if (obj.isFastCompAvailable()) {
68  return obj.computeCostWithMinimizingSign(ang, op_width, poly);
69  }
70  return obj.computeCostWithMinimizingSign(poly,
71  generateSwaths(ang, op_width, poly));
72 }
73 
75  double width, const F2CCell& poly) {
76  return computeBestAngle(obj, width, poly);
77 }
78 
79 } // namespace f2c::sg
80 
5_route_planning.swaths
swaths
Definition: 5_route_planning.py:58
f2c::sg::SwathGeneratorBase::generateBestSwaths
virtual F2CSwaths generateBestSwaths(f2c::obj::SGObjective &obj, double op_width, const F2CCell &poly)
Definition: swath_generator_base.cpp:19
f2c::types::Geometry::getHeight
double getHeight() const
Get the height of the geometry.
Definition: Geometry_impl.hpp:116
swath_generator_base.h
f2c::types::MultiLineString
Definition: MultiLineString.h:18
f2c::obj::SGObjective
Base class for objective functions of swath generators.
Definition: sg_objective.h:21
f2c::types::Cell
Definition: Cell.h:32
f2c::types::Point::rotateFromPoint
Point rotateFromPoint(double angle, const Point &p_r) const
Definition: Point.cpp:121
7_decomposition.obj
obj
Definition: 7_decomposition.py:32
f2c::types::SwathType::MAINLAND
@ MAINLAND
2_objective_functions.width
float width
Definition: 2_objective_functions.py:29
f2c::sg::SwathGeneratorBase::computeBestAngle
virtual double computeBestAngle(f2c::obj::SGObjective &obj, double op_width, const F2CCell &poly)=0
Definition: swath_generator_base.cpp:74
f2c::sg::SwathGeneratorBase::getAllowOverlap
bool getAllowOverlap() const
Definition: swath_generator_base.cpp:11
f2c::types::Cells
Definition: Cells.h:21
f2c::sg
Swath generator algorithms' namespace.
Definition: brute_force.h:18
f2c::types::Point
Definition: Point.h:21
f2c::sg::SwathGeneratorBase::allow_overlap
bool allow_overlap
Definition: swath_generator_base.h:43
f2c::sg::SwathGeneratorBase::setAllowOverlap
void setAllowOverlap(bool)
Definition: swath_generator_base.cpp:15
f2c::sg::SwathGeneratorBase::generateSwaths
virtual F2CSwaths generateSwaths(double angle, double op_width, const F2CCell &poly)
Definition: swath_generator_base.cpp:43
f2c::types::SwathsByCells
Definition: SwathsByCells.h:17
f2c::sg::SwathGeneratorBase::computeCostOfAngle
virtual double computeCostOfAngle(f2c::obj::SGObjective &obj, double ang, double op_width, const F2CCell &poly)
Definition: swath_generator_base.cpp:65
f2c::types::Swaths
Definition: Swaths.h:20
f2c::types::MultiLineString::addGeometry
void addGeometry(const LineString &line)
Definition: MultiLineString.cpp:120
F2CPoint
f2c::types::Point F2CPoint
Definition: types.h:38


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31