Skip to content
Snippets Groups Projects
Commit 3dc8a350 authored by Tom Fischer's avatar Tom Fischer
Browse files

[GeoLib] Impl. of computeAndInsertAllIntersectionPoints().

Conflicts:
	GeoLib/AnalyticalGeometry.cpp
parent 82e78473
No related branches found
No related tags found
No related merge requests found
......@@ -155,7 +155,7 @@ bool lineSegmentIntersect(
return false;
}
bool lineSegmentsIntersect(const GeoLib::Polyline* ply,
bool lineSegmentsIntersect(const GeoLib::Polyline* ply,
size_t &idx0,
size_t &idx1,
GeoLib::Point& intersection_pnt)
......@@ -435,4 +435,26 @@ bool isCoplanar(const GeoLib::Point& a, const GeoLib::Point& b, const GeoLib::Po
return (sqr_scalar_triple/normalisation_factor < 1e-11);
}
void computeAndInsertAllIntersectionPoints(GeoLib::PointVec &pnt_vec,
std::vector<GeoLib::Polyline*> & plys)
{
for (auto it0(plys.begin()); it0 != plys.end(); it0++) {
auto it1(it0);
it1++;
for (; it1 != plys.end(); it1++) {
GeoLib::Point s;
for (std::size_t i(0); i<(*it0)->getNumberOfPoints()-1; i++) {
for (std::size_t j(0); j<(*it1)->getNumberOfPoints()-1; j++) {
if (lineSegmentIntersect(*(*it0)->getPoint(i), *(*it0)->getPoint(i+1),
*(*it1)->getPoint(j), *(*it1)->getPoint(j+1), s)) {
std::size_t const id(pnt_vec.push_back(new GeoLib::Point(s)));
(*it0)->insertPoint(i+1, id);
(*it1)->insertPoint(j+1, id);
}
}
}
}
}
}
} // end namespace GeoLib
......@@ -17,6 +17,7 @@
// GeoLib
#include "Triangle.h"
#include "PointVec.h"
// MathLib
#include "LinAlg/Dense/DenseMatrix.h"
......@@ -166,6 +167,16 @@ double scalarTriple(MathLib::Vector3 const& u, MathLib::Vector3 const& v, MathLi
const GeoLib::Point& c, const GeoLib::Point& d);
/**
* Method first compute the intersection points of line segements of GeoLib::Polyline objects
* (@see computeIntersectionPoints()) and pushs each intersection point in the GeoLib::PointVec
* pnt_vec. For each intersection an id is returned. This id is used to split the two
* intersecting straight line segments in four straight line segments.
*/
void computeAndInsertAllIntersectionPoints(
GeoLib::PointVec &pnt_vec,
std::vector<GeoLib::Polyline*> & plys);
} // end namespace GeoLib
#endif /* ANALYTICAL_GEOMETRY_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment