79 static_cast<std::vector<std::size_t>::difference_type
>(pos));
94 static_cast<std::vector<std::size_t>::difference_type
>(pos));
129 for (std::size_t i = 3; i < n_points; ++i)
134 "Point {:d} is not coplanar to the first three points of the "
180 const std::vector<Polyline*>& ply_vec,
double prox)
182 std::size_t nLines = ply_vec.size();
184 auto* new_ply =
new Polyline(*ply_vec[0]);
185 std::vector<GeoLib::Point*> pnt_vec(new_ply->getPointsVec());
187 std::vector<Polyline*> local_ply_vec;
188 for (std::size_t i = 1; i < nLines; i++)
190 local_ply_vec.push_back(ply_vec[i]);
193 while (!local_ply_vec.empty())
195 bool ply_found(
false);
197 for (
auto it = local_ply_vec.begin(); it != local_ply_vec.end(); ++it)
199 if (pnt_vec == (*it)->getPointsVec())
201 std::size_t nPoints((*it)->getNumberOfPoints());
205 (*it)->getPointID(0), prox))
207 auto* tmp =
new Polyline((*it)->getPointsVec());
208 for (std::size_t k = 0; k < nPoints; k++)
210 tmp->addPoint((*it)->getPointID(nPoints - k - 1));
213 std::size_t new_ply_size(new_ply->getNumberOfPoints());
214 for (std::size_t k = 1; k < new_ply_size; k++)
216 tmp->addPoint(new_ply->getPointID(k));
225 (*it)->getPointID(nPoints - 1),
229 std::size_t new_ply_size(new_ply->getNumberOfPoints());
230 for (std::size_t k = 1; k < new_ply_size; k++)
232 tmp->addPoint(new_ply->getPointID(k));
242 new_ply->getPointID(new_ply->getNumberOfPoints() -
244 (*it)->getPointID(0), prox))
246 for (std::size_t k = 1; k < nPoints; k++)
248 new_ply->addPoint((*it)->getPointID(k));
256 new_ply->getPointID(new_ply->getNumberOfPoints() -
258 (*it)->getPointID(nPoints - 1), prox))
260 for (std::size_t k = 1; k < nPoints; k++)
262 new_ply->addPoint((*it)->getPointID(nPoints - k - 1));
268 local_ply_vec.erase(it);
274 ERR(
"Error in Polyline::contructPolylineFromSegments() - Line "
275 "segments use different point vectors.");
281 ERR(
"Error in Polyline::contructPolylineFromSegments() - Not all "
282 "segments are connected.");
295 ERR(
"Polyline::closePolyline(): Input polyline needs to be composed of "
296 "at least three points.");
305 const double epsilon_radius)
const
310 double act_length_of_ply = 0.0;
316 double const seg_length((b - a).norm());
317 act_length_of_ply += seg_length;
324 dist) <= epsilon_radius)
326 double const lower_lambda(-epsilon_radius / seg_length);
327 double const upper_lambda(1 + epsilon_radius / seg_length);
329 if (lower_lambda <= lambda && lambda <= upper_lambda)
332 dist = act_length_of_ply + dist;
351 std::size_t segment_number)
354 static_cast<std::vector<
GeoLib::
Point*>::size_type>(segment_number))
399 return !(*
this != other);
409 std::vector<GeoLib::Point>::difference_type n)
414 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
419 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
429 std::vector<GeoLib::Point>::difference_type n)
437 std::vector<GeoLib::Point>::difference_type n)
442 static_cast<std::vector<GeoLib::Point>::size_type
>(n);
447 static_cast<std::vector<GeoLib::Point>::size_type
>(-n);
457 std::vector<GeoLib::Point>::difference_type n)
469 "internal error in resetPointIDs(): polyline based on point vector "
470 "of size {}, given mapping has size {}",
481 if (polyline.
getPointsVec().size() != used_points.size())
484 "internal error in markUsedPoints(): polyline based on point "
485 "vector of size {}, given used_points has size {}",
498 ERR(
"no valid edge id0 == id1 == {:d}.", id0);
506 for (std::size_t k(0); k < n; k++)
510 if (ply_pnt0 > ply_pnt1)
512 std::swap(ply_pnt0, ply_pnt1);
514 if (ply_pnt0 == id0 && ply_pnt1 == id1)
530 for (std::size_t k(0); k < n; k++)
554 std::vector<std::size_t>&& point_ids)
556 auto const& point_id_map = points_vec.
getIDMap();
557 auto polyline = std::make_unique<Polyline>(points_vec.
getVector());
558 for (
auto point_id : point_ids)
560 if (point_id >= point_id_map.size())
562 WARN(
"The point id {} doesn't exist in the underlying PointVec.",
566 polyline->addPoint(point_id_map[point_id]);
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)
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(Polyline const &polyline, std::size_t segment_number)
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)