<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hello everyone,</div>

<div>I attempt the vtkHedgeHog example to rewrite from the vtkStructuredGrid to vtkStructuredPoints (ImageGrid) in order to obtain 3D VectorField.</div>

<div>I succeeded with the vtkHedgeHog example to create a 3D Grid with points.<br/>
And this I attempt now with vtkStructurePoints. Below the code:</div>

<div><br/>
void CreateData(vtkStructuredPoints* structuredPoints);</div>

<div>int main(int argc, char* argv[])<br/>
{</div>

<div>    vtkSmartPointer<vtkStructuredPoints> structuredPoints =<br/>
       vtkSmartPointer<vtkStructuredPoints>::New();<br/>
    CreateData(structuredPoints);</div>

<div>    vtkArrowSource* arrowSource =<br/>
       vtkArrowSource::New();<br/>
    arrowSource->Update();<br/>
        <br/>
    vtkGlyph3D* glyphFilter =<br/>
       vtkGlyph3D::New();<br/>
    glyphFilter->SetSourceConnection(arrowSource->GetOutputPort());<br/>
    glyphFilter->OrientOn();<br/>
    glyphFilter->SetVectorModeToUseVector();<br/>
    glyphFilter->SetInputData(structuredPoints);<br/>
    glyphFilter->Update();<br/>
        <br/>
    vtkPolyDataMapper *sgridMapper =<br/>
       vtkPolyDataMapper::New();<br/>
    sgridMapper->SetInputConnection(glyphFilter->GetOutputPort());<br/>
    <br/>
    vtkActor* sgridActor =<br/>
       vtkActor::New();<br/>
    sgridActor->SetMapper(sgridMapper);<br/>
    sgridActor->GetProperty()->SetColor(0,0,0);<br/>
    <br/>
    vtkRenderer* renderer =<br/>
       vtkRenderer::New();    <br/>
    renderer->AddActor(sgridActor);<br/>
    renderer->SetBackground(1,1,1);<br/>
    renderer->ResetCamera();<br/>
    renderer->GetActiveCamera()->Elevation(0.0);    <br/>
    renderer->GetActiveCamera()->Azimuth(0.0);        <br/>
    renderer->GetActiveCamera()->Zoom(1.25);<br/>
    <br/>
    vtkSmartPointer<vtkRenderWindow> renWin =<br/>
       vtkSmartPointer<vtkRenderWindow>::New();<br/>
    renWin->AddRenderer(renderer);<br/>
    renWin->SetSize(300,300);<br/>
    <br/>
    vtkSmartPointer<vtkRenderWindowInteractor> iren =<br/>
       vtkSmartPointer<vtkRenderWindowInteractor>::New();<br/>
    iren->SetRenderWindow(renWin);<br/>
        <br/>
    vtkAxesActor* axes =<br/>
       vtkAxesActor::New();    <br/>
    vtkOrientationMarkerWidget* widget =<br/>
       vtkOrientationMarkerWidget::New();<br/>
    widget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );<br/>
    widget->SetOrientationMarker( axes );<br/>
    widget->SetInteractor( iren );<br/>
    widget->SetViewport( 0.0, 0.0, 0.4, 0.4 );<br/>
    widget->SetEnabled( 1 );<br/>
    widget->InteractiveOn();<br/>
    <br/>
    renWin->Render();<br/>
    iren->Start();<br/>
    <br/>
    return EXIT_SUCCESS;<br/>
}</div>

<div> </div>

<div>void CreateData(vtkStructuredPoints* structuredPoints)<br/>
{<br/>
    int dimX = 7.0;<br/>
    int dimY = 7.0;<br/>
    int dimZ = 7.0;<br/>
    int anzahlXYZ=dimX*dimY*dimY;<br/>
    float *array_xyz = new float[anzahlXYZ];<br/>
    int index;<br/>
    float v_xyz[3];            <br/>
    static int dims[3]={dimX,dimY,dimZ};<br/>
    <br/>
    structuredPoints->SetDimensions(dims);</div>

<div>    vtkSmartPointer<vtkFloatArray> vectors =<br/>
    vtkSmartPointer<vtkFloatArray>::New();<br/>
    vectors->SetNumberOfComponents(3);<br/>
    vectors->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);<br/>
    <br/>
    vtkSmartPointer<vtkPoints> points =<br/>
      vtkSmartPointer<vtkPoints>::New();<br/>
    <br/>
    <br/>
    points->Allocate(dims[0]*dims[1]*dims[2]);<br/>
    <br/>
    for(int x=0; x<dims[0]; x++)<br/>
    {<br/>
        for(int y=0; y<dims[1]; y++)<br/>
        {<br/>
            for(int z=0; z<dims[2]; z++)<br/>
            {<br/>
                .<br/>
                .<br/>
            Create Data in Array an put it in Vectors                <br/>
                .<br/>
                .            <br/>
            }<br/>
        }<br/>
    }<br/>
    <br/>
    for(int x=0; x<dims[0]; x++)<br/>
    {<br/>
        for(int y=0; y<dims[1]; y++)<br/>
        {<br/>
            for(int z=0; z<dims[2]; z++)<br/>
            {                                                                                                                                          //Question:<br/>
            double* pixel = static_cast<double*>(structuredPoints->GetScalarPointer(x,y,z));         //Is the ScalarPointer the wrong way?<br/>
            pixel[0] = v_xyz[0];<br/>
            pixel[1] = v_xyz[1];<br/>
            pixel[2] = v_xyz[2];<br/>
            <br/>
            points->InsertPoint(index,array_xyz);<br/>
            vectors->InsertTuple(index,v_xyz);<br/>
            index++;<br/>
            }<br/>
        }<br/>
    }<br/>
    //structuredPoints->SetPoints(points); //at the basic example Hedgehog  <br/>
    structuredPoints->GetPointData()->SetVectors(vectors);                                                          //->SetVector(to commit the vectors); ?<br/>
}</div>

<div><br/>
What is the right way to commit the data in ->SetVector(.......); ?</div>

<div>When I build it, it looks as if everything was okay but when I play it, the output-window is not open.</div>

<div>It is impossible to work with vectors when I work with vtkStructuredPoints?</div>

<div><br/>
Can anyone help me, tanks in advance.</div>

<div>V.M</div>
</div></div></body></html>