源码在这里,放在一个函数里,把actor传出去,有没有大佬救我
![[泪]](/static/emoticons/u6cea.png)
vtkSmartPointer<vtkMarchingCubes> marchingcube = vtkSmartPointer<vtkMarchingCubes>::New();
marchingcube->SetInputData(mask->imageData);//头文件包含
marchingcube->ComputeNormalsOn();
marchingcube->SetValue(0, 1);
marchingcube->ReleaseDataFlagOn();
//marchingcube->Update();
//this->calculateProgressBar->setValue(10);
this->calculateProgressBar->setValue(10);
this->tipLabel->setText("smooth model...");
vtkSmartPointer<vtkWindowedSincPolyDataFilter> smooth = vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New(); //使图像更加光滑
smooth->SetInputConnection(marchingcube->GetOutputPort());
smooth->SetNumberOfIterations(300);
smooth->ReleaseDataFlagOn();
//smooth->Update();
this->calculateProgressBar->setValue(20);
this->tipLabel->setText("optimization model...");
vtkSmartPointer<vtkQuadricDecimation> deci = vtkSmartPointer<vtkQuadricDecimation>::New();
deci->SetInputConnection(smooth->GetOutputPort());
int radioId = this->radioButtonGroup->checkedId();
if(radioId ==0)
deci->SetTargetReduction(0.9);
else if(radioId==1)
deci->SetTargetReduction(0.6);
else if(radioId==2)
deci->SetTargetReduction(0.3);
else if(radioId==3)
deci->SetTargetReduction(0);
deci->ReleaseDataFlagOn();
//deci->Update();
this->calculateProgressBar->setValue(30);
this->tipLabel->setText("calculate normals...");
vtkSmartPointer<vtkPolyDataNormals> skinNormals = vtkSmartPointer<vtkPolyDataNormals>::New();//绘制法线
skinNormals->SetInputConnection(deci->GetOutputPort());
skinNormals->ReleaseDataFlagOn();
//skinNormals->Update();
this->calculateProgressBar->setValue(40);
this->tipLabel->setText("stripper model...");
vtkSmartPointer<vtkStripper>skinStripper = vtkSmartPointer<vtkStripper>::New(); //三角带连接
skinStripper->SetInputConnection(skinNormals->GetOutputPort());
skinStripper->ReleaseDataFlagOn();
//skinStripper->Update();
this->calculateProgressBar->setValue(50);
this->tipLabel->setText("mapper...");
vtkSmartPointer<vtkPolyDataMapper> skinMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
skinMapper->SetInputConnection(skinStripper->GetOutputPort());
skinMapper->ReleaseDataFlagOn();
//skinMapper->Update();
//skinMapper->ScalarVisibilityOff();
this->calculateProgressBar->setValue(60);
this->tipLabel->setText("create obj...");
vtkSmartPointer<vtkActor> objActor =
vtkSmartPointer<vtkActor>::New();
objActor->SetMapper(skinMapper);
//创建Object对象存入管理对象
this->calculateProgressBar->setValue(70);
this->tipLabel->setText("save obj...");
std::shared_ptr<Object> newObj = std::make_shared<Object>(mask->name,objActor);
this->objPtrQMapPtr->insert(newObj->name, newObj);
//显示在第四个窗口上
this->calculateProgressBar->setValue(80);
this->tipLabel->setText("show obj...");
this->ren_3dViewer->AddActor(objActor);
this->ren_3dViewer->Modified();
this->widget_3dViewer->GetRenderWindow()->Render();