So I figured out the problem . If I do InsetComponent instead of SetComponent it works without crashing . <br><br>So I guess the problem was I did not Allocate the Space before doing SetComponent .<br><br>Regards<br>Darshan<br>
<br><div class="gmail_quote">On Thu, Mar 25, 2010 at 1:19 AM, Darshan Pai <span dir="ltr"><<a href="mailto:darshanpai@gmail.com">darshanpai@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Added a compilable version here . Please check . I am clueless<br><br>#include <vtkActor.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderWindowInteractor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkDoubleArray.h><br>#include <vtkPoints.h><br>#include <vtkCellArray.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkPolydata.h><br>#include <iostream><br>#include <fstream><br>
#include <vtkProperty.h><br>#include <vtkPointData.h><br><br>int main()<br>{<br> vtkPoints *points = vtkPoints::New();<br> vtkCellArray *lines = vtkCellArray::New();<br> vtkPolyData *indata = vtkPolyData::New();<br>
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br> vtkActor* fiber_actor = vtkActor::New();<br> vtkDoubleArray *dbar = vtkDoubleArray::New();<br><br> dbar->SetNumberOfTuples(10);<br> dbar->SetNumberOfComponents(9);<br>
points->SetNumberOfPoints(10);<br> lines->SetNumberOfCells(10);<br><br> points->InsertPoint(0,101.822,56.87,64.0516);<br> points->InsertPoint(1,101.844,57.7007,64.5);<br> points->InsertPoint(2,101.818,57.81,64.4116);<br>
points->InsertPoint(3,101.497,58.75,63.6901);<br> points->InsertPoint(4,101.147,59.69,63.0351);<br> points->InsertPoint(5,101.05,60.0038,62.8423);<br> points->InsertPoint(6,100.88,60.63,62.4272);<br>
points->InsertPoint(7,100.701,61.57,61.9138);<br> points->InsertPoint(8,100.609,62.3104,61.5);<br> points->InsertPoint(9,100.591,62.51,61.3388);<br> indata->SetPoints(points);<br><br> for (int j = 0; j < 10 - 1; j++)<br>
{<br> lines->InsertNextCell(2);<br> lines->InsertCellPoint(j);<br> lines->InsertCellPoint(j+1);<br> }<br> indata->SetLines(lines);<br> for (int i = 0; i < 10; i++)<div class="im">
<br> {<br>
dbar->SetComponent(i,0,1);<br> dbar->SetComponent(i,1,1);<br></div> dbar->SetComponent(i,2,1);<br> dbar->SetComponent(i,3,1);<br> dbar->SetComponent(i,4,1);<br> dbar->SetComponent(i,5,1);<br>
dbar->SetComponent(i,6,1);<br> dbar->SetComponent(i,7,1);<br> dbar->SetComponent(i,8,1);<br> }<br> indata->GetPointData()->SetTensors(dbar);<br> mapper->SetInput(indata);<br>
<br> fiber_actor->SetMapper(mapper);<br> fiber_actor->GetProperty()->SetLineWidth(3.0);<br> vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();<br> renderer->AddActor(fiber_actor);<br>
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();<br> renderWindow->AddRenderer( renderer );<br> renderWindow->SetSize(1000,1000);<br> <br> vtkSmartPointer<vtkRenderWindowInteractor> interactor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> interactor->SetRenderWindow( renderWindow );<br> <br> // Initialize the event loop and then start it<br> interactor->Initialize();<br> interactor->Start(); <br>
<div><div></div><div class="h5">
}<br><br><div class="gmail_quote">On Wed, Mar 24, 2010 at 7:25 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="gmail_quote"><div><div></div><div>On Wed, Mar 24, 2010 at 6:46 PM, Darshan Pai <span dir="ltr"><<a href="mailto:darshanpai@gmail.com" target="_blank">darshanpai@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I am trying to make a polydata composed of polylines , I am planning to add tensor information at each of the points .<br>i want to make a EllipsoidTensorProbeRepresentation which will add this polyline as a trajectory so that I can get an <br>
ellipsoid representation across the polyline.<br><br>My main problem is adding the tensor.<br>I did the following<br><br>vtkDoubleArray *dbar = vtkDoubleArray::New();<br>dbar->SetNumberOfValues(size);<br>dbar->SetNumberOfComponents(9);<br>
<br>The for each point I add the 9 components using the following function<br><br>dbar->SetComponent(i,0,1)<br>dbar->SetComponent(i,1,1);<br>.............. and so on <br><br>When I try to add it to the polydata though <br>
indata->GetPointData()->SetTensors(dbar);<br><br>It crashes .<br><br>I am not sure where I am going wrong <br><br>Please Help<br><font color="#888888"><br>Darshan<br><br></font></blockquote><div class="gmail_quote">
<br></div></div></div><div class="gmail_quote">Can you make the smallest compilable example that demonstrates this behavior and post it to the list?</div><br clear="all">Thanks,<br><br><div>David </div></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>