Commit 2a3ae917 authored by Valentin Platzgummer's avatar Valentin Platzgummer

after QList -> QVector, circ survey 4 times faster

parent 19b98503
This diff is collapsed.
......@@ -88,38 +88,38 @@ QPointF Circle::origin() const
/*!
* \fn QList<QPointF> Circle::approximate(int numberOfCorners)
* \fn QVector<QPointF> Circle::approximate(int numberOfCorners)
* Returns a polygon with \a numberOfCorners corners which approximates the circle.
*
* \sa QPointF
*/
QList<QPointF> Circle::approximate(int numberOfCorners) const
QVector<QPointF> Circle::approximate(int numberOfCorners) const
{
if ( numberOfCorners < 3)
return QList<QPointF>();
return QVector<QPointF>();
return approximateSektor(numberOfCorners+1, 0, 2*M_PI);
}
QList<QPointF> Circle::approximate(double angleDiscretisation) const
QVector<QPointF> Circle::approximate(double angleDiscretisation) const
{
return approximateSektor(angleDiscretisation, 0, 2*M_PI);
}
QList<QPointF> Circle::approximateSektor(int numberOfCorners, double alpha1, double alpha2) const
QVector<QPointF> Circle::approximateSektor(int numberOfCorners, double alpha1, double alpha2) const
{
if ( numberOfCorners < 2) {
qWarning("numberOfCorners < 2");
return QList<QPointF>();
return QVector<QPointF>();
}
return approximateSektor(PlanimetryCalculus::truncateAngle(alpha2-alpha1)/double(numberOfCorners-1), alpha1, alpha2);
}
QList<QPointF> Circle::approximateSektor(double angleDiscretisation, double alpha1, double alpha2) const
QVector<QPointF> Circle::approximateSektor(double angleDiscretisation, double alpha1, double alpha2) const
{
using namespace PlanimetryCalculus;
// check if input is valid
if ( qFuzzyCompare(alpha1, alpha2) )
return QList<QPointF>();
return QVector<QPointF>();
alpha1 = truncateAngle(alpha1);
alpha2 = truncateAngle(alpha2);
......@@ -130,10 +130,10 @@ QList<QPointF> Circle::approximateSektor(double angleDiscretisation, double alph
// check if input is valid
if ( qFuzzyIsNull(angleDiscretisation))
return QList<QPointF>();
return QVector<QPointF>();
QList<QPointF> sector;
QVector<QPointF> sector;
double currentAngle = alpha1;
// how many nodes?
int j = floor(fabs(deltaAlpha/angleDiscretisation));
......
......@@ -27,10 +27,10 @@ public:
QPointF origin() const;
// Member methodes
QList<QPointF> approximate (int numberOfCorners) const;
QList<QPointF> approximate (double angleDiscretisation) const;
QList<QPointF> approximateSektor(int numberOfCorners, double alpha1, double alpha2) const;
QList<QPointF> approximateSektor(double angleDiscretisation, double alpha1, double alpha2) const;
QVector<QPointF> approximate (int numberOfCorners) const;
QVector<QPointF> approximate (double angleDiscretisation) const;
QVector<QPointF> approximateSektor(int numberOfCorners, double alpha1, double alpha2) const;
QVector<QPointF> approximateSektor(double angleDiscretisation, double alpha1, double alpha2) const;
void toCoordinate (QPointF &toCoordinate, double alpha) const;
QPointF toCoordinate (double alpha) const;
bool isNull() const;
......
......@@ -462,14 +462,14 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// generate transects
QList<QList<QPointF>> transectPath;
QVector<QVector<QPointF>> transectPath;
double r = r_min;
while (r < r_max) {
Circle circle(r, origin);
QList<QPointFList> intersectPoints;
QList<IntersectType> typeList;
QList<QPair<int, int>> neighbourList;
QVector<QPointFVector> intersectPoints;
QVector<IntersectType> typeList;
QVector<QPair<int, int>> neighbourList;
if (intersects(circle, surveyPolygon, intersectPoints, neighbourList, typeList)) {
// intersection Points between circle and polygon, entering polygon
......@@ -480,7 +480,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
QPointFList exitPoints;
// determine entryPoints and exit Points
for (int j = 0; j < intersectPoints.size(); j++) {
QList<QPointF> intersects = intersectPoints[j]; // one pt = tangent, two pt = sekant
QVector<QPointF> intersects = intersectPoints[j]; // one pt = tangent, two pt = sekant
QPointF p1 = surveyPolygon[neighbourList[j].first];
QPointF p2 = surveyPolygon[neighbourList[j].second];
......@@ -544,7 +544,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// qDebug() << "dAlpha" << dAlpha;
// qDebug() << "numNodes" << numNodes;
QList<QPointF> sectorPath = circle.approximateSektor(numNodes, alpha1, alpha2);
QVector<QPointF> sectorPath = circle.approximateSektor(numNodes, alpha1, alpha2);
// use shortestPath() here if necessary, could be a problem if dr >>
if (sectorPath.size() > 0)
transectPath.append(sectorPath);
......@@ -552,7 +552,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
} else if (originInside) {
// circle fully inside polygon
int numNodes = int(ceil(2*M_PI/dalpha)) + 1;
QList<QPointF> sectorPath = circle.approximateSektor(numNodes, 0, 2*M_PI);
QVector<QPointF> sectorPath = circle.approximateSektor(numNodes, 0, 2*M_PI);
// use shortestPath() here if necessary, could be a problem if dr >>
transectPath.append(sectorPath);
}
......@@ -579,10 +579,10 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// optimize path to snake or zig-zag pattern
bool isSnakePattern = _isSnakePath.rawValue().toBool();
QList<QPointF> currentSection = transectPath.takeFirst();
QVector<QPointF> currentSection = transectPath.takeFirst();
if ( currentSection.isEmpty() )
return;
QList<QList<QPointF>> optiPath; // optimized path
QVector<QPointF> optiPath; // optimized path
while( !transectPath.empty() ) {
optiPath.append(currentSection);
QPointF endVertex = currentSection.last();
......@@ -616,24 +616,21 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// convert to CoordInfo_t
for ( QList<QPointF> &transect : optiPath) {
// for ( const QList<QPointF> &transect : fullPath) {
if (_reverse.rawValue().toBool())
PolygonCalculus::reversePath(transect);
QList<QGeoCoordinate> geoPath = toGeo(transect, _referencePoint);
QList<CoordInfo_t> transectList;
for ( const QGeoCoordinate &coordinate : geoPath) {
CoordInfo_t coordinfo = {coordinate, CoordTypeInterior};
transectList.append(coordinfo);
}
_transects.append(transectList);
if (_reverse.rawValue().toBool())
PolygonCalculus::reversePath(optiPath);
QList<QGeoCoordinate> geoPath = toGeo(optiPath, _referencePoint);
QList<CoordInfo_t> transectList;
for ( const QGeoCoordinate &coordinate : geoPath) {
CoordInfo_t coordinfo = {coordinate, CoordTypeInterior};
transectList.append(coordinfo);
}
_transects.append(transectList);
qDebug() << "CircularSurveyComplexItem::_rebuildTransectsPhase1(): calls: " << _updateCounter;
auto delta = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
qDebug() << "CircularSurveyComplexItem::_rebuildTransectsPhase1(): time: " << delta;
qDebug() << sizeof(QPointF);
qDebug() << "CircularSurveyComplexItem::_rebuildTransectsPhase1(): time: " << delta << " ms";
//qDebug() << sizeof(QPointF);
}
......
......@@ -101,5 +101,14 @@ namespace GeoUtilities {
return coordinates;
}
QGeoList toGeo(const QPointFVector &points, const QGeoCoordinate &origin)
{
QGeoList coordinates;
for ( auto point : points)
coordinates.append(toGeo(point, origin));
return coordinates;
}
}
......@@ -11,9 +11,10 @@
namespace GeoUtilities {
typedef QList<QVector3D> QVector3DList;
typedef QList<QPointF> QPointFList;
typedef QList<QGeoCoordinate> QGeoList;
typedef QList<QVector3D> QVector3DList;
typedef QList<QPointF> QPointFList;
typedef QVector<QPointF> QPointFVector;
typedef QList<QGeoCoordinate> QGeoList;
const double earthRadius = 6378137; // meter
......@@ -21,6 +22,7 @@ namespace GeoUtilities {
QGeoList toGeo (const QVector3DList &points, const QGeoCoordinate &origin);
QGeoCoordinate toGeo (const QPointF &point, const QGeoCoordinate &origin);
QGeoList toGeo (const QPointFList &points, const QGeoCoordinate &origin);
QGeoList toGeo (const QPointFVector &points, const QGeoCoordinate &origin);
QVector3D toCartesian (const QGeoCoordinate &coordinate, const QGeoCoordinate &origin);
QVector3DList toCartesian (const QGeoList &coordinates, const QGeoCoordinate &origin);
QPointF toCartesian2D (const QGeoCoordinate &point, const QGeoCoordinate &origin);
......
......@@ -12,7 +12,7 @@ namespace PlanimetryCalculus {
\sa QPointF, Circle
*/
bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints, IntersectType &type, bool calcInstersect)
bool intersects(const Circle &circle, const QLineF &line, QPointFVector &intersectionPoints, IntersectType &type, bool calcInstersect)
{
if (!circle.isNull() && ! line.isNull()) {
QPointF translationVector = line.p1();
......@@ -87,7 +87,7 @@ namespace PlanimetryCalculus {
\sa Circle
*/
bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints, IntersectType type, bool calcIntersection)
bool intersects(const Circle &circle1, const Circle &circle2, QPointFVector &intersectionPoints, IntersectType type, bool calcIntersection)
{
if (!circle1.isNull() && !circle2.isNull()) {
double r1 = circle1.radius();
......@@ -180,7 +180,7 @@ namespace PlanimetryCalculus {
}
}
void rotateReference(QPointFList &points, double alpha)
void rotateReference(QPointFVector &points, double alpha)
{
for (int i = 0; i < points.size(); i++) {
rotateReference(points[i], alpha);
......@@ -196,7 +196,7 @@ namespace PlanimetryCalculus {
rotateReference(point, alpha/180*M_PI);
}
void rotateReferenceDegree(QPointFList &points, double alpha)
void rotateReferenceDegree(QPointFVector &points, double alpha)
{
for (int i = 0; i < points.size(); i++) {
rotateReferenceDegree(points[i], alpha);
......@@ -212,12 +212,12 @@ namespace PlanimetryCalculus {
*/
bool intersects(const Circle &circle, const QLineF &line)
{
QPointFList dummyList;
QPointFVector dummyList;
IntersectType type = NoIntersection;
return intersects(circle, line, dummyList, type, false /* calculate intersection points*/);
}
bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints)
bool intersects(const Circle &circle, const QLineF &line, QPointFVector &intersectionPoints)
{
IntersectType type = NoIntersection;
return intersects(circle, line, intersectionPoints, type, true /* calculate intersection points*/);
......@@ -396,15 +396,15 @@ angle
* \a neighbourList has entries of type \c {QPair<int, int>}, where \c{pair.first} would contain 1 and \c{pair.second} would contain 2, when
* relating to the above example.
*
* Returns the \c IntersectionType of each intersection point within a QList.
* Returns the \c IntersectionType of each intersection point within a QVector.
*
* \sa QPair, QList
* \sa QPair, QVector
*/
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, NeighbourList &neighbourList, IntersectList &typeList)
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, NeighbourVector &neighbourList, IntersectVector &typeList)
{
if (polygon.size() >= 2) {
IntersectList intersectionTypeList;
IntersectVector intersectionTypeList;
// Assemble a line form each tow consecutive polygon vertices and check whether it intersects with line
for (int i = 0; i < polygon.size(); i++) {
......@@ -442,12 +442,12 @@ angle
* \overload IntersectType intersects(const QPolygonF &polygon, const QLineF &line)
* Returns \c true if any intersection between \a polygon and \a line exists, \c false else.
*
* \sa QPair, QList
* \sa QPair, QVector
*/
bool intersects(const QPolygonF &polygon, const QLineF &line)
{
QPointFList dummyGeo;
QList<QPair<int, int>> dummyNeighbour;
QPointFVector dummyGeo;
QVector<QPair<int, int>> dummyNeighbour;
intersects(polygon, line, dummyGeo, dummyNeighbour);
if (dummyGeo.size() > 0)
......@@ -468,7 +468,7 @@ angle
return point;
}
QPointFList rotateReturn(QPointFList points, double alpha)
QPointFVector rotateReturn(QPointFVector points, double alpha)
{
rotateReference(points, alpha);
return points;
......@@ -488,22 +488,22 @@ angle
return intersects(line1, line2, intersectionPt, dummyType);
}
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, NeighbourList &neighbourList)
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, NeighbourVector &neighbourList)
{
IntersectList typeList;
IntersectVector typeList;
return intersects(polygon, line, intersectionList, neighbourList, typeList);
}
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, IntersectList &typeList)
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, IntersectVector &typeList)
{
NeighbourList neighbourList;
NeighbourVector neighbourList;
return intersects(polygon, line, intersectionList, neighbourList, typeList);
}
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList)
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList)
{
NeighbourList neighbourList;
IntersectList typeList;
NeighbourVector neighbourList;
IntersectVector typeList;
return intersects(polygon, line, intersectionList, neighbourList, typeList);
}
......@@ -518,23 +518,23 @@ angle
bool intersects(const Circle &circle1, const Circle &circle2)
{
IntersectType type = NoIntersection;
QPointFList intersectionPoints;
QPointFVector intersectionPoints;
return intersects(circle1, circle2, intersectionPoints, type, false /*calculate intersection points*/);
}
bool intersects(const Circle &circle1, const Circle &circle2, IntersectType &type)
{
QPointFList intersectionPoints;
QPointFVector intersectionPoints;
return intersects(circle1, circle2, intersectionPoints, type, false /*calculate intersection points*/);
}
bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints)
bool intersects(const Circle &circle1, const Circle &circle2, QPointFVector &intersectionPoints)
{
IntersectType type;
return intersects(circle1, circle2, intersectionPoints, type);
}
bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints, IntersectType &type)
bool intersects(const Circle &circle1, const Circle &circle2, QPointFVector &intersectionPoints, IntersectType &type)
{
return intersects(circle1, circle2, intersectionPoints, type, true /*calculate intersection points*/);
}
......@@ -623,7 +623,7 @@ angle
return truncateAngle(qAtan2(p1.y(), p1.x()));
}
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, NeighbourList &neighbourList, IntersectList &typeList)
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, NeighbourVector &neighbourList, IntersectVector &typeList)
{
using namespace PolygonCalculus;
for (int i = 0; i < polygon.size(); i++) {
......@@ -632,7 +632,7 @@ angle
QPointF p2 = polygon[j];
QLineF line(p1, p2);
QPointFList lineIntersecPts;
QPointFVector lineIntersecPts;
IntersectType type;
if (intersects(circle, line, lineIntersecPts, type)) {
QPair<int, int> neigbours;
......@@ -652,27 +652,27 @@ angle
}
}
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, NeighbourList &neighbourList)
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, NeighbourVector &neighbourList)
{
QList<IntersectType> types;
QVector<IntersectType> types;
return intersects(circle, polygon, intersectionPoints, neighbourList, types);
}
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, IntersectList &typeList)
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, IntersectVector &typeList)
{
NeighbourList neighbourList;
NeighbourVector neighbourList;
return intersects(circle, polygon, intersectionPoints, neighbourList, typeList);
}
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints)
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints)
{
NeighbourList neighbourList;
NeighbourVector neighbourList;
return intersects(circle, polygon, intersectionPoints, neighbourList);
}
bool intersects(const Circle &circle, const QPolygonF &polygon)
{
QList<QPointFList> intersectionPoints;
QVector<QPointFVector> intersectionPoints;
return intersects(circle, polygon, intersectionPoints);
}
......@@ -682,7 +682,7 @@ angle
return intersects(line1, line2, intersectionPoint);
}
bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints, IntersectType &type)
bool intersects(const Circle &circle, const QLineF &line, QPointFVector &intersectionPoints, IntersectType &type)
{
return intersects(circle, line, intersectionPoints, type, true /* calculate intersection points*/);
}
......
......@@ -26,43 +26,43 @@ namespace PlanimetryCalculus {
NoIntersection, Error // general
};
typedef QList<QPair<int, int>> NeighbourList;
typedef QList<QPointF> QPointFList;
typedef QList<IntersectType> IntersectList;
typedef QVector<QPair<int, int>> NeighbourVector;
typedef QVector<QPointF> QPointFVector;
typedef QVector<IntersectType> IntersectVector;
void rotateReference(QPointF &point, double alpha);
void rotateReference(QPointFList &points, double alpha);
void rotateReference(QPointFVector &points, double alpha);
void rotateReference(QLineF &line, double alpha);
//void rotateReference(QPolygonF &polygon, double alpha);
QPointF rotateReturn(QPointF point, double alpha);
QPointFList rotateReturn(QPointFList points, double alpha);
QPointFVector rotateReturn(QPointFVector points, double alpha);
QLineF rotateReturn(QLineF line, double alpha);
//QPolygonF rotateReturn(QPolygonF &polygon, double alpha);
bool intersects(const Circle &circle1, const Circle &circle2);
bool intersects(const Circle &circle1, const Circle &circle2, IntersectType &type);
bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints);
bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints, IntersectType &type);
bool intersects(const Circle &circle1, const Circle &circle2, QPointFVector &intersectionPoints);
bool intersects(const Circle &circle1, const Circle &circle2, QPointFVector &intersectionPoints, IntersectType &type);
bool intersects(const Circle &circle, const QLineF &line);
bool intersects(const Circle &circle, const QLineF &line, IntersectType &type);
bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints);
bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints, IntersectType &type);
bool intersects(const Circle &circle, const QLineF &line, QPointFVector &intersectionPoints);
bool intersects(const Circle &circle, const QLineF &line, QPointFVector &intersectionPoints, IntersectType &type);
bool intersects(const Circle &circle, const QPolygonF &polygon);
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints);
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, IntersectList &typeList);
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, NeighbourList &neighbourList);
bool intersects(const Circle &circle, const QPolygonF &polygon, QList<QPointFList> &intersectionPoints, NeighbourList &neighbourList, IntersectList &typeList);
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints);
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, IntersectVector &typeList);
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, NeighbourVector &neighbourList);
bool intersects(const Circle &circle, const QPolygonF &polygon, QVector<QPointFVector> &intersectionPoints, NeighbourVector &neighbourList, IntersectVector &typeList);
bool intersects(const QLineF &line1, const QLineF &line2);
bool intersects(const QLineF &line1, const QLineF &line2, QPointF &intersectionPt);
bool intersects(const QLineF &line1, const QLineF &line2, QPointF &intersectionPt, IntersectType &type);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, IntersectList &typeList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, NeighbourList &neighbourList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList, NeighbourList &neighbourList, IntersectList &typeList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, IntersectVector &typeList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, NeighbourVector &neighbourList);
bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFVector &intersectionList, NeighbourVector &neighbourList, IntersectVector &typeList);
bool contains(const QLineF &line, const QPointF &point);
bool contains(const QLineF &line, const QPointF &point, IntersectType &type);
......@@ -84,7 +84,7 @@ namespace PlanimetryCalculus {
* \fntemplate <typename T> int signum(T val)
* Returns the signum of a value \a val.
*
* \sa QPair, QList
* \sa QPair, QVector
*/
template <typename T> int signum(T val)
{
......
......@@ -32,11 +32,11 @@ namespace PolygonCalculus {
if ( !polygon.containsPoint(c1, Qt::FillRule::OddEvenFill)
|| !polygon.containsPoint(c2, Qt::FillRule::OddEvenFill))
return false;
QList<QPointF> intersectionList;
QVector<QPointF> intersectionList;
QLineF line;
line.setP1(c1);
line.setP2(c2);
PlanimetryCalculus::IntersectList intersectTypeList;
PlanimetryCalculus::IntersectVector intersectTypeList;
bool retValue = PlanimetryCalculus::intersects(polygon, line, intersectionList, intersectTypeList);
if (retValue) {
......@@ -191,8 +191,8 @@ namespace PolygonCalculus {
walkerPolySegment.setP1(currentVertex);
walkerPolySegment.setP2(protoNextVertex);
QList<QPair<int, int>> neighbourList;
QList<QPointF> intersectionList;
QVector<QPair<int, int>> neighbourList;
QVector<QPointF> intersectionList;
//qDebug("IntersectionList.size() on init: %i", intersectionList.size());
PlanimetryCalculus::intersects(*crossPoly, walkerPolySegment, intersectionList, neighbourList);
......@@ -538,10 +538,19 @@ namespace PolygonCalculus {
for ( auto element : path) {
pathReversed.prepend(element);
}
path.clear();
path.append(pathReversed);
path = pathReversed;
}
void reversePath(QPointFVector &path)
{
QPointFVector pathReversed;
for ( auto element : path) {
pathReversed.prepend(element);
}
path = pathReversed;
}
} // end PolygonCalculus namespace
......@@ -13,6 +13,7 @@ namespace PolygonCalculus {
typedef QList<QVector3D> QVector3DList;
typedef QList<QPointF> QPointFList;
typedef QVector<QPointF> QPointFVector;
int closestVertexIndex (const QPolygonF &polygon, const QPointF &coordinate);
QPointF closestVertex (const QPolygonF &polygon, const QPointF &coordinate);
......@@ -23,6 +24,7 @@ namespace PolygonCalculus {
bool hasClockwiseWinding (const QPolygonF &path);
void reversePath (QPolygonF &path);
void reversePath (QPointFList &path);
void reversePath (QPointFVector &path);
void offsetPolygon (QPolygonF &polygon, double offset);
bool containsPath (QPolygonF polygon, const QPointF &c1, const QPointF &c2);
void decomposeToConvex (const QPolygonF &polygon, QList<QPolygonF> &convexPolygons);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment