Search in sources :

Example 11 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method getNormalVertexWeighted.

public Point3f getNormalVertexWeighted(int idx) {
    if (vertices_faces_index == null) {
        computeUniqueVertices();
    }
    List<Integer> list = vertices_faces_index.get(idx);
    Vector3D N = new Vector3D();
    Point3f P = vertices.get(idx);
    for (int i : list) {
        Point3f C = getCenterFace(i);
        // Vector3D V = new Vector3D(P, C);
        // Vector3D Nf = new Vector3D(getNormalFace(i));
        Vector3D V = new Vector3D();
        V.setVectorTwoPoint3f(P, C);
        Vector3D Nf = new Vector3D();
        Nf.setVectorPoint3f(getNormalFace(i));
        Nf.multiplyMe(1.0 / V.getLength());
        N.addMe(Nf);
        // TEST
        if (idx == 100) {
            IJ.log("normal " + Nf + " " + " " + N);
        }
    }
    N.normalize();
    return N.getPoint3f();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Point3f(org.scijava.vecmath.Point3f)

Example 12 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method getRotated.

public ArrayList<Point3f> getRotated(Vector3D Axis, double angle) {
    GeomTransform3D trans = new GeomTransform3D();
    trans.setRotation(Axis, angle);
    Vector3D center = this.getCenterAsVector();
    ArrayList<Point3f> res = new ArrayList(faces.size());
    for (Point3f v : faces) {
        Vector3D tmp = new Vector3D();
        tmp.setVectorPoint3f(v);
        Vector3D tv = trans.getVectorTransformed(tmp, center);
        res.add(new Point3f((float) tv.getX(), (float) tv.getY(), (float) tv.getZ()));
    }
    return res;
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Example 13 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method getCenterFace.

public Point3f getCenterFace(int idx) {
    if (vertices_faces_index == null) {
        computeUniqueVertices();
    }
    int ba = (idx / 3) * 3;
    Point3f C = new Point3f(faces.get(ba));
    C.add(faces.get(ba + 1));
    C.add(faces.get(ba + 2));
    C.scale(0.333f);
    return C;
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Example 14 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method getSurfaceTrianglesUnit.

public List<Point3f> getSurfaceTrianglesUnit(boolean smooth) {
    if ((smooth) && (smooth_faces == null)) {
        computeSmoothSurfaceArea();
    }
    List<Point3f> l;
    if (smooth) {
        l = smooth_faces;
    } else {
        l = faces;
    }
    // calibration
    ArrayList<Point3f> unit_vertices = new ArrayList();
    Iterator it = l.iterator();
    Point3f P, PP;
    // coordinates are normally calibrated
    while (it.hasNext()) {
        P = (Point3f) it.next();
        PP = new Point3f(P.x, P.y, P.z);
        unit_vertices.add(PP);
    }
    return unit_vertices;
}
Also used : Point3f(org.scijava.vecmath.Point3f)

Example 15 with Point3f

use of org.scijava.vecmath.Point3f in project mcib3d-core by mcib3d.

the class Object3DSurface method computeConvexHull3D.

public ArrayList<Point3f> computeConvexHull3D() {
    QuickHull3D hull = new QuickHull3D();
    ArrayList<Voxel3D> pointsList = this.getContours();
    Point3d[] points = new Point3d[pointsList.size()];
    for (int ve = 0; ve < points.length; ve++) {
        points[ve] = new Point3d(pointsList.get(ve).getX(), pointsList.get(ve).getY(), pointsList.get(ve).getZ());
    }
    hull.build(points);
    hull.triangulate();
    ArrayList<Point3f> convex = new ArrayList<Point3f>();
    int[][] faceIndices = hull.getFaces();
    Point3d[] verticesHull = hull.getVertices();
    for (int ve = 0; ve < verticesHull.length; ve++) {
        for (int k = 0; k < faceIndices[ve].length; k++) {
            Point3d point = verticesHull[faceIndices[ve][k]];
            convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
        }
    }
    for (int[] faceIndice : faceIndices) {
        for (int ve = 0; ve < 3; ve++) {
            Point3d point = verticesHull[faceIndice[ve]];
            convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
        }
    }
    return convex;
}
Also used : Point3f(org.scijava.vecmath.Point3f) QuickHull3D(com.github.quickhull3d.QuickHull3D) Point3d(com.github.quickhull3d.Point3d)

Aggregations

Point3f (org.scijava.vecmath.Point3f)58 ArrayList (java.util.ArrayList)20 Calibration (ij.measure.Calibration)6 HashMap (java.util.HashMap)5 Color3f (org.scijava.vecmath.Color3f)5 Point (java.awt.Point)4 Color (java.awt.Color)3 Area (java.awt.geom.Area)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 Point3d (com.github.quickhull3d.Point3d)2 QuickHull3D (com.github.quickhull3d.QuickHull3D)2 PolygonRoi (ij.gui.PolygonRoi)2 Rectangle (java.awt.Rectangle)2 AffineTransform (java.awt.geom.AffineTransform)2 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Vector3f (org.scijava.vecmath.Vector3f)2 CustomLineMesh (customnode.CustomLineMesh)1 CustomMesh (customnode.CustomMesh)1