[vtkusers] hedgehog error...

Luke Hetrick lhetrick at nnu.edu
Mon Jun 11 18:13:35 EDT 2012


Hello,

    I am fairly new to VTK and am going through the Visualizing Toolkit 4th
edition text and am hitting a problem in one of the examples. When I go to
make the pipeline to connect the data with the hedgehog function, I do not
know what command to use. In the example, they use
HedgeHog->SetInputData(SGrid), where HedgeHog and Grid are classes definded
by the user, but HedgeHog does not have a member called SetInputData...I
have check the doxygen page and in my vtkpython wrapping. Does anyone know
how to connect this pipeline then? Here is the code I have written for
it...the line of interest lies one paragraph after the end of the nested
for loops. Please no laughing at my code, I am also new to C++ object
oriented programming as well.

#include "vtkPoints.h"
#include "vtkFloatArray.h"
#include "vtkMath.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkStructuredGrid.h"
#include "vtkHedgeHog.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "
vtkInteractorStyleTrackballCamera.h"

int main ()
{

  int i,j,k,kOffset,jOffset,offset;
  float x[3],v[3],rMin=0.5,rMax=1.0,deltaRad,deltaZ;
  float radius, theta;
  static int dims[3]={13,11,11};

vtkStructuredGrid *grid = vtkStructuredGrid::New();
 grid->SetDimensions(dims);

vtkPoints *points = vtkPoints::New();
 points->Allocate(dims[0]*dims[1]*dims[2]);

vtkFloatArray *vector = vtkFloatArray::New();
 vector->SetNumberOfComponents(3);
 vector->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);

 deltaZ = 2.0 / (dims[2]-1);
 deltaRad = (rMax-rMin) / (dims[1]-1);

 v[2] = 0.0;

 for (k=0; k<dims[2]; k++)
   {
     x[2] = -1.0 + k * deltaZ;
     kOffset = k * dims[0] * dims[1];
     for (j=0; j<dims[1]; j++)
       {
     radius= rMin + j * deltaRad;
     jOffset= j * dims[0];
     for (i=0; i<dims[0]; i++);
     {
       theta = i * vtkMath::DegreesFromRadians(15.0);
       x[0]=radius *cos( theta );
       x[1] = radius * sin( theta );
       v[0] = -x[1];
       v[1] = x[0];
       offset=i + jOffset + kOffset;
       points->InsertPoint( offset,x );
       vector->InsertTuple( offset,v );
     }
       }
   }

 grid->SetPoints(points);
 grid->GetPointData()->SetVectors( vector );

vtkHedgeHog *hog = vtkHedgeHog::New();
 hog->SetVectorMode( vector );
 hog->SetScaleFactor( 0.1 );

vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
 mapper->SetInputConnection( hog->GetOutputPort() );

vtkActor *actor = vtkActor::New();
 actor->SetMapper( mapper );
 actor->GetProperty()->SetColor( 0,0,0 );

vtkRenderer *ren = vtkRenderer::New();
 ren->AddActor( actor );
 ren->SetBackground( 0.1,0.2,0.4 );

vtkRenderWindow *renWin = vtkRenderWindow::New();
 renWin->AddRenderer( ren );
 renWin->SetSize( 500,500 );

vtkRenderWindowInteractor *wink = vtkRenderWindowInteractor::New();
 wink->SetRenderWindow( renWin );

vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();
 wink->SetInteractorStyle( style );

 wink->Initialize();
 wink->Start();

 style->Delete();
 wink->Delete();
 renWin->Delete();
 ren->Delete();
 actor->Delete();
 mapper->Delete();
 hog->Delete();
 vector->Delete();
 points->Delete();
 grid->Delete();

return 0;
}


Thank you for your help and support,
Luke H
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120611/d6146d5b/attachment.htm>


More information about the vtkusers mailing list