Skip to content
Snippets Groups Projects
Commit 2e0d7476 authored by Thomas  MUSSET's avatar Thomas MUSSET
Browse files

updated pom, optimized code for java 11

parent 2faaa888
No related branches found
No related tags found
No related merge requests found
......@@ -7,4 +7,5 @@ bin/
*.jar
.classpath
.project
export.jardesc
\ No newline at end of file
export.jardesc
**/.DS_Store
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.bioimageanalysis.icy</groupId>
<artifactId>parent-pom-plugin</artifactId>
<version>1.0.8</version>
<artifactId>pom-icy</artifactId>
<version>2.2.0</version>
</parent>
<artifactId>convexify</artifactId>
<version>2.0.7</version>
<version>3.0.0</version>
<packaging>jar</packaging>
......@@ -28,12 +28,10 @@
<dependency>
<groupId>org.bioimageanalysis.icy</groupId>
<artifactId>quickhull</artifactId>
<version>${quickhull.version}</version>
</dependency>
<dependency>
<groupId>org.bioimageanalysis.icy</groupId>
<artifactId>3d-mesh-roi</artifactId>
<version>${three-d-mesh-roi.version}</version>
</dependency>
</dependencies>
......
/*
* Copyright (c) 2010-2023. Institut Pasteur.
*
* This file is part of Icy.
* Icy is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Icy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Icy. If not, see <https://www.gnu.org/licenses/>.
*/
package plugins.adufour.roi;
import icy.roi.ROI;
......@@ -6,13 +24,6 @@ import icy.roi.ROI3D;
import icy.roi.ROIUtil;
import icy.sequence.Sequence;
import icy.type.point.Point3D;
import java.awt.geom.Point2D;
import java.util.Arrays;
import java.util.List;
import javax.vecmath.Point3d;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.ezplug.EzPlug;
......@@ -27,52 +38,50 @@ import plugins.kernel.roi.roi2d.ROI2DPolygon;
import plugins.kernel.roi.roi2d.ROI2DShape;
import plugins.kernel.roi.roi3d.ROI3DArea;
public class Convexify extends EzPlug implements ROIBlock
{
private EzVarSequence input = new EzVarSequence("Input sequence");
import javax.vecmath.Point3d;
import java.awt.geom.Point2D;
import java.util.Arrays;
import java.util.List;
public class Convexify extends EzPlug implements ROIBlock {
private final EzVarSequence input = new EzVarSequence("Input sequence");
private EzVarBoolean replace = new EzVarBoolean("Replace existing ROI", false);
private final EzVarBoolean replace = new EzVarBoolean("Replace existing ROI", false);
private VarROIArray roiIN = new VarROIArray("List of ROI");
private final VarROIArray roiIN = new VarROIArray("List of ROI");
private VarROIArray roiOUT = new VarROIArray("List of ROI");
private final VarROIArray roiOUT = new VarROIArray("List of ROI");
@Override
protected void initialize()
{
protected void initialize() {
addEzComponent(input);
addEzComponent(replace);
}
@Override
public void clean()
{
public void clean() {
}
@Override
public void execute()
{
if (!isHeadLess())
{
public void execute() {
if (!isHeadLess()) {
roiIN.setValue(new ROI[0]);
Sequence s = input.getValue(true);
final Sequence s = input.getValue(true);
roiIN.add(s.getROIs().toArray(new ROI[0]));
}
roiOUT.setValue(new ROI[0]);
for (ROI roi : roiIN)
for (final ROI roi : roiIN)
roiOUT.add(createConvexROI(roi));
if (!isHeadLess())
{
Sequence s = input.getValue(true);
if (!isHeadLess()) {
final Sequence s = input.getValue(true);
if (replace.getValue())
s.removeAllROI();
for (ROI roi : roiOUT)
{
for (final ROI roi : roiOUT) {
s.addROI(roi);
}
}
......@@ -80,36 +89,28 @@ public class Convexify extends EzPlug implements ROIBlock
/**
* Creates a convex ROI from the specified ROI.
*
* @param roi
* the ROI to be converted into a convex version
*
* @param roi the ROI to be converted into a convex version
* @return a convex version of the ROI. This ROI is currently of type {@link ROI2DPolygon} in
* 2D, and of type {@link ROI3DArea} in 3D, although the return types may change in the
* future.
* @throws IllegalArgumentException
* if the specified ROI is not supported
* 2D, and of type {@link ROI3DArea} in 3D, although the return types may change in the
* future.
* @throws IllegalArgumentException if the specified ROI is not supported
*/
public static ROI createConvexROI(ROI roi) throws IllegalArgumentException
{
public static ROI createConvexROI(final ROI roi) throws IllegalArgumentException {
ROI output = null;
try
{
if (roi instanceof ROI2D)
{
try {
if (roi instanceof ROI2D) {
final List<Point2D> envelope;
if (roi instanceof ROI2DShape)
{
if (roi instanceof ROI2DShape) {
envelope = QuickHull2D.computeConvexEnvelope(((ROI2DShape) roi).getPoints());
}
else if (roi instanceof ROI2DArea)
{
Point2D[] points = ((ROI2DArea) roi).getBooleanMask(true).getContourPoints();
else if (roi instanceof ROI2DArea) {
final Point2D[] points = ((ROI2DArea) roi).getBooleanMask(true).getContourPoints();
envelope = QuickHull2D.computeConvexEnvelope(Arrays.asList(points));
}
else
{
else {
throw new IllegalArgumentException("Cannot compute convex hull for ROI " + roi.getName()
+ " of type " + roi.getClassName() + ".");
}
......@@ -122,19 +123,17 @@ public class Convexify extends EzPlug implements ROIBlock
((ROI2D) output).setZ(roi2d.getZ());
((ROI2D) output).setC(roi2d.getC());
}
else if (roi instanceof ROI3D)
{
Point3D[] points = ((ROI3D) roi).getBooleanMask(true).getContourPoints();
else if (roi instanceof ROI3D) {
final Point3D[] points = ((ROI3D) roi).getBooleanMask(true).getContourPoints();
// convert to vecmath's Point3d
Point3d[] pt3d = new Point3d[points.length];
for (int i = 0; i < points.length; i++)
{
Point3D p = points[i];
final Point3d[] pt3d = new Point3d[points.length];
for (int i = 0; i < points.length; i++) {
final Point3D p = points[i];
pt3d[i] = new Point3d(p.getX(), p.getY(), p.getZ());
}
QuickHull3D qhull = new QuickHull3D();
final QuickHull3D qhull = new QuickHull3D();
qhull.build(pt3d, pt3d.length);
// Use a 3D mesh to prepare the final ROI
......@@ -142,12 +141,11 @@ public class Convexify extends EzPlug implements ROIBlock
// copy position info
final ROI3D roi3d = (ROI3D) roi;
((ROI3D)output).setT(roi3d.getT());
((ROI3D)output).setC(roi3d.getC());
((ROI3D) output).setT(roi3d.getT());
((ROI3D) output).setC(roi3d.getC());
}
}
catch (Throwable t)
{
catch (final Throwable t) {
// can happen with QuickHull3D / ROI3DPolygonalMesh...
throw new IllegalArgumentException(
"Cannot compute convex hull for ROI " + roi.getName() + " of type " + roi.getClassName() + ".", t);
......@@ -164,14 +162,12 @@ public class Convexify extends EzPlug implements ROIBlock
}
@Override
public void declareInput(VarList inputMap)
{
public void declareInput(final VarList inputMap) {
inputMap.add("Regions of interest", roiIN);
}
@Override
public void declareOutput(VarList outputMap)
{
public void declareOutput(final VarList outputMap) {
outputMap.add("Regions of interest", roiOUT);
}
}
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