コード例 #1
0
 private void View_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Right || e.KeyCode == Keys.Left)
     {
         this.onPatch = true;
         TetMesh      mesh        = GlobalData.Instance.TetMesh;
         DataGridView dgv         = (DataGridView)sender;
         int          columnIndex = 0;
         foreach (DataGridViewColumn column in dgv.Columns)
         {
             if (column.Name.EndsWith("Flag"))
             {
                 columnIndex = column.Index;
             }
         }
         foreach (DataGridViewRow row in dgv.Rows)
         {
             if (row.Selected)
             {
                 DataGridViewCell cell = row.Cells[columnIndex];
                 if (e.KeyCode == Keys.Right)
                 {
                     cell.Value = (int)cell.Value + 1;
                 }
                 else if (e.KeyCode == Keys.Left)
                 {
                     cell.Value = (int)cell.Value > 0 ? (int)cell.Value - 1 : 0;
                 }
             }
         }
         this.onPatch = false;
         mesh.ComputeSelectedNormal();
         GlobalData.Instance.OnChanged(new EventArgs());
     }
 }
コード例 #2
0
        void ChangePlane()
        {
            TetMesh mesh = GlobalData.Instance.TetMesh;

            foreach (var tet in mesh.Tetras)
            {
                PlaneIntersectionType intersect = TetMeshUtil.Intersect(this.plane, tet);
                if (intersect == PlaneIntersectionType.Front ||
                    (intersecting && intersect == PlaneIntersectionType.Intersecting))
                {
                    tet.Flag = 1;
                }
                else
                {
                    tet.Flag = 0;
                }
            }
            mesh.ComputeSelectedNormal();
            GlobalData.Instance.OnChanged(EventArgs.Empty);
        }
コード例 #3
0
        private void CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (!this.onLoad)
            {
                TetMesh            mesh   = GlobalData.Instance.TetMesh;
                DataGridView       dgv    = (DataGridView)sender;
                DataGridViewColumn column = dgv.Columns[e.ColumnIndex];
                DataGridViewRow    row    = dgv.Rows[e.RowIndex];
                int index = (int)row.Cells[0].Value;
                switch (column.Name)
                {
                case "VFlag":
                    mesh.Vertices[index].Flag = Convert.ToInt32(row.Cells[e.ColumnIndex].Value);
                    break;

                case "EFlag":
                    mesh.Edges[index].Flag = Convert.ToInt32(row.Cells[e.ColumnIndex].Value);
                    break;

                case "FFlag":
                    mesh.Faces[index].Flag = Convert.ToInt32(row.Cells[e.ColumnIndex].Value);
                    break;

                case "TFlag":
                    mesh.Tetras[index].Flag = Convert.ToInt32(row.Cells[e.ColumnIndex].Value);
                    break;

                default:
                    break;
                }
                if (!this.onPatch)
                {
                    mesh.ComputeSelectedNormal();
                    GlobalData.Instance.OnChanged(new EventArgs());
                }
            }
        }