Exemplo n.º 1
0
        private void buttonResize_Click(object sender, EventArgs e)
        {
            if (_waveFront == null)
            {
                MessageBox.Show("You must load a OBJ first");
                return;
            }
            FormResize fr = new FormResize();

            // recover backup
            _waveFront.V = objSrv.CloneList(_waveFront.VBackup);
            objSrv.ObjGetStat(_waveFront);

            fr.WaveFront = _waveFront;
            fr.rescale   = _rescale;
            fr.ShowDialog();

            if (!fr.ok)
            {
                _rescale = new Rescale(); // reset rescale
                return;                   // operation cancelled.
            }

            ShowMsg("Calculating");

            // rescale
            var newList = new List <Vector>();

            for (var i = 0; i < _waveFront.V.Count; i++)
            {
                var v = _waveFront.V[i];
                newList.Add(_rescale.Modify(v));
            }

            _waveFront.V = newList; // changed the list
            ShowMsg("Drawing...");
            objSrv.ObjGetStat(_waveFront);
            DrawStat();
            var scale = objSrv.Scale(_waveFront.Max, _waveFront.Min, panel1.Width, panel1.Height, 0);
            int axis  = comboBox1.SelectedIndex;

            _bitmap = objDraw.Draw(_waveFront, panel1.Width, panel1.Height, scale, axis);
            panel1.Refresh();
            HideMsg();
            fr.Close();
        }
Exemplo n.º 2
0
        private string AddVector(string[] line, Rescale r)
        {
            if (line.Length < 4)
            {
                //error, vector incorrectly defined.
                throw new Exception("Error in vector");
            }


            Vector vector = new Vector(double.Parse(line[1], culture)
                                       , double.Parse(line[2], culture)
                                       , double.Parse(line[3], culture));

            vector = r.Modify(vector);
            return("v " + vector.X.ToString("0.########", culture) + " "
                   + vector.Y.ToString("0.########", culture) + " "
                   + vector.Z.ToString("0.########", culture));
        }