From 2ea687d94af37620638629b133a2df92c1ea6d1c Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 23 Feb 2024 13:23:50 +0100 Subject: [PATCH] preparing release version. Bug fix in furrow interception code. --- README.md | 16 ++++ pom.xml | 2 +- .../Deforming3DMesh_Plugin.java | 2 +- .../java/deformablemesh/geometry/Box3D.java | 7 ++ .../deformablemesh/geometry/Furrow3D.java | 6 +- .../geometry/SplittingSpheres.java | 75 +++++++++++++++++++ 6 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/test/java/deformablemesh/geometry/SplittingSpheres.java diff --git a/README.md b/README.md index 3fe5716..4a5a3e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ [![Build Status](https://github.com/PaluchLabUCL/DeformingMesh3D/actions/workflows/build.yml/badge.svg)](https://github.com/PaluchLabUCL/DeformingMesh3D/actions/workflows/build.yml) # DM3D + +## +**This is being moved. This is the original version that was published. I've moved it to +a version 1.0.x to signify feature complete release. Development will continue at +[Living Technologies](https://github.com/Living-Technologies)** + +This one will remain at the update site and might receive bug fixes. Future features +will be found at a new update site. + ThreeD image segmentation algorithm, for roundish cells. The latest documentation can be found at: @@ -35,6 +44,13 @@ which can be found in "plugins"->"PL_Mesh3D"->"Deforming Mesh 3D", and JFilament This includes guides for using the plugin, and javadoc for using the plugin via scripting. # Changes + +1.0.0 +- Furrow controls in the 3D Canvas window. +- Tracking controls in 3D canvas window +- guessMesh api has more options +- BUG FIX: there was a condition error in the spit mesh algorithm + 0.9.8 - Changed volume calculation technique. - Added a way to create training labels from a labelled image. diff --git a/pom.xml b/pom.xml index 03c1b66..687dbf2 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ paluchlab Deformable_Mesh - 0.9.11-SNAPSHOT + 1.0.0 Deforming Mesh Triangulated surface for deforming in 3D. diff --git a/src/main/java/deformablemesh/Deforming3DMesh_Plugin.java b/src/main/java/deformablemesh/Deforming3DMesh_Plugin.java index a9424cc..ce00dc4 100644 --- a/src/main/java/deformablemesh/Deforming3DMesh_Plugin.java +++ b/src/main/java/deformablemesh/Deforming3DMesh_Plugin.java @@ -43,7 +43,7 @@ * Created by msmith on 12/1/15. */ public class Deforming3DMesh_Plugin implements PlugInFilter { - public static final String version = "0.9.7"; + public static final String version = "1.0.0 Last One Targeting Eight"; public static SegmentationController createDeformingMeshApplication(){ MeshFrame3D mf3d = new MeshFrame3D(); diff --git a/src/main/java/deformablemesh/geometry/Box3D.java b/src/main/java/deformablemesh/geometry/Box3D.java index 314ca82..f1f0cbb 100644 --- a/src/main/java/deformablemesh/geometry/Box3D.java +++ b/src/main/java/deformablemesh/geometry/Box3D.java @@ -28,6 +28,7 @@ import deformablemesh.util.Vector3DOps; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -185,6 +186,11 @@ public double getVolume() { public double[] getCenter() { return Vector3DOps.average(high, low); } + + @Override + public String toString(){ + return "Box3D: " + Arrays.toString(low) + " :: " + Arrays.toString(high); + } } class AxisPlane implements Interceptable{ @@ -220,4 +226,5 @@ public List getIntersections(double[] origin, double[] direction) return Collections.unmodifiableList(sections); } + } diff --git a/src/main/java/deformablemesh/geometry/Furrow3D.java b/src/main/java/deformablemesh/geometry/Furrow3D.java index e59d701..f8b64bf 100644 --- a/src/main/java/deformablemesh/geometry/Furrow3D.java +++ b/src/main/java/deformablemesh/geometry/Furrow3D.java @@ -492,8 +492,10 @@ public List getIntersections(double[] origin, double[] direction) double toPlane = Vector3DOps.dot(r, normal); double dot = Vector3DOps.dot(direction, normal); - double t = dot<0 ? 1 + dot : 1 - dot; - if(t < 1e-6 ){ + //Line has to be going towards the plan and against the normal. + + final double tolerance = 1e-6; + if(dot < 0 ? dot > - tolerance : dot < tolerance ){ //parallel to normal. return new ArrayList<>(); } diff --git a/src/test/java/deformablemesh/geometry/SplittingSpheres.java b/src/test/java/deformablemesh/geometry/SplittingSpheres.java new file mode 100644 index 0000000..df0523a --- /dev/null +++ b/src/test/java/deformablemesh/geometry/SplittingSpheres.java @@ -0,0 +1,75 @@ +package deformablemesh.geometry; + +import deformablemesh.meshview.MeshFrame3D; +import deformablemesh.util.Vector3DOps; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class SplittingSpheres { + public static void main(String[] args){ + MeshFrame3D mesh = new MeshFrame3D(); + mesh.showFrame(true); + mesh.addLights(); + //create a spherical mesh + double[] center = new double[]{0, 0, 0}; + DeformableMesh3D m = RayCastMesh.sphereRayCastMesh(2); + m.translate(center); + m.scale(0.025, center); + //place the furrow at the center + Furrow3D f = new Furrow3D(center, Vector3DOps.nzhat); + List meshes = f.sliceMesh(m); + Furrow3D reversed = new Furrow3D(f.cm, + new double[]{-f.normal[0], -f.normal[1], -f.normal[2]} + ); + List splits = new ArrayList<>(); + Color[] colors = {new Color(255, 0, 0, 79), new Color(0,0, 255, 79)}; + int ci = 0; + + InterceptingMesh3D im = new InterceptingMesh3D(m); + + + List> nodes = f.splitNodes(m.nodes); + + for(List side: nodes){ + List interceptables = Arrays.asList(reversed, f, im); + if(side.size()==0){ + continue; + } + double[] c = new double[3]; + for(Node3D n: side){ + double[] xyz = n.getCoordinates(); + c[0] += xyz[0]; + c[1] += xyz[1]; + c[2] += xyz[2]; + } + c[0] = c[0]/side.size(); + c[1] = c[1]/side.size(); + c[2] = c[2]/side.size(); + DeformableMesh3D a = RayCastMesh.rayCastMesh(interceptables, c, 2); + splits.add(a); + } + + //split it + //BUG the split mesh has a point across the midline. + DeformableMesh3D a = splits.get(0); + DeformableMesh3D b = splits.get(1); + System.out.println(a.getBoundingBox()); + System.out.println(b.getBoundingBox()); + + a.setColor(Color.RED); + a.setShowSurface(true); + a.create3DObject(); + b.setColor(Color.BLUE); + b.setShowSurface(true); + b.create3DObject(); + mesh.addDataObject(b.data_object); + mesh.addDataObject(a.data_object); + f.create3DObject(); + mesh.addDataObject(f.getDataObject()); + + + } +}