Verified Commit 51e0986a authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

Distance heuristic function takes threshold into account now

Ref T10894
parent 5adb8eb6
......@@ -84,14 +84,15 @@ class AStarHeuristic : public boost::astar_heuristic<KisMagneticGraph, double> {
PredecessorMap m_pmap;
VertexDescriptor m_goal;
double coeff_a, coeff_b;
KisMagneticGraph m_graph;
public:
AStarHeuristic(VertexDescriptor goal, PredecessorMap pmap, double a, double b):
m_pmap(pmap), m_goal(goal), coeff_a(a), coeff_b(b)
AStarHeuristic(VertexDescriptor goal, PredecessorMap pmap, double a, double b, KisMagneticGraph g):
m_pmap(pmap), m_goal(goal), coeff_a(a), coeff_b(b), m_graph(g)
{ }
AStarHeuristic(VertexDescriptor goal, PredecessorMap pmap):
m_pmap(pmap), m_goal(goal), coeff_a(0.5), coeff_b(0.5)
AStarHeuristic(VertexDescriptor goal, PredecessorMap pmap, KisMagneticGraph g):
m_pmap(pmap), m_goal(goal), coeff_a(0.5), coeff_b(0.5), m_graph(g)
{ }
double operator()(VertexDescriptor v){
......@@ -101,7 +102,8 @@ class AStarHeuristic : public boost::astar_heuristic<KisMagneticGraph, double> {
double dz = EuclideanDistance(prev, m_goal);
di = di/dz;
double dm = EuclideanDistance(v, m_goal);
return coeff_a * di + coeff_b * (dm - dz);
double i = m_graph.getIntensity(QPoint(v.x,v.y));
return (coeff_a * di + coeff_b * (dm - dz)) * (i+1) ;
}
};
......@@ -187,7 +189,7 @@ QVector<QPointF> KisMagneticWorker::computeEdge(KisPaintDeviceSP dev, int radius
std::map<VertexDescriptor, boost::default_color_type> cmap;
std::map<VertexDescriptor, unsigned> imap;
WeightMap wmap;
AStarHeuristic heuristic(goal,pmap);
AStarHeuristic heuristic(goal, pmap, g);
QVector<QPointF> result;
try{
......
......@@ -44,8 +44,10 @@ void KisMagneticWorkerTest::testWorker()
const QRect rect = dev->exactBounds();
KisPaintDeviceSP grayscaleDev = KisPainter::convertToAlphaAsGray(dev);
KisMagneticWorker worker;
KIS_DUMP_DEVICE_2(grayscaleDev, rect, "main", "dd");
QVector<QPointF> result = worker.computeEdge(dev, 2, QPoint(10,10), QPoint(20,20));
KIS_DUMP_DEVICE_2(dev, rect, "main", "dd");
auto points = worker.computeEdge(grayscaleDev, 2, QPoint(30,10), QPoint(50,65));
KIS_DUMP_DEVICE_2(grayscaleDev, rect, "draw", "dd");
KisPainter p(grayscaleDev);
KIS_DUMP_DEVICE_2(grayscaleDev, rect, "draw", "dd");
}
......
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