[vtk-developers] void vtkCamera::SetPosition crashed

Joachim Pouderoux joachim.pouderoux at kitware.com
Thu Jan 7 18:56:41 EST 2016


Dennis,
GetPosition() writes 3 double at the provided pointer. Here you pass it a
pointer sized for 3 floats (2 times smaller), so it crashes (you
misunderstand the meaning of reinterpret_cast).
Declare cpos as a double array instead of a float array and it will work
(double cpos[3];).

Best,

*Joachim Pouderoux*

*PhD, Technical Expert*
*Kitware SAS <http://www.kitware.fr>*


2016-01-08 0:08 GMT+01:00 dieutan via vtk-developers <vtk-developers at vtk.org
>:

> Hi Everyone,
>
> My application crashed when calling vtkCamera::SetPosition
>
> Here is some of my code:
> float cpos[3];
> vtkRenderer *ren1;
> ren1 = vtkRenderer::New();
> vtkCamera *cam1 = ren1->GetActiveCamera();
>
> cam1->GetPosition(reinterpret_cast<double *>(cpos));
> cam1->SetPosition(0.000000,0.000000,7.453844);
>
> Here is the error message:
> Unhandled exception at 0x019661e1 in Sersim.exe: 0xC0000005: Access
> violation reading location 0x00000050.
>
> I'm using w1ndows 7, visual studio 2010, VTK version 5.10.1.
>
> Please advice to fix the issue.
>
> Thanks in advance,
> Dennis
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/void-vtkCamera-SetPosition-crashed-tp5735862.html
> Sent from the VTK - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160108/3daa36ee/attachment.html>


More information about the vtk-developers mailing list