[vtkusers] PolyData and tensors

Darshan Pai darshanpai at gmail.com
Thu Mar 25 01:19:38 EDT 2010


Added a compilable version here . Please check . I am clueless

#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkDoubleArray.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolydata.h>
#include <iostream>
#include <fstream>
#include <vtkProperty.h>
#include <vtkPointData.h>

int main()
{
    vtkPoints *points = vtkPoints::New();
    vtkCellArray *lines = vtkCellArray::New();
    vtkPolyData *indata = vtkPolyData::New();
    vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
    vtkActor* fiber_actor = vtkActor::New();
    vtkDoubleArray *dbar = vtkDoubleArray::New();

    dbar->SetNumberOfTuples(10);
    dbar->SetNumberOfComponents(9);
    points->SetNumberOfPoints(10);
    lines->SetNumberOfCells(10);

    points->InsertPoint(0,101.822,56.87,64.0516);
    points->InsertPoint(1,101.844,57.7007,64.5);
    points->InsertPoint(2,101.818,57.81,64.4116);
    points->InsertPoint(3,101.497,58.75,63.6901);
    points->InsertPoint(4,101.147,59.69,63.0351);
    points->InsertPoint(5,101.05,60.0038,62.8423);
    points->InsertPoint(6,100.88,60.63,62.4272);
    points->InsertPoint(7,100.701,61.57,61.9138);
    points->InsertPoint(8,100.609,62.3104,61.5);
    points->InsertPoint(9,100.591,62.51,61.3388);
    indata->SetPoints(points);

    for (int j = 0; j < 10 - 1; j++)
    {
        lines->InsertNextCell(2);
        lines->InsertCellPoint(j);
        lines->InsertCellPoint(j+1);
    }
    indata->SetLines(lines);
    for (int i = 0; i < 10; i++)
    {
        dbar->SetComponent(i,0,1);
        dbar->SetComponent(i,1,1);
        dbar->SetComponent(i,2,1);
        dbar->SetComponent(i,3,1);
        dbar->SetComponent(i,4,1);
        dbar->SetComponent(i,5,1);
        dbar->SetComponent(i,6,1);
        dbar->SetComponent(i,7,1);
        dbar->SetComponent(i,8,1);
    }
    indata->GetPointData()->SetTensors(dbar);
    mapper->SetInput(indata);

    fiber_actor->SetMapper(mapper);
    fiber_actor->GetProperty()->SetLineWidth(3.0);
    vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
    renderer->AddActor(fiber_actor);
    vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
     renderWindow->AddRenderer( renderer );
     renderWindow->SetSize(1000,1000);

    vtkSmartPointer<vtkRenderWindowInteractor> interactor =
        vtkSmartPointer<vtkRenderWindowInteractor>::New();
     interactor->SetRenderWindow( renderWindow );

  // Initialize the event loop and then start it
    interactor->Initialize();
     interactor->Start();
}

On Wed, Mar 24, 2010 at 7:25 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> On Wed, Mar 24, 2010 at 6:46 PM, Darshan Pai <darshanpai at gmail.com> wrote:
>
>> I am trying to make a polydata composed of polylines , I am planning to
>> add tensor information at each of the points .
>> i want to make a EllipsoidTensorProbeRepresentation which will add this
>> polyline as a trajectory so that I can get an
>> ellipsoid representation across the polyline.
>>
>> My main problem is adding the tensor.
>> I did the following
>>
>> vtkDoubleArray *dbar = vtkDoubleArray::New();
>> dbar->SetNumberOfValues(size);
>> dbar->SetNumberOfComponents(9);
>>
>> The for each point I add the 9 components using the following function
>>
>> dbar->SetComponent(i,0,1)
>> dbar->SetComponent(i,1,1);
>> .............. and so on
>>
>> When I try to add it to the polydata though
>> indata->GetPointData()->SetTensors(dbar);
>>
>> It crashes .
>>
>> I am not sure where I am going wrong
>>
>> Please Help
>>
>> Darshan
>>
>>
> Can you make the smallest compilable example that demonstrates this
> behavior and post it to the list?
>
> Thanks,
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100325/33116240/attachment.htm>


More information about the vtkusers mailing list