private HashSet <string> DiagnoseResult(StorageFileNames fileNames) { HashSet <string> typeList = new HashSet <string>(); Scene scene = OpenInput(fileNames); //create scene diagnoser var sd = SceneDiagnoser.LoadFromScene(scene); //print the problems we just found if (sd.Issues.Length == 0) { //Console.WriteLine("No errors found for this scene"); } else { //Console.WriteLine($"{sd.Issues.Length} errors found for this scene:"); foreach (var issue in sd.Issues) { typeList.Add($"{issue.IssueType}"); //Console.WriteLine($"\t{issue.IssueType}"); } } using (var fs = new FileStream(fileNames[AnalyzeResult], FileMode.Create)) { sd.SaveToStream(fs); } //save the mesh and delta mesh for client side review: Scene review = new Scene(); //review scene has the merged mesh with a default material(grey color) review.RootNode.CreateChildNode(sd.Mesh).Material = new LambertMaterial() { DiffuseColor = new Vector3(0.5, 0.5, 0.5) }; //delta meshes that points to the problem area, and highlighted in red color using red material var errorMaterial = new LambertMaterial() { DiffuseColor = new Vector3(1, 0, 0) }; foreach (var issue in sd.Issues) { if (issue.DeltaMesh != null) { var node = review.RootNode.CreateChildNode(issue.IssueType.ToString(), issue.DeltaMesh); node.Material = errorMaterial; } } review.Save(fileNames[ReviewFile], FileFormat.Aspose3DWeb); return(typeList); }
public IActionResult DownloadResult(string type, string resultType, string sessionId) { var outputFormat = GetFileFormat(type); if (outputFormat == null) { return(NotFound()); } var fileNames = _storageRepository.ParseNames(sessionId); if (fileNames == null || !FileIO.Exists(fileNames[AnalyzeResult])) { return(NotFound()); } return(OpRepair.Measure <IActionResult>(fileNames.Id, () => { if (!string.IsNullOrEmpty(resultType)) { var issuesToRepair = ParseIssues(resultType); using (var fs = FileIO.OpenRead(fileNames[AnalyzeResult])) { SceneDiagnoser sd; try { sd = SceneDiagnoser.LoadFromStream(fs); } catch (Exception e) { _logger.LogError(e, "Failed to restore the diagnosing result, session id = {0}", sessionId); OperationFailed(e); return this.Problem("Internal server error"); } Mesh result; try { result = sd.Repair(issuesToRepair); } catch (Exception e) { _logger.LogError(e, "Failed to repair the input mesh, session id = {0}", sessionId); OperationFailed(e); return this.Problem("Internal server error"); } try { Scene scene = new Scene(result); scene.Save(fileNames[RepairedFile], outputFormat); } catch (Exception e) { _logger.LogError(e, "Failed to save the repaired result, session id = {0}", sessionId); OperationFailed(e); return this.Problem("Internal server error"); } } } else { //No issues were selected, just make a direct conversion. try { Scene scene = OpenInput(fileNames); scene.Save(fileNames[RepairedFile], outputFormat); } catch (Exception e) { _logger.LogError(e, "Failed to save to the required type, session id = {0}", sessionId); OperationFailed(e); return this.Problem("Internal server error"); } } if (!FileIO.Exists(fileNames[RepairedFile])) { return NotFound(); } try { var path = fileNames[RepairedFile]; string downfile = Guid.NewGuid().ToString(); return PhysicalFile(path, "application/octet-stream", downfile + "." + type); } catch (Exception e) { OperationFailed(e); return NotFound(); } })); }