Bugfix: crash in some circumstances when avoid_crossing_perimeters is enabled. #2266
This commit is contained in:
parent
39b41fda12
commit
6b8f03ff1c
3 changed files with 16 additions and 1 deletions
|
@ -18,10 +18,17 @@ MotionPlanner::~MotionPlanner()
|
||||||
delete *graph;
|
delete *graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
MotionPlanner::islands_count() const
|
||||||
|
{
|
||||||
|
return this->islands.size();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MotionPlanner::initialize()
|
MotionPlanner::initialize()
|
||||||
{
|
{
|
||||||
if (this->initialized) return;
|
if (this->initialized) return;
|
||||||
|
if (this->islands.empty()) return; // prevent initialization of empty BoundingBox
|
||||||
|
|
||||||
ExPolygons expp;
|
ExPolygons expp;
|
||||||
for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
|
for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
|
||||||
|
@ -70,6 +77,12 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl
|
||||||
{
|
{
|
||||||
if (!this->initialized) this->initialize();
|
if (!this->initialized) this->initialize();
|
||||||
|
|
||||||
|
if (this->islands.empty()) {
|
||||||
|
polyline->points.push_back(from);
|
||||||
|
polyline->points.push_back(to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Are both points in the same island?
|
// Are both points in the same island?
|
||||||
int island_idx = -1;
|
int island_idx = -1;
|
||||||
for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
|
for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ class MotionPlanner
|
||||||
MotionPlanner(const ExPolygons &islands);
|
MotionPlanner(const ExPolygons &islands);
|
||||||
~MotionPlanner();
|
~MotionPlanner();
|
||||||
void shortest_path(const Point &from, const Point &to, Polyline* polyline);
|
void shortest_path(const Point &from, const Point &to, Polyline* polyline);
|
||||||
|
size_t islands_count() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExPolygons islands;
|
ExPolygons islands;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
MotionPlanner(ExPolygons islands);
|
MotionPlanner(ExPolygons islands);
|
||||||
~MotionPlanner();
|
~MotionPlanner();
|
||||||
|
|
||||||
|
int islands_count();
|
||||||
Polyline* shortest_path(Point* from, Point* to)
|
Polyline* shortest_path(Point* from, Point* to)
|
||||||
%code%{ RETVAL = new Polyline(); THIS->shortest_path(*from, *to, RETVAL); %};
|
%code%{ RETVAL = new Polyline(); THIS->shortest_path(*from, *to, RETVAL); %};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue