POV-Ray : Newsgroups : povray.general : CH2RGB somehow causes infinite loop Server Time
26 Nov 2024 01:46:24 EST (-0500)
  CH2RGB somehow causes infinite loop (Message 1 to 4 of 4)  
From: Cousin Ricky
Subject: CH2RGB somehow causes infinite loop
Date: 20 May 2012 22:30:00
Message: <web.4fb9a70082db4bf885de7b680@news.povray.org>
The following scene files fall into an infinite loop:
_____________________________________________________

#version 3.6;
global_settings { assumed_gamma 1 }
camera { location <0.5, 0.5, -1.1> }
light_source { -1000 * z, rgb 1 }

#include "colors.inc"

#local I = 0;
#while (I <= 360)
  #debug concat (str(I,0,1), "\n")
  #local I = I + 60;
#end

box
{ 0, 1
  pigment
  { gradient x color_map
    { #local I = 0;
      #while (I <= 360)
        #debug concat (str(I,0,2), "\n")
        [I / 360 rgb CH2RGB (I)]
        #local I = I + 60;
      #end
    }
  }
}
_____________________________________________________

#version 3.7;
global_settings { assumed_gamma 1 }
camera { location <0.5, 0.5, -1.1> }
light_source { -1000 * z, rgb 1 }

#include "colors.inc"

#for (I, 0, 360, 60)
  #debug concat (str(I,0,1), "\n")
#end

box
{ 0, 1
  pigment
  { gradient x color_map
    { #for (I, 0, 360, 60)
        #debug concat (str(I,0,2), "\n")
        [I / 360 rgb CH2RGB (I)]
      #end
    }
  }
}
_____________________________________________________

The first loop runs from 0.0 to 360.0, as expected.  The loop inside the
color_map block runs from 0.00 to 360.00, then repeats 60.00 to 360.00 until it
halts with a Blend_Map too long error.  Here is sample output from the 3.6 run.
_______________________________________________________________

Persistence of Vision(tm) Ray Tracer Version 3.6.1 (g++ 3.4.1 @
 i686-pc-linux-gnu)
  .
  .
  .
Redirecting Options
  All Streams to console..........On
  Debug Stream to console.........On
  Fatal Stream to console.........On
  Render Stream to console........On
  Statistics Stream to console....On
  Warning Stream to console.......On
Parsing Options
  Input file: temp.pov (compatible to version 3.61)
  Remove bounds........On
  Split unions.........Off
  Library paths:
    /usr/local/share/povray-3.6
    /usr/local/share/povray-3.6/ini
    /usr/local/share/povray-3.6/include
    /home/ricky/Documents/POV-Ray/include
    /home/ricky/Documents/POV-Ray/Object_collection
    /home/ricky/Documents/POV-Ray/LightsysIV
    /usr/share/fonts/truetype
Output Options
  Image resolution 320 by 240 (rows 1 to 240, columns 1 to 320).
  Output file: /home/ricky/Documents/POV-Ray/test/temp.png, 24 bpp PNG
  Graphic display......On  (gamma: 2.2)
  Mosaic preview.......Off
  CPU usage histogram..Off
  Continued trace......Off
Tracing Options
  Quality:  9
  Bounding boxes.......On   Bounding threshold: 3
  Light Buffer.........On
  Vista Buffer.........On   Draw Vista Buffer....Off
  Antialiasing.........Off
  Clock value:    0.000  (Animation off)

  0:00:00 Parsing
0.0
60.0
120.0
180.0
240.0
300.0
360.0
0.00
60.00
120.00
180.00
240.00
300.00
360.00
60.00
120.00
180.00
240.00
300.00
360.00
60.00
120.00
180.00
240.00
300.00
360.00
  .
  .
  .
60.00
120.00
180.00
File: temp.pov  Line: 21
File Context (5 lines):
  { gradient x color_map
    { #local I = 0;
      #while (I <= 360)
        #debug concat (str(I,0,2), "\n")
        [I / 360 rgb CH2RGB (I)]
Parse Error: Blend_Map too long.
Total Scene Processing Times
  Parse Time:    0 hours  0 minutes  0 seconds (0 seconds)
  Photon Time:   0 hours  0 minutes  0 seconds (0 seconds)
  Render Time:   0 hours  0 minutes  0 seconds (0 seconds)
  Total Time:    0 hours  0 minutes  0 seconds (0 seconds)
_______________________________________________________________

Without the CH2RGB call, the loop completes normally.  I cannot figure out
what's going wrong.  (A similar, but more complicated scene ran fine with
CHSL2RGB.)

The scene files were run with POV-Ray 3.6.1 and 3.7RC5 respectively, under
openSUSE Linux 12.1.


Post a reply to this message

From: Le Forgeron
Subject: Re: CH2RGB somehow causes infinite loop
Date: 21 May 2012 02:59:32
Message: <4fb9e7d4$1@news.povray.org>
Le 21/05/2012 04:22, Cousin Ricky a écrit :

> Without the CH2RGB call, the loop completes normally.  I cannot figure out
> what's going wrong.  (A similar, but more complicated scene ran fine with
> CHSL2RGB.)
> 
> The scene files were run with POV-Ray 3.6.1 and 3.7RC5 respectively, under
> openSUSE Linux 12.1.
> 
> 


CH2RGB starts like:
#macro CH2RGB (H)
   #local H = mod(H, 360);
   #local H = (H < 0 ? H+360 : H);
   #switch (H)

Guess that the H used both as a local and an argument of the macro was
not a so smart idea: it ends up modifiying the original argument.

It should have been something like

#macro CH2RGB (H_not_modified)
   #local H = mod(H_not_modified, 360);
   #local H = (H < 0 ? H+360 : H);
   #switch (H)

Just my 0.02€, tax not included.


-- 
Software is like dirt - it costs time and money to change it and move it
around.

Just because you can't see it, it doesn't weigh anything,
and you can't drill a hole in it and stick a rivet into it doesn't mean
it's free.


Post a reply to this message

From: Cousin Ricky
Subject: Re: CH2RGB somehow causes infinite loop
Date: 21 May 2012 10:20:00
Message: <web.4fba4ec4f5b698985de7b680@news.povray.org>
Le_Forgeron <lef### [at] freefr> wrote:
> Guess that the H used both as a local and an argument of the macro was
> not a so smart idea: it ends up modifiying the original argument.

That would be consistent with my long-ago experience of how POV-Ray works.

Should we open a bug report for colors.inc?


Post a reply to this message

From: James Holsenback
Subject: Re: CH2RGB somehow causes infinite loop
Date: 23 May 2012 08:43:24
Message: <4fbcdb6c$1@news.povray.org>
On 05/21/2012 10:18 AM, Cousin Ricky wrote:
> Le_Forgeron<lef### [at] freefr>  wrote:
>> Guess that the H used both as a local and an argument of the macro was
>> not a so smart idea: it ends up modifiying the original argument.
>
> That would be consistent with my long-ago experience of how POV-Ray works.
>
> Should we open a bug report for colors.inc?
>
>
submitted change #5653 to address this ... thanks for raising the issue


Post a reply to this message

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