POV-Ray : Newsgroups : povray.beta-test : spline in, out array bug : Re: spline in, out array bug Server Time
22 Sep 2021 05:13:31 EDT (-0400)
  Re: spline in, out array bug  
From: clipka
Date: 15 Jul 2021 16:56:27
Message: <60f0a0fb$1@news.povray.org>
Am 15.07.2021 um 13:29 schrieb William F Pokorny:

> Looks like a problem with spline{} block parsing when passing a spline 
> id. The current Parse_Spline() code expects the spline type token to 
> exist otherwise it assumes the intent was a linear spline.
> 
> A fix is to add some dynamic_cast 'type checking' to:
> 
> GenericSpline *Parser::Parse_Spline()

Fortunately, there's a more elegant solution: The `GenericSpline` class 
has a virtual member function, `Clone()`, that is implemented by each 
subclass to return a newly constructed copy of whatever the actual type 
of the object is.

So the code in question can remain as simple as:

     if (!New)
     {
         if (Old)
             New = Old->Clone();
         else
             New = new LinearSpline();
     }

Will you do the honors, or shall I?


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.