Path.h
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 
7 #pragma once
8 #ifndef FIELDS2COVER_TYPES_PATH_H_
9 #define FIELDS2COVER_TYPES_PATH_H_
10 
11 #include <gdal/ogr_geometry.h>
12 #include <fstream>
13 #include <vector>
14 #include <string>
20 
21 namespace f2c::types {
22 
23 struct Path {
24  public:
25  PathState& getState(size_t i);
26  const PathState& getState(size_t i) const;
27  void setState(size_t i, const PathState& ps);
28 
29  void addState(const PathState& ps);
30  void addState(const Point& p, double ang, double len,
32  PathSectionType type = PathSectionType::SWATH, double vel = 1.0);
33 
34  std::vector<PathState>& getStates();
35  const std::vector<PathState>& getStates() const;
36  void setStates(const std::vector<PathState>& v_ps);
37 
38  double getTaskTime() const;
39 
40  std::vector<PathState>::const_iterator cbegin() const;
41  std::vector<PathState>::const_iterator cend() const;
42  std::vector<PathState>::const_iterator begin() const;
43  std::vector<PathState>::const_iterator end() const;
44  std::vector<PathState>::iterator begin();
45  std::vector<PathState>::iterator end();
46 
47  const PathState& operator[](size_t idx) const;
48  PathState& operator[](size_t idx);
49  const PathState& back() const;
50  PathState& back();
51 
52 
53  Path& operator+=(const Path& path);
54  size_t size() const;
55 
56  double getDimMinX() const;
57  double getDimMinY() const;
58  double getDimMaxX() const;
59  double getDimMaxY() const;
60 
61  void moveTo(const Point&);
62  void rotateFromPoint(const Point&, double ang);
63 
64  void mirrorX();
65  void mirrorY();
66  void setBackwardDir();
67  void setBackwardDir(int i);
68  void setForwardDir();
69  void setForwardDir(int i);
70  void setSwathType();
71  void setSwathType(int i);
72  void setTurnType();
73  void setTurnType(int i);
74 
75  double length(void) const;
76 
77  void appendSwath(const Swath& swath, double cruise_speed);
78 
79  PathState at(double t) const;
80  Point atStart() const;
81  Point atEnd() const;
82 
83  LineString toLineString() const;
84  std::string serializePath(size_t digit_precision = 6) const;
85  void saveToFile(const std::string& file, size_t precision = 6) const;
86  void loadFile(const std::string& file);
87 
88  Path discretizeSwath(double step_size) const;
89  Path& discretize(double step_size);
90  Path& populate(int number_points = 100);
91  Path& reduce(double min_dist_equal = 0.1);
92 
93  private:
94  std::vector<PathState> states_;
95 };
96 
97 } // namespace f2c::types
98 
99 #endif // FIELDS2COVER_TYPES_PATH_H_
f2c::types::PathDirection
PathDirection
Definition: PathState.h:21
f2c::types::Path::cend
std::vector< PathState >::const_iterator cend() const
Definition: Path.cpp:63
f2c::types::Path::appendSwath
void appendSwath(const Swath &swath, double cruise_speed)
Definition: Path.cpp:210
f2c::types::Path::discretize
Path & discretize(double step_size)
Definition: Path.cpp:434
Point.h
f2c::types::Path::getStates
std::vector< PathState > & getStates()
Definition: Path.cpp:42
f2c::types
Types used by fields2cover library.
Definition: Cell.h:20
2_objective_functions.path
path
Definition: 2_objective_functions.py:88
f2c::types::Path::setTurnType
void setTurnType()
Definition: Path.cpp:194
f2c::types::Path::getTaskTime
double getTaskTime() const
Definition: Path.cpp:54
f2c::types::Path::rotateFromPoint
void rotateFromPoint(const Point &, double ang)
Definition: Path.cpp:144
f2c::types::Path::end
std::vector< PathState >::const_iterator end() const
Definition: Path.cpp:71
f2c::types::Swath
Definition: Swath.h:23
f2c::types::Path::size
size_t size() const
Definition: Path.cpp:106
f2c::types::Path::atStart
Point atStart() const
Definition: Path.cpp:252
f2c::types::Path::at
PathState at(double t) const
Definition: Path.cpp:225
f2c::types::Path::reduce
Path & reduce(double min_dist_equal=0.1)
Definition: Path.cpp:397
f2c::types::Path::operator+=
Path & operator+=(const Path &path)
Definition: Path.cpp:99
f2c::types::Path::operator[]
const PathState & operator[](size_t idx) const
Definition: Path.cpp:83
Swath.h
PathState.h
f2c::types::PathState
Definition: PathState.h:27
f2c::types::PathSectionType
PathSectionType
Definition: PathState.h:15
f2c::types::Path::begin
std::vector< PathState >::const_iterator begin() const
Definition: Path.cpp:67
f2c::types::Path::getState
PathState & getState(size_t i)
Definition: Path.cpp:14
f2c::types::PathDirection::FORWARD
@ FORWARD
f2c::types::Path::addState
void addState(const PathState &ps)
Definition: Path.cpp:26
f2c::types::Path::populate
Path & populate(int number_points=100)
Definition: Path.cpp:346
f2c::types::Path::setBackwardDir
void setBackwardDir()
Definition: Path.cpp:164
LineString.h
f2c::types::Path::getDimMaxX
double getDimMaxX() const
Definition: Path.cpp:124
f2c::types::Path
Definition: Path.h:23
f2c::types::Path::serializePath
std::string serializePath(size_t digit_precision=6) const
Definition: Path.cpp:283
f2c::types::PathSectionType::SWATH
@ SWATH
f2c::types::LineString
Definition: LineString.h:19
f2c::types::Path::setSwathType
void setSwathType()
Definition: Path.cpp:184
8_complete_flow.ps
list ps
Definition: 8_complete_flow.py:43
MultiLineString.h
f2c::types::Path::getDimMaxY
double getDimMaxY() const
Definition: Path.cpp:131
f2c::types::Path::atEnd
Point atEnd() const
Definition: Path.cpp:256
f2c::types::Path::states_
std::vector< PathState > states_
Definition: Path.h:94
f2c::types::Path::toLineString
LineString toLineString() const
Definition: Path.cpp:425
f2c::types::Path::getDimMinY
double getDimMinY() const
Definition: Path.cpp:117
f2c::types::Point
Definition: Point.h:21
f2c::types::Path::setStates
void setStates(const std::vector< PathState > &v_ps)
Definition: Path.cpp:50
f2c::types::Path::length
double length(void) const
Definition: Path.cpp:205
f2c::types::Path::discretizeSwath
Path discretizeSwath(double step_size) const
Discretize the swath sections of the path and return a new path.
Definition: Path.cpp:305
f2c::types::Path::back
const PathState & back() const
Definition: Path.cpp:91
f2c::types::Path::setState
void setState(size_t i, const PathState &ps)
Definition: Path.cpp:22
f2c::types::Path::loadFile
void loadFile(const std::string &file)
Definition: Path.cpp:330
f2c::types::Path::moveTo
void moveTo(const Point &)
Definition: Path.cpp:138
f2c::types::Path::mirrorX
void mirrorX()
Definition: Path.cpp:151
f2c::types::Path::saveToFile
void saveToFile(const std::string &file, size_t precision=6) const
Definition: Path.cpp:324
f2c::types::Path::mirrorY
void mirrorY()
Definition: Path.cpp:157
f2c::types::Path::cbegin
std::vector< PathState >::const_iterator cbegin() const
Definition: Path.cpp:59
f2c::types::Path::getDimMinX
double getDimMinX() const
Definition: Path.cpp:110
f2c::types::Path::setForwardDir
void setForwardDir()
Definition: Path.cpp:174


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