<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
OK, as far as I understand the problem is that my inPtr and outPtr -arrays are on the stack and I nead it on the heap.<br>ahm.. how do I malloc or new the memory in this case? I thought that my call to SetArray does automatically allocate the necessary memory for my new_scalars array..<br>thx,<br>NH<br><br>> Date: Fri, 19 Sep 2008 08:59:19 -0400<br>> From: burlen.loring@kitware.com<br>> To: nataliehapp@hotmail.com<br>> CC: paraview@paraview.org<br>> Subject: Re: [Paraview] problem configuring the output of a filter<br>> <br>> Natalie Happenhofer wrote:<br>> > Hi!<br>> > I have problems configuring the output of my filter, the filter is a <br>> > subclass of vtkDataSetToStructuredGrid and setting the output looks as <br>> > following:<br>> ><br>> > //setting the new point data<br>> > vtkSmartPointer<vtkFloatArray> new_scalars = <br>> > vtkSmartPointer<vtkFloatArray>::New();<br>> ><br>> > double inPtr[numOfTuples + 1]; //pointer for casting the values <br>> > actually to double, so I can perform arithmetic operations with them<br>> > float outPtr[numOfTuples + 1];<br>> > //calculating ..<br>> ><br>> > new_scalars -> SetArray(outPtr,numOfTuples,1);<br>> <br>> You are passing a stack based array here, when your function returns <br>> inPtr and outPtr no longer are valid. If you are going to use SetArray <br>> you'll have to malloc or new the memory you need.<br>> <br>> ><br>> ><br>> ><br>> > output -> SetDimensions(dims);<br>> > output -> SetPoints(pts); //Now the points are set<br>> > output -> GetPointData() -> SetScalars(new_scalars);<br>> > output -> Squeeze();<br>> ><br>> ><br>> > dims are the dimensions of the input, which is a RectilinearGrid or a <br>> > StructuredGrid, new_scalars is a vtkFloatArray. I believe that the <br>> > "output->GetPointData() ->SetScalars(new_scalars)"-line is causing the <br>> > problem, because I get the following error messages:<br>> ><br>> > Program received signal SIGSEGV, Segmentation fault.<br>> > vtkFieldData::GetActualMemorySize<br>> > at C:/ParaviewSource/ParaView3/VTK/Filtering/vtkFieldData.cxx:577<br>> > size +=this->Data[i]->GetActualMemorySize();<br>> ><br>> > Backtracing, functions in vtkPVDataInformation and vtkSelfConnections <br>> > are called,<br>> > so I guess, this does not actually happen in my source code but in the <br>> > rendering pipeline. As I did not change anything in the rendering <br>> > pipeline, there must be an allocation or a call in my code with <br>> > incorrect arguments, but I do not really know where to look for the <br>> > error.<br>> > Does anyone have an idea?<br>> ><br>> > Thx,<br>> > NH<br>> ><br>> ><br>> > ------------------------------------------------------------------------<br>> > Express yourself instantly with MSN Messenger! MSN Messenger <br>> > <http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/><br>> > ------------------------------------------------------------------------<br>> ><br>> > _______________________________________________<br>> > ParaView mailing list<br>> > ParaView@paraview.org<br>> > http://www.paraview.org/mailman/listinfo/paraview<br>> > <br>> <br>> <br>> -- <br>> Burlen Loring<br>> Kitware, Inc.<br>> R&D Engineer<br>> 28 Corporate Drive<br>> Clifton Park, NY 12065-8662<br>> Phone: 518-371-3971 x137<br>> <br><br /><hr />Express yourself instantly with MSN Messenger! <a href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN Messenger</a></body>
</html>