[Paraview] problem configuring the output of a filter

Burlen Loring burlen.loring at kitware.com
Fri Sep 19 13:12:43 EDT 2008


By using SetArray you are telling VTK to not allocate any memory, and 
instead use the memory you provide. You could allocate the memory with a 
call to something like
double *pd=static_cast<double *>(malloc(nTups*nComps*sizeof(double))); 
In your call to set array consider passing save as 0 so that VTK will 
free the array when its done with it.

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


-- 
Burlen Loring
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x137



More information about the ParaView mailing list