[vtkusers] Generic vtkMatrix

Aashish Chaudhary aashish.chaudhary at kitware.com
Wed Nov 25 12:10:45 EST 2009


I think we can use existing data structures (like vtkArray) and have
vtkVector or vtkMatrix. The reason which I think everyone agrees the
expressiveness and semantics.

For example I think it would make sense to have transpose and inverse on
something like vtkMatrix but probably would not be very intuitive to use
these operations on  vtkArray?

Most of the open source SceneGraph libraries such as OpenSG, OpenSceneGraph
provide vector, point and matrix classes so I think seeing them in VTK would
not confuse new users of VTK probably?

Like Marcus said as it is we cannot have locals (which would have been nice)
but I think I am ok with having it on heap.

~Thanks,
Aashish



On Wed, Nov 25, 2009 at 11:28 AM, Marcus D. Hanwell <
marcus.hanwell at kitware.com> wrote:

> On Wednesday 25 November 2009 11:07:01 David Doria wrote:
> > On Wed, Nov 25, 2009 at 10:44 AM, Aashish Chaudhary <
> >
> > aashish.chaudhary at kitware.com> wrote:
> > > I think it will be really useful to have it. Last week I was looking
> for
> > > something similar...
> > >
> > > Also Passing array (pointers) is not the best thing without passing the
> > > size of the array which I think will be gone if we pass the vectors (or
> > > there references)
> > >
> > > Regards
> >
> > That is a very good point. Also, you could then even return objects
> >
> > vtkPoint GetPoint(int index);
> >
> > instead of
> > void GetPoint(int index, double* point);
>
> With the current VTK this would not work, as vtkObjects are allocated from
> the
> heap. It would be great to have lightweight objects for points and colors
> for
> example. They could be returned by value, and the API would be simpler but
> this API cannot be wrapped as far as I know.
> >
> > Another thing is that code readability is tremendously improved. From my
> > example above, the math equations map directly to the c++ code:
> >
> > c = a-b;
>
> Wouldn't it be *c = (*a) - (*b); right now if they were vtkObject derived
> classes following the current heap based semantics?
> >
> > rather than having to interpret what is going on when you see something
> >  like this (or typically even much more complicated):
> >
> > for(unsigned int i = 0; i < 3; i++)
> > {
> > c[i] = a[i] - b[i];
> > }
> >
> I agree that the code is more expressive. I spent a lot of time using Eigen
> inside the Avogadro project. Eigen allows for a very expressive syntax.
> Because of the data structure they employ it also allowed for,
>
> std::vector<Eigen::Vector3f> points.
> points.resize(3);
> points[0] = Eigen::Vector3f(0.0, 1.0, 2.0);
> ....
>
> You could then grab a pointer to the data, i.e. points[0].data(), and pass
> that straight to glVertexPointer as in memory it was a float[] of length
> n*3.
> Currently I don't think any of this could be wrapped, and so would be of
> less
> use. It would also not fit well with the API currently in use in VTK.
>
> You can use vtkPoints (and now vtkPoints2D) in a similar way, but the
> syntax
> is not as expressive due to dealing with pointers and needing to check the
> underlying type of the array.
>
> I will be pushing more of my work with 2D in VTK which will demonstrate
> some
> of the progress I have made whilst accommodating the VTK API.
>
> Marcus
> --
> Marcus D. Hanwell, Ph.D.
> R&D Engineer, Kitware Inc.
> (518) 881-4937
> _______________________________________________
> 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
>



-- 
Aashish Chaudhary
R&D Engineer
Kitware Inc.
www.kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091125/e3389d64/attachment.htm>


More information about the vtkusers mailing list