[vtkusers] matrix output VERY hard to read

Francois Bertel francois.bertel at kitware.com
Wed Oct 21 19:08:21 EDT 2009


You don't need all these things if you're working in C++.
You just have to change the flag on your ostream:

Example with cout:

vtkObject *a;

cout.setf(ios::scientific,ios::floatfield); // ios::fixed or ios::scientific
cout.precision(5);

a->Print(cout);

ref: http://www.cplusplus.com/reference/iostream/ostream/
ref: http://www.cplusplus.com/reference/iostream/ios_base/fmtflags/


On Wed, Oct 21, 2009 at 7:03 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Wed, Oct 21, 2009 at 6:52 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>> I agree with Jeff that a method for pretty-printing would be handy.  A
>> generic way of doing this is to create a "formatting" object that can
>> be sent to PrintSelf:
>>
>> void PrintSelf(ostream& os, vtkIndent indent, vtkPrintFormat *format);
>>
>> The "format" object could provide information about precision, column
>> widths, and "level of detail" i.e. whether to print all attributes or
>> just the important ones i.e. the data values.
>>
>> This would be an optional method, i.e. if any object that didn't
>> define the new form of PrintSelf would fall back to the old PrintSelf.
>>  The reason to modify PrintSelf, instead of adding new methods, is
>> because it makes it easy to convert relevant object (matrix,
>> transform, array) over to the new system.
>>
>> There could be two ways of invoking the pretty-print methods:
>>
>> vtkPrintFormat::Print(ostream &stream, vtkObject *object);
>>
>> vtkObject::Print(ostream &stream, vtkPrintFormat *format);
>>
>> Overall, this would be fairly easy to implement and would be very
>> general-purpose.  In fact it is general enough to even encompass such
>> things as serialization of VTK objects.
>>
>>    David
>> ___
>
> David Gobbi,
>
> That sounds like a very reasonable idea to me. Are you or Jeff
> interested in setting up the framework? Once it's setup, I'd be happy
> to try to write a few of the Print functions. We should make a list of
> things that could really use the new idea: vtkMatrix4x4,
> vtk*Transform, vtk*Array, ?
>
> This "level of detail" is also a nice feature, almost all the classes
> could eventually be updated to have a few different levels of detail.
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list