本文整理汇总了C++中vtkSmartPointer::AddRenderer方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::AddRenderer方法的具体用法?C++ vtkSmartPointer::AddRenderer怎么用?C++ vtkSmartPointer::AddRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::AddRenderer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vtk_draw_view2
void vtk_draw_view2(vtkSmartPointer<vtkRenderWindow> renderWindow,vtkSmartPointer<vtkRenderWindowInteractor> interactor)
{
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
Renderers[1]=renderer;
//renderer->RemoveLight( renderer->GetLights()->GetNextItem());
vtkSmartPointer<vtkLight> light = vtkSmartPointer<vtkLight>::New();
light->SetLightTypeToSceneLight();
light->SetPosition(100, 100, 100);
light->SetFocalPoint(-100,-100,-100);
light->SetColor(0.5,0.5,0);
light->SetPositional(true); // required for vtkLightActor below
renderer->AddLight(light);
renderer->UpdateLightsGeometryToFollowCamera();
light->SetSwitch(false);
// light->SetConeAngle(10);
// light->SetFocalPoint(lightFocalPoint[0], lightFocalPoint[1], lightFocalPoint[2]);
// light->SetDiffuseColor(1,0,0);
// light->SetAmbientColor(0,1,0);
// light->SetSpecularColor(0,0,1);
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->SetViewport(xmins[1],ymins[1],xmaxs[1],ymaxs[1]);
// m_source.m_display->draw_normal_points(renderer);
m_source.m_display->draw_triangle(renderer,interactor);
renderer->GetActiveCamera()->SetParallelProjection(1);
renderer->ResetCamera();
// renderWindow->Render();
}
示例2: main
int main(int argc, char** argv)
{
// initialize vtk pipeline
ren = vtkSmartPointer<vtkRenderer>::New();
renWin = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renWin->AddRenderer(ren);
renWin->SetInteractor(iren);
renWin->SetSize(1024,768);
// mummy
vtkSmartPointer<vtkDataSetReader> data = vtkSmartPointer<vtkDataSetReader>::New();
vtkSmartPointer<vtkContourFilter> contour = vtkSmartPointer<vtkContourFilter>::New();
vtkSmartPointer<vtkPolyDataMapper> cMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
vtkSmartPointer<vtkActor> cActor = vtkSmartPointer<vtkActor>::New();
cMapper->SetInput(contour->GetOutput());
cActor->SetMapper(cMapper);
ren->AddActor(cActor);
// isosurfaces
data->SetFileName("mummy.128.vtk");
contour->SetInput(data->GetOutput());
contour->SetValue(0, 125);
// sphere
vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
vtkSmartPointer<vtkPolyDataMapper> sMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
vtkSmartPointer<vtkActor> sActor = vtkSmartPointer<vtkActor>::New();
sMapper->SetInput(sphere->GetOutput());
sActor->SetMapper(sMapper);
ren->AddActor(sActor);
sphere->SetCenter(50, 500, 0);
sphere->SetRadius(50);
//Add timer callback
vtkSmartPointer<UpdateData> updateCallback = vtkSmartPointer<UpdateData>::New();
iren->AddObserver(vtkCommand::TimerEvent, updateCallback);
iren->CreateRepeatingTimer(100);
// initialize the kinect
sensor = new SensorDevice();
sensor->initialize();
sensor->startGeneratingAll();
sensor->lookForCalibrationPoseOn();
// initial position of center of camera
lastPoint.x_ = 320;
lastPoint.y_ = 240;
lastPoint.z_ = 0;
iren->Initialize();
iren->Start();
delete sensor;
return 0;
}
示例3: vtk_draw_view4
void vtk_draw_view4(vtkSmartPointer<vtkRenderWindow> renderWindow,vtkSmartPointer<vtkRenderWindowInteractor> interactor)
{
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
Renderers[3]=renderer;
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->SetViewport(xmins[3],ymins[3],xmaxs[3],ymaxs[3]);
m_source.m_display->draw_skeleton(renderer,interactor);
renderer->GetActiveCamera()->SetParallelProjection(1);
renderer->ResetCamera();
// renderWindow->Render();
}
示例4: vtk_draw_view3
void vtk_draw_view3(vtkSmartPointer<vtkRenderWindow> renderWindow,vtkSmartPointer<vtkRenderWindowInteractor> interactor)
{
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
Renderers[2]=renderer;
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->SetViewport(xmins[2],ymins[2],xmaxs[2],ymaxs[2]);
//if transformed vector size =0 ; will render the origin points
m_source.m_display->draw_transformed_points(renderer);
renderer->GetActiveCamera()->SetParallelProjection(1);
renderer->ResetCamera();
// renderWindow->Render();
}
示例5: vtk_draw_view1
void vtk_draw_view1(vtkSmartPointer<vtkRenderWindow> renderWindow,vtkSmartPointer<vtkRenderWindowInteractor> interactor)
{
vtkSmartPointer<vtkRenderer> renderer= vtkSmartPointer<vtkRenderer>::New();
Renderers[0]=renderer;
// renderer->RemoveLight( renderer->GetLights()->GetNextItem());
renderWindow->AddRenderer(renderer);
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->SetViewport(xmins[0],ymins[0],xmaxs[0],ymaxs[0]);
// m_source.m_display->draw_origin_points(renderer);
m_source.m_display->draw_normal_points(renderer);
renderer->GetActiveCamera()->SetParallelProjection(1);
renderer->ResetCamera();
// renderWindow->Render();
}
示例6: CStatic
void CDialog_subSTL::OnBnClickedButton3()// move STL
{
init_loc(); // set initial value for MFC slicer and edit
vtkSmartPointer<vtkSTLReader> pickedDoneSTL=vtkSmartPointer<vtkSTLReader>::New();
pickedDoneSTL->SetFileName("test_picked.stl");
pickedDoneSTL->Update();
//vtkSmartPointer<vtkTransformPolyDataFilter> Femur_transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
Femur_transformFilter->SetInputConnection(pickedDoneSTL->GetOutputPort());
//vtkSmartPointer<vtkTransform> Femur_translation = vtkSmartPointer<vtkTransform>::New();
Femur_translation->Translate(0,0,0);
Femur_transformFilter->SetTransform(Femur_translation);
Femur_transformFilter->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(Femur_transformFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();
axes->SetTotalLength(100,100,100);
vtkSmartPointer<vtkTransform> transform_axes = vtkSmartPointer<vtkTransform>::New();
axes->SetUserTransform(transform_axes);
vtkSmartPointer<vtkRenderer> renderer =vtkSmartPointer<vtkRenderer>::New();
//vtkSmartPointer<vtkRenderWindow> Femur_renderWindow =vtkSmartPointer<vtkRenderWindow>::New();
Femur_renderWindow->AddRenderer(renderer);
CStatic *pclStatic = new CStatic();
LPRECT rect = new CRect;
pclStatic = (CStatic*)GetDlgItem(IDC_STATIC_V);
Femur_renderWindow->SetParentId(pclStatic->m_hWnd);//
pclStatic->GetWindowRect(rect);
Femur_renderWindow->SetSize(rect->right-rect->left, rect->bottom-rect->top);
Femur_renderWindow->SetPosition(0,0);
//vtkSmartPointer<vtkRenderWindowInteractor> Femur_renderWindowInteractor =vtkSmartPointer<vtkRenderWindowInteractor>::New();
Femur_renderWindowInteractor->SetRenderWindow(Femur_renderWindow);
renderer->AddActor(actor);
renderer->AddActor(axes);
Femur_renderWindow->Render();
Femur_renderWindowInteractor->Start();
}
示例7: initScene
void initScene(vtkSmartPointer<vtkRenderer> render, vtkSmartPointer<vtkRenderWindow> renWin,
vtkSmartPointer<vtkRenderWindowInteractor> rwi, vtkSmartPointer<vtkInteractorStyleTrackballCamera> style){
splatAssembly = 0;
tranparencyEnabled = false;
render->SetBackground(clear_color);
renWin->GetRenderers()->RemoveAllItems();
renWin->AddRenderer(render);
renWin->SetSize(window_width, window_height );
textActor->SetInput("Init");
textActor->SetDisplayPosition(window_width*0.5, window_height*0.05);
vtkTextProperty *tprop = textActor->GetTextProperty();
tprop->SetColor(0.0,0.0,1.0);
tprop->SetJustificationToCentered();
render->AddViewProp(textActor);
VTK_CREATE(vtkCallbackCommand, keyCommand);
VTK_CREATE(vtkCallbackCommand, mouseCommand);
keyCommand->SetClientData(style);
keyCommand->SetCallback(keyCallback);
mouseCommand->SetClientData(style);
mouseCommand->SetCallback(mouseCallback);
style->AddObserver(vtkCommand::KeyPressEvent, keyCommand);
style->AddObserver(vtkCommand::MouseMoveEvent, mouseCommand);
style->AddObserver(vtkCommand::LeftButtonPressEvent, mouseCommand);
VTK_CREATE(vtkPointPicker, picker);
rwi->SetPicker(picker);
//picker->SetTolerance (0.025);//0.025 is the defaul fraction of rendering window size. (Rendering window size is measured across diagonal.)
// for drawing picked points
pickSource->SetRadius(sphereRadius*pickRadiusRadio);
pickMapper->SetInputConnection(pickSource->GetOutputPort());
pickActors.clear();
pickActors.reserve(npts);
for(int i=0; i<npts; ++i){
pickActors.push_back(0);
pickPtsIdx[i] = 0.0;
}
}
示例8: SID
void CDialog_init::OnBnClickedButton1() // load STL file and X-ray contour image
{
vtkSmartPointer<vtkSTLReader> pickedDoneSTL=vtkSmartPointer<vtkSTLReader>::New(); //load STL
if(!g_prox_or_dist)
pickedDoneSTL->SetFileName(g_STL_PNG_DIST[0].c_str());
else
pickedDoneSTL->SetFileName(g_STL_PNG_PROX[0].c_str());
pickedDoneSTL->Update();
transformFilter->SetInputConnection(pickedDoneSTL->GetOutputPort());//move and rotate STL
translation->Translate(0,0,0);
transformFilter->SetTransform(translation);
transformFilter->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(transformFilter->GetOutputPort());
//mapper->SetInputConnection(pickedDoneSTL->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> FemurRenderer =vtkSmartPointer<vtkRenderer>::New();
FemurRenderer->AddActor(actor);
vtkSmartPointer<vtkCamera> Femurcam=vtkSmartPointer<vtkCamera>::New();
Femurcam->SetPosition(0,-DETECTOR_SID/2,0); //555 is a half of SID (=1110)
Femurcam->SetFocalPoint(0,DETECTOR_SID/2,0);
Femurcam->SetViewUp(0,-DETECTOR_SID/2,1);
//Femurcam->SetViewAngle(14.9);
Femurcam->SetViewAngle(17);
Femurcam->SetClippingRange(-500,700);
//fx is roughly 6035 for 1560x1440 images
//fx is modified into 6035/2 since our x-ray images has 720x780 sizes.
//from this value, we estimated the real size of the detector : Height 132.5 = 360(=720/2)*1110(SID)/3017.5(=6035/2)
//Then, one side angle was calucated as 6.807 = atan(DETECTOR_WIDTH/2/1110)
//view angle was calculated as 7.45 * 2 = 14.9
FemurRenderer->SetActiveCamera(Femurcam);
vtkSmartPointer<vtkJPEGReader> JPEGReader =vtkSmartPointer<vtkJPEGReader>::New(); //load contour image
if(!g_prox_or_dist)
JPEGReader->SetFileName(g_STL_PNG_DIST[1].c_str());
else
JPEGReader->SetFileName(g_STL_PNG_PROX[1].c_str());
JPEGReader->Update();
vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(JPEGReader->GetOutputPort());
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
//y direction is normal of the plane
//-z direction is up direction of camera
//x direction is lateral direction of camera
plane->SetOrigin(0,DETECTOR_SID/2,0);
plane->SetPoint1(-DETECTOR_WIDTH/2, DETECTOR_SID/2,0);
plane->SetPoint2(0,DETECTOR_SID/2,-DETECTOR_HEIGHT/2);
plane->SetNormal(0,DETECTOR_SID/2,0);
plane->SetResolution(XRAY_WIDTH,XRAY_HEIGHT);
plane->SetCenter(0,0,0);
//plane->Push(45);
vtkSmartPointer<vtkTextureMapToPlane> texturePlane = vtkSmartPointer<vtkTextureMapToPlane>::New();
texturePlane->SetInputConnection(plane->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
planeMapper->SetInputConnection(texturePlane->GetOutputPort());
vtkSmartPointer<vtkActor> texturedPlane = vtkSmartPointer<vtkActor>::New();
texturedPlane->SetMapper(planeMapper);
texturedPlane->SetTexture(texture);
vtkSmartPointer<vtkTextActor> textActor=vtkSmartPointer<vtkTextActor>::New();
textActor->GetTextProperty()->SetFontSize(12);
textActor->GetTextProperty()->SetColor(1.0,1.0,0.0);
textActor->SetPosition2(10,20);
textActor->SetInput("Cam Pos : 0, 555,0");
vtkSmartPointer<vtkRenderer> ren =vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(ren);
renderWindow->AddRenderer(FemurRenderer);
vtkSmartPointer<vtkCamera> cam=vtkSmartPointer<vtkCamera>::New();
cam->SetPosition(0,-DETECTOR_SID/2,0);
cam->SetFocalPoint(0,DETECTOR_SID/2,0);
//cam->SetViewAngle(14.9);
cam->SetViewAngle(17);
cam->SetViewUp(0,-DETECTOR_SID/2,-1);
cam->SetClippingRange(-500,700);
ren->SetActiveCamera(cam);
ren->AddActor(texturedPlane);
ren->AddActor(textActor);
ren->SetBackground(0.2,0.3,0.4);
ren->SetLayer(0);
ren->InteractiveOff();
FemurRenderer->SetLayer(1); // choose window render for interactor
renderWindow->SetNumberOfLayers(2);
CStatic *pclStatic = new CStatic();
LPRECT rect = new CRect;
pclStatic = (CStatic*)GetDlgItem(IDC_STATIC_VIEW);
renderWindow->SetParentId(pclStatic->m_hWnd);//
pclStatic->GetWindowRect(rect);
renderWindow->SetSize(rect->right-rect->left, rect->bottom-rect->top);
renderWindow->SetPosition(0,0);
//.........这里部分代码省略.........