@ -249,179 +249,6 @@ void cv::viz::Viz3d::VizImpl::setBackgroundColor (const Color& color)
renderer_ - > SetBackground ( c . val ) ;
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool cv : : viz : : Viz3d : : VizImpl : : getPointCloudRenderingProperties ( int property , double & value , const std : : string & id )
{
CloudActorMap : : iterator am_it = cloud_actor_map_ - > find ( id ) ;
if ( am_it = = cloud_actor_map_ - > end ( ) )
return false ;
vtkLODActor * actor = vtkLODActor : : SafeDownCast ( am_it - > second . actor ) ;
switch ( property )
{
case VIZ_POINT_SIZE :
{
value = actor - > GetProperty ( ) - > GetPointSize ( ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_OPACITY :
{
value = actor - > GetProperty ( ) - > GetOpacity ( ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_LINE_WIDTH :
{
value = actor - > GetProperty ( ) - > GetLineWidth ( ) ;
actor - > Modified ( ) ;
break ;
}
default :
CV_Assert ( " getPointCloudRenderingProperties: Unknown property " ) ;
}
return true ;
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool cv : : viz : : Viz3d : : VizImpl : : setPointCloudRenderingProperties ( int property , double value , const std : : string & id )
{
CloudActorMap : : iterator am_it = cloud_actor_map_ - > find ( id ) ;
if ( am_it = = cloud_actor_map_ - > end ( ) )
return std : : cout < < " [setPointCloudRenderingProperties] Could not find any PointCloud datasets with id < " < < id < < " >! " < < std : : endl , false ;
vtkLODActor * actor = vtkLODActor : : SafeDownCast ( am_it - > second . actor ) ;
switch ( property )
{
case VIZ_POINT_SIZE :
{
actor - > GetProperty ( ) - > SetPointSize ( float ( value ) ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_OPACITY :
{
actor - > GetProperty ( ) - > SetOpacity ( value ) ;
actor - > Modified ( ) ;
break ;
}
// Turn on/off flag to control whether data is rendered using immediate
// mode or note. Immediate mode rendering tends to be slower but it can
// handle larger datasets. The default value is immediate mode off. If you
// are having problems rendering a large dataset you might want to consider
// using immediate more rendering.
case VIZ_IMMEDIATE_RENDERING :
{
actor - > GetMapper ( ) - > SetImmediateModeRendering ( int ( value ) ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_LINE_WIDTH :
{
actor - > GetProperty ( ) - > SetLineWidth ( float ( value ) ) ;
actor - > Modified ( ) ;
break ;
}
default :
CV_Assert ( " setPointCloudRenderingProperties: Unknown property " ) ;
}
return true ;
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool cv : : viz : : Viz3d : : VizImpl : : setShapeRenderingProperties ( int property , double value , const std : : string & id )
{
ShapeActorMap : : iterator am_it = shape_actor_map_ - > find ( id ) ;
if ( am_it = = shape_actor_map_ - > end ( ) )
return std : : cout < < " [setShapeRenderingProperties] Could not find any shape with id < " < < id < < " >! \n " < < std : : endl , false ;
vtkActor * actor = vtkActor : : SafeDownCast ( am_it - > second ) ;
switch ( property )
{
case VIZ_POINT_SIZE :
{
actor - > GetProperty ( ) - > SetPointSize ( float ( value ) ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_OPACITY :
{
actor - > GetProperty ( ) - > SetOpacity ( value ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_LINE_WIDTH :
{
actor - > GetProperty ( ) - > SetLineWidth ( float ( value ) ) ;
actor - > Modified ( ) ;
break ;
}
case VIZ_FONT_SIZE :
{
vtkTextActor * text_actor = vtkTextActor : : SafeDownCast ( am_it - > second ) ;
vtkSmartPointer < vtkTextProperty > tprop = text_actor - > GetTextProperty ( ) ;
tprop - > SetFontSize ( int ( value ) ) ;
text_actor - > Modified ( ) ;
break ;
}
case VIZ_REPRESENTATION :
{
switch ( int ( value ) )
{
case REPRESENTATION_POINTS : actor - > GetProperty ( ) - > SetRepresentationToPoints ( ) ; break ;
case REPRESENTATION_WIREFRAME : actor - > GetProperty ( ) - > SetRepresentationToWireframe ( ) ; break ;
case REPRESENTATION_SURFACE : actor - > GetProperty ( ) - > SetRepresentationToSurface ( ) ; break ;
}
actor - > Modified ( ) ;
break ;
}
case VIZ_SHADING :
{
switch ( int ( value ) )
{
case SHADING_FLAT : actor - > GetProperty ( ) - > SetInterpolationToFlat ( ) ; break ;
case SHADING_GOURAUD :
{
if ( ! actor - > GetMapper ( ) - > GetInput ( ) - > GetPointData ( ) - > GetNormals ( ) )
{
std : : cout < < " [cv::viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Gouraud shading was requested. Estimating normals... \n " < < std : : endl ;
vtkSmartPointer < vtkPolyDataNormals > normals = vtkSmartPointer < vtkPolyDataNormals > : : New ( ) ;
normals - > SetInput ( actor - > GetMapper ( ) - > GetInput ( ) ) ;
normals - > Update ( ) ;
vtkDataSetMapper : : SafeDownCast ( actor - > GetMapper ( ) ) - > SetInput ( normals - > GetOutput ( ) ) ;
}
actor - > GetProperty ( ) - > SetInterpolationToGouraud ( ) ;
break ;
}
case SHADING_PHONG :
{
if ( ! actor - > GetMapper ( ) - > GetInput ( ) - > GetPointData ( ) - > GetNormals ( ) )
{
std : : cout < < " [cv::viz::PCLVisualizer::setShapeRenderingProperties] Normals do not exist in the dataset, but Phong shading was requested. Estimating normals... \n " < < std : : endl ;
vtkSmartPointer < vtkPolyDataNormals > normals = vtkSmartPointer < vtkPolyDataNormals > : : New ( ) ;
normals - > SetInput ( actor - > GetMapper ( ) - > GetInput ( ) ) ;
normals - > Update ( ) ;
vtkDataSetMapper : : SafeDownCast ( actor - > GetMapper ( ) ) - > SetInput ( normals - > GetOutput ( ) ) ;
}
actor - > GetProperty ( ) - > SetInterpolationToPhong ( ) ;
break ;
}
}
actor - > Modified ( ) ;
break ;
}
default :
CV_Assert ( " setShapeRenderingProperties: Unknown property " ) ;
}
return true ;
}
/////////////////////////////////////////////////////////////////////////////////////////////
void cv : : viz : : Viz3d : : VizImpl : : initCameraParameters ( )
{