[vtkusers] Can an actor be used to interact at the same time with a rendered CT volume and line widget

manzohar lancia58 at gmail.com
Sat Jun 8 12:42:23 EDT 2013


Hi 

I refererd to the example tried and follow it but still the line widgest
stand still as the CT volume rotates/pans/zoomed below I cut and past the
relevant part of my code. I'll appreciate if you can look and let me know
what I am doing wrong.


>===== This part is creates the CT volume =====<
static vtkRenderer *renderer ;
static vtkRenderWindow *renWin;

void CreateCTVolumeRendererWindow(int *HWND)
{
  renderer = vtkRenderer::New();
  renWin = vtkRenderWindow::New();
  renWin->SetParentId((void*)HWND);

  renWin->AddRenderer(renderer);
 
}

static vtkImageData *input;
static vtkAlgorithm *reader;
static vtkVolume *volume;

bool CreateDicomReader(char *dirName)
{
	
vtkDICOMImageReader *dicomReader= vtkDICOMImageReader::New();
//	dicomReader->SetFileNames(VolumeFilesArray);

    dicomReader->SetDirectoryName(dirName);
    dicomReader->Update();

    input=dicomReader->GetOutput();
		
    reader=dicomReader;

   int dim[3];
  input->GetDimensions(dim);
  if ( dim[0] < 2 ||
       dim[1] < 2 ||
       dim[2] < 2 )
    {
    cout << "Error loading data!" << endl;
    exit(EXIT_FAILURE);    
    }
return true;
}

static vtkSmartVolumeMapper *mapper;
 
void CreateTheCTVolumeMapper()
{

      mapper->SetInputConnection( reader->GetOutputPort() );
  
          
   // Set the sample distance on the ray to be 1/2 the average spacing
   double spacing[3];
    input->GetSpacing(spacing);
  
}

static vtkRenderer *renderer ;
static vtkRenderWindow *renWin;
void StartCTRendering(int width, int height)
{
  // Set the default window size
  renWin->SetSize(width, height);
  
  // Add the volume to the scene
  renderer->AddVolume( volume );

  renderer->ResetCamera();

 
  // interact with data
  renWin->Render();

}

static vtkRenderWindowInteractor *iren ;

void CreateCTVolumeInteractor()
{
int clip = 0;
	
	
  iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin); //ZoharMann
  iren->SetDesiredUpdateRate(frameRate / (1+clip) );
  
  iren->GetInteractorStyle()->SetDefaultRenderer(renderer); 

  vtkSmartPointer<vtkInteractorStyleTrackballActor> style = 
      vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();

  iren->SetInteractorStyle(style);


}
vtkVolumeInteractorCallback *InteractorCallback;

void StartCTVolumeIntercator()
{
   InteractorCallback = vtkVolumeInteractorCallback::New();
      InteractorCallback->SetMapper(mapper);
      volume->AddObserver(vtkCommand::PickEvent, InteractorCallback);
      
  iren->Start();
  
  }

void  Render(int *HWND, int width, int height,char *scenarioDir)
{
  
  CreateCTVolumeRendererWindow(HWND);
  CreateCTVolumeInteractor();
  CreateDicomReader(scenarioDir);
  CreateTheCTVolumeMapper();
  CreatTheTransferFunction();
  StartCTRendering( width,  height);
  StartCTVolumeIntercator(); 

}


>====================  This is the line widget code ====================<

void CreatWidgetLine()
{
LineWidget *line = LineWidget::New();
  
 
    
     line>SetPlaceFactor(1.01);
	  line->SetEndPointsRadius(0.01);
      line->SetInput(input);
	  
          line->SetDefaultRenderer(renderer);
     line->PlaceWidget();
   

     
            line->EnabledOn();
	  
	  renderer->AddActor(line->GetActor());	
	  (*line)->SetInteractor(iren);

}






Thanks a lot
Zohar



--
View this message in context: http://vtk.1045678.n5.nabble.com/Can-an-actor-be-used-to-interact-at-the-same-time-with-a-rendered-CT-volume-and-line-widget-tp5721258p5721289.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list