[vtkusers] loading arrays to a vtkStructuredPoints object

Theodore Holden theodoreholden at yahoo.com
Sat May 30 19:52:11 EDT 2009


Hi,

If this one rings any bells for anybody I'd appreciate hearing about it.  I have an application with which a user will repeatedly open an application specific file which includes volume data, and use vtk code to put that data on the screen;  the application file also contains other kinds of data with which other things are being done so that using a .vtk file would not help anything.  What I'd like to do is eliminate having to write my own data to a .vtk file and then re-read it.  I can do that by using a vtkStructuredPoints object directly rather than using vtkStructuredPointsReader, and setting the data for that object directly including adding individual data points by calling SetScalarComponentFromFloat.  Nonetheless that is not as fast as I'd like since it amounts to calling a wrapped function several million times, literally.  What I've tried to do is reduce wrapped calls to one by making up my own load method for the vtkStructuredPoints class in
 the Filtering section thus:

in vtkFiltering:

void vtkStructuredPoints::loadByteArray(int Width, int Height, int NumSlices, float *bdata )
{
        int SliceSize;
        float vv;
        int i, j, k, ii, jj, kk;
        int x, y, z;

        SliceSize = Width * Height;    
    
        for (z = 0; z < NumSlices; z++)
        {
            for (y = 0; y < Height; y++)
            {
                for (x = 0; x < Width; x++)
                {
                    ii = z * SliceSize + y * Width + x;                   
                    this->SetScalarComponentFromFloat(x, y, z, 0, bdata[ii]);
                }
            }
        }    
}    

That gets translated via the SourceForge wrapping software and cmake into:

in vtkFilteringDotNet:

void vtkStructuredPoints::loadByteArray(int Width, int Height, int NumSlices, array<float>^ bdata)
{
  pin_ptr<float> bdataPin = &bdata[0];
  float* nativebdataPin = bdataPin;
  vtk::ConvertManagedToNative<::vtkStructuredPoints>(m_instance)->loadByteArray(Width, Height, NumSlices, nativebdataPin);
}

That compiles and builds, and the VS intellisense understands it and indicates that the input array is float[], and you'd think it would work.  Nonetheless when I try to use it I get a no-such-method exception.

I'll be looking at this one a bit more this coming week;  again if anybody has any suggestions or anything, I'm all ears.


Ted


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090530/acd64b5d/attachment.htm>


More information about the vtkusers mailing list