Hello, <br><br> 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.<br>
<br>#include "vtkPoints.h"<br>#include "vtkFloatArray.h"<br>#include "vtkMath.h"<br>#include "vtkPointData.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkProperty.h"<br>
#include "vtkStructuredGrid.h"<br>#include "vtkHedgeHog.h"<br>#include "vtkCamera.h"<br>#include "vtkActor.h"<br>#include "vtkRenderer.h"<br>#include "vtkRenderWindowInteractor.h"<br>
#include "vtkRenderWindow.h"<br>#include "<div id=":fr">vtkInteractorStyleTrackballCamera.h"<br><br>int main ()<br>{<br><br> int i,j,k,kOffset,jOffset,offset;<br> float x[3],v[3],rMin=0.5,rMax=1.0,deltaRad,deltaZ;<br>
float radius, theta;<br> static int dims[3]={13,11,11};<br><br>vtkStructuredGrid *grid = vtkStructuredGrid::New();<br> grid->SetDimensions(dims);<br><br>vtkPoints *points = vtkPoints::New();<br> points->Allocate(dims[0]*dims[1]*dims[2]);<br>
<br>vtkFloatArray *vector = vtkFloatArray::New();<br> vector->SetNumberOfComponents(3);<br> vector->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);<br><br> deltaZ = 2.0 / (dims[2]-1);<br> deltaRad = (rMax-rMin) / (dims[1]-1);<br>
<br> v[2] = 0.0;<br><br> for (k=0; k<dims[2]; k++)<br> {<br> x[2] = -1.0 + k * deltaZ;<br> kOffset = k * dims[0] * dims[1];<br> for (j=0; j<dims[1]; j++)<br> {<br> radius= rMin + j * deltaRad;<br>
jOffset= j * dims[0];<br> for (i=0; i<dims[0]; i++);<br> {<br> theta = i * vtkMath::DegreesFromRadians(15.0);<br> x[0]=radius *cos( theta );<br> x[1] = radius * sin( theta );<br> v[0] = -x[1];<br>
v[1] = x[0];<br> offset=i + jOffset + kOffset;<br> points->InsertPoint( offset,x );<br> vector->InsertTuple( offset,v );<br> }<br> }<br> }<br><br> grid->SetPoints(points);<br>
grid->GetPointData()->SetVectors( vector );<br><br>vtkHedgeHog *hog = vtkHedgeHog::New();<br> hog->SetVectorMode( vector );<br> hog->SetScaleFactor( 0.1 );<br><br>vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br>
mapper->SetInputConnection( hog->GetOutputPort() );<br><br>vtkActor *actor = vtkActor::New();<br> actor->SetMapper( mapper );<br> actor->GetProperty()->SetColor( 0,0,0 );<br><br>vtkRenderer *ren = vtkRenderer::New();<br>
ren->AddActor( actor );<br> ren->SetBackground( 0.1,0.2,0.4 );<br><br>vtkRenderWindow *renWin = vtkRenderWindow::New();<br> renWin->AddRenderer( ren );<br> renWin->SetSize( 500,500 );<br><br>vtkRenderWindowInteractor *wink = vtkRenderWindowInteractor::New();<br>
wink->SetRenderWindow( renWin );<br><br>vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();<br> wink->SetInteractorStyle( style );<br><br> wink->Initialize();<br> wink->Start();<br>
<br> style->Delete();<br> wink->Delete();<br> renWin->Delete();<br> ren->Delete();<br> actor->Delete();<br> mapper->Delete();<br> hog->Delete();<br> vector->Delete();<br> points->Delete();<br> grid->Delete();<br>
<br>return 0;<br>}<br><br><br>Thank you for your help and support,<br>Luke H</div>