[vtkusers] Purpose of safedowncast()

Seth Gilchrist seth at mech.ubc.ca
Thu Jul 11 16:19:25 EDT 2013


Hi Rahul,
Downcasting is a c++ term for converting (casting) a parent class to an
inherited class. In c++ you can always use (for public inheritance, anyway)
a child class in place of a parent class (called upcasting, i.e. moving up
the inheritance chain). If you want to use a parent class in a place where
a child class is required you must downcast the parent (i.e. move down the
inheritance chain). safeDownCast() give you a safe way to do this.

I searched "downcast upcast c++" on google and got a number of good
explanations with example code.

Cheers,
Seth

*Seth Gilchrist, MASc, PhD Candidate
+---------------------------------------+
Orthopaedic and Injury Biomechanics Group
UBC Department of Mechanical Engineering
6th Floor-2635 Laurel Street
Vancouver, BC V5Z-1M9
+---------------------------------------+
seth at mech.ubc.ca
Fax 604-675-2576*


On Thu, Jul 11, 2013 at 1:05 PM, rahul indoria <rahulindoria5 at gmail.com>wrote:

>  Hi All,
>          I just want to ask, what is purpose of function safeDownCast(),
> as it is not described ???
>
>
>
>  Looking forward your reply soon.
>
>  rahul indoria
>
>
>
>
>
>
>
>
>
>
> On Thu, Jul 11, 2013 at 6:19 PM, Seth Gilchrist <seth at mech.ubc.ca> wrote:
>
>>  Hi Rahul,
>> It seems that you want to provide x,y,z coordinates and get the index of
>> the point back. Once you have the index, you can use polydata's
>> "GetPointData" method to access the point data.
>>
>>  To do this, you can use the vtkKdTreePointLocator which as methods like
>> "FindClosestPoint", "FindNClosestPoints", and "FindPointsWithinRadius".
>> There are a few examples of how to use this class at
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx#KD-Tree. There are other
>> classes like vtkPointLocator, vtkOctreePointLocator which you can look at
>> too.
>>
>>  Cheers,
>> Seth
>>
>>  Seth Gilchrist, MASc, PhD Candidate
>> +---------------------------------------+
>> Orthopaedic and Injury Biomechanics Group
>> UBC Department of Mechanical Engineering
>> 6th Floor-2635 Laurel Street
>> Vancouver, BC V5Z-1M9
>> +---------------------------------------+
>> seth at mech.ubc.ca
>> Fax 604-675-2576
>>
>
>
>
>  --
> *Best  Regards
> Rahul Indoria
> Mobile No: +49-157-35652212*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130711/4da46221/attachment.htm>


More information about the vtkusers mailing list