我编写了一个简单的 Windows 窗体应用程序,它使用 ReconstructMe SDK,一个 3D 对象重建库。当我单击一个按钮时,程序会打开一个返回文件路径的文件选择器。然后,它应该加载 .obj 文件以打开现有的 3D 重建。但是,当我选择文件来创建表面时,它不会加载,并且会出现以下输出:
Error: ..\..\source\lib_reconstructme\src\surface\io.cpp(133): Throw in function void __cdecl LibReconstructMe::load_surface_osg(const class boost::filesystem::path &,class OpenMesh::TriMesh_ArrayKernelT<struct OpenMesh::DefaultTraits> &)
Dynamic exception type: class boost::exception_detail::clone_impl<class LibFundament::robvis_error>
std::exception::what: load_surface_osg not implemented
[struct LibFundament::tag_robvis_message *] = load_surface_osg not implemented
这是按钮的点击事件:
private: System::Void viewButton_Click(System::Object^ sender, System::EventArgs^ e) {
std::string filename;
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK){
filename = marshal_as< std::string >(openFileDialog1->FileName);
}
ReconstructionView(filename);
}
}
这是我尝试加载文件的功能:
reme_error_t ReconstructionView(string fileName){
// Create a new context
reme_context_t context;
reme_context_create(&context);
reme_context_set_log_callback(context, reme_default_log_callback, 0);
// Create and set new options
reme_options_t option;
reme_options_create(context, &option);
// Bind the reconstruction options.
reme_context_bind_reconstruction_options(context, option);
// Increase resolution in all dimensions
reme_options_set_int(context, option, "device_id", 2);
// Compile for OpenCL device using the upper options
reme_context_compile(context);
// Create a new surface
reme_surface_t surface;
reme_surface_create(context, &surface);
// Load surface from file
if(!REME_SUCCESS(reme_surface_load_from_file(context, surface, fileName.c_str()))){ //error
cout << "Failed to load file.\n";
reme_surface_destroy(context, &surface);
// Make sure to release all memory acquired
reme_context_destroy(&context);
return REME_ERROR_UNSPECIFIED;
}
// Visualize resulting surface
reme_viewer_t viewer_surface;
reme_viewer_create_surface(context, surface, ("ReconstructMe SDK: " + fileName).c_str(), &viewer_surface);
reme_viewer_wait(context, viewer_surface);
reme_surface_destroy(context, &surface);
// Print pending errors
reme_context_print_errors(context);
// Make sure to release all memory acquired
reme_context_destroy(&context);
return REME_ERROR_SUCCESS;
}
即使我尝试加载不存在的文件,也会出现错误。例如,if(!REME_SUCCESS(reme_surface_load_from_file(context, surface, "example.obj")))
即使文件不存在,此行也会生成相同的错误。我不知道问题出在文件选择器对话框的返回值上,还是出在导致错误的函数上。有人能帮我吗?