Exemplo n.º 1
0
        public OneCoreHandler(int dimension)
        {
            nester = new Nester(dimension);
#if CheckingCorrectness
            checker = new MachingChecker(dimension);
#endif
        }
Exemplo n.º 2
0
        private void Button_play_Click(object sender, RoutedEventArgs e)
        {
            // if the nester is working cancel the work
            if (_nester != null && _nester.IsBusy())
            {
                _nester.CancelExecute();
                Debug.WriteLine("cancelling...");
                return;
            }

            // get the path of the .obj
            string file_path = string.Empty;

            OpenFileDialog open_file_dialog = new OpenFileDialog();

            open_file_dialog.Filter = "Object files (*.obj; *.OBJ)|*.obj;*.OBJ";
            if (open_file_dialog.ShowDialog() == true)
            {
                file_path = open_file_dialog.FileName;
            }

            // if no path then return
            if (string.IsNullOrEmpty(file_path))
            {
                return;
            }

            // try to get the model data
            UVObjData data = null;

            try
            {
                data = ObjHandler.GetData(file_path);
            }
            catch { return; }

            // if data is null return
            if (data == null)
            {
                return;
            }

            // get the uv verts and triangles
            Vector64[] pts  = data.uvs.Select(p => new Vector64(p.X, p.Y)).ToArray();
            int[]      tris = data.tris;

            // get the canvas container
            Rect64 container = new Rect64(0, canvas_main.Height, canvas_main.Width, 0);

            // create a new nester object and populate its data
            _nester  = new Nester();
            _handles = _nester.AddUVPolygons(pts, tris, 0.0);

            // set the nesting commands
            _nester.ClearCommandBuffer();
            _nester.ResetTransformLib();

            canvas_main.Children.Clear();

            _nester.CMD_OptimalRotation(null);

            _nester.CMD_Nest(null, NFPQUALITY.Full);

            _nester.CMD_Refit(container, false, null);

            // change the button text and execute work
            button_play.Content = STOP;

            _nester.ExecuteCommandBuffer(NesterProgress, NesterComplete);
        }