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