[vtkusers] multiple isosurface?

Radim Kolár kolarr at feec.vutbr.cz
Tue Mar 11 10:01:46 EST 2003


thanks.
I have another problem:) How to generate a multiple isosurface with Marching cubes in one render window?
thanks radim
  ----- Original Message ----- 
  From: Amy Henderson 
  To: Radim Koláø ; VTK 
  Sent: Tuesday, March 11, 2003 3:15 PM
  Subject: Re: [vtkusers] rendering a sphere problem


  The main reason this won't work is that vtkSphereSource produces vtkPolyData output, not vtkImageData, so you can't volume render it in VTK.  You should use a vtkPolyDataMapper and a vtkActor to render the output of vtkSphereSource instead.

  - Amy

  At 09:16 AM 3/11/2003 +0100, Radim Koláø wrote:

    Hi all,
    please could you help me with this simple problem?
    I want to render the sphere with the vtkVolumeRayCastMapper. So I create sphere, mapper, volume properties and finally vtkVolume and I render it with vtkRenderWindowInteractor. But the program crash when I call iren->Render(). Bellow is the short C++ code. Are there some mistakes?
    I'm using VTK 4.0 and Borland C++ 6
    Thanks a lot.
    Radim
     
    //---------------------------------------------------------------------------
    #include "vtkSphereSource.h"
    #include "vtkVolumeRayCastMapper.h"
    #include "vtkActor.h"
    #include "vtkRenderer.h"
    #include "vtkRenderWindowInteractor.h"
    #include "vtkRenderWindow.h"
    #include "vtkVolumeRayCastMIPFunction.h"
    #include "vtkImageData.h"
    #include "vtkVolumeProperty.h"
    #include "vtkPiecewiseFunction.h"
     
    #include <vcl.h>
    #pragma hdrstop
    //---------------------------------------------------------------------------
     
    #pragma argsused
    int main(int argc, char* argv[])
    {
            vtkSphereSource *sphere;        sphere = vtkSphereSource::New();
     
            vtkVolumeRayCastMIPFunction *RayCastMethod = vtkVolumeRayCastMIPFunction::New();
            vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::New();
     
            mapper->SetVolumeRayCastFunction( RayCastMethod );
     
            vtkImageData *vol;      vol = vtkImageData::New();
            vol->SetSource( sphere );
            mapper->SetInput( vol );
     
     vtkColorTransferFunction *colorF = vtkColorTransferFunction::New();
        colorF->AddRGBSegment( 0, 0.0, 0.0, 0.0, 255, 0.5, 0.1, 1.0 );
     
           //-------- Mapping from scalar -> opacity ------------
     vtkPiecewiseFunction *opacityF = vtkPiecewiseFunction::New();
         opacityF->AddPoint( 10, 0.1 );
         opacityF->AddPoint( 200, 0.9 );
         opacityF->ClampingOff();
     
    vtkVolumeProperty *volumeP = vtkVolumeProperty::New();
        volumeP->SetColor( colorF );
         volumeP->SetScalarOpacity( opacityF );
     
     vtkVolume *volume = vtkVolume::New();
         volume->SetMapper( mapper );
         volume->SetProperty( volumeP );
     

    vtkRenderer *ren1;      ren1 = vtkRenderer::New();
        ren1->AddProp( volume );
     
    vtkRenderWindow *renWin; renWin = vtkRenderWindow::New();
        renWin->AddRenderer( ren1 );
     
    vtkRenderWindowInteractor *iren; iren = vtkRenderWindowInteractor::New();
        iren->SetRenderWindow( renWin );
     
            iren->Render();     //here it crash
            iren->Start();
     
            iren->Delete();
            renWin->Delete();
            ren1->Delete();
            RayCastMethod->Delete();
            volume->Delete();
            vol->Delete();
            mapper->Delete();
            sphere->Delete();
     
            return 0;
    }
    //---------------------------------------------------------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030311/f30f27af/attachment.htm>


More information about the vtkusers mailing list