#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkMarchingCubes.h>
#include <vtkPoints.h>
#include <vtkStructuredPointsReader.h>
#include <vtkLine.h>
#include <vtkPolyDataWriter.h>
#include <vtkPolyDataReader.h>
#include <vtkPNGReader.h>
#include <vtkImageViewer2.h>
#include <vtkJPEGWriter.h>
#include <vtkJPEGReader.h>
#include <vtkStringArray.h>
#include <vtkInteractorStyleImage.h>
#include <vtkVolume16Reader.h>
#include <vtkStripper.h>
#include <vtkCamera.h>
#include <vtkProperty.h>
#include <vtkDICOMImageReader.h>
#include <vtkMarchingCubes.h>
#include <vtkAutoInit.h>
#include <vtkPolyDataNormals.h>
#include <vtkContourFilter.h>
#include <vtkOutlineFilter.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);
#define vtkRenderingCore_AUTOINIT 4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL2,vtkRenderingOpenGL2)
#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL2)
int main(int argc, char* argv[])
{
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renWin->AddRenderer(renderer);
iren->SetRenderWindow(renWin);
vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetDirectoryName("D:/VTK/DICOM/S67950/S4010");
reader->SetDataSpacing(3.2, 3.2, 1.5);
vtkSmartPointer<vtkContourFilter> extractor = vtkSmartPointer<vtkContourFilter>::New();
extractor->SetInputConnection(reader->GetOutputPort());
extractor->SetValue(0, 500);
vtkSmartPointer<vtkPolyDataNormals> skinNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
skinNormals->SetInputConnection(extractor->GetOutputPort());
skinNormals->SetFeatureAngle(60.0);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(extractor->GetOutputPort());
mapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkOutlineFilter> outlineData = vtkSmartPointer<vtkOutlineFilter>::New();
outlineData->SetInputConnection(reader->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> mapOutline = vtkSmartPointer<vtkPolyDataMapper>::New();
mapOutline->SetInputConnection(outlineData->GetOutputPort());
vtkSmartPointer<vtkActor> outline = vtkSmartPointer<vtkActor>::New();
outline->SetMapper(mapOutline);
outline->GetProperty()->SetColor(0, 0, 0);
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
renderer->AddActor(outline);
renderer->AddActor(actor);
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
camera->Dolly(1.5);
renderer->SetBackground(1, 1, 1);
renWin->SetSize(600, 500);
renderer->ResetCameraClippingRange();
iren->Initialize();
iren->Start();
return 0;
}
vtk体绘制三维重建
最新推荐文章于 2023-05-16 11:34:22 发布