vtkActor置顶显示

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr Var = vtkSPtr::New();

int main()
{
    vtkSPtrNew(sphere, vtkSphereSource);
    sphere->SetCenter(0, 0, 0);
    sphere->SetRadius(1);
    sphere->Update();


    vtkSPtrNew(sphereMapper, vtkPolyDataMapper);
    const double units0 = -66000;
    sphereMapper->SetInputData(sphere->GetOutput());
    sphereMapper->SetResolveCoincidentTopologyToPolygonOffset();
    sphereMapper->SetRelativeCoincidentTopologyLineOffsetParameters(0, units0);
    sphereMapper->SetRelativeCoincidentTopologyPolygonOffsetParameters(0, units0);
    sphereMapper->SetRelativeCoincidentTopologyPointOffsetParameter(units0);

    vtkSPtrNew(sphereActor, vtkActor);
    sphereActor->SetMapper(sphereMapper);
    sphereActor->GetProperty()->SetColor(1, 0, 0);

    vtkSPtrNew(cone, vtkConeSource);
    cone->SetRadius(2);
    cone->SetHeight(4);
    cone->Update();

    vtkSPtrNew(coneMapper, vtkPolyDataMapper);
    coneMapper->SetInputData(cone->GetOutput());
    vtkSPtrNew(coneActor, vtkActor);
    coneActor->SetMapper(coneMapper);

    vtkSPtrNew(renderer, vtkRenderer);
    renderer->AddActor(coneActor);
    renderer->AddActor(sphereActor);
    renderer->SetBackground(0, 0, 0);

    vtkSPtrNew(renderWindow, vtkRenderWindow);
    renderWindow->AddRenderer(renderer);

    vtkSPtrNew(renderWindowInteractor, vtkRenderWindowInteractor);
    renderWindowInteractor->SetRenderWindow(renderWindow);

    renderer->ResetCamera();
    renderWindow->Render();
    renderWindowInteractor->Start();
    return 0;
}

参考

你可能感兴趣的:(vtk)