Commit da286265 authored by Valentin Platzgummer's avatar Valentin Platzgummer

CircularSurvey::rebuildTransectsPhase1 split in slow and fast version

parent 46eb801f
......@@ -357,12 +357,10 @@ void TransectStyleComplexItem::_rebuildTransects(void)
return;
}
//CALLGRIND_TOGGLE_COLLECT;
//auto startTime = std::chrono::high_resolution_clock::now();
auto startTime = std::chrono::high_resolution_clock::now();
_rebuildTransectsPhase1();
//auto delta = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
//qWarning() << "TransectStyleComplexItem::_rebuildTransects(): time: " << delta << " us";
//CALLGRIND_TOGGLE_COLLECT;
auto delta = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
qWarning() << "TransectStyleComplexItem::_rebuildTransects(): time: " << delta << " us";
if (_followTerrain) {
// Query the terrain data. Once available terrain heights will be calculated
......
......@@ -44,6 +44,7 @@
"shortDescription": "The maximum number of waypoints the circular survey can containt. To many waypoints cause a performance hit.",
"type": "uint32",
"defaultValue": 2000,
"min": 1
"min": 1,
"max": 20000
}
]
This diff is collapsed.
......@@ -28,7 +28,6 @@ public:
Q_PROPERTY(bool isInitialized READ isInitialized WRITE setIsInitialized NOTIFY isInitializedChanged)
Q_INVOKABLE void resetReference(void);
Q_INVOKABLE void setReferencePointBeingChanged(bool changeing); // used by gui to indicate a changeing reference point (dagging by user)
// Property setters
void setRefPoint(const QGeoCoordinate &refPt);
......@@ -90,9 +89,11 @@ signals:
private slots:
// Overrides from TransectStyleComplexItem
void _rebuildTransectsPhase1 (void) final; // do not call this function, it is called by TransectStyleComplexItem::_rebuildTransects()
void _rebuildTransectsSlow (void); // the slow version of _rebuildTransectsPhase1 which properly connects the _transects
void _recalcComplexDistance (void) final;
void _recalcCameraShots (void) final;
void _reverseTransects (void);
bool _shortestPath (const QGeoCoordinate &start, const QGeoCoordinate &destination, QVector<QGeoCoordinate> shortestPath);
signals:
......@@ -121,8 +122,7 @@ private:
bool _referencePointBeingChanged; // is set to true by gui, if user is changeing the reference point
int _updateCounter;
int _transectsDiry;
};
......
#include "OptimisationTools.h"
#include <QPointF>
namespace OptimisationTools {
namespace {
}
bool dijkstraAlgorithm(const int numNodes,const int startIndex,const int endIndex, QVector<int> &elementPath, std::function<double(const int, const int)> distance)
{
if ( numNodes < 0
|| startIndex < 0
|| endIndex < 0
|| endIndex >= numNodes
|| startIndex >= numNodes
|| endIndex == startIndex) {
return false;
}
// distanceToStart[i] contains the distance of element[i] to element[startIndex] (after successful algorithm termination)
QVector<double> distanceToStart(numNodes, std::numeric_limits<qreal>::infinity());
// elementPredecessor[i] contains the predecessor of element[i]
QVector<int> elementPredecessor(numNodes, -1);
// Elements will be successively removed from this list during the execution of the Dijkstra Algorithm.
QVector<int> workingSet;
workingSet.reserve(numNodes);
//fill workingSet with 0, 1, ..., numNodes-1
for (int i = 0; i < numNodes; i++) workingSet.append(i);
distanceToStart[startIndex] = 0;
// Dijkstra Algorithm
// https://de.wikipedia.org/wiki/Dijkstra-Algorithmus
while (workingSet.size() > 0) {
// serach Node with minimal distance
double minDist = std::numeric_limits<qreal>::infinity();
int minIndex = -1; // index of element with least distance to element[startIndex]
for (int i = 0; i < workingSet.size(); i++) {
int e = workingSet[i];
double dist = distanceToStart[e];
if (dist < minDist) {
minDist = dist;
minIndex = i;
}
}
if (minIndex == -1)
return false;
int u = workingSet.takeAt(minIndex);
if (u == endIndex) // shortest path found
break;
//update distance
double distanceU = distanceToStart[u];
for (int i = 0; i < workingSet.size(); i++) {
int v = workingSet[i];
double dist = distance(u, v);
// is ther a alternative path which is shorter?
double alternative = distanceU + dist;
if (alternative < distanceToStart[v]) {
distanceToStart[v] = alternative;
elementPredecessor[v] = u;
}
}
}
// end Djikstra Algorithm
// reverse assemble elementPath
int e = endIndex;
while (1) {
if (e == -1) {
if (elementPath[0] == startIndex)// check if starting point was reached
break;
return false;
}
elementPath.prepend(e);
//Update Node
e = elementPredecessor[e];
}
return true;
}
// end anonymous namespace
} // end OptimisationTools namespace
......@@ -103,7 +103,7 @@ Item {
_destroyVisualElements()
}
QGCMapPolygonVisuals {
WimaMapPolygonVisuals {
id: mapPolygonVisuals
qgcView: _root.qgcView
mapControl: map
......@@ -179,7 +179,6 @@ Item {
property var refPoint: _missionItem.refPoint
onCoordinateChanged: _missionItem.refPoint = coordinate
onRefPointChanged: {
if (refPoint !== coordinate) {
coordinate = refPoint
......@@ -188,17 +187,10 @@ Item {
onClicked: {
_root.clicked(_missionItem.sequenceNumber)
_missionItem.setReferencePointBeingChanged(true)
}
onDragClicked: {// replace with entered
_missionItem.setReferencePointBeingChanged(true)
console.log('onDragClicked')
}
onDragReleased: { // replace with exited
_missionItem.setReferencePointBeingChanged(false)
console.log('onDragReleased')
onDragReleased: {
_missionItem.refPoint = coordinate
}
}
}
......
......@@ -20,7 +20,7 @@ import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl.ShapeFileHelper 1.0
/// QGCMapPolygon map visuals
/// WimaMapPolygon map visuals
Item {
id: _root
......
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