30 : _ply_pnts(ply._ply_pnts), _ply_pnt_ids(ply._ply_pnt_ids)
80 static_cast<std::vector<std::size_t>::difference_type
>(pos));
95 static_cast<std::vector<std::size_t>::difference_type
>(pos));
130 for (std::size_t i = 3; i < n_points; ++i)
135 "Point {:d} is not coplanar to the first three points of the "
188 const std::vector<Polyline*>& ply_vec,
double prox)
190 std::size_t nLines = ply_vec.size();
192 auto* new_ply =
new Polyline(*ply_vec[0]);
193 std::vector<GeoLib::Point*> pnt_vec(new_ply->getPointsVec());
195 std::vector<Polyline*> local_ply_vec;
196 for (std::size_t i = 1; i < nLines; i++)
198 local_ply_vec.push_back(ply_vec[i]);
201 while (!local_ply_vec.empty())
203 bool ply_found(
false);
205 for (
auto it = local_ply_vec.begin(); it != local_ply_vec.end(); ++it)
207 if (pnt_vec == (*it)->getPointsVec())
209 std::size_t nPoints((*it)->getNumberOfPoints());
213 (*it)->getPointID(0), prox))
215 auto* tmp =
new Polyline((*it)->getPointsVec());
216 for (std::size_t k = 0; k < nPoints; k++)
218 tmp->addPoint((*it)->getPointID(nPoints - k - 1));
221 std::size_t new_ply_size(new_ply->getNumberOfPoints());
222 for (std::size_t k = 1; k < new_ply_size; k++)
224 tmp->addPoint(new_ply->getPointID(k));
233 (*it)->getPointID(nPoints - 1),
237 std::size_t new_ply_size(new_ply->getNumberOfPoints());
238 for (std::size_t k = 1; k < new_ply_size; k++)
240 tmp->addPoint(new_ply->getPointID(k));
250 new_ply->getPointID(new_ply->getNumberOfPoints() -
252 (*it)->getPointID(0), prox))
254 for (std::size_t k = 1; k < nPoints; k++)
256 new_ply->addPoint((*it)->getPointID(k));
264 new_ply->getPointID(new_ply->getNumberOfPoints() -
266 (*it)->getPointID(nPoints - 1), prox))
268 for (std::size_t k = 1; k < nPoints; k++)
270 new_ply->addPoint((*it)->getPointID(nPoints - k - 1));
276 local_ply_vec.erase(it);
282 ERR(
"Error in Polyline::contructPolylineFromSegments() - Line "
283 "segments use different point vectors.");
289 ERR(
"Error in Polyline::contructPolylineFromSegments() - Not all "
290 "segments are connected.");
303 ERR(
"Polyline::closePolyline(): Input polyline needs to be composed of "
304 "at least three points.");
319 long double a[2] = {dest[0] - source[0], dest[1] - source[1]};
320 long double b[2] = {pnt[0] - source[0], pnt[1] - source[1]};
322 long double det_2x2(a[0] * b[1] - a[1] * b[0]);
324 if (det_2x2 > std::numeric_limits<double>::epsilon())
328 if (std::numeric_limits<double>::epsilon() < std::abs(det_2x2))
332 if (a[0] * b[0] < 0.0 || a[1] * b[1] < 0.0)
336 if (a[0] * a[0] + a[1] * a[1] < b[0] * b[0] + b[1] * b[1])
341 pow(std::numeric_limits<double>::epsilon(), 2))
346 std::sqrt(std::numeric_limits<double>::epsilon()))
354 const double epsilon_radius)
const
359 double act_length_of_ply = 0.0;
364 Eigen::Map<Eigen::Vector3d const>(
getPoint(k)->getCoords());
366 Eigen::Map<Eigen::Vector3d const>(
getPoint(k + 1)->getCoords());
367 double const seg_length((b - a).
norm());
368 act_length_of_ply += seg_length;
375 dist) <= epsilon_radius)
377 double const lower_lambda(-epsilon_radius / seg_length);
378 double const upper_lambda(1 + epsilon_radius / seg_length);
380 if (lower_lambda <= lambda && lambda <= upper_lambda)
383 dist = act_length_of_ply + dist;
397 std::size_t segment_number)
398 : _polyline(&polyline),
400 static_cast<std::vector<
GeoLib::
Point*>::size_type>(segment_number))
405 : _polyline(src._polyline), _segment_number(src._segment_number)
424 return static_cast<std::size_t
>(_segment_number);
435 return _polyline->getSegment(_segment_number);
440 return _polyline->getSegment(_segment_number);
445 return !(*
this != other);
455 std::vector<GeoLib::Point>::difference_type n)
460 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
465 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
467 if (_segment_number > _polyline->getNumberOfSegments())
475 std::vector<GeoLib::Point>::difference_type n)
483 std::vector<GeoLib::Point>::difference_type n)
488 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
493 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
495 if (_segment_number > _polyline->getNumberOfSegments())
503 std::vector<GeoLib::Point>::difference_type n)
514 ERR(
"no valid edge id0 == id1 == {:d}.", id0);
522 for (std::size_t k(0); k < n; k++)
526 if (ply_pnt0 > ply_pnt1)
528 std::swap(ply_pnt0, ply_pnt1);
530 if (ply_pnt0 == id0 && ply_pnt1 == id1)
546 for (std::size_t k(0); k < n; k++)
Definition of analytical geometry functions.
void ERR(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
Definition of the PolyLine class.
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 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)
virtual bool addPoint(std::size_t pnt_id)
const std::vector< Point * > & _ply_pnts
Location getLocationOfPoint(std::size_t k, MathLib::Point3d const &pnt) const
LineSegment getSegment(std::size_t i) const
Polyline(const std::vector< Point * > &pnt_vec)
bool isPointIDInPolyline(std::size_t pnt_id) const
virtual void removePoint(std::size_t pos)
std::vector< Point * > const & getPointsVec() 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)
bool operator==(LineSegment const &s0, LineSegment const &s1)
double norm(MatrixOrVector const &x, MathLib::VecNormType type)
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)