Q: How to use vtkGlyph3D with self-built vtkPolyDatas?

Mirco Müller mirco at pool.informatik.rwth-aachen.de
Fri Mar 10 06:40:58 EST 2000


Greetings vtk-wizards!

    I have a problem with my selfmade vtkPolyData structures. I define a
source and input "object" like this:

        vtkPolyData       *line       = vtkPolyData::New(), *spike
= vtkPolyData::New();
        vtkPoints         *points     = vtkPoints::New(), *s_points   =
vtkPoints::New();
        vtkCellArray      *polys      = vtkCellArray::New(), *s_cells
= vtkCellArray::New();
        vtkLookupTable    *lut        = vtkLookupTable::New();
        vtkScalars        *scalars    = vtkScalars::New(), *s_scalars  =
vtkScalars::New();
        vtkVectors        *s_vectors  = vtkVectors::New();
        vtkActor          *actor      = vtkActor::New();
        vtkPolyDataMapper *mapper     = vtkPolyDataMapper::New();
        vtkGlyph3D        *s_glyph3d  = vtkGlyph3D::New();

        // build source object
        s_vectors->InsertNextVector( 1.0, 0.0, 0.0 );
        s_vectors->InsertNextVector( 0.0, 1.0, 0.0 );
        s_vectors->InsertNextVector( 0.0, 0.0, 1.0 );
        s_vectors->InsertNextVector( 1.0, 0.5, 0.0 );
        s_vectors->InsertNextVector( 0.5, 1.0, 0.0 );
        s_vectors->InsertNextVector( 0.0, 0.5, 1.0 );

        s_scalars->InsertNextScalar( 0.0 );
        s_scalars->InsertNextScalar( 1.0 );
        s_scalars->InsertNextScalar( 0.5 );
        s_scalars->InsertNextScalar( 0.75 );
        s_scalars->InsertNextScalar( 0.25 );
        s_scalars->InsertNextScalar( 0.5 );

        s_points->InsertNextPoint( 0.0, 0.0, 0.0 );
        s_points->InsertNextPoint( 1.0, 0.0, 0.0 );
        s_points->InsertNextPoint( 1.0, 1.0, 0.0 );
        s_points->InsertNextPoint( 0.0, 1.0, 0.0 );
        s_points->InsertNextPoint( 0.0, 0.0, 1.0 );
        s_points->InsertNextPoint( 1.0, 0.0, 1.0 );

        s_cells->InsertNextCell( 2 );
        s_cells->InsertCellPoint( 0 );
        s_cells->InsertCellPoint( 1 );
        s_cells->InsertNextCell( 2 );
        s_cells->InsertCellPoint( 1 );
        s_cells->InsertCellPoint( 2 );
        s_cells->InsertNextCell( 2 );
        s_cells->InsertCellPoint( 2 );
        s_cells->InsertCellPoint( 3 );
        s_cells->InsertNextCell( 2 );
        s_cells->InsertCellPoint( 3 );
        s_cells->InsertCellPoint( 0 );

        spike->SetLines( s_cells );
        spike->SetPoints( s_points );
        spike->GetCellData()->SetVectors( s_vectors );

        // build input object
        points->InsertNextPoint( 0.0, 0.0, 0.0 );
        points->InsertNextPoint( 1.0, 0.0, 0.0 );

        polys->InsertNextCell( 2 );
        polys->InsertCellPoint( 0 );
        polys->InsertCellPoint( 1 );

        scalars->InsertScalar( 0, 0.0 );
        scalars->InsertScalar( 1, 1.0 );

        line->SetPoints( points );
        line->SetLines( polys );
        line->GetPointData()->SetScalars( scalars );

        // setup glyph3d
        s_glyph3d->SetInput( spike );
        s_glyph3d->SetSource( line );

        // setup lookup-table and assign it
        lut->SetNumberOfColors( 2 );
        lut->SetTableValue( 0, 1.0, 1.0, 1.0, 1.0 );
        lut->SetTableValue( 1, 0.0, 0.0, 1.0, 1.0 );
        scalars->SetLookupTable( lut );

        // complete the pipeline
        mapper->SetInput( s_glyph3d->GetOutput() );
        mapper->SetScalarRange( 0.0, 2.0 );
        actor->SetMapper( mapper );

All this compiles very nicely, but crashes with an access ("read")
violation.

    What I actually want to achieve is to be able to use a custom-made
object as glyph for the visualization of vector data. I know about
vtkHedgeHog, but this does not allow me to use my own object/geometry as
glyph.

    I use vtk 2.3 (C/C++) on a SGI Visual PC 320 running NT 4.0 (SP 4).
I hope someone encountered and solved this problem already.

Thanks in advance for your time and kind advice!

Best regards...

Mirco

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list