home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / POLYTOPE.ZIP / arrayget.inc next >
Encoding:
Text File  |  1997-08-01  |  2.0 KB  |  76 lines

  1. /*
  2.  
  3.     POLYTOPE OBJECT INCLUDE FILE v1.0b - arrayget include file
  4.     Copyright (C) 1997 Thomas Willhalm
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. */
  22.  
  23. /*
  24.       Get vector from array of vectors strored as string
  25.  
  26.       Usage:
  27.     PRE:  <array>     is string with comma-separated list of vectors
  28.                   with no additional blanks
  29.     PRE:  <array>     contains at least <array_pos> vectors
  30.     POST: <float_vector> contains vector at <array_pos> position
  31.     SIDE: <__cur_pos>, <__old_pos>, <__x>, <__y>, <string_vector>
  32.           <_cur_pos>, <_old_pos>, <_count>, <_end>
  33.               altered
  34. */
  35.  
  36. // checking
  37. #ifndef (array)
  38.     #error "\narray undefined in arrayget.inc\n"
  39. #end
  40. #ifndef (array_pos)
  41.     #error "\narray_pos undefined in arrayget.inc\n"
  42. #end
  43.  
  44. // find first <
  45. #declare _cur_pos=2
  46. #while (strcmp(substr(array,_cur_pos,1),"<"))
  47.     #declare _cur_pos = _cur_pos+1
  48. #end
  49.  
  50. #if (array_pos=1)
  51.     #declare _old_pos = 1
  52. #else
  53.     // find < no <array_pos>
  54.     #declare _count = -1
  55.     #declare _cur_pos = 0
  56.     #while (_count<array_pos)
  57.         #declare _old_pos = _cur_pos
  58.         #declare _end = 1
  59.         #while (_end)
  60.             #declare _cur_pos = _cur_pos+1
  61.             #if (_cur_pos>strlen(array))
  62.                 #declare _end = 0
  63.                 #declare _cur_pos = strlen(array)+2
  64.             #else
  65.                 #if (!strcmp(substr(array,_cur_pos,1),"<"))
  66.                     #declare _end = 0
  67.                 #end
  68.             #end
  69.         #end
  70.         #declare _count = _count+1
  71.     #end
  72. #end
  73.  
  74. #declare string_vector = substr(array,_old_pos,_cur_pos-_old_pos-1)
  75. #include "vectorval.inc"
  76.