-
Notifications
You must be signed in to change notification settings - Fork 43
Overhaul of Voxelization ops with new algorithm. Also included test #657
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
base: master
Are you sure you want to change the base?
Changes from all commits
83b5c4c
ff5da48
d840532
ff45913
b004747
25001a5
3b49daf
c3f0c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imagej.ops.OpMethod; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imagej.ops.Ops.Geometric.Voxelization; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imagej.ops.geom.geom3d.mesh.VertexInterpolator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imglib2.Interval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imglib2.IterableInterval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imglib2.RandomAccessibleInterval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import net.imglib2.RealLocalizable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -278,13 +279,6 @@ public List convexHull(final Mesh in) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| net.imagej.ops.Ops.Geometric.ConvexHull.class, in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final int width, final int height, final int depth ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final RandomAccessibleInterval<BitType> result = (RandomAccessibleInterval<BitType>) ops().run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Voxelization.class, in, width, height, depth ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom2d.DefaultConvexityPolygon.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public DoubleType convexity(final Polygon2D in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -678,26 +672,47 @@ public double[] vertexInterpolator(final int[] p1, final int[] p2, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @SuppressWarnings("unchecked") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final int width) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @SuppressWarnings("unchecked") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final Interval dimensions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, dimensions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final Interval dimensions, boolean scaleMeshToDimesions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, width); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, dimensions, scaleMeshToDimesions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Two OpMethods below cause a Mismatched inputs error, though they both work fine if built with 'Skip tests' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // public RandomAccessibleInterval<BitType> voxelization(final Mesh in, double wallThickness) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, null, false, wallThickness); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final Interval dimensions, double wallThickness) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, dimensions, false, wallThickness); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+694
to
+708
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These do not work because optional Op signatures are only "valid" if parameters are left off right to left. In this case, valid signatures would be:
Of course these two signatures are not included. The context for this right-to-left dropping is to remove ambiguity when you have two optional parameters that are of the same type e.g. for some voxelization(final Mesh in, final double a, final Double b)you could not have both voxelization(final Mesh in, final double a)
voxelization(final Mesh in, final double b)However, your use case does not have this problem. You could consider skipping the type check (unclear if this is what you meant by skip tests) - do you think this is an acceptable use case of that parameter @ctrueden?
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be great to either get these working or delete them from the code
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with it either way. Wasn't strongly invested in having these signatures, I just wasn't really sure what the issue was, or how to do the SkipTypeCheck.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also do not feel strongly - I just want to make sure that you get the code you want in, and it's easier to add these things in later than to remove them now. So if you don't have a use let's just remove them?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final int width, final int height) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RandomAccessibleInterval<BitType> voxelization(final Mesh in, final Interval dimensions, boolean scaleMeshToDimesions, double wallThickness) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final RandomAccessibleInterval<BitType> result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, width, height); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (RandomAccessibleInterval<BitType>) ops().run(net.imagej.ops.geom.geom3d.DefaultVoxelization3D.class, in, dimensions, scaleMeshToDimesions, wallThickness); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @OpMethod(op = net.imagej.ops.geom.geom2d.DefaultVerticesCountPolygon.class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public DoubleType verticesCount(final Polygon2D in) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change 🛠️
Since your Op has no overlap in parameter types with the existing Op, we could consider offering the two Ops side-by-side? Could also consider some sort of deprecation for the old Op...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would change the algorithm used, so I'm not sure you would want to do this, but you could do:
final RandomAccessibleInterval<BitType> result = (RandomAccessibleInterval<BitType>) ops().run( Voxelization.class, in, new FinalInterval(width, height, depth));This means that the output from any old code would change, but the function call wouldn't.
I imagine that is not the preferred option, but it doesn't really matter to me, can definitely keep the old algorithm in there in whatever manner you deem best. I simply forgot about the whole "can't make breaking changes" thing, never done any library coding before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this option is certainly available, however I think I'd prefer avoiding breakages if possible. I wouldn't say that the previous implementation was a bug, it's just a different algorithm (although certainly a strange one)
It happens to the best of us, don't worry 🙂