示例#1
0
        public static void Main(string[] args)
        {
            ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs expArgs) {
                Console.WriteLine(expArgs.ExceptionObject.ToString());
                expArgs.ExitApplication = true;
            };

            Gtk.Application.Init();

            MainWindow = new Window("gsCNCViewer");
            MainWindow.SetDefaultSize(900, 600);
            MainWindow.SetPosition(WindowPosition.Center);
            MainWindow.DeleteEvent += delegate {
                Gtk.Application.Quit();
            };

            //DMesh3 part = StandardMeshReader.ReadMesh("../../../sample_files/hemisphere_h2p4.obj");
            //DMesh3 stock = StandardMeshReader.ReadMesh("../../../sample_files/stock_5x5x2p5.obj");

            DMesh3 part  = StandardMeshReader.ReadMesh("../../../sample_files/mechpart1.obj");
            DMesh3 stock = StandardMeshReader.ReadMesh("../../../sample_files/mechpart1_stock.obj");


            PrintMeshAssembly meshes = new PrintMeshAssembly();

            meshes.AddMesh(stock);
            meshes.AddMesh(part, PrintMeshOptions.Cavity());

            View = new SliceViewCanvas();
            MainWindow.Add(View);


            //DMesh3 tube_mesh = GenerateTubeMeshesForGCode("c:\\Users\\rms\\Downloads\\gear train.nc");
            //StandardMeshWriter.WriteMesh("../../../sample_output/tubes.obj", tube_mesh, WriteOptions.Defaults);

            string sPath = GenerateGCodeForMeshes(meshes);

            if (SHOW_RELOADED_GCODE_PATHS)
            {
                LoadGeneratedGCodeFile(sPath);
            }

            MainWindow.KeyReleaseEvent += Window_KeyReleaseEvent;

            // support drag-drop
            Gtk.TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("text/uri-list", 0, 0),
            };
            Gtk.Drag.DestSet(MainWindow, DestDefaults.All, target_table, Gdk.DragAction.Copy);
            MainWindow.DragDataReceived += MainWindow_DragDataReceived;;


            MainWindow.ShowAll();

            Gtk.Application.Run();
        }
示例#2
0
        public static void Main(string[] args)
        {
            GtkUtil.CheckWindowsGtk();

            ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs expArgs) {
                Console.WriteLine(expArgs.ExceptionObject.ToString());
                expArgs.ExitApplication = true;
            };

            Gtk.Application.Init();

            MainWindow = new Window("gsSlicerViewer");
            MainWindow.SetDefaultSize(900, 600);
            MainWindow.SetPosition(WindowPosition.Center);
            MainWindow.DeleteEvent += delegate {
                Gtk.Application.Quit();
            };

            string sPath = "../../../sample_files/disc_single_layer.gcode";
            //string sPath = "../../../sample_files/disc_0p6mm.gcode";
            //string sPath = "../../../sample_files/square_linearfill.gcode";
            //string sPath = "../../../sample_files/thin_hex_test_part.gcode";
            //string sPath = "../../../sample_files/box_infill_50.gcode";
            //string sPath = "../../../sample_files/tube_adapter.gcode";
            //string sPath = "../../../sample_files/ring_2p2_makerbot.gcode";
            //string sPath = "/Users/rms/Desktop/print_experiment/cura_ring_2p2.gcode";
            //string sPath = "/Users/rms/Desktop/print_experiment/slic3r_ring_2p2.gcode";

            DMesh3 readMesh = null;

            //GCodeFile genGCode = MakerbotTests.SimpleFillTest();
            //GCodeFile genGCode = MakerbotTests.SimpleShellsTest();
            //GCodeFile genGCode = MakerbotTests.InfillBoxTest();

            //GeneralPolygon2d poly = GetPolygonFromMesh("../../../sample_files/bunny_open.obj");
            //GCodeFile genGCode = MakerbotTests.ShellsPolygonTest(poly);
            //GCodeFile genGCode = MakerbotTests.StackedPolygonTest(poly, 2);
            //GCodeFile genGCode = MakerbotTests.StackedScaledPolygonTest(poly, 20, 0.5);

            readMesh = StandardMeshReader.ReadMesh("../../../sample_files/cotan_cylinder.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/bunny_solid_2p5cm.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/bunny_solid_5cm_min.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/basic_step.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/slab_5deg.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/sphere_angles_1cm.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/inverted_cone_1.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/tube_adapter.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/tube_1.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/50x50x1_box.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/crop_bracket.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/thinwall2.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/box_and_cylsheet.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/box_and_opensheet.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/radial_fins.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/radial_fins_larger.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/bunny_hollow_5cm.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/notch_test_1.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/square_minus_shapes.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/variable_thins.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/arrow_posx.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/blobby_shape.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/socket_ros_simplified.obj");
            //readMesh = StandardMeshReader.ReadMesh("c:\\scratch\\bunny_fixed_flat.obj");
            //MeshUtil.ScaleMesh(readMesh, Frame3f.Identity, 1.1f*Vector3f.One);
            //readMesh = StandardMeshReader.ReadMesh("c:\\scratch\\ARCHFORM_EXPORT_stage_12_lower.stl");

            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/unsupported_slab_5deg.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/overhang_slab_1.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/edge_overhang.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/support_tilted_cone.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/support_mintip.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/support_mintip_vtx.obj");
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/tilted_thin_slab.obj");

            //readMesh = StandardMeshReader.ReadMesh("C:\\meshes\\user_bugs\\inverted_part.obj");
            //readMesh = StandardMeshReader.ReadMesh("C:\\meshes\\user_bugs\\tail_tiny_support_dots.obj");
            //readMesh = StandardMeshReader.ReadMesh("C:\\meshes\\user_bugs\\cone_inner.obj");

            // interesting test case for clipselfoverlaps and scheduler
            //readMesh = StandardMeshReader.ReadMesh("../../../sample_files/Slim_Type1.stl");

            DMesh3 cavityMesh = null;

            DMesh3 supportMesh = null;

            //supportMesh = StandardMeshReader.ReadMesh("../../../sample_files/edge_overhang_support.obj");

            // rotate to be z-up
            //MeshTransforms.Rotate(readMesh, Vector3d.Zero, Quaternionf.AxisAngleD(Vector3f.AxisX, 90));
            //if ( supportMesh != null )
            //    MeshTransforms.Rotate(supportMesh, Vector3d.Zero, Quaternionf.AxisAngleD(Vector3f.AxisX, 90));

            //readMesh = CalibrationModelGenerator.MakePrintStepSizeTest(10.0f, 10.0f, 0.1, 1.0, 10);

            //DMesh3[] meshComponents = MeshConnectedComponents.Separate(readMesh);
            DMesh3[] meshComponents = new DMesh3[] { readMesh };

            PrintMeshAssembly meshes = new PrintMeshAssembly();

            meshes.AddMeshes(meshComponents);

            if (cavityMesh != null)
            {
                meshes.AddMesh(cavityMesh, PrintMeshOptions.Cavity());
            }
            if (supportMesh != null)
            {
                meshes.AddMesh(supportMesh, PrintMeshOptions.Support());
            }

            AxisAlignedBox3d bounds  = meshes.TotalBounds;
            AxisAlignedBox2d bounds2 = new AxisAlignedBox2d(bounds.Center.xy, bounds.Width / 2, bounds.Height / 2);

            View = new SliceViewCanvas();
            MainWindow.Add(View);

            if (readMesh != null)
            {
                // generate gcode file for mesh
                sPath = GenerateGCodeForMeshes(meshes);
            }

            if (SHOW_RELOADED_GCODE_PATHS)
            {
                LoadGeneratedGCodeFile(sPath);
            }

            //GenerateGCodeForSliceFile("c:\\scratch\\output.gslice");

            MainWindow.KeyReleaseEvent += Window_KeyReleaseEvent;

            // support drag-drop
            Gtk.TargetEntry[] target_table = new TargetEntry[] {
                new TargetEntry("text/uri-list", 0, 0),
            };
            Gtk.Drag.DestSet(MainWindow, DestDefaults.All, target_table, Gdk.DragAction.Copy);
            MainWindow.DragDataReceived += MainWindow_DragDataReceived;;


            MainWindow.ShowAll();

            Gtk.Application.Run();
        }