[vtkusers] Re: Example of the use of vtkProgrammableGlyphFilter
Nick Arini
nick.arini at amersham.com
Fri Jun 18 11:13:15 EDT 2004
>>Have you looked at:
>>
>>/Graphics/Testing/Tcl/progGlyphs.tcl
>>/Graphics/Testing/Tcl/progGlyphsBySource.tcl
Sorry no, I missed those.
I have now taken a look at these examples and tried to implement progGlyphs.tcl as C++. I have evidently lost something in the translation however as my
output is not the same as the test. The test puts nicely scaled and
coloured glyphs at each vertex in the mesh of the plane. My output however
just has a single large blue sphere. My CalcGlyph function is being called
the right number of times but it does not seem to be having any effect.
Can anyone see what I have done wrong?
Many thanks,
Nick
<begin code>
#include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkProperty.h"
#include "vtkPlaneSource.h"
#include <vtkProgrammableGlyphFilter.h>
#include <vtkElevationFilter.h>
#include <vtkSuperquadricSource.h>
static int res;
static int count =0;
void CalcGlyph(void *arg)
{
std::cout << "Calculating glyph: " << count << std::endl;
vtkProgrammableGlyphFilter *glyph = (vtkProgrammableGlyphFilter*)arg;
int ptId = glyph->GetPointId();
vtkPointData *pd = glyph->GetPointData();
float x,y,z;
glyph->GetPoint( x, y, z );
double length = ( glyph->GetInput() )->GetLength();
double scale = ( length / (2*res) );
vtkSuperquadricSource *squad = (vtkSuperquadricSource*)
glyph->GetSource();
squad->SetScale( scale, scale, scale );
squad->SetCenter( x, y, z );
squad->SetPhiRoundness( (fabs(x)*5) );
squad->SetThetaRoundness( fabs(y)*5 );
count++;
}
int main( int argc, char *argv[] )
{
res = 6;
vtkPlaneSource *plane = vtkPlaneSource::New();
plane->SetResolution( res, res );
vtkElevationFilter *colors = vtkElevationFilter::New();
colors->SetInput( plane->GetOutput() );
colors->SetLowPoint( -0.25, -0.25, -0.25 );
colors->SetHighPoint( 0.25, 0.25, 0.25 );
vtkPolyDataMapper* planeMapper = vtkPolyDataMapper::New();
planeMapper->SetInput( colors->GetPolyDataOutput() );
vtkActor *planeActor = vtkActor::New();
planeActor->SetMapper( planeMapper );
( planeActor->GetProperty() )->SetRepresentationToWireframe();
vtkSuperquadricSource *squad = vtkSuperquadricSource::New();
vtkProgrammableGlyphFilter *glyph = vtkProgrammableGlyphFilter::New();
glyph->SetInput( colors->GetOutput() );
glyph->SetSource( squad->GetOutput() );
glyph->SetGlyphMethod( CalcGlyph, glyph );
vtkPolyDataMapper *glyphMapper = vtkPolyDataMapper::New();
glyphMapper->SetInput( glyph->GetOutput() );
vtkActor *glyphActor = vtkActor::New();
glyphActor->SetMapper( glyphMapper );
vtkRenderer *ren = vtkRenderer::New();
ren->AddActor( planeActor );
ren->AddActor( glyphActor );
ren->SetBackground(1, 1, 1);
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
renWin->SetSize(450,450);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->Initialize();
iren->Start();
plane->Delete();
colors->Delete();
planeMapper->Delete();
planeActor->Delete();
squad->Delete();
glyph->Delete();
glyphMapper->Delete();
glyphActor->Delete();
ren->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
<end code>
"Goodwin Lawlor" <goodwin.lawlor at ucd.ie>
Sent by: vtkusers-bounces at vtk.org
17/06/2004 22:06
To: vtkusers at public.kitware.com
cc:
Subject: [vtkusers] Re: Example of the use of vtkProgrammableGlyphFilter
Have you looked at:
/Graphics/Testing/Tcl/progGlyphs.tcl
/Graphics/Testing/Tcl/progGlyphsBySource.tcl
"Nick Arini" <nick.arini at amersham.com> wrote in message
news:OFF501534D.8712673B-ON80256EB6.0049A380 at se.apbiotech.com...
Dear VTK users,
does anyone have an example of the use of vtkProgrammableGlyphFilter?
I have unstructured data of the form:
x-coord, y-coord, z-coord, attribute1, attribute2,...
I want to place a glyph (for example a sphere) at the point in 3D space
defined by the coordinates and dictate the size and colour of the sphere
with the attribute data. I could not find any example of the use of this
class in /Examples, the docs or in the mailing list archive.
Many thanks,
Nick
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040618/96c13568/attachment.htm>
More information about the vtkusers
mailing list