Exemplo n.º 1
0
        private void Exporter_Click(object sender, RoutedEventArgs e)
        {
            if (this.dataMesh == null)
            {
                MessageBox.Show("Valid Mesh not found!");
                return;
            }
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.Title      = "Save the Scene to Wavefront Obj format";
            dlg.DefaultExt = ".obj";
            dlg.Filter     = "PNG documents (.obj)|*.obj";
            dlg.FileName   = string.Format("Type '{0}' -- Name '{1}' (Vertical scaling factor {2})",
                                           this._selectedData.SelectedSpatialData.Type.ToString(), this._selectedData.SelectedSpatialData.Name, this.scaledZ.Text);
            Nullable <bool> result      = dlg.ShowDialog(this);
            string          fileAddress = "";

            if (result == true)
            {
                fileAddress = dlg.FileName;
            }
            else
            {
                return;
            }
            SpatialDataToMesh.SaveToWavefrontObj(this.dataMeshModel, fileAddress);
        }
Exemplo n.º 2
0
        private void chooseData_Click(object sender, RoutedEventArgs e)
        {
            this._selectedData       = new SelectDataFor3DVisualization(this._host);
            this._selectedData.Owner = this;
            this._selectedData.ShowDialog();
            if (this._selectedData.SelectedSpatialData == null)
            {
                return;
            }
            if (this.dataMeshModel != null)
            {
                this.AllModels.Children.Remove(this.dataMeshModel);
                this.dataMeshModel         = null;
                this.ZScaler.ValueChanged -= ZScaler_ValueChanged;
            }

            //load the mesh
            try
            {
                SpatialDataToMesh meshBuilder = new SpatialDataToMesh(this._host, this._selectedData);
                this.dataMesh              = meshBuilder.Mesh;
                this.dataMeshModel         = new GeometryModel3D(this.dataMesh, this.dataMeshMaterial);
                dataMeshModel.BackMaterial = new DiffuseMaterial(Brushes.DarkGray);
                this.UpdateMaterial();
                this.AllModels.Children.Add(this.dataMeshModel);
                this._transform3DGroup.Children.Clear();
                this._scaleTransform3D = new ScaleTransform3D(1, 1, meshBuilder.SuggestedZScale, this.objectCenter.X, this.objectCenter.Y, 0);
                this._transform3DGroup.Children.Add(this._scaleTransform3D);
                this._transform3DGroup.Children.Add(this._translateTransform3D);

                this.dataMeshModel.Transform = this._transform3DGroup;
                this.ZScaler.Minimum         = 0;
                this.ZScaler.Maximum         = 5 * meshBuilder.SuggestedZScale;
                this.ZScaler.Value           = meshBuilder.SuggestedZScale;
                this.ZScaler.ValueChanged   += new RoutedPropertyChangedEventHandler <double>(ZScaler_ValueChanged);

                scaledZ.Text           = this.ZScaler.Value.ToString();
                this.dataType.Text     = this._selectedData.SelectedSpatialData.Type.ToString();
                this.dataName.Text     = this._selectedData.SelectedSpatialData.Name;
                this.translationZ.Text = meshBuilder.MinValue.ToString();
                this.minVal.Text       = meshBuilder.MinValue.ToString();
                this.maxVal.Text       = meshBuilder.MaxValue.ToString();

                this.objectCenter.Z = (meshBuilder.MaxValue - meshBuilder.MinValue) * meshBuilder.SuggestedZScale / 2;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }