Commit 7f869b1c authored by Stephane Dallongeville's avatar Stephane Dallongeville
Browse files

small refactoring

parent 0e5a4626
......@@ -182,7 +182,7 @@ public class Polygon2D extends ActiveContour
}
setZ(roi.getZ());
// setName("Contour (" + roi.getName() + ")");
// setName("Contour (" + roi.getName() + ")");
// better to just keep original name, AC will rename it later
setName(roi.getName());
......@@ -543,6 +543,7 @@ public class Polygon2D extends ActiveContour
}
}
}
axis.normalize();
}
......@@ -601,21 +602,16 @@ public class Polygon2D extends ActiveContour
// compute the gradient (2nd order)
final double nextX = getPixelValue(image, p.x + 0.5d, p.y, channel); // getPixelValue(data, width, height, p.x + 0.5, p.y);
if (nextX == 0)
continue;
final double prevX = getPixelValue(image, p.x - 0.5d, p.y, channel); // getPixelValue(data, width, height, p.x - 0.5, p.y);
if (prevX == 0)
continue;
final double nextY = getPixelValue(image, p.x, p.y + 0.5d, channel); // getPixelValue(data, width, height, p.x, p.y + 0.5);
if (nextY == 0)
continue;
final double prevY = getPixelValue(image, p.x, p.y - 0.5d, channel); // getPixelValue(data, width, height, p.x, p.y - 0.5);
if (prevY == 0)
continue;
grad.set(nextX - prevX, nextY - prevY, 0.0);
grad.scale(weight);
force.add(grad);
if ((nextX != 0d) && (prevX != 0d) && (nextY != 0d) && (prevY != 0d))
{
grad.set(nextX - prevX, nextY - prevY, 0.0);
grad.scale(weight);
force.add(grad);
}
}
}
......@@ -699,7 +695,7 @@ public class Polygon2D extends ActiveContour
{
prev = curr;
curr = next;
next = points.get((i + 1)%n);
next = points.get((i + 1) % n);
force = feedbackForces[i];
force.x += weight * (prev.x - 2 * curr.x + next.x);
......@@ -720,15 +716,16 @@ public class Polygon2D extends ActiveContour
Vector3d totalForce = new Vector3d();
for (int i = 0; i < n; i++)
{
totalForce.add(feedbackForces[i], modelForces[i]);
totalForce.add(feedbackForces[i], modelForces[i]);
// 2) check whether the final force has same direction as the outer normal
double forceNorm = totalForce.dot(contourNormals[i]);
if (forceNorm * volumeDiff < 0) {
totalForce.set(contourNormals[i]);
totalForce.scale(volumeDiff * weight / targetVolume);
volumeConstraintForces[i].set(totalForce);
if (forceNorm * volumeDiff < 0)
{
totalForce.set(contourNormals[i]);
totalForce.scale(volumeDiff * weight / targetVolume);
volumeConstraintForces[i].set(totalForce);
}
}
}
......
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