21 #include <boost/graph/adjacency_list.hpp>
22 #include <boost/graph/properties.hpp>
23 #include <boost/graph/graph_traits.hpp>
24 #include <boost/function.hpp>
25 #include <tbb/spin_rw_mutex.h>
29 namespace MAKVRinTerra
35 : location(0.0, 0.0, 0.0)
54 : feature(p.getPathPtr())
72 : x(xIndex), y(yIndex) { }
78 else if (x == rhs.
x && y < rhs.
y)
95 typedef boost::property<boost::edge_weight_t, double>
Weight;
97 typedef boost::adjacency_list<
109 typedef std::list<boost::graph_traits<DtBoostGraph>::vertex_descriptor>
VertexList;
117 PathVertex() : localLocation(0.0, 0.0, 0.0), nextEdgeFeature() { }
119 : localLocation(l), nextEdgeFeature(f) { }
124 typedef std::list<PathVertex>
Path;
135 : myTolerance(tolerance) { }
137 bool operator()(
const DtPoint& lhs,
const DtPoint& rhs)
const
139 if (
DtALMOST(lhs.x(), rhs.x(), myTolerance))
141 if (
DtALMOST(lhs.y(), rhs.y(), myTolerance))
143 if (
DtALMOST(lhs.z(), rhs.z(), myTolerance) || lhs.z() > rhs.z())
149 return lhs.y() < rhs.y();
151 return lhs.x() < rhs.x();
165 , myBestPointOnNetwork()
166 , myBestEdgeDistance(std::numeric_limits<double>::infinity())
194 std::auto_ptr<DtFeatureSet> s,
196 boost::shared_ptr<DtTerrainInterfaceConfig> config,
197 std::string label = std::string());
200 void addFeatureToGraph(
const DtFeature & r);
205 DtPoint locationForVertex(
const vertex_descriptor& vertex);
207 vertex_descriptor vertexForLocation(
const DtPoint& localLocation);
217 Path makePath(
const DtPoint& startLocation,
const DtPoint& endLocation,
218 const double& maxSearchRadius,
const double& startProximityThreshold,
219 DtWeightFactorsListPtr weightFactors, boost::function<
bool ()> cancelCheck,
224 bool onPathFeature(
const DtPoint& location,
double offset = 0.5);
229 DtGridKey MakeGridKey(
const DtPoint& localLocation);
234 tbb::spin_rw_mutex::scoped_lock&,
235 boost::function<
bool ()> cancelCheck = boost::function<
bool ()>());
237 DtBoostGraph* graph();
239 std::auto_ptr<DtPathFeatureSet> paths()
const
241 return std::auto_ptr<DtPathFeatureSet>(myInputPathFeatureSet->clone());
259 const double& searchRadius,
bool* dataAvailable = NULL);
263 int numFeatures()
const;
265 void setDrawing(
bool);
271 Path makePath(
const vertex_descriptor& source,
const vertex_descriptor& destination,
272 double maxSearchRadius, DtWeightFactorsListPtr weightFactors,
273 tbb::spin_rw_mutex::scoped_lock& lock, boost::function<
bool ()> cancelCheck,
274 AstarSearchResults& astarResults, ReturnCode& pathFindResult);
279 DtPoint closestPointOnNetwork(
const DtPoint& startingLocation,
280 const double& searchRadius, vertex_descriptor& edgeA, vertex_descriptor& edgeB,
294 bool determineStartAndEndVertices(
const DtPoint& startLocation,
const DtPoint& endLocation,
295 vertex_descriptor& startEdgeVertexToUse, vertex_descriptor& startEdgeOtherVertex,
296 vertex_descriptor& endEdgeVertexToUse, vertex_descriptor& endEdgeOtherVertex,
297 DtPoint& startEdgeClosestPoint, DtPoint& endEdgeClosestPoint,
333 std::auto_ptr<DtSharedMemoryFeaturesDebugDrawer>
myDrawer;
348 const DtPoint& localStart,
const DtPoint& localDestination,
349 const double& maxSearchRadius,
const double& startProximityThreshold,
352 , myPathFinder(pathFinder)
353 , myLocalStart(localStart)
354 , myLocalDestination(localDestination)
355 , myMaxSearchRadius(maxSearchRadius)
356 , myStartProximityThreshold(startProximityThreshold)
357 , myWeightFactors(factors)
367 DtVerbose <<
"Job canceled before path plan." << std::endl;
372 boost::shared_ptr<DtAsyncJobMapEntry> entry = getEntry();
376 if (entry->status() ==
queued)
382 DtWarn <<
"Job " << entry->id() <<
" in invalid state " << entry->status() << std::endl;
389 myLocalStart, myLocalDestination, myMaxSearchRadius,
390 myStartProximityThreshold, myWeightFactors, boost::ref(cancelCheck),
391 myPathFindReturnCode);
393 boost::shared_ptr<DtAsyncJobMapEntry> entry = getEntry();
398 result->returnCode = myPathFindReturnCode;
401 entry->setResult(
complete, result.release());
407 boost::shared_ptr<DtAsyncJobMapEntry> entry = getEntry();
412 result->returnCode = myPathFindReturnCode;
414 entry->setResult(
complete, result.release());