<div dir="ltr">My reaction STL vector of vectors is "yuck". That would cause horrible memory segmentation and allocation of it would be terribly inefficient when using it in the high performance context, special across multiple threads.<div>

<br></div><div>Having said that, David is working on allowing arbitrary subclasses of an abstract cell array which would allow for creating such an implementation when it is the best fit. We definitely need a compact array implementation for performance reasons though.<br>

<div><br></div><div>-berk</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 20, 2013 at 7:15 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">But if the API is going to be broken, we discuss many alternatives. The cell array could be a vector of vectors. Then we could use stl iterators. What overhead in time or memory would this introduce?<div>

<br></div><div>What would the overhead be if we use stl vector's? <div><div class="h5"><br>
<br><div class="gmail_quote">On Wed, Mar 20, 2013 at 4:12 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


 A backward compatible approach might use an additional offset array into the existing cell ids array.<br><br><div class="gmail_quote"><div><div>On Wed, Mar 20, 2013 at 2:22 PM, David Lonie <span dir="ltr"><<a href="mailto:david.lonie@kitware.com" target="_blank">david.lonie@kitware.com</a>></span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi list,<div><br></div><div>I have some questions about the vtkCellArray implementation, as well as some concerns about it after seeing some widespread abuses of its "internal" access methods.</div>





<div><br></div><div>First, some background:</div><div><br></div><div>The vtkCellArray currently stores cell information in the form</div><div><br></div><div>[ cellSize1 id id ... cellSize2 id id ... cellSizeN id id ... ]</div>





<div><br></div><div>where the cell sizes tell the number of points in each cell, and the ids are offsets into an array of points. So a real vtkCellArray may look something like:</div><div><br></div><div>

[(2) 0 1 (4) 3 2 0 4 (3) 1 3 5 (3) 3 5 7]</div><div><br></div><div>where the numbers in parenthesis are the sizes of the cells.</div><div><br></div><div>The docs do point out the current implementation is "totally inadequate" for random access, and I'm trying to understand what benefit it offers at the expense of random cell lookup? There is a vtkCellTypes class that will build up an offset array like the one I propose above, but this approach effectively doubles the amount of memory needed to store the cell sizes (per vtkCellTypes instance, which is often used by parent containers as well as filters), and time must be spent generating these supplemental structures each time the data changes.<br>





</div><div><br></div><div>It seems to me that another implementation would be more useful. In particular, splitting the array into two, one with cell offsets and another with just point ids, transforming the above list into:</div>





<div><br></div><div>[0 2 6 9 12] (offsets, last entry points to end of ids)</div><div>[(0 1) (3 2 0 4) (1 3 5) (3 5 7)] (ids)</div><div><br></div><div>The parentheses in ids just group cells for readability.</div>

<div><br></div><div>This offers random access by cell id for free, and eliminates the time/memory spent building the supplemental vtkCellTypes objects. There is a slightly higher penalty for sequential access than before, due to having to iterate through two arrays, but I doubt that this would have serious performance impacts.</div>





<div><br></div><div>I've also noticed that there are a number of "random access" methods like vtkCellArray::GetCell(vtkIdType loc, ...) that take an offset into the "mixed" internal array. This breaks encapsulation and is rather unintuitive -- I think it's safe to say that most developers would expect the "loc" argument to be a cell id. Since these methods depend on implementation details they are labeled as internal in the docs. However, they have public visibility and are used commonly throughout various filters, which often build up a structure similar to vtkCellTypes in order to perform their lookups.</div>





<div><br></div><div>I'm asking at this time because I'm looking at some changes that may modify the vtkCellArray API/implementation anyway, and it'd be nice to fix up this mix of sequential access, unintuitive random-access, and auxiliary lookup structures into a more friendly and intuitive API. These changes would not be effected until after VTK 6.0 is out.</div>





<div><br></div><div>Thoughts? Discussions? Alternate perspectives? All are welcome :-)</div><div><br></div><div>Thanks,</div><div>Dave</div></div>
<br></div></div>_______________________________________________<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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div></div></div>
<br>_______________________________________________<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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><br></div>