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); }
private void AdjustSkin(object sender, RoutedEventArgs e) { if (_currentTextureType != TextureTypeEnum.FourCorners) { return; } var adjustSkinWindow = new AdjustSkin(_xCoodRangesFor4ImageTexture, _userXCoodRangesFor4ImageTexture); var result = adjustSkinWindow.ShowDialog(); if (!result.HasValue || !result.Value || adjustSkinWindow.ReturnValue == null) { return; } var returnValue = adjustSkinWindow.ReturnValue; if (_4CornerTextureAndBitmap == null) { return; } var indices = MainProcessor.GetIndicesFor4CornerTexture(_createMeshContract.ClickInputs.Angles); if (indices == null) { MessageBox.Show("Error in generating textures: Cannot identify photos for four corners.\nPlease check if photos are available for a full 360 degree view."); return; } var quickProcessingWindow = new QuickProcessingWindowHelper(ParentGrid); var add4CornerTexture = MainProcessor.GetAddTextureInfoForIndexCollection(_createMeshContract, indices); if (add4CornerTexture.ImageInfos != null) { SetUserSuppliedLimit(0, add4CornerTexture, returnValue.FrontPhotoTexCoodValueLimits); SetUserSuppliedLimit(1, add4CornerTexture, returnValue.RightPhotoTexCoodValueLimits); SetUserSuppliedLimit(2, add4CornerTexture, returnValue.BackPhotoTexCoodValueLimits); SetUserSuppliedLimit(3, add4CornerTexture, returnValue.LeftPhotoTexCoodValueLimits); } _userXCoodRangesFor4ImageTexture = returnValue; _4CornerTextureAndBitmap = TextureProcessor.GenerateTexture(add4CornerTexture, (MeshGeometry3D)_currentModel.Geometry, ""); quickProcessingWindow.Close(); ApplyTextureOnCurrentModel(_4CornerTextureAndBitmap); }
private void Generate2CornerTexture() { if (_2CornerTextureAndBitmap != null) { return; } var quickProcessingWindow = new QuickProcessingWindowHelper(ParentGrid); var addTextureInfoForFrontAndBack = MainProcessor.GetAddTextureInfoForFrontAndBackImage(_createMeshContract); if (addTextureInfoForFrontAndBack == null) { MessageBox.Show("Error in generating textures: Cannot identify front and back photos.\nPlease check if photos are available from front to back."); quickProcessingWindow.Close(); return; } _2CornerTextureAndBitmap = TextureProcessor.GenerateTexture(addTextureInfoForFrontAndBack, (MeshGeometry3D)_currentModel.Geometry, ""); quickProcessingWindow.Close(); }
private void Generate8CornerTexture() { if (_8CornerTextureAndBitmap != null) { return; } var indices = MainProcessor.GetIndicesFor8CornerTexture(_createMeshContract.ClickInputs.Angles); if (indices == null) { MessageBox.Show("Error in generating textures: Cannot identify photos for eight corners.\nPlease check if photos are available for a full 360 degree view."); return; } var quickProcessingWindow = new QuickProcessingWindowHelper(ParentGrid); var add8CornerTexture = MainProcessor.GetAddTextureInfoForIndexCollection(_createMeshContract, indices); _8CornerTextureAndBitmap = TextureProcessor.GenerateTexture(add8CornerTexture, (MeshGeometry3D)_currentModel.Geometry, ""); quickProcessingWindow.Close(); if (indices.Length < 8) { MessageBox.Show(string.Format("Texture generated for {0} images as only {0} out of 8 images could be identified.", indices.Length)); } }
private void Return(object sender, RoutedEventArgs routedEventArgs) { if (_minPixelsForBaseDisc == null) { MessageBox.Show("Please mark the area in the image that contains just the base disc."); return; } else if (_minPixelsForBaseDisc < 10) { MessageBox.Show("The height of the base disc should at least be 10 pixels."); return; } var quickProcessingWindow = new QuickProcessingWindowHelper(ParentCanvas); var processor = new AutoConfigureImgPoints.Processor(); var markerPrcoessingParams = new MarkerProcessingParams { MarkerColorVariationPercent = 10, MarkerWidthPercent = 5, MaximumMarkerCount = 10 }; var @params = new AutoConfigureImgPointsParams { MarkerProcessingParams = markerPrcoessingParams, BackgroundColor = _backgroundColor, BackgroundStrippingParams = _backgroundStrippingParams, MinPixelsForBaseDisc = _minPixelsForBaseDisc.Value, MinPixelsForBaseDiscEndOfEdge = 10, ResizeHeight = 500, ResizeWidth = 500 }; var clickPositions = processor.GetClickPositionsForImgFolder(_folderPath, @params); var gotResults = clickPositions != null && clickPositions.Count > 0 && clickPositions.Any(x => (x.ClickPositionListForImages != null && x.ClickPositionListForImages.Count > 0)); if (!gotResults) { var statusMessages = new List <string> { "Autoconfigure was unsuccessful. No image positions could be determined.", "Please click on the 'Requirements' button to check how to take photos to support autoconfigure.", "Press the cancel button to go back to entering the positions manually." }; quickProcessingWindow.Close(); var messageBox = new HelpMessageBox(statusMessages, null); messageBox.ShowDialog(); return; } var fileCount = GetImageFilesHelper.GetImageFilesFromLocation(_folderPath); var requiredCount = GetRequiredClickInputsCount(fileCount); var identifiedCount = 0; var innerStatusMessages = new List <string>(); for (var ctr = 0; ctr < clickPositions.Count; ctr++) { var clickInput = clickPositions[ctr]; var count = clickInput != null && clickInput.ClickPositionListForImages != null? clickInput.ClickPositionListForImages.Count : 0; identifiedCount += count; if (ctr == 0) { innerStatusMessages.Add(string.Format("{0}: {1} identified out of required 5.", clickInput == null? (ctr + 1).ToString() : clickInput.ImageName, count)); } else { innerStatusMessages.Add(string.Format("{0}: {1} identified out of required 4.", clickInput == null ? (ctr + 1).ToString() : clickInput.ImageName, count)); } } quickProcessingWindow.Close(); if (identifiedCount == requiredCount) { var statusMessages = new List <string> { "AutoConfigure Successful!", string.Format("All required {0} click positions were identified.", requiredCount), "We will now display all the click positions for your review.." }; var messageBox = new HelpMessageBox(statusMessages, null); messageBox.ShowDialog(); } else { var statusMessages = new List <string> { "AutoConfigure was partially successful in identifying the click positions.", string.Format("{0} out of total of {1} positions could be identified.", identifiedCount, requiredCount), "Below is a break down of the identified positions.", "Click close to to review the identified positions and fill in the missed ones..." }; var messageBox = new HelpMessageBox(statusMessages, innerStatusMessages); messageBox.ShowDialog(); } if (AutoConfigured != null) { AutoConfigured(this, new AutoConfigureSettingsEventArgs { ClickInputs = new ClickInputs { ImageClickInputDetailsList = clickPositions, Angles = null } }); } }