POV-Ray : Newsgroups : povray.programming : Re:Modification of dimensions() function. Possible solution? Server Time
2 May 2024 10:22:07 EDT (-0400)
  Re:Modification of dimensions() function. Possible solution? (Message 1 to 1 of 1)  
From: Muulhed
Subject: Re:Modification of dimensions() function. Possible solution?
Date: 14 Dec 2005 15:22:41
Message: <0512141520454@news.povray.org>
Hi all,
I'm a POV-Ray hacking newbie, and I'd like to run this by you guys.
I'm interested in being able to discover what type of identifier is being passed to a
macro.
Specifically, distinguishing between a float id and an array id.
  It occurred to me that tweaking of the dimensions() function would be a simple way.
In a perfect world, I'd probably add a couple of new functions that would explicitly
do this checking.
Maybe I'll try that later, when I'm more familiar with the inner workings.
  I've prepared a snippet of code that I *think* will do what I want. It should return
a zero if
dimensions() is passed a float ID, and the standard behaviour if passed an array id.
  If you feel this will do what I have in mind, I'll try to figure out how to compile
this beast.

Any comments?

From express.cpp line 1028:
 case DIMENSIONS_TOKEN:
            GET(LEFT_PAREN_TOKEN)
            GET(ARRAY_ID_TOKEN)
            a = (POV_ARRAY *)(*(Token.DataPtr));
            Val = a->Dims+1;
            GET(RIGHT_PAREN_TOKEN)
            break;

Would be replaced with:
 case DIMENSIONS_TOKEN:
            GET(LEFT_PAREN_TOKEN)
            Get_Token();
            if (Token.Token_Id == FLOAT_ID_TOKEN)
              Val = 0;
            else
              {
              UNGET
              GET(ARRAY_ID_TOKEN)
              a = (POV_ARRAY *)(*(Token.DataPtr));
              Val = a->Dims+1;
              }
            GET(RIGHT_PAREN_TOKEN)
            break;

Regards,
Mark LaBonte


Post a reply to this message

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