[vtkusers] matrix output VERY hard to read

David Doria daviddoria+vtk at gmail.com
Sun Dec 6 19:28:04 EST 2009


On Wed, Oct 21, 2009 at 6:28 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> Yes, that's true, I guess it really is that easy.
>
> Still, I wish that VTK did have a vtkPrintFormat object because it
> would make writing PrintSelf methods a lot less tedious.
>
> For example, there are tons of lines of code in VTK like this
> (probably many with little errors and inconsistencies here and there):
>
>  os << "Origin: " << this->Origin[0] << " " << this->Origin[1] << " "
> << this->Origin[2] << "\n";
>
> These could have been simply like this:
>
>  format->PrintAttribute(os, "Origin", this->Origin, 3);
>
> Or even a macro:
>
>  vtkPrintAttributeMacro(Origin,3);
>
> Unfortunately all those "<<" operators have already been typed... but
> it's not too late to switch to a better system.
>
>   David
>
>
> On Wed, Oct 21, 2009 at 5:08 PM, Francois Bertel
> <francois.bertel at kitware.com> wrote:
> > 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<daviddoria%2Bvtk 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
>
>
Was the decision to do nothing? If so, that would be unfortunate :(

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091206/1fe4c315/attachment.htm>


More information about the vtkusers mailing list