public ModelContainer(ModelMeshAndPositionNeighbors modelMeshAndPositionNeighbors, CreateMeshContract createMeshContract) { InitializeComponent(); _modelMeshAndPositionNeighbors = modelMeshAndPositionNeighbors; _createMeshContract = createMeshContract; //smoothen two times by default const int defaultSmoothening = 2; var newMesh = GetNewModifiableMeshWithNoSmoothing(); var newModel = SmoothenProcessor.SmoothenMesh(defaultSmoothening, _modelMeshAndPositionNeighbors.PositionNeighbors, newMesh); _currentSmootheningCount = defaultSmoothening; SetSmootheningCountDisplayToCurrent(); _currentModel = new GeometryModel3D { Geometry = newModel, BackMaterial = new DiffuseMaterial(Brushes.DarkOliveGreen) }; SetNoTextureDisplay(); this.Loaded += OnLoad; }
private void Smoothen(object sender, RoutedEventArgs e) { if (IsDisplayTextEqualToCurrentSmoothingValue()) { return; } var quickProcessingWindow = new QuickProcessingWindowHelper(ParentGrid); var requestedSmoothenCount = Convert.ToInt32(SmootheningCountDisplay.Text); MeshGeometry3D newMesh = null; if (requestedSmoothenCount == 0) { newMesh = GetNewModifiableMeshWithNoSmoothing(); _currentModel.Geometry = newMesh; } else if (requestedSmoothenCount < _currentSmootheningCount) { newMesh = GetNewModifiableMeshWithNoSmoothing(); var newModel = SmoothenProcessor.SmoothenMesh(requestedSmoothenCount, _modelMeshAndPositionNeighbors.PositionNeighbors, newMesh); _currentModel.Geometry = newModel; } else if (requestedSmoothenCount > _currentSmootheningCount) { newMesh = (MeshGeometry3D)_currentModel.Geometry; var remainingCt = requestedSmoothenCount - _currentSmootheningCount; var newModel = SmoothenProcessor.SmoothenMesh(remainingCt, _modelMeshAndPositionNeighbors.PositionNeighbors, newMesh); _currentModel.Geometry = newModel; } _currentModel.Geometry = newMesh; _currentSmootheningCount = requestedSmoothenCount; UpdateModelDisplay(_currentModel); SetSmootheningCountDisplayToCurrent(); quickProcessingWindow.Close(); CurrentSmoothenCountMsg.Text = string.Format("Model is smoothened {0} times", _currentSmootheningCount); }