我调试了一下发现这个程序异常终止在vtkexporter的writer()上,但当我将vtkQuadricDecimation换成vtkDecimationPro就正常运行:
vtkSmartPointer<vtkDICOMImageReader>Reader = vtkSmartPointer<vtkDICOMImageReader>::New();
Reader->SetDataByteOrderToLittleEndian();
Reader->SetDirectoryName(ctFile.c_str());
Reader->SetDataSpacing(3.2, 3.2, 1.5);
Reader->Update()
vtkSmartPointer<vtkMarchingCubes>marchingcube = vtkSmartPointer<vtkMarchingCubes>::New();
marchingcube->SetInputConnection(Reader->GetOutputPort());
marchingcube->SetValue(0, ctValue);
vtkSmartPointer<vtkQuadricDecimation> deci = vtkSmartPointer<vtkQuadricDecimation>::New(); //替换成vtkDecimationPro算法就正常运行: deci->SetInputConnection(marchingcube->GetOutputPort());
deci->SetTargetReduction(reduct);
vtkSmartPointer<vtkSmoothPolyDataFilter> smooth = vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
smooth->SetInputConnection(deci->GetOutputPort());
smooth->SetNumberOfIterations(100);
vtkSmartPointer<vtkPolyDataNormals> skinNormals = vtkSmartPointer<vtkPolyDataNormals>::New();//绘制法线
skinNormals->SetInputConnection(smooth->GetOutputPort());
vtkSmartPointer<vtkStripper>skinStripper = vtkSmartPointer<vtkStripper>::New(); //三角带连接
skinStripper->SetInputConnection(skinNormals->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> skinMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
skinMapper->SetInputConnection(skinStripper->GetOutputPort());
skinMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> skin =
vtkSmartPointer<vtkActor>::New();
skin->SetMapper(skinMapper);
vtkSmartPointer<vtkRenderer> aRenderer = vtkSmartPointer<vtkRenderer>::New();
aRenderer->AddActor(skin);
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(aRenderer);
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer<vtkOBJExporter> porter = vtkSmartPointer<vtkOBJExporter>::New();
porter->SetFilePrefix(outputFile.c_str());
porter->SetInput(renWin);
porter->Write() //在这里异常终止
iren->Initialize();
iren->Start();
萌新刚学,啥也不懂,求指教