[Shootout-list] Re: Re: [Shootout-list] Binary trees
Simon Geard
simon@whiteowl.co.uk
Mon, 20 Jun 2005 21:35:19 +0100
Jon Harrop wrote:
>The difference is that the C++ has separate structures for spheres and groups,
>i.e. a node in the scene tree is either a "Sphere" or a "Group":
>
>struct Scene {
> ...
>};
>struct Sphere : public Scene {
> Vec center;
> double radius;
> ...
>};
>typedef list<Scene *> Scenes;
>struct Group : public Scene {
> Vec center;
> double radius;
> Scenes child;
> ...
>};
>
>In contrast, the Fortran uses the same data structure for both spheres and
>groups, i.e. a node in the scene tree is always of type "Tree":
>
> type Sphere
> real*8, dimension(3) :: centre = (/ 0.0d0,0.0d0,0.0d0 /)
> real*8 :: radius = 0.0d0
> end type Sphere
> type Tree
> type(Sphere) :: data
> type(Tree), pointer :: children(:) => null()
> integer :: num_children = 0
> end type Tree
>
>On Monday 20 June 2005 11:34, simon@whiteowl.co.uk wrote:
>
>
>>If the current implementation really is deficient as you describe it
>>would be useful to have a specification so that it can be implemented
>>as you intend.
>>
>>
>
>I am perfectly happy with the current implementations provided they work. The
>deficiency would only show up if the ray tracer were extended, for example to
>allow colored spheres, because the most of the implementations allow extra
>data like color to be associated only with visible spheres and not with
>bounding spheres whereas the Fortran implementation would have to carry an
>unused color with every bounding sphere.
>
>
>
Ok, I understand the difference now. When f2003 compilers are released
(later this year?) this type of functionality will be supported.
Simon