[vtkusers] IntPtr for ActiViz.Net
mirko heuegger
mheuegger at gmail.com
Fri Sep 2 03:55:58 EDT 2011
Hello!
On Thu, Sep 1, 2011 at 6:35 PM, zlf <jxdw_zlf at yahoo.com.cn> wrote:
> vtkMatrix4x4#MultiplyDoublePoint only accept IntPtr parameter. How to pass
> double[] typed parameter into it?
SampleCode:
//ZOOT is you desired array of whatever (eg: double[] ZOOT = new double[42];)
int s = Marshal.SizeOf(ZOOT[0]) * ZOOT.Length;
System.IntPtr p = Marshal.AllocHGlobal(s);
try
{
Marshal.Copy(ZOOT, 0, p, ZOOT.Length); // copy array to
unmanaged memory.
// do you (pointer) stuff here
// ....
Marshal.Copy(p, ZOOT, 0, ZOOT.Length); // copy results back (if needed)
}
catch (Exception eX)
{
//handle error here
}
finally
{
Marshal.FreeHGlobal(p); //free
}
hth
mirko
--
Real programmers don't document; if it was
hard to write, it should be hard to understand.
More information about the vtkusers
mailing list