private bool SaveMesh(PXCM3DScan scan) { form.Invoke(new Action(() => form.HideTrackingAlert())); form.Invoke(new Action(() => form.HideRangeAlerts())); bool sts = true; form.UpdateStatus("Saving..."); // wait for filename to be filled string filename = null; do { filename = form.GetMeshFileName(); System.Threading.Thread.Sleep(100); } while (filename == null); if (filename != "c") { form.UpdateStatus("Saving " + filename + "..."); string mesh_format = filename.Substring(filename.Length - 3); pxcmStatus res = pxcmStatus.PXCM_STATUS_NO_ERROR; if (mesh_format.ToLower() == "obj") { res = scan.Reconstruct(PXCM3DScan.FileFormat.OBJ, filename); } else if (mesh_format.ToLower() == "ply") { res = scan.Reconstruct(PXCM3DScan.FileFormat.PLY, filename); } else if (mesh_format.ToLower() == "stl") { res = scan.Reconstruct(PXCM3DScan.FileFormat.STL, filename); } if (res < pxcmStatus.PXCM_STATUS_NO_ERROR) { if (res == pxcmStatus.PXCM_STATUS_FILE_WRITE_FAILED) { form.UpdateStatus("Error: Write failed to " + filename + " Exiting..."); } else { form.UpdateStatus("Reconstruct() returned " + res); } sts = false; } else { form.UpdateStatus(filename + " saved."); sts = false; if (mesh_format.ToLower() == "obj") // Viewer only supports obj format in this release { if (!form.isTextureSelected()) // Viewer only supports non-textured meshes in this release { // Generate an html version of the obj file String htmlFile = filename + ".html"; if (!GenerateHtmlFromObj(filename, htmlFile)) { // Load the resulting html file GC.Collect(); // Free up as much system RAM as possible before loading the html file. System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; process.StartInfo.FileName = (string)htmlFile; process.Start(); process.Dispose(); } } } } } else { form.UpdateStatus("Canceled"); } form.UseWaitCursor = false; form.reconstruct_requested = false; form.ReleaseMeshFileName(); return(sts); }