Search in sources :

Example 6 with DefaultMesh

use of net.imagej.ops.geom.geom3d.mesh.DefaultMesh in project imagej-ops by imagej.

the class QuickHull3DTest method quickhull_4_Test.

@Test
public void quickhull_4_Test() {
    LinkedHashSet<RealLocalizable> points = new LinkedHashSet<>();
    points.add(new Vertex(0, 0, 0));
    points.add(new Vertex(1, 0, 0));
    points.add(new Vertex(0, 0, 1));
    points.add(new Vertex(0, 1, 0));
    DefaultMesh df = new DefaultMesh(points);
    DefaultMesh convexHull = (DefaultMesh) ops.run(DefaultConvexHull3D.class, df);
    assertTrue(isConvex(convexHull.getFacets(), convexHull.getEpsilon()));
    assertEquals(4, convexHull.getVertices().size());
}
Also used : RealLocalizable(net.imglib2.RealLocalizable) LinkedHashSet(java.util.LinkedHashSet) Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) DefaultMesh(net.imagej.ops.geom.geom3d.mesh.DefaultMesh) DefaultConvexHull3D(net.imagej.ops.geom.geom3d.DefaultConvexHull3D) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 7 with DefaultMesh

use of net.imagej.ops.geom.geom3d.mesh.DefaultMesh in project imagej-ops by imagej.

the class QuickHull3DTest method quickhull_40_Test.

@Test
public void quickhull_40_Test() {
    // 20 result points
    LinkedHashSet<RealLocalizable> points = new LinkedHashSet<>();
    points.add(new Vertex(0.3215426810286406, 0.1678336189760208, -0.2203710966001927));
    points.add(new Vertex(0.2229772524190855, -0.4213242506806965, -0.1966818060695024));
    points.add(new Vertex(0.3688830163971363, -0.1831502133823468, -0.2056387967482571));
    points.add(new Vertex(-0.1712592515826777, -0.3542439228428937, 0.2223876390814666));
    points.add(new Vertex(-0.3309556113844324, -0.370961861099081, 0.2439994981922204));
    points.add(new Vertex(-0.1004397059794885, -0.09014152417903909, -0.008600084584765189));
    points.add(new Vertex(0.458374538420117, -0.09914027349943322, -0.2505798421339875));
    points.add(new Vertex(-0.4954086979808367, -0.3339869997780649, -0.3195065691317492));
    points.add(new Vertex(0.053091190339151, 0.3036317017894533, 0.1380056861210668));
    points.add(new Vertex(0.4615616439483703, 0.4665423151725366, 0.1766835406205464));
    points.add(new Vertex(-0.4797380864431505, 0.0419809916447671, -0.4254776681079321));
    points.add(new Vertex(-0.003168473023146823, -0.2525299883005488, -0.27151530400991));
    points.add(new Vertex(-0.3577162826971303, -0.1375644040643837, -0.04494194644032229));
    points.add(new Vertex(-0.3392973838740004, 0.4288679723896719, -0.01599531622230571));
    points.add(new Vertex(0.1667164640191164, 0.003605551555385444, -0.4014989499947977));
    points.add(new Vertex(0.00714666676441833, 0.1140243407469469, 0.407090128778564));
    points.add(new Vertex(-0.03621271768232132, 0.3728502838619522, 0.4947140370446388));
    points.add(new Vertex(-0.3411871756810576, -0.3328629143842151, -0.4270033635450559));
    points.add(new Vertex(0.3544683273457627, -0.450828987127942, -0.0827870439577727));
    points.add(new Vertex(-0.4018510635028137, 0.08917494033386464, -0.2367824197158054));
    points.add(new Vertex(0.3978697768392692, -0.002667689232777493, 0.1641431727112673));
    points.add(new Vertex(-0.245701439441835, 0.495905311308713, -0.3194406286994373));
    points.add(new Vertex(0.161352035739787, -0.1563404972258401, 0.3852604361113724));
    points.add(new Vertex(0.07214279572678994, -0.4960366976410492, 0.1112227161519441));
    points.add(new Vertex(0.3201855824516951, 0.359077846965825, 0.02136723140381946));
    points.add(new Vertex(0.1190541238701475, -0.05734495917087884, 0.2032677509852384));
    points.add(new Vertex(0.3210853052521919, 0.4807189479290684, 0.4433501688235907));
    points.add(new Vertex(0.3862800354941562, 0.2085496142586224, 0.09336129957191763));
    points.add(new Vertex(0.1233572616459404, 0.265491605052251, 0.117400122450106));
    points.add(new Vertex(0.1438531872293476, -0.2594872752758556, -0.2026374435076839));
    points.add(new Vertex(0.2724846394476338, -0.3506708492996831, 0.2750346518820475));
    points.add(new Vertex(-0.4926118841325975, -0.3279366743079728, 0.3683135596740186));
    points.add(new Vertex(0.2459906458351674, 0.3647787136629026, -0.1641662355178652));
    points.add(new Vertex(-0.141922976953837, -0.2994764654892278, -0.3009570467294725));
    points.add(new Vertex(-0.1850859398814719, 0.2606059478228967, 0.004159106876849283));
    points.add(new Vertex(-0.09789466634196664, -0.3156603563722785, -0.303610991503681));
    points.add(new Vertex(0.2100642609503719, -0.4499717643018549, 0.3245569875692548));
    points.add(new Vertex(-0.1707163766685095, -0.2301452446078371, -0.05112823569320907));
    points.add(new Vertex(-0.312260808713977, -0.1674135249735914, 0.2808831662692904));
    points.add(new Vertex(-0.1966306233747216, 0.2291105671125563, -0.3387042454804333));
    DefaultMesh df = new DefaultMesh(points);
    DefaultMesh convexHull = (DefaultMesh) ops.run(DefaultConvexHull3D.class, df);
    assertTrue(isConvex(convexHull.getFacets(), convexHull.getEpsilon()));
    assertEquals(20, convexHull.getVertices().size());
}
Also used : RealLocalizable(net.imglib2.RealLocalizable) LinkedHashSet(java.util.LinkedHashSet) Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) DefaultMesh(net.imagej.ops.geom.geom3d.mesh.DefaultMesh) DefaultConvexHull3D(net.imagej.ops.geom.geom3d.DefaultConvexHull3D) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 8 with DefaultMesh

use of net.imagej.ops.geom.geom3d.mesh.DefaultMesh in project imagej-ops by imagej.

the class QuickHull3DTest method quickhull_6_Test.

@Test
public void quickhull_6_Test() {
    LinkedHashSet<RealLocalizable> points = new LinkedHashSet<>();
    points.add(new Vertex(3.2, 4.8, 4.4));
    points.add(new Vertex(0, -4.9, 1.1));
    points.add(new Vertex(-2.4, 4.9, -3.1));
    points.add(new Vertex(4.5, -0.9, -2.5));
    points.add(new Vertex(-4.7, 0.4, -4.2));
    points.add(new Vertex(-1.9, 2.2, -3.3));
    DefaultMesh df = new DefaultMesh(points);
    DefaultMesh convexHull = (DefaultMesh) ops.run(DefaultConvexHull3D.class, df);
    assertTrue(isConvex(convexHull.getFacets(), convexHull.getEpsilon()));
    assertEquals(5, convexHull.getVertices().size());
}
Also used : RealLocalizable(net.imglib2.RealLocalizable) LinkedHashSet(java.util.LinkedHashSet) Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) DefaultMesh(net.imagej.ops.geom.geom3d.mesh.DefaultMesh) DefaultConvexHull3D(net.imagej.ops.geom.geom3d.DefaultConvexHull3D) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 9 with DefaultMesh

use of net.imagej.ops.geom.geom3d.mesh.DefaultMesh in project imagej-ops by imagej.

the class MeshFeatureTests method marchingCubes.

@Test
public void marchingCubes() {
    final DefaultMesh result = (DefaultMesh) ops.run(DefaultMarchingCubes.class, ROI);
    final List<Facet> expectedFacets = mesh.getFacets();
    final List<Facet> resultFacets = result.getFacets();
    for (int i = 0; i < expectedFacets.size(); i++) {
        final TriangularFacet tmpR = (TriangularFacet) resultFacets.get(i);
        final TriangularFacet tmpE = (TriangularFacet) expectedFacets.get(i);
        for (int j = 0; j < 3; j++) {
            final Vertex resultVertex = tmpR.getVertex(j);
            final Vertex expectedVertex = tmpE.getVertex(j);
            assertEquals("Triangular Facet point " + j + " differes in x- coordinate:", expectedVertex.getDoublePosition(0), resultVertex.getDoublePosition(0), EPSILON);
            assertEquals("Triangular Facet point " + j + " differes in y- coordinate:", expectedVertex.getDoublePosition(1), resultVertex.getDoublePosition(1), EPSILON);
            assertEquals("Triangular Facet point " + j + " differes in z- coordinate:", expectedVertex.getDoublePosition(2), resultVertex.getDoublePosition(2), EPSILON);
        }
    }
}
Also used : Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) TriangularFacet(net.imagej.ops.geom.geom3d.mesh.TriangularFacet) DefaultMesh(net.imagej.ops.geom.geom3d.mesh.DefaultMesh) DefaultMarchingCubes(net.imagej.ops.geom.geom3d.DefaultMarchingCubes) Facet(net.imagej.ops.geom.geom3d.mesh.Facet) TriangularFacet(net.imagej.ops.geom.geom3d.mesh.TriangularFacet) Test(org.junit.Test) AbstractFeatureTest(net.imagej.ops.features.AbstractFeatureTest)

Example 10 with DefaultMesh

use of net.imagej.ops.geom.geom3d.mesh.DefaultMesh in project imagej-ops by imagej.

the class AbstractFeatureTest method getMesh.

protected static Mesh getMesh() {
    final List<Vertex> vertices = new ArrayList<>();
    try {
        Files.lines(Paths.get(AbstractFeatureTest.class.getResource("3d_geometric_features_mesh.txt").toURI())).forEach(l -> {
            String[] coord = l.split(" ");
            Vertex v = new Vertex(Double.parseDouble(coord[0]), Double.parseDouble(coord[1]), Double.parseDouble(coord[2]));
            vertices.add(v);
        });
    } catch (IOException | URISyntaxException exc) {
        exc.printStackTrace();
    }
    final DefaultMesh m = new DefaultMesh();
    for (int i = 0; i < vertices.size(); i += 3) {
        final TriangularFacet f = new TriangularFacet(vertices.get(i), vertices.get(i + 1), vertices.get(i + 2));
        m.addFace(f);
    }
    return m;
}
Also used : Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) TriangularFacet(net.imagej.ops.geom.geom3d.mesh.TriangularFacet) DefaultMesh(net.imagej.ops.geom.geom3d.mesh.DefaultMesh) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) RealPoint(net.imglib2.RealPoint)

Aggregations

DefaultMesh (net.imagej.ops.geom.geom3d.mesh.DefaultMesh)10 Vertex (net.imagej.ops.geom.geom3d.mesh.Vertex)8 RealLocalizable (net.imglib2.RealLocalizable)6 Test (org.junit.Test)6 LinkedHashSet (java.util.LinkedHashSet)5 AbstractOpTest (net.imagej.ops.AbstractOpTest)5 DefaultConvexHull3D (net.imagej.ops.geom.geom3d.DefaultConvexHull3D)5 TriangularFacet (net.imagej.ops.geom.geom3d.mesh.TriangularFacet)5 ArrayList (java.util.ArrayList)2 Facet (net.imagej.ops.geom.geom3d.mesh.Facet)2 FinalInterval (net.imglib2.FinalInterval)2 RealPoint (net.imglib2.RealPoint)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 AbstractFeatureTest (net.imagej.ops.features.AbstractFeatureTest)1 DefaultMarchingCubes (net.imagej.ops.geom.geom3d.DefaultMarchingCubes)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 BitType (net.imglib2.type.logic.BitType)1 BoolType (net.imglib2.type.logic.BoolType)1 ExtendedRandomAccessibleInterval (net.imglib2.view.ExtendedRandomAccessibleInterval)1