31 : _ply_pnts(ply._ply_pnts), _ply_pnt_ids(ply._ply_pnt_ids)
90 static_cast<std::vector<std::size_t>::difference_type
>(pos));
105 static_cast<std::vector<std::size_t>::difference_type
>(pos));
140 for (std::size_t i = 3; i < n_points; ++i)
145 "Point {:d} is not coplanar to the first three points of the "
191 const std::vector<Polyline*>& ply_vec,
double prox)
193 std::size_t nLines = ply_vec.size();
195 auto* new_ply =
new Polyline(*ply_vec[0]);
196 std::vector<GeoLib::Point*> pnt_vec(new_ply->getPointsVec());
198 std::vector<Polyline*> local_ply_vec;
199 for (std::size_t i = 1; i < nLines; i++)
201 local_ply_vec.push_back(ply_vec[i]);
204 while (!local_ply_vec.empty())
206 bool ply_found(
false);
208 for (
auto it = local_ply_vec.begin(); it != local_ply_vec.end(); ++it)
210 if (pnt_vec == (*it)->getPointsVec())
212 std::size_t nPoints((*it)->getNumberOfPoints());
216 (*it)->getPointID(0), prox))
218 auto* tmp =
new Polyline((*it)->getPointsVec());
219 for (std::size_t k = 0; k < nPoints; k++)
221 tmp->addPoint((*it)->getPointID(nPoints - k - 1));
224 std::size_t new_ply_size(new_ply->getNumberOfPoints());
225 for (std::size_t k = 1; k < new_ply_size; k++)
227 tmp->addPoint(new_ply->getPointID(k));
236 (*it)->getPointID(nPoints - 1),
240 std::size_t new_ply_size(new_ply->getNumberOfPoints());
241 for (std::size_t k = 1; k < new_ply_size; k++)
243 tmp->addPoint(new_ply->getPointID(k));
253 new_ply->getPointID(new_ply->getNumberOfPoints() -
255 (*it)->getPointID(0), prox))
257 for (std::size_t k = 1; k < nPoints; k++)
259 new_ply->addPoint((*it)->getPointID(k));
267 new_ply->getPointID(new_ply->getNumberOfPoints() -
269 (*it)->getPointID(nPoints - 1), prox))
271 for (std::size_t k = 1; k < nPoints; k++)
273 new_ply->addPoint((*it)->getPointID(nPoints - k - 1));
279 local_ply_vec.erase(it);
285 ERR(
"Error in Polyline::contructPolylineFromSegments() - Line "
286 "segments use different point vectors.");
292 ERR(
"Error in Polyline::contructPolylineFromSegments() - Not all "
293 "segments are connected.");
306 ERR(
"Polyline::closePolyline(): Input polyline needs to be composed of "
307 "at least three points.");
316 const double epsilon_radius)
const
321 double act_length_of_ply = 0.0;
327 double const seg_length((b - a).norm());
328 act_length_of_ply += seg_length;
335 dist) <= epsilon_radius)
337 double const lower_lambda(-epsilon_radius / seg_length);
338 double const upper_lambda(1 + epsilon_radius / seg_length);
340 if (lower_lambda <= lambda && lambda <= upper_lambda)
343 dist = act_length_of_ply + dist;
362 std::size_t segment_number)
363 : _polyline(&polyline),
365 static_cast<std::vector<
GeoLib::
Point*>::size_type>(segment_number))
370 : _polyline(src._polyline), _segment_number(src._segment_number)
389 return static_cast<std::size_t
>(_segment_number);
400 return _polyline->getSegment(_segment_number);
405 return _polyline->getSegment(_segment_number);
410 return !(*
this != other);
420 std::vector<GeoLib::Point>::difference_type n)
425 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
430 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
432 if (_segment_number > _polyline->getNumberOfSegments())
440 std::vector<GeoLib::Point>::difference_type n)
448 std::vector<GeoLib::Point>::difference_type n)
453 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
458 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
460 if (_segment_number > _polyline->getNumberOfSegments())
468 std::vector<GeoLib::Point>::difference_type n)
480 "internal error in resetPointIDs(): polyline based on point vector "
481 "of size {}, given mapping has size {}",
492 if (polyline.
getPointsVec().size() != used_points.size())
495 "internal error in markUsedPoints(): polyline based on point "
496 "vector of size {}, given used_points has size {}",
509 ERR(
"no valid edge id0 == id1 == {:d}.", id0);
517 for (std::size_t k(0); k < n; k++)
521 if (ply_pnt0 > ply_pnt1)
523 std::swap(ply_pnt0, ply_pnt1);
525 if (ply_pnt0 == id0 && ply_pnt1 == id1)
541 for (std::size_t k(0); k < n; k++)
565 std::vector<std::size_t>&& point_ids)
567 auto const& point_id_map = points_vec.
getIDMap();
568 auto polyline = std::make_unique<Polyline>(points_vec.
getVector());
569 for (
auto point_id : point_ids)
571 if (point_id >= point_id_map.size())
573 WARN(
"The point id {} doesn't exist in the underlying PointVec.",
577 polyline->addPoint(point_id_map[point_id]);
Definition of analytical geometry functions.
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the PointVec class.
Definition of the PolyLine class.
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
const std::vector< std::size_t > & getIDMap() const
GeoLib::Polyline const * _polyline
SegmentIterator & operator++()
SegmentIterator operator-(std::vector< GeoLib::Point >::difference_type n)
SegmentIterator & operator+=(std::vector< GeoLib::Point >::difference_type n)
LineSegment operator*() const
SegmentIterator & operator=(SegmentIterator const &rhs)
bool operator==(SegmentIterator const &other) const
SegmentIterator operator+(std::vector< GeoLib::Point >::difference_type n)
std::vector< GeoLib::Point * >::size_type _segment_number
std::size_t getSegmentNumber() const
bool operator!=(SegmentIterator const &other) const
SegmentIterator & operator-=(std::vector< GeoLib::Point >::difference_type n)
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
double getDistanceAlongPolyline(const MathLib::Point3d &pnt, const double epsilon_radius) const
std::size_t getPointID(std::size_t const i) const
std::size_t getNumberOfSegments() const
static Polyline * constructPolylineFromSegments(const std::vector< Polyline * > &ply_vec, double prox=0.0)
std::size_t getNumberOfPoints() const
const Point * getPoint(std::size_t i) const
returns the i-th point contained in the polyline
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
std::vector< std::size_t > _ply_pnt_ids
void setPointID(std::size_t idx, std::size_t id)
void reverseOrientation()
virtual bool addPoint(std::size_t pnt_id)
const std::vector< Point * > & _ply_pnts
LineSegment getSegment(std::size_t i) const
Polyline(const std::vector< Point * > &pnt_vec)
bool isPointIDInPolyline(std::size_t pnt_id) const
void removePoint(std::size_t pos)
std::vector< Point * > const & getPointsVec() const
std::vector< T * > const & getVector() const
Eigen::Vector3d const & asEigenVector3d() const
bool containsEdge(const Polyline &ply, std::size_t id0, std::size_t id1)
bool pointsAreIdentical(const std::vector< Point * > &pnt_vec, std::size_t i, std::size_t j, double prox)
void markUsedPoints(Polyline const &polyline, std::vector< bool > &used_points)
Resets the point IDs of the polyline corresponding to the mapping.
void resetPointIDs(Polyline &polyline, std::vector< std::size_t > const &mapping)
Resets the point IDs of the polyline corresponding to the mapping.
bool operator==(LineSegment const &s0, LineSegment const &s1)
std::unique_ptr< Polyline > createPolyline(GeoLib::PointVec const &points_vec, std::vector< std::size_t > &&point_ids)
Create a polyline from given point ids.
bool isCoplanar(const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
Checks if the four given points are located on a plane.
double calcProjPntToLineAndDists(Point3d const &pp, Point3d const &pa, Point3d const &pb, double &lambda, double &d0)
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)