[vtkusers] vtkHelpPlease

yala kaluma yala_aiiii at hotmail.com
Thu Mar 24 12:07:19 EST 2005


Hi,

What i am trying to do is pretty simple.
I would like to create an 3d object, pass it through an image filter and 
then visualize the result.
Seems like a pretty basic thing to do!

To do that I create the object with vtkcubesource, I used vtkrenderersource 
at the output of the source 's renderer to switch it into an image.
And to see the result i used vtkimageviewer.

I haven t filtered anything yet,because even without it doesn t work. The 
output is a all black window.
If you could take a look at my script below that would be really nice.

Best regards,
Yala

#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRendererSource.h"
#include "vtkImageViewer.h"

int main( int argc, char *argv[] )
{
  vtkConeSource *cone = vtkConeSource::New();
  cone->SetHeight( 6.0 );
  cone->SetRadius( 2.0 );
  cone->SetResolution( 30 );

  vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
  coneMapper->SetInput( cone->GetOutput() );

  vtkActor *coneActor = vtkActor::New();
  coneActor->SetMapper( coneMapper );

  vtkRenderer *ren1= vtkRenderer::New();
  ren1->AddActor( coneActor );
  ren1->SetBackground( 0, 0, 0 );

  vtkRendererSource *ren1Image=vtkRendererSource::New();
  ren1Image->SetInput(ren1);

  vtkImageViewer *viewer=vtkImageViewer::New();
  viewer->SetInput(ren1Image->GetOutput());
  viewer->Render();

  int i;
  for (i = 0; i < 300; ++i)
    {
          viewer->Render();
    }


  //
  // Free up any objects we created. All instances in VTK are deleted by
  // using the Delete() method.
  //
  cone->Delete();
  coneMapper->Delete();
  coneActor->Delete();
  ren1->Delete();
  ren1Image->Delete();
  viewer->Delete();

  return 0;
}

_________________________________________________________________





More information about the vtkusers mailing list