Hello David<br><br>Yes, I think this is the best option. I am thinking that I could create this as a new concrete subclass of vtkAbstractArray available to all, and not only as a helper class internal to my hyper tree implementation. What do you think? Would this be useful?<br>
<br>Thanks<br>Philippe <br><br><div class="gmail_quote">On Tue, Nov 20, 2012 at 6:25 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Phillippe,<br>
<br>
Actually I was wrong about vtkVariant not having any size overhead.  It needs<br>
to store the type along with the value.  So vtkVariantArray is no good for this.<br>
<br>
A helper class might be the best option.  You could make a vtkObjectArray<br>
class which would be just like vtkVoidArray except that it would objects.<br>
<br>
 - David<br>
<br>
<br>
On Tue, Nov 20, 2012 at 9:54 AM, Philippe Pébay<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:philippe.pebay@kitware.com">philippe.pebay@kitware.com</a>> wrote:<br>
> Hello David<br>
><br>
> Thanks for the summary about the absence of performance hit when using SPs<br>
> as opposed to RPs. I will remember it and use them more often as a result.<br>
><br>
> Regarding the variant array, yes, the conversion to vtkObject is a concern.<br>
> I think that the most efficient option would be to create a small helper<br>
> class that would internally store a raw array of pointers. That helper would<br>
> derive from vtkObjectBase. That should avoid any perfomance hit.<br>
><br>
> Philippe<br>
><br>
><br>
> On Tue, Nov 20, 2012 at 5:49 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
>><br>
>> Hi Phillippe,<br>
>><br>
>> A vtkVariant is 64 bits, it should be no larger than a pointer.  There<br>
>> is a function call overhead in ToVTKObject(), which might be a concern to<br>
>> you.<br>
>><br>
>> The vtkSmartPointer is exactly the same size as a pointer, so there is no<br>
>> size<br>
>> overhead.  It has no computational overhead, either, except for the<br>
>> "operator=",<br>
>> the copy constructor, and the destructor (I wouldn't even count the<br>
>> overhead in<br>
>> the destructor, because you have to call ->Delete() eventually anyway).<br>
>> So do<br>
>> not avoid smart pointers because you are worried about efficiency.  The<br>
>> VTK<br>
>> smart pointers are very efficient because vtkObjectBase already has a<br>
>> built-in<br>
>> reference count.<br>
>><br>
>>  - David<br>
>><br>
>><br>
>> On Tue, Nov 20, 2012 at 9:35 AM, Philippe Pébay<br>
>> <<a href="mailto:philippe.pebay@kitware.com">philippe.pebay@kitware.com</a>> wrote:<br>
>> > Hello David<br>
>> ><br>
>> > Thanks for the suggestion: I am concerned by the overhead that comes<br>
>> > with<br>
>> > variants. Wouldn't it be more lightweight to use a vtkVoidArray instead?<br>
>> > The<br>
>> > array can potentially contain O(10⁶) pointers. By the way this is for<br>
>> > the<br>
>> > same reason that I have, so far, refrained from using vtkSmartPointers<br>
>> > as<br>
>> > opposed to raw pointers, by fear of the overhead involved. Is this extra<br>
>> > caution excessive?<br>
>> ><br>
>> > Thanks<br>
>> > Philippe<br>
>> ><br>
>> > On Tue, Nov 20, 2012 at 5:31 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Hi Philippe,<br>
>> >><br>
>> >> If the pointers are pointers to VTK objects, then you can use<br>
>> >> vtkVariantArray.<br>
>> >><br>
>> >>  - David<br>
>> >><br>
>> >><br>
>> >> On Tue, Nov 20, 2012 at 9:29 AM, Philippe Pébay<br>
>> >> <<a href="mailto:philippe.pebay@kitware.com">philippe.pebay@kitware.com</a>> wrote:<br>
>> >> > Just an idea: couldn't a vtkVoidArray be used (or abused) as<br>
>> >> > container<br>
>> >> > of<br>
>> >> > raw pointers, that would be appropriately downcasted internally to<br>
>> >> > the<br>
>> >> > concrete type to which they are supposed to point? For instance,<br>
>> >> > instead<br>
>> >> > of<br>
>> >> > having a<br>
>> >> >  vtkMyInternalObject** obj<br>
>> >> > instance variable, couldn't I use a<br>
>> >> >  vtkVoidArray* obj<br>
>> >> > instead, where each entry in obj would be the raw pointer to a<br>
>> >> > vtkSmartPointer<vtkMyInternalObject>?<br>
>> >> ><br>
>> >> > Thanks<br>
>> >> > Philippe<br>
>> >> ><br>
>> >> ><br>
>> >> > On Tue, Nov 20, 2012 at 5:14 PM, Philippe Pébay<br>
>> >> > <<a href="mailto:philippe.pebay@kitware.com">philippe.pebay@kitware.com</a>><br>
>> >> > wrote:<br>
>> >> >><br>
>> >> >> Hello Kyle<br>
>> >> >><br>
>> >> >> Yes, I would want to avoid a dependency on Boost. But this is<br>
>> >> >> basically<br>
>> >> >> what I am tried to reproduce (the Boost shared array of pointers).<br>
>> >> >><br>
>> >> >> Thanks<br>
>> >> >> P<br>
>> >> >><br>
>> >> >><br>
>> >> >> On Tue, Nov 20, 2012 at 5:13 PM, Kyle Lutz <<a href="mailto:kyle.lutz@kitware.com">kyle.lutz@kitware.com</a>><br>
>> >> >> wrote:<br>
>> >> >>><br>
>> >> >>> Would using boost suffice? Or do you want a solution using just<br>
>> >> >>> VTK?<br>
>> >> >>><br>
>> >> >>> -kyle<br>
>> >> >>><br>
>> >> >>> On Tue, Nov 20, 2012 at 7:58 AM, Philippe Pébay<br>
>> >> >>> <<a href="mailto:philippe.pebay@kitware.com">philippe.pebay@kitware.com</a>> wrote:<br>
>> >> >>> > Hello all,<br>
>> >> >>> ><br>
>> >> >>> > I need to keep track of shared ownership of an array of pointers.<br>
>> >> >>> > Can<br>
>> >> >>> > someone point me towards an example of code that already does<br>
>> >> >>> > this?<br>
>> >> >>> > This<br>
>> >> >>> > should amount to a small helper class that contains the array of<br>
>> >> >>> > pointers<br>
>> >> >>> > along with a reference count.<br>
>> >> >>> ><br>
>> >> >>> > Thank you!<br>
>> >> >>> > Philippe<br>
>> >> >>> ><br>
>> >> >>> ><br>
>> >> >>> > --<br>
>> >> >>> > Philippe Pébay, PhD<br>
>> >> >>> > Director of Visualization and High Performance Computing /<br>
>> >> >>> > Directeur de la Visualisation et du Calcul Haute Performance<br>
>> >> >>> > Kitware SAS<br>
>> >> >>> > 26 rue Louis Guérin, 69100 Villeurbanne, France<br>
>> >> >>> > <a href="tel:%2B33%20%280%29%206.83.61.55.70" value="+33683615570">+33 (0) 6.83.61.55.70</a> / 4.37.45.04.15<br>
>> >> >>> > <a href="http://www.kitware.fr" target="_blank">http://www.kitware.fr</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Philippe Pébay, PhD<br>
> Director of Visualization and High Performance Computing /<br>
> Directeur de la Visualisation et du Calcul Haute Performance<br>
> Kitware SAS<br>
> 26 rue Louis Guérin, 69100 Villeurbanne, France<br>
> <a href="tel:%2B33%20%280%29%206.83.61.55.70" value="+33683615570">+33 (0) 6.83.61.55.70</a> / 4.37.45.04.15<br>
> <a href="http://www.kitware.fr" target="_blank">http://www.kitware.fr</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font color="#888888">Philippe Pébay, PhD<br></font><font color="#888888">Director of Visualization and High Performance Computing /<br>
</font><font color="#888888">Directeur de la Visualisation et du Calcul Haute Performance<br>
Kitware SAS<br>26 rue Louis Guérin, 69100 Villeurbanne, France</font><br>
<font color="#888888"><a value="+33426685003">+33 (0) 6.83.61.55.70 / 4.37.45.04.15</a></font><font color="#888888"><br><a href="http://www.kitware.fr/" target="_blank">http://www.kitware.fr</a></font><font color="#888888"><a href="http://www.kitware.fr/" target="_blank"></a></font><br>