|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Threading.Tasks;
namespace DelaunayWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// set up the trackball
var trackball = new Wpf3DTools.Trackball();
trackball.EventSource = background;
viewport.Camera.Transform = trackball.Transform;
light.Transform = trackball.RotateTransform;
}
RandomTriangulation triangulation;
void Create()
{
if (triangulation != null) viewport.Children.Remove(triangulation);
int count;
if (!int.TryParse(numPoints.Text, out count) && count < 10) count = 100;
triangulation = RandomTriangulation.Create(count, 10);
viewport.Children.Add(triangulation);
infoText.Text = string.Format("{0} tetrahedrons", triangulation.Count);
}
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
Create();
}
private void GenerateButton_Click(object sender, RoutedEventArgs e)
{
Create();
}
private void ExpandButton_Click(object sender, RoutedEventArgs e)
{
triangulation.Expand();
}
private void ExpandRandomButton_Click(object sender, RoutedEventArgs e)
{
triangulation.ExpandRandom();
}
private void CollapseButton_Click(object sender, RoutedEventArgs e)
{
triangulation.Collapse();
}
private void PulseButton_Click(object sender, RoutedEventArgs e)
{
triangulation.Pulse();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have a master's degree in computer science and currently I am a PhD student. My main research interest is in computational chemistry (sort of), although I am more interested in the computational than the chemical aspects of the field.