Commit 721fd2e9 authored by William McLendon's avatar William McLendon Committed by Kitware Robot
Browse files

Merge topic 'vtkTable_Dump_rowcount'

07f12d14 Added a rowLimit parameter to vtkTable::Dump()
parents e6df451f 07f12d14
...@@ -75,7 +75,7 @@ void vtkTable::PrintSelf(ostream &os, vtkIndent indent) ...@@ -75,7 +75,7 @@ void vtkTable::PrintSelf(ostream &os, vtkIndent indent)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkTable::Dump( unsigned int colWidth ) void vtkTable::Dump( unsigned int colWidth, int rowLimit )
{ {
if ( ! this->GetNumberOfColumns() ) if ( ! this->GetNumberOfColumns() )
...@@ -121,31 +121,35 @@ void vtkTable::Dump( unsigned int colWidth ) ...@@ -121,31 +121,35 @@ void vtkTable::Dump( unsigned int colWidth )
cout << " |\n" cout << " |\n"
<< lineStr; << lineStr;
for ( vtkIdType r = 0; r < this->GetNumberOfRows(); ++ r ) if ( rowLimit != 0 )
{ {
for ( int c = 0; c < this->GetNumberOfColumns(); ++ c ) for ( vtkIdType r = 0; r < this->GetNumberOfRows(); ++ r )
{ {
cout << "| "; for ( int c = 0; c < this->GetNumberOfColumns(); ++ c )
vtkStdString str = this->GetValue( r, c ).ToString();
if ( colWidth < str.length() )
{ {
cout << str.substr( 0, colWidth ); cout << "| ";
} vtkStdString str = this->GetValue( r, c ).ToString();
else
{ if ( colWidth < str.length() )
cout << str;
for ( unsigned int i = static_cast<unsigned int>(str.length()); i < colWidth; ++ i )
{ {
cout << " "; cout << str.substr( 0, colWidth );
}
else
{
cout << str;
for ( unsigned int i = static_cast<unsigned int>(str.length()); i < colWidth; ++ i )
{
cout << " ";
}
} }
} }
cout << " |\n";
if ( rowLimit != -1 && r >= rowLimit )
break;
} }
cout << " |\n"; cout << lineStr;
cout.flush();
} }
cout << lineStr;
cout.flush();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -62,8 +62,11 @@ public: ...@@ -62,8 +62,11 @@ public:
void PrintSelf(ostream &os, vtkIndent indent); void PrintSelf(ostream &os, vtkIndent indent);
// Description: // Description:
// Dump table contents. // Dump table contents. If rowLimit is -1 then the full table
void Dump( unsigned int colWidth = 16 ); // is printed out (Default). If rowLimit is 0 then only the
// header row will be displayed. Otherwise, if rowLimit > 0
// then Dump will print the first rowLimit rows of data.
void Dump( unsigned int colWidth = 16, int rowLimit = -1 );
// Description: // Description:
// Return what type of dataset this is. // Return what type of dataset this is.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment