问题:

	//读取模型文件
	vtkSmartPointer<vtkSTLReader> obj = vtkSmartPointer<vtkSTLReader>::New();
	obj->SetFileName("D:\ct\20201102113826651_3d\pelvis.stl");

在VTK项目运行读取模型文件的代码时,出现以下问题:

ERROR: In vtkSTLReader.cxx, line 106
vtkSTLReader (000001DA1CF5EDD0): File D:ct?01102113826651_3dpelvis.stl not found

ERROR: In vtkExecutive.cxx, line 741
vtkCompositeDataPipeline (000001DA1CF925B0): Algorithm vtkSTLReader (000001DA1CF5EDD0) returned failure for request: vtkInformation (000001DA1CF57980)
  Debug: Off
  Modified Time: 1511
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA
  FORWARD_DIRECTION: 0
  ALGORITHM_AFTER_FORWARD: 1
  FROM_OUTPUT_PORT: 0

VTK读取文件时显示无法找到(如.stl not found)解决方案-LMLPHP

 

解决方案:将代码里的地址改为双斜杠,即可正常读取文件。

 

	//读取模型文件
	vtkSmartPointer<vtkSTLReader> obj = vtkSmartPointer<vtkSTLReader>::New();
	obj->SetFileName("D:\\ct\\20201102113826651_3d\\pelvis.stl");

 VTK读取文件时显示无法找到(如.stl not found)解决方案-LMLPHP

01-19 15:43