[vtkusers] vtkAxesActor and user matrix/transform
Phuong Toan Tran
PhuongToan.Tran at kuleuven.be
Thu May 7 12:36:17 EDT 2015
Hello,
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 :
void Viewer::addAxes( vtkSmartPointer<vtkAxesActor>& _axesActor,
const std::string& _xLabel,
const std::string& _yLabel,
const std::string& _zLabel,
bool _instantiate)
{
if(_instantiate)
_axesActor = vtkSmartPointer<vtkAxesActor>::New();
// Axes labels
_axesActor->SetXAxisLabelText(_xLabel.c_str());
_axesActor->SetYAxisLabelText(_yLabel.c_str());
_axesActor->SetZAxisLabelText(_zLabel.c_str());
renderer_->AddActor(_axesActor);
}
void Viewer::updateAxes( vtkSmartPointer<vtkAxesActor>& _axesActor, const Eigen::Matrix4d& _matrix)
{
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
for(int row = 0; row < 4; ++row)
for(int col = 0; col < 4; ++col)
matrix->SetElement(row, col, _matrix(row,col));
_axesActor->SetUserMatrix(matrix);
_axesActor->Modified();
}
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:
https://www.dropbox.com/s/h2i4fi8duo20ucl/vtkAxesActor1.png?dl=0
ERROR: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObject.cxx, line 160
vtkObject (0x7fffb0223940): Trying to delete object with non-zero reference count.
https://www.dropbox.com/s/uh3bgg0h801fyl2/vtkAxesActor2.png?dl=0
*** glibc detected *** free(): corrupted unsorted chunks: 0x00007fffb00bb120 ***
https://www.dropbox.com/s/fp835mo85z9wicp/vtkAxesActor3.png?dl=0
Generic Warning: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObjectBase.cxx, line 93
Trying to delete object with non-zero reference count.
ERROR: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObject.cxx, line 160
vtkObject (0x7fffb0010fe0): Trying to delete object with non-zero reference count.
Generic Warning: In /home/toan/Libraries/vtk/VTK6.0.0/Common/Core/vtkObjectBase.cxx, line 93
Trying to delete object with non-zero reference count.
https://www.dropbox.com/s/r02j73o7c9n8x5v/vtkAxesActor4.png?dl=0
(no printed message)
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.
The VTK rendering is embedded within a QVTKWidget and I use VTK6.0.
Any help is appreciated.
Toan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150507/7aef4c3a/attachment.html>
More information about the vtkusers
mailing list