- // Show endpoints
- vtkSmartPointer< vtkPoints > endpoints_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > endpoints_cells =
- vtkSmartPointer< vtkCellArray >::New( );
- for(
- TFilter::TUniqueVertices::ConstIterator epIt = endpoints->Begin( );
- epIt != endpoints->End( );
- ++epIt
- )
- {
- TImage::PointType pnt;
- input_image->TransformIndexToPhysicalPoint( *epIt, pnt );
- endpoints_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- endpoints_cells->InsertNextCell( 1 );
- endpoints_cells->
- InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 1 );
-
- } // rof
- vtkSmartPointer< vtkPolyData > endpoints_polydata =
- vtkSmartPointer< vtkPolyData >::New( );
- endpoints_polydata->SetPoints( endpoints_points );
- endpoints_polydata->SetVerts( endpoints_cells );
- view.AddPolyData( endpoints_polydata, 0, 0, 1, 1 );
-
- // Show bifurcations
- vtkSmartPointer< vtkPoints > bifurcations_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > bifurcations_cells =
- vtkSmartPointer< vtkCellArray >::New( );
- for(
- TFilter::TUniqueVertices::ConstIterator bfIt = bifurcations->Begin( );
- bfIt != bifurcations->End( );
- ++bfIt
- )
- {
- TImage::PointType pnt;
- input_image->TransformIndexToPhysicalPoint( *bfIt, pnt );
- bifurcations_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- bifurcations_cells->InsertNextCell( 1 );
- bifurcations_cells->
- InsertCellPoint( bifurcations_points->GetNumberOfPoints( ) - 1 );
-
- } // rof
- vtkSmartPointer< vtkPolyData > bifurcations_polydata =
- vtkSmartPointer< vtkPolyData >::New( );
- bifurcations_polydata->SetPoints( bifurcations_points );
- bifurcations_polydata->SetVerts( bifurcations_cells );
- view.AddPolyData( bifurcations_polydata, 0, 1, 0, 1 );
-
- // Show branches (simple and detailed)
- vtkSmartPointer< vtkPoints > simple_branches_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > simple_branches_cells =
- vtkSmartPointer< vtkCellArray >::New( );
-
- vtkSmartPointer< vtkPoints > detailed_branches_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > detailed_branches_cells =
- vtkSmartPointer< vtkCellArray >::New( );
- vtkSmartPointer< vtkFloatArray > detailed_branches_scalars =
- vtkSmartPointer< vtkFloatArray >::New( );
-
- TFilter::TBranches::ConstIterator brIt = branches->Begin( );
- for( ; brIt != branches->End( ); ++brIt )
- {
- // Branch's first point
- TImage::PointType first_point;
- input_image->TransformIndexToPhysicalPoint( brIt->first, first_point );
- unsigned long first_id = simple_branches_points->GetNumberOfPoints( );
- simple_branches_points->InsertNextPoint(
- first_point[ 0 ], first_point[ 1 ], first_point[ 2 ]
- );
-
- TFilter::TBranches::ConstRowIterator brRowIt = branches->Begin( brIt );
- for( ; brRowIt != branches->End( brIt ); ++brRowIt )
- {
- // Branch's second point
- TImage::PointType second_point;
- input_image->
- TransformIndexToPhysicalPoint( brRowIt->first, second_point );
- unsigned long second_id = simple_branches_points->GetNumberOfPoints( );
- simple_branches_points->InsertNextPoint(
- second_point[ 0 ], second_point[ 1 ], second_point[ 2 ]
- );
- simple_branches_cells->InsertNextCell( 2 );
- simple_branches_cells->InsertCellPoint( first_id );
- simple_branches_cells->InsertCellPoint( second_id );
-
- // Detailed path
- double pathId = double( brRowIt->second - 1 ) / double( nBranches - 1 );
- TFilter::TVertices path;
- mst->GetPath( path, brIt->first, brRowIt->first );
- TFilter::TVertices::const_iterator pIt = path.begin( );
- for( ; pIt != path.end( ); ++pIt )
- {
- TImage::PointType path_point;
- input_image->TransformIndexToPhysicalPoint( *pIt, path_point );
- detailed_branches_points->InsertNextPoint(
- path_point[ 0 ], path_point[ 1 ], path_point[ 2 ]
- );
- detailed_branches_scalars->InsertNextTuple1( pathId );
- if( pIt != path.begin( ) )
- {
- unsigned long nPoints =
- detailed_branches_points->GetNumberOfPoints( );
- detailed_branches_cells->InsertNextCell( 2 );
- detailed_branches_cells->InsertCellPoint( nPoints - 2 );
- detailed_branches_cells->InsertCellPoint( nPoints - 1 );
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
- vtkSmartPointer< vtkPolyData > simple_branches_polydata =
- vtkSmartPointer< vtkPolyData >::New( );
- simple_branches_polydata->SetPoints( simple_branches_points );
- simple_branches_polydata->SetLines( simple_branches_cells );
- view.AddPolyData( simple_branches_polydata, 1, 0, 1, 1 );
-
- vtkSmartPointer< vtkPolyData > detailed_branches_polydata =
- vtkSmartPointer< vtkPolyData >::New( );
- detailed_branches_polydata->SetPoints( detailed_branches_points );
- detailed_branches_polydata->SetLines( detailed_branches_cells );
- detailed_branches_polydata->
- GetPointData( )->SetScalars( detailed_branches_scalars );
- view.AddPolyData( detailed_branches_polydata, 1 );
-
- // Let some more interaction
- view.Render( );
- view.Start( );
-