POV-Ray : Newsgroups : povray.general : remove array element after N uses? : Re: remove array element after N uses? Server Time
16 May 2024 06:13:31 EDT (-0400)
  Re: remove array element after N uses?  
From: [GDS|Entropy]
Date: 25 Mar 2009 14:02:14
Message: <49ca71a6$1@news.povray.org>
"clipka" <nomail@nomail> wrote in message 
news:web.49ca4fd59fb46029c1f399840@news.povray.org...
>
> Oh, those pesky OOP-spoilt greenhorns! ;)
>
> When I was still young and handsome, such information would be stored in a
> separate array, like this:
>
<SNIP>

o_O'

Eew...BASIC...I'd rather learn just get it over with and Assembly (its on 
the TODO list)..

> (Yeah, those were the days! You just flipped the power switch, and your
> programming IDE would be up and running in 5 seconds... ah, modern
> technological advancement has deprived us of all that joy...)

Ubuntu will boot on a very old machine I have from the liveCD in just over 6 
times that...not that bad considering that includes GNOME.

> .... then someone invented structs (oh, well, "records" for me back then, 
> because
> I went for Turbo Pascal)...

Structs rock.

> But I'm getting a bit off topic... so back to your problem:
>
> First thing to know: No, POV SDL unfortunately doesn't have something like
> structs. Nor does it have dynamic lists. Be happy and content that you 
> don't
> have to mess around with line numbers ;)

Dynamic lists also rock.
I did mess around with BASIC back in elementary school (early/mid 80's). 
That is when I decided that I didn't like it much, and chose to avoid any 
language with Basic in the name.

Damn...maybe it would be seriously worth the effort of tracking down 
whatever code handles structs and dynamic lists and etc.. in the language 
that pov was written, and integrating that into povray with some nice SDL 
implementation. I'm more than sick of needing and not having those kinds of 
things.

http://www.haskell.org/haskellwiki/POV-Ray_SDL_project

Someone has the right idea.
They said this too: "Endless flamewars have raged over the subject of 
whether the SDL should become object-oriented."
When did THAT happen?! O_o'

This newsgroup seems rife with thoughtful discourse and quite a high SNR, 
not "endless flamewars"...

>>   #declare Array[i][0][0] = <RRand(RsA, Min, Max),RRand(RsA, Min,
>> Max),RRand(RsA, Min, Max)>;
>>   #declare Array[i][1][0] = <0,0,0>;
>>   #declare Array[i][1][1] = <0,RRand(RsA, rMin, rMax),0>;
>
> Why use a 3-dimensional array when a 2-dimensional one will do the job?

Beyond being just something that I threw together to do something like what 
I wanted, I decided that I might want to add an absurd amount of 
functionality later and that this would be the most logical way to leave my 
options open. For example I might add other related things to each of the 
dimensions, and it might be best to keep each category of data seperate.

> #declare Array[i][0] = <...>;
> #declare Array[i][1] = <0,0,0>;
> #declare Array[i][2] = <0,RRand(RsA, rMin, rMax),0>;
>
> Then, to get rid of an entry of such an array, you could use:
>
> #undef Array[i][0]
> #undef Array[i][1]
> #undef Array[i][2]

I might be able to adapt such a thing to do what I wanted in the first 
place. I guess if the following (untested) macro works, I could just call it 
once the established number of "uses" has been reached to purge the elements 
I need to.

#macro 
undefElement(Array,dim1Element,dim2Element,dim3Element,dim4Element,dim5Element)
 #local numDimensions = dimensions(Array);
 #if (numDimensions = 1)
  #undef Array[dim1Element]
 #end
 #if (numDimensions = 2)
  #undef Array[dim1Element][dim2Element]
 #end
 #if (numDimensions = 3)
  #undef Array[dim1Element][dim2Element][dim3Element]
 #end
 #if (numDimensions = 4)
  #undef Array[dim1Element][dim2Element][dim3Element]][dim4Element]
 #end
 #if (numDimensions = 5)
  #undef 
Array[dim1Element]][dim2Element][dim3Element]][dim4Element][dim5Element]
 #end
#end

> and check for #ifdef(Array[i][0]) when you loop through the array.
>
> I guess that's as close as you can get to what you want.

So I wasn't too far off from what I was looking for. That is a good sign. 
:-)
I suppose I could just redefine the wiped element with interpolated 
vectors...or something...should I need to, by using the above macros 
functionally mirror image.

As a side note, why in the nine hells aren't there Round and VRound macros 
in pov to start with??
They seem kind of useful to just have been left out...then again...so do 
structs, enums, custom types, multi-datatype arrays, type casting, type 
conversion and list<T>'s...

More of a side note....it would be cool to create a set of macros which 
emulated basic circuit components, so that one could produce such an act of 
irony as a properly functioning raytraced circuit...
Hmm....to make a macro which can produce accurate semiconductor curves.... 
Gah! I need to finish this damn macro suite...no new projects! :-p

ian


Post a reply to this message

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