Skip to content

Commit

Permalink
preparing release version. Bug fix in furrow interception code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt committed Feb 23, 2024
1 parent 4f6024e commit 2ea687d
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 4 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>paluchlab</groupId>
<artifactId>Deformable_Mesh</artifactId>
<version>0.9.11-SNAPSHOT</version>
<version>1.0.0</version>

<name>Deforming Mesh</name>
<description>Triangulated surface for deforming in 3D.</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/deformablemesh/Deforming3DMesh_Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/deformablemesh/geometry/Box3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import deformablemesh.util.Vector3DOps;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -220,4 +226,5 @@ public List<Intersection> getIntersections(double[] origin, double[] direction)

return Collections.unmodifiableList(sections);
}

}
6 changes: 4 additions & 2 deletions src/main/java/deformablemesh/geometry/Furrow3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,10 @@ public List<Intersection> 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<>();
}
Expand Down
75 changes: 75 additions & 0 deletions src/test/java/deformablemesh/geometry/SplittingSpheres.java
Original file line number Diff line number Diff line change
@@ -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<DeformableMesh3D> meshes = f.sliceMesh(m);
Furrow3D reversed = new Furrow3D(f.cm,
new double[]{-f.normal[0], -f.normal[1], -f.normal[2]}
);
List<DeformableMesh3D> 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<List<Node3D>> nodes = f.splitNodes(m.nodes);

for(List<Node3D> side: nodes){
List<Interceptable> 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());


}
}

0 comments on commit 2ea687d

Please sign in to comment.