POV-Ray : Newsgroups : povray.beta-test : spline in, out array bug : Re: spline in, out array bug Server Time
18 Apr 2024 03:36:18 EDT (-0400)
  Re: spline in, out array bug  
From: William F Pokorny
Date: 16 Jul 2021 05:42:05
Message: <60f1546d$1@news.povray.org>
On 7/15/21 4:56 PM, clipka wrote:
> 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?

Please go ahead.

I'll be updating my own pile of code to your cleaner fix - thank you.

Bill P.


Post a reply to this message

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