Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix immediate ClassCastExceptions in wrapping RealPointCollections #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.imagej.legacy.convert.roi.MaskPredicateWrapper;
import net.imglib2.RealLocalizable;
import net.imglib2.RealPoint;
import net.imglib2.RealPositionable;
import net.imglib2.roi.geom.real.WritableRealPointCollection;
import net.imglib2.roi.util.RealLocalizableRealPositionable;
import net.imglib2.roi.util.RealLocalizableRealPositionableWrapper;
Expand Down Expand Up @@ -100,23 +101,23 @@ public void synchronize() {

// -- Helper methods --

private static <L extends RealLocalizable> float[] getCoors(
final WritableRealPointCollection<RealLocalizableRealPositionable> rpc,
private static <L extends RealLocalizable & RealPositionable> float[] getCoors(
final WritableRealPointCollection<L> rpc,
final int d)
{
final FloatArray coor = new FloatArray();
final Iterator<RealLocalizableRealPositionable> itr = rpc.points()
final Iterator<L> itr = rpc.points()
.iterator();
while (itr.hasNext())
coor.addValue(itr.next().getFloatPosition(d));

return coor.getArray();
}

private static <L extends RealLocalizable> int countPoints(
final WritableRealPointCollection<RealLocalizableRealPositionable> rpc)
private static <L extends RealLocalizable & RealPositionable> int countPoints(
final WritableRealPointCollection<L> rpc)
{
final Iterator<RealLocalizableRealPositionable> itr = rpc.points()
final Iterator<L> itr = rpc.points()
.iterator();
int count = 0;
while (itr.hasNext()) {
Expand Down