<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hello,<br>
<br>
I'm trying to set the position and orientation of a vtkAxesActor by call SetUserMatrix(), but sometimes (not always) get segmentation faults during execution. The code to create and update the vtkAxesActor is as follows :
<br>
<br>
<br>
void Viewer::addAxes( vtkSmartPointer<vtkAxesActor>& _axesActor,<br>
const std::string& _xLabel,<br>
const std::string& _yLabel,<br>
const std::string& _zLabel,<br>
bool _instantiate)<br>
{<br>
if(_instantiate)<br>
_axesActor = vtkSmartPointer<vtkAxesActor>::New();<br>
<br>
// Axes labels<br>
_axesActor->SetXAxisLabelText(_xLabel.c_str());<br>
_axesActor->SetYAxisLabelText(_yLabel.c_str());<br>
_axesActor->SetZAxisLabelText(_zLabel.c_str());<br>
<br>
renderer_->AddActor(_axesActor);<br>
}<br>
<br>
void Viewer::updateAxes( vtkSmartPointer<vtkAxesActor>& _axesActor, const Eigen::Matrix4d& _matrix)<br>
{<br>
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();<br>
for(int row = 0; row < 4; ++row)<br>
for(int col = 0; col < 4; ++col)<br>
matrix->SetElement(row, col, _matrix(row,col));<br>
<br>
_axesActor->SetUserMatrix(matrix);<br>
_axesActor->Modified();<br>
}<br>
<br>
The segmentation faults don't always occur and if they occur, they don't always occur at the same location in the vtk code ... The error messages also differ... Here are some examples of where the segmentation faults occur and the associated printed error:<br>
<br>
<a href="https://www.dropbox.com/s/h2i4fi8duo20ucl/vtkAxesActor1.png?dl=0" target="_blank">https://www.dropbox.com/s/h2i4fi8duo20ucl/vtkAxesActor1.png?dl=0</a>
<br>
ERROR: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObject.cxx, line 160<br>
vtkObject (0x7fffb0223940): Trying to delete object with non-zero reference count.<br>
<br>
<a href="https://www.dropbox.com/s/uh3bgg0h801fyl2/vtkAxesActor2.png?dl=0" target="_blank">https://www.dropbox.com/s/uh3bgg0h801fyl2/vtkAxesActor2.png?dl=0</a>
<br>
*** glibc detected *** free(): corrupted unsorted chunks: 0x00007fffb00bb120 ***<br>
<br>
<a href="https://www.dropbox.com/s/fp835mo85z9wicp/vtkAxesActor3.png?dl=0" target="_blank">https://www.dropbox.com/s/fp835mo85z9wicp/vtkAxesActor3.png?dl=0</a>
<br>
Generic Warning: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObjectBase.cxx, line 93<br>
Trying to delete object with non-zero reference count.<br>
ERROR: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObject.cxx, line 160<br>
vtkObject (0x7fffb0010fe0): Trying to delete object with non-zero reference count.<br>
Generic Warning: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObjectBase.cxx, line 93<br>
Trying to delete object with non-zero reference count.<br>
<br>
<a href="https://www.dropbox.com/s/r02j73o7c9n8x5v/vtkAxesActor4.png?dl=0" target="_blank">https://www.dropbox.com/s/r02j73o7c9n8x5v/vtkAxesActor4.png?dl=0</a><br>
(no printed message)<br>
<br>
I am not quite sure why this happens. Would it have something to do with the way I create/update the vtkAxesActor or the vtkMatrix4x4 ? Using another vtk object (e.g. vtkSphereSource and vtkActor) instead of vtkAxesActor to display the origin of the axes doesn't
seem to generate any segmentation fault. <br>
<br>
The VTK rendering is embedded within a QVTKWidget and I use VTK6.0.<br>
<br>
Any help is appreciated.<br>
<br>
Toan<br>
<br>
<br>
</div>
</div>
</div>
</div>
</body>
</html>