[vtkusers] Volume Rendering with vtkUnstructuredGridRayCastMapper

Peter F Bradshaw pfb at exadios.com
Sat Dec 31 01:05:14 EST 2005


On Thu, 29 Dec 2005, Randall Hand wrote:

> It's not a Bash/Tcsh issue, we've tried it with bash/tcsh/csh/ksh/sh ..
> Still the same problem. I've been told the only way to fix it is to
> recompile the Kernel to enable longer commandlines, but as our SGI admins
> seem to be on holiday...
>
> I was using 4.5 previously, but even it doesn't have some of these latest
> changes.  The latest version of Paraview (2.4.1, the version that I'm using)
> is based on stuff later than 4.5 as well.

The version of VTK that comes with ParaView 2.4.1 is VTK-5.1.0. Maybe try
that.

>
> On 12/29/05, Peter F Bradshaw <pfb at exadios.com> wrote:
> >
> > Hi Randall;
> >
> > On Wed, 28 Dec 2005, Randall Hand wrote:
> >
> > > I pull it from cvs (cvs co -r VTK-5-0).
> > >
> > > As for using the version with Paraview, i'ld love to.. But unfortunately
> > due
> > > to a wierd quirk with Cmake/Paraview/Irix we are unable to compile
> > Paraview
> > > on Irix due to problems with command lines being too long.  Also, no
> > binary
> > > version of paraview is offered for Irix anymore via paraview.org .  So I
> > > have to run Paraview on Windows, but this VTK work is being done on
> > Irix.
> >
> > The command line length problem is likely to do with the shell you are
> > using. Try installing bash on the SGI Irix.
> >
> > The version of VTK that comes with ParaView 2.2.1 is VTK4.5.0. You might
> > be able to pull that from CVS. In any case the VTK that comes with
> > Paraview is a complete and self contained source set. So, if you
> > download Paraview and then cd Paraview/VTK and cmake, make, ... etc you
> > will end up with a stand alone VTK library. I'm assuming that if you can
> > compile VTK5.0 then you will be able to compile VTK4.5.0.
> >
> > BTW VTK4.5.0 is quite different to VTK4.4 - it seems to be very close to
> > VTK5.0.
> >
> > >
> > > On 12/28/05, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> > > >
> > > > where did you get 5.0 from? I dont see it on vtk.org
> > > > then why not try vtk that comes along with paraview?
> > > > --domi
> > > >
> > > > Randall Hand wrote:
> > > > > I don't think these classes exist in the 4.4.  Plus alot of stuff
> > has
> > > > > changed between 4.4 & 5.0 (This isn't CVS head, it's the 5.0 Branch
> > > > that's
> > > > > supposed to be pretty stable), that makes it pretty difficult for me
> > to
> > > > > backport.
> > > > >
> > > > > On 12/28/05, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> > > > >
> > > > >>Did you try with the "official" 4.4? I often have problems with the
> > CVS
> > > > >>version.
> > > > >>--domi
> > > > >>
> > > > >>Randall Hand wrote:
> > > > >>
> > > > >>>I'm attempting to render an unstructured dataset that contains 1
> > vector
> > > > >>>field and 7 scalar fields.  I want to map Color & Opacity to one of
> > the
> > > > >>
> > > > >>1
> > > > >>
> > > > >>>scalar fields (both to the same one) and volume render it.  I can
> > do
> > > > >>
> > > > >>this in
> > > > >>
> > > > >>>Paraview easily (screenie attached), but my VTK code returns a
> > blank
> > > > >>
> > > > >>black
> > > > >>
> > > > >>>window everytime.  Am I missing something here?
> > > > >>>
> > > > >>>I'm doing it all offscreen on an SGI Irix box (Onyx340) with the
> > VTK
> > > > >>>5.0Branch installed & MangledMesa.  The code I'm using is below:
> > > > >>>
> > > > >>>==============================
> > > > >>>#include <vtkColorTransferFunction.h >
> > > > >>>#include <vtkDataSetReader.h>
> > > > >>>#include <vtkPiecewiseFunction.h>
> > > > >>>#include <vtkUnstructuredGridVolumeRayCastMapper.h>
> > > > >>>#include <vtkUnstructuredGrid.h>
> > > > >>>#include < vtkDataSet.h>
> > > > >>>#include <vtkRenderWindow.h>
> > > > >>>#include <vtkRenderer.h>
> > > > >>>#include <vtkRenderLargeImage.h>
> > > > >>>#include <vtkPNGWriter.h>
> > > > >>>#include <vtkVolumeProperty.h>
> > > > >>>#include <vtkDataSetTriangleFilter.h >
> > > > >>>#include <vtkImagingFactory.h>
> > > > >>>#include <vtkGraphicsFactory.h>
> > > > >>>void main(void) {
> > > > >>>    vtkGraphicsFactory *factGraphics = vtkGraphicsFactory::New();
> > > > >>>    factGraphics->SetUseMesaClasses(1);
> > > > >>>    factGraphics->SetOffScreenOnlyMode(1);
> > > > >>>    factGraphics->Delete();
> > > > >>>    vtkImagingFactory *factImage = vtkImagingFactory::New();
> > > > >>>    factImage->SetUseMesaClasses(1);
> > > > >>>    factImage->Delete();
> > > > >>>    vtkDataSetReader *reader = vtkDataSetReader::New();
> > > > >>>    reader->SetFileName("../VTK/step_127.vtk");
> > > > >>>    reader->ReadAllScalarsOn();
> > > > >>>
> > > > >>>    vtkDataSetTriangleFilter *tri =
> > vtkDataSetTriangleFilter::New();
> > > > >>>    tri->SetInput(reader->GetOutput());
> > > > >>>
> > > > >>>
> > > > >>>    vtkColorTransferFunction *color =
> > vtkColorTransferFunction::New();
> > > > >>>
> > > > >>>    color->AddRGBPoint(250, 0, 0, 1);
> > > > >>>    color->AddRGBPoint(450, 1, 0, 0);
> > > > >>>    color->AddRGBPoint(2600, 1, 1, 0);
> > > > >>>    color->AddRGBPoint(5000, 1, 1, 1);
> > > > >>>
> > > > >>>    vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();
> > > > >>>    opacity->AddPoint(250, 0.1);
> > > > >>>    opacity->AddPoint(450, 0.1);
> > > > >>>    opacity->AddPoint(2600, 0.25);
> > > > >>>    opacity->AddPoint(5000, 1.0);
> > > > >>>
> > > > >>>    vtkVolumeProperty *volProp = vtkVolumeProperty::New();
> > > > >>>    volProp->SetColor(color);
> > > > >>>    volProp->SetScalarOpacity(opacity);
> > > > >>>    volProp->SetInterpolationTypeToLinear();
> > > > >>>
> > > > >>>    vtkUnstructuredGridVolumeRayCastMapper *mapper =
> > > > >>>            vtkUnstructuredGridVolumeRayCastMapper::New();
> > > > >>>    mapper->SetScalarModeToUsePointFieldData();
> > > > >>>    mapper->SelectScalarArray("Temperature");
> > > > >>>    mapper->SetInput(tri->GetOutput());
> > > > >>>
> > > > >>>    vtkVolume *volume = vtkVolume::New();
> > > > >>>    volume->SetMapper(mapper);
> > > > >>>    volume->SetProperty(volProp);
> > > > >>>    volume->Update();
> > > > >>>    vtkRenderWindow *renWin = vtkRenderWindow::New();
> > > > >>>    vtkRenderer *ren1 = vtkRenderer::New();
> > > > >>>    renWin->OffScreenRenderingOn();
> > > > >>>    renWin->AddRenderer(ren1);
> > > > >>>
> > > > >>>    ren1->AddVolume(volume);
> > > > >>>    ren1->ResetCamera();
> > > > >>>    renWin->SetSize(1024, 1024);
> > > > >>>    renWin->Modified();
> > > > >>>
> > > > >>>    vtkRenderLargeImage *w2if = vtkRenderLargeImage::New();
> > > > >>>    w2if->SetInput(ren1);
> > > > >>>    w2if->SetMagnification(1);
> > > > >>>
> > > > >>>    vtkPNGWriter *png  = vtkPNGWriter::New();
> > > > >>>    png->SetInput(w2if->GetOutput());
> > > > >>>    png->SetFileName("output.png");
> > > > >>>    png->Write();
> > > > >>>}
> >
> > Cheers
> >

Cheers

-- 
Peter F Bradshaw, http://www.exadios.com, ICQ 75431157 (exadios).
Public key at www.exadios.com/pfb.pgp.key and www.exadios.com/pfb.gpg.key
"I love truth, and the way the government still uses it occasionally to
 keep us guessing." - Sam Kekovich.



More information about the vtkusers mailing list