diff --git a/geometry/Line.cpp b/geometry/Line.cpp index 614289bd13ef9c4c4b01b9bd72098f614ad7b47d..a3e31113a2baa24b18f82b09a1862060d56fa7d3 100644 --- a/geometry/Line.cpp +++ b/geometry/Line.cpp @@ -49,24 +49,24 @@ using namespace std; ************************************************************/ Line::Line(const Point& point1, const Point& point2) : _as_linestring(new boost::geometry::model::linestring<Point>()), - _line(new boost::geometry::model::segment<Point>(point1, point2)) + _line(new std::pair<Point, Point>(std::make_pair(point1, point2))) { boost::geometry::append(*_as_linestring, point1); boost::geometry::append(*_as_linestring, point2); Point p; - boost::geometry::centroid(*_line, p); + boost::geometry::centroid(*_as_linestring, p); _centre = std::unique_ptr<Point>(new Point(p)); _length = boost::geometry::distance(point1, point2); _uid = _static_UID++; } Line::Line(const Line &orig) : _as_linestring(new boost::geometry::model::linestring<Point>()), - _line(new boost::geometry::model::segment<Point>(orig._line->first, orig._line->second)) + _line(new std::pair<Point, Point>(std::make_pair(orig._line->first, orig._line->second))) { boost::geometry::append(*_as_linestring, orig._line->first); boost::geometry::append(*_as_linestring, orig._line->second); Point p; - boost::geometry::centroid(*_line, p); + boost::geometry::centroid(*_as_linestring, p); _centre = std::unique_ptr<Point>(new Point(p)); _length = boost::geometry::distance(orig._line->first, orig._line->second); _uid = orig.GetUniqueID(); @@ -204,7 +204,7 @@ bool Line::IsInLineSegment(const Point &p) const double Line::DistanceTo(const Point& p) const { - return boost::geometry::distance(*_line, p); + return boost::geometry::distance(*_as_linestring, p); } double Line::DistToSquare(const Point &p) const { @@ -215,7 +215,7 @@ double Line::DistToSquare(const Point &p) const { * gleich sind * */ bool Line::operator==(const Line &l) const { - return boost::geometry::equals(*_line, *l._line); + return boost::geometry::equals(*_as_linestring, *l._as_linestring); } /* Zwei Linien sind ungleich, wenn ihre beiden Punkte diff --git a/geometry/Line.h b/geometry/Line.h index 96705fb238975f22a08f7fbdb48b18c600a3fa69..d10a721d48207199358b0fb7da4ba940a3941c93 100644 --- a/geometry/Line.h +++ b/geometry/Line.h @@ -63,7 +63,7 @@ private: int _uid; protected: - std::shared_ptr<segment_t> _line; + std::unique_ptr<std::pair<Point, Point>> _line; public: Line(const Point&, const Point&); @@ -231,7 +231,16 @@ public: * @param d * @return */ - Line Enlarge(double d) const; + Line Enlarge(double d) const; + + Line& operator=(Line other) + { + std::swap(_as_linestring, other._as_linestring); + std::swap(_line, other._line); + std::swap(_length, other._length); + std::swap(_uid, other._uid); + return *this; + } }; diff --git a/geometry/SubRoom.cpp b/geometry/SubRoom.cpp index 77c5ec3a967e62cdc0a1bf33d455db6fb64b9bd3..226b6153cda0389cd0b6f5f017db9ae619a18c02 100644 --- a/geometry/SubRoom.cpp +++ b/geometry/SubRoom.cpp @@ -1244,12 +1244,11 @@ bool Stair::ConvertLineToPoly(const vector<Line*>& goals) // Polygon aus allen Linen erzeugen for (int i = 0; i < (int) copy.size(); i++) { - nextLine = *copy[i]; nextPoint = NULL; - if ((aktPoint - nextLine.GetPoints().first).Norm() < J_TOLERANZ) { - nextPoint = nextLine.GetPoints().second; - } else if ((aktPoint - nextLine.GetPoints().second).Norm() < J_TOLERANZ) { - nextPoint = nextLine.GetPoints().first; + if ((aktPoint - copy[i]->GetPoints().first).Norm() < J_TOLERANZ) { + nextPoint = copy[i]->GetPoints().second; + } else if ((aktPoint - copy[i]->GetPoints().second).Norm() < J_TOLERANZ) { + nextPoint = copy[i]->GetPoints().first; } if (nextPoint != NULL) { Point rueck = CheckCorner(otherPoint, aktPoint, nextPoint);