Skip to content

Commit 0c4fcd2

Browse files
committed
Add points to shortest path list in the right order.
1 parent af9238a commit 0c4fcd2

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/main/java/sc/fiji/analyzeSkeleton/AnalyzeSkeleton_.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ private void reconstructPath(
33063306
// remember a and b are indices and not the actual vertices.
33073307

33083308
int b = endIndex;
3309-
int a = startIndex;
3309+
final int a = startIndex;
33103310

33113311
while (b != a)
33123312
{
@@ -3339,16 +3339,10 @@ private void reconstructPath(
33393339
}
33403340

33413341
}
3342-
3343-
// add slab points of the shortest edge to the list of points
3344-
for (Point p : shortestedge.getSlabs())
3345-
{
3346-
shortestPathPoints.add(p);
3347-
setPixel(this.shortPathImage, p.x, p.y, p.z, SHORTEST_PATH);
3348-
}
3349-
3350-
// add vertex points too
3351-
for (Point p : shortestedge.getV1().getPoints())
3342+
// add vertex 1 points
3343+
Vertex v1 = shortestedge.getV2() != predecessor ?
3344+
shortestedge.getV2() : shortestedge.getV1();
3345+
for (Point p : v1.getPoints())
33523346
{
33533347
if( ! shortestPathPoints.contains( p ))
33543348
{
@@ -3357,7 +3351,21 @@ private void reconstructPath(
33573351
}
33583352
}
33593353

3360-
for (Point p : shortestedge.getV2().getPoints())
3354+
// add slab points of the shortest edge to the list of points
3355+
ArrayList<Point> slabs = shortestedge.getSlabs();
3356+
// reverse order if needed
3357+
if( shortestedge.getV2() != predecessor )
3358+
Collections.reverse( slabs );
3359+
for (Point p : slabs)
3360+
{
3361+
shortestPathPoints.add(p);
3362+
setPixel(this.shortPathImage, p.x, p.y, p.z, SHORTEST_PATH);
3363+
}
3364+
3365+
// add vertex 2 points too
3366+
Vertex v2 = shortestedge.getV2() != predecessor ?
3367+
shortestedge.getV1() : shortestedge.getV2();
3368+
for (Point p : v2.getPoints())
33613369
{
33623370
if( ! shortestPathPoints.contains( p ))
33633371
{

0 commit comments

Comments
 (0)