[vtkusers] I convert a vtkImplicitSelectionLoop sample code from TCL to c++, it executes, but I can' see the display window?
BoShi
chinaren.vtk at gmail.com
Tue Jun 6 07:20:14 EDT 2006
Thank you very much ,your advice does work!
Thomas Lambertz 写道:
> Hi,
>
> iren->Start(); afaik starts an eventloop.
> When you close your programm the loop will be left and your following
> code will be executed. So renWin->Render();
> does what you saw as a flash.
>
> Code like
> iren->AddObserver(vtkCommand::EndPickEvent,pcallcmd);
> should be executed before iren->Start();
>
> Dont´s know why your initial screen is black.Maybe someone else can
> tell you.
>
> hth
> Tom
>
>
>
> BoShi wrote:
>> Hi,
>>
>> The phenomenon is that as the programme start I just can see a black
>> window, when I close the programme I can see a flash of image. Who can
>> tell me why? Thanks a lot!
>> The source code is as follows:
>>
>> void pick(vtkObject *caller, unsigned long eid, void *clientdata, void
>> *calldata)
>> {
>> }
>> void main()
>> {
>> vtkSphereSource* sphere = vtkSphereSource::New();
>>
>> sphere->SetRadius(1.0);
>> sphere->SetPhiResolution(100);
>> sphere->SetThetaResolution(100);
>>
>>
>> vtkPoints* selectionPoints = vtkPoints::New();
>>
>> selectionPoints->InsertPoint(0, 0.07325, 0.8417, 0.5612);
>> selectionPoints->InsertPoint(1, 0.07244, 0.6568, 0.7450);
>> selectionPoints->InsertPoint(2, 0.1727, 0.4597, 0.8850);
>> selectionPoints->InsertPoint(3, 0.3265, 0.6054, 0.7309);
>> selectionPoints->InsertPoint(4, 0.5722, 0.5848, 0.5927);
>> selectionPoints->InsertPoint(5, 0.4305, 0.8138, 0.4189);
>>
>> vtkImplicitSelectionLoop* loop = vtkImplicitSelectionLoop::New();
>> loop->SetLoop(selectionPoints);
>>
>> vtkExtractGeometry* extract = vtkExtractGeometry::New();
>> extract->SetInputConnection(sphere->GetOutputPort());
>> extract->SetImplicitFunction(loop);
>>
>> //vtkTubeFilter *pTulb
>>
>> vtkConnectivityFilter* connect = vtkConnectivityFilter::New();
>> connect->SetInputConnection(extract->GetOutputPort());
>> connect->SetExtractionModeToClosestPointRegion();
>> connect->SetClosestPoint(selectionPoints->GetPoint(0));
>>
>> vtkDataSetMapper* clipMapper = vtkDataSetMapper::New();
>> clipMapper->SetInputConnection(connect->GetOutputPort());
>>
>> vtkProperty* backProp = vtkProperty::New();
>> backProp->SetDiffuseColor(1.0, 0.3, 0.5);
>>
>> vtkActor* clipActor = vtkActor::New();
>> clipActor->SetMapper(clipMapper);
>> clipActor->GetProperty()->SetColor(0.0, 0.5, 0.0);
>> clipActor->SetBackfaceProperty(backProp);
>>
>> vtkRenderer* ren1 = vtkRenderer::New();
>> vtkRenderWindow* renWin = vtkRenderWindow::New();
>> renWin->AddRenderer(ren1);
>>
>> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>> iren->SetRenderWindow(renWin);
>> iren->Initialize();
>> iren->Start();
>>
>> ren1->AddActor(clipActor);
>> ren1->SetBackground(1.0, 1.0, 1.0);
>> ren1->ResetCamera();
>> ren1->GetActiveCamera()->Azimuth(30);
>> ren1->GetActiveCamera()->Elevation(30);
>> ren1->GetActiveCamera()->Dolly(1.2);
>> ren1->ResetCameraClippingRange();
>> renWin->SetSize(400, 400);
>> renWin->Render();
>>
>>
>> vtkCallbackCommand* pcallcmd = vtkCallbackCommand::New();
>> pcallcmd->SetCallback(pick);
>> iren->AddObserver(vtkCommand::EndPickEvent,pcallcmd);
>>
>> pcallcmd->Delete();
>> sphere->Delete();
>> selectionPoints->Delete();
>> loop->Delete();
>> extract->Delete();
>> connect->Delete();
>> clipMapper->Delete();
>> backProp->Delete();
>> clipActor->Delete();
>> ren1->Delete();
>> renWin->Delete();
>> iren->Delete();
>> }
>>
>>
>> Best regards,
>> BHS
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages
>> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list