X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;h=bec0cc21cbda152a7c96b23af4c757d4b46cd947;hp=4ae3a8e519f57df01a7d131f7554ef8e6de9ad0e;hb=2d6566bcf01b3853392ec13863671282f825444f;hpb=e4d317da98c8126fa7cfb4d0097419d8f0d383a5 diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 4ae3a8e..bec0cc2 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -9,6 +9,7 @@ import java.util.*; import edu.berkeley.qfat.bind.*; import edu.berkeley.qfat.geom.*; import edu.berkeley.qfat.stl.*; +import edu.berkeley.qfat.voxel.*; import edu.berkeley.qfat.geom.Point; import edu.berkeley.qfat.geom.Polygon; @@ -291,6 +292,25 @@ public class Main extends InteractiveMeshViewer { public void hit() {} } + public void marchingCubes() { + Mesh mesh = new Mesh(false); + mesh.coalesce = true; + MarchingCubes.march(new SampledField() { + public float getSample(Point p) { + double x = p.x; + double y = p.y; + double z = p.z; + x-=0.7; + y-=0.7; + z-=0.7; + return (float)Math.sqrt(x*x+y*y+z*z); + } + }, + 0.8, 20, 0.1, mesh); + setTile(mesh); + //fixupTile(); + } + public void hexBrick(boolean offset, boolean rotated) { setTile(new Mesh(false)); float width = (float)0.8; @@ -918,11 +938,14 @@ public class Main extends InteractiveMeshViewer { }; fixupTile(); }}}); + tileMenu.add(new MyMenuItem("Marching Cubes") { public void hit() { + marchingCubes(); + }}); // Finally, add all the menus to the menu bar. add(tileMenu); - add(goalMenu); - add(hideMenu); + //add(goalMenu); + //add(hideMenu); } } @@ -1085,11 +1108,27 @@ public class Main extends InteractiveMeshViewer { f.setLayout(new BorderLayout()); Main main = new Main(f); f.add(main, BorderLayout.CENTER); - f.setJMenuBar(main.new MyMenuBar()); + + f.addWindowListener(new WindowListener() { + public void windowActivated(WindowEvent e) { } + public void windowClosed(WindowEvent e) { System.exit(0); } + public void windowClosing(WindowEvent e) { System.exit(0); } + public void windowDeactivated(WindowEvent e) { } + public void windowDeiconified(WindowEvent e) { } + public void windowIconified(WindowEvent e) { } + public void windowOpened(WindowEvent e) { } + }); + f.pack(); f.show(); f.setSize(900, 900); f.doLayout(); + + JFrame f2 = new JFrame(); + f2.setJMenuBar(main.new MyMenuBar()); + f2.setSize(100,100); + f2.show(); + main.anneal(); }