FRAME.H 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  1. /****************************************************************************
  2. * frame.h
  3. *
  4. * This header file is included by all C modules in POV-Ray. It defines all
  5. * globally-accessible types and constants.
  6. *
  7. * from Persistence of Vision(tm) Ray Tracer
  8. * Copyright 1996,1999 Persistence of Vision Team
  9. *---------------------------------------------------------------------------
  10. * NOTICE: This source code file is provided so that users may experiment
  11. * with enhancements to POV-Ray and to port the software to platforms other
  12. * than those supported by the POV-Ray Team. There are strict rules under
  13. * which you are permitted to use this file. The rules are in the file
  14. * named POVLEGAL.DOC which should be distributed with this file.
  15. * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  16. * Team Coordinator by email to team-coord@povray.org or visit us on the web at
  17. * http://www.povray.org. The latest version of POV-Ray may be found at this site.
  18. *
  19. * This program is based on the popular DKB raytracer version 2.12.
  20. * DKBTrace was originally written by David K. Buck.
  21. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  22. *
  23. * Modified by Andreas Dilger to add PNG file format support 05/09/95
  24. *
  25. *****************************************************************************/
  26. #ifndef FRAME_H
  27. #define FRAME_H
  28. /* Generic header for all modules */
  29. #include <math.h>
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <limits.h>
  33. #include "config.h"
  34. /*
  35. * These two are used if POV is being called from within another program
  36. * like a GUI interface.
  37. */
  38. #ifndef MAIN_RETURN_TYPE
  39. #define MAIN_RETURN_TYPE void
  40. #endif
  41. #ifndef MAIN_RETURN_STATEMENT
  42. #define MAIN_RETURN_STATEMENT
  43. #endif
  44. /*
  45. * Functions that POV calls once per render to do various initializations,
  46. * in the order that they are normally called.
  47. */
  48. #ifndef STARTUP_POVRAY /* First function called in main() for each render */
  49. #define STARTUP_POVRAY
  50. #endif
  51. #ifndef PRINT_CREDITS /* Prints POV-Ray version information banner */
  52. #define PRINT_CREDITS Print_Credits();
  53. #endif
  54. #ifndef PRINT_OTHER_CREDITS /* Prints credits for custom POV versions */
  55. #define PRINT_OTHER_CREDITS
  56. #endif
  57. /*
  58. * These read the INI files. READ_ENV_VAR reads an INI file specified by
  59. * (usually) the POVINI environment variable instead of the default file.
  60. * PROCESS_POVRAY_INI reads the INI file from the default location if
  61. * READ_ENV_VAR wasn't successful. ALT_WRITE_INI_FILE writes out a new
  62. * INI file with the values as specified by the used for this render.
  63. */
  64. #ifndef READ_ENV_VAR
  65. #define READ_ENV_VAR Warning(0.0,"Environment variable not implemented on this platform.\n");
  66. #endif
  67. #ifndef PROCESS_POVRAY_INI
  68. #define PROCESS_POVRAY_INI Warning(0.0,"Reading 'povray.ini' not implemented on this platform.\n");
  69. #endif
  70. #ifndef ALT_WRITE_INI_FILE
  71. #define ALT_WRITE_INI_FILE
  72. #endif
  73. #ifndef FINISH_POVRAY /* The last call that POV makes to exit */
  74. #define FINISH_POVRAY(n) exit(n);
  75. #endif
  76. /*
  77. * Functions that POV calls once per frame to do varios (de)initializations,
  78. * in the order they are normally called.
  79. */
  80. #ifndef POV_PRE_RENDER /* Called just prior to the start of rendering */
  81. #define POV_PRE_RENDER
  82. #endif
  83. #ifndef CONFIG_MATH /* Macro for setting up any special FP options */
  84. #define CONFIG_MATH
  85. #endif
  86. #ifndef POV_PRE_PIXEL /* Called before each pixel is rendered */
  87. #define POV_PRE_PIXEL(x,y,c)
  88. #endif
  89. #ifndef POV_POST_PIXEL /* Called after each pixel is rendered */
  90. #define POV_POST_PIXEL(x,y,c)
  91. #endif
  92. #ifndef POV_PRE_SHUTDOWN /* Called before memory and objects are freed */
  93. #define POV_PRE_SHUTDOWN
  94. #endif
  95. #ifndef POV_POST_SHUTDOWN /* Called after memory and objects are freed */
  96. #define POV_POST_SHUTDOWN
  97. #endif
  98. #ifndef PRINT_STATS
  99. #define PRINT_STATS(a) Print_Stats(a);
  100. #endif
  101. /* Platform-specific User Interface callbacks, allowing the UI to get status information */
  102. #ifndef UICB_PARSE_ERROR /* Alert UI that a parse error occurred */
  103. #define UICB_PARSE_ERROR
  104. #endif
  105. #ifndef UICB_USER_ABORT /* alert UI that user aborted the render */
  106. #define UICB_USER_ABORT
  107. #endif
  108. #ifndef UICB_OPEN_INCLUDE_FILE /* alert UI that an include file was opened during parse */
  109. #define UICB_OPEN_INCLUDE_FILE
  110. #endif
  111. #ifndef UICB_CLOSE_INCLUDE_FILE /* alert UI that an include file was closed during parse */
  112. #define UICB_CLOSE_INCLUDE_FILE
  113. #endif
  114. /* Various numerical constants that are used in the calculations */
  115. #ifndef EPSILON /* A small value used to see if a value is nearly zero */
  116. #define EPSILON 1.0e-10
  117. #endif
  118. #ifndef HUGE_VAL /* A very large value, can be considered infinity */
  119. #define HUGE_VAL 1.0e+17
  120. #endif
  121. /*
  122. * If the width of a bounding box in one dimension is greater than
  123. * the critical length, the bounding box should be set to infinite.
  124. */
  125. #ifndef CRITICAL_LENGTH
  126. #define CRITICAL_LENGTH 1.0e6
  127. #endif
  128. #ifndef BOUND_HUGE /* Maximum lengths of a bounding box. */
  129. #define BOUND_HUGE 2.0e10
  130. #endif
  131. /*
  132. * These values determine the minumum and maximum distances
  133. * that qualify as ray-object intersections.
  134. */
  135. #define Small_Tolerance 0.001
  136. #define Max_Distance 1.0e7
  137. #ifndef DBL_FORMAT_STRING
  138. #define DBL_FORMAT_STRING "%lf"
  139. #endif
  140. #ifndef DBL
  141. #define DBL double
  142. #endif
  143. #ifndef SNGL
  144. #define SNGL float
  145. #endif
  146. #ifndef COLC
  147. #define COLC float
  148. #endif
  149. #ifndef M_PI
  150. #define M_PI 3.1415926535897932384626
  151. #endif
  152. #ifndef M_PI_2
  153. #define M_PI_2 1.57079632679489661923
  154. #endif
  155. #ifndef TWO_M_PI
  156. #define TWO_M_PI 6.283185307179586476925286766560
  157. #endif
  158. #ifndef M_PI_180
  159. #define M_PI_180 0.01745329251994329576
  160. #endif
  161. #ifndef M_PI_360
  162. #define M_PI_360 0.00872664625997164788
  163. #endif
  164. /* Some implementations of scanf return 0 on failure rather than EOF */
  165. #ifndef SCANF_EOF
  166. #define SCANF_EOF EOF
  167. #endif
  168. /* Get minimum/maximum of two values. */
  169. #ifndef min
  170. #define min(x,y) (((x)>(y))?(y):(x))
  171. #endif
  172. #ifndef max
  173. #define max(x,y) (((x)<(y))?(y):(x))
  174. #endif
  175. /* Get minimum/maximum of three values. */
  176. #define max3(x,y,z) (((x)>(y))?(((x)>(z))?(x):(z)):(((y)>(z))?(y):(z)))
  177. #define min3(x,y,z) (((x)<(y))?(((x)<(z))?(x):(z)):(((y)<(z))?(y):(z)))
  178. #ifndef labs /* Absolute value of the long integer x. */
  179. #define labs(x) (long) (((x)<0)?-(x):(x))
  180. #endif
  181. #ifndef fabs /* Absolute value of the double x. */
  182. #define fabs(x) ((x) < 0.0 ? -(x) : (x))
  183. #endif
  184. #ifndef TRUE
  185. #define TRUE 1
  186. #define FALSE 0
  187. #endif
  188. #ifndef CONST /* How to define a local variable - normally 'const' */
  189. #define CONST
  190. #endif
  191. #ifndef CDECL
  192. #define CDECL
  193. #endif
  194. #ifndef NEW_LINE_STRING
  195. #define NEW_LINE_STRING "\n"
  196. #endif
  197. /* If compiler version is undefined, then make it 'u' for unknown */
  198. #ifndef COMPILER_VER
  199. #define COMPILER_VER ".u"
  200. #endif
  201. #ifndef QSORT
  202. #define QSORT(a,b,c,d) qsort((a),(b),(c),(d))
  203. #endif
  204. /*
  205. * POV_NAME_MAX is for file systems that have a separation of the filename
  206. * into name.ext. The POV_NAME_MAX is the name part. FILE_NAME_LENGTH
  207. * is the sum of name + extension.
  208. */
  209. #ifndef POV_NAME_MAX
  210. #define POV_NAME_MAX 8
  211. #endif
  212. #ifndef FILE_NAME_LENGTH
  213. #define FILE_NAME_LENGTH 150
  214. #endif
  215. #ifndef FILENAME_SEPARATOR
  216. #define FILENAME_SEPARATOR '/'
  217. #endif
  218. #ifndef DRIVE_SEPARATOR
  219. #define DRIVE_SEPARATOR ':'
  220. #endif
  221. /*
  222. * Splits a given string into the path and file components using the
  223. * FILENAME_SEPARATOR and DRIVE_SEPARATOR
  224. */
  225. #ifndef POV_SPLIT_PATH
  226. #define POV_SPLIT_PATH(s,p,f) POV_Split_Path((s),(p),(f))
  227. #endif
  228. /* How to read, write and append to files using fopen() */
  229. /* -- Binary -- */
  230. #ifndef READ_BINFILE_STRING
  231. #define READ_BINFILE_STRING "rb"
  232. #endif
  233. #ifndef WRITE_BINFILE_STRING
  234. #define WRITE_BINFILE_STRING "wb"
  235. #endif
  236. #ifndef APPEND_BINFILE_STRING
  237. #define APPEND_BINFILE_STRING "ab"
  238. #endif
  239. /* -- Text -- */
  240. #ifndef READ_TXTFILE_STRING
  241. #define READ_TXTFILE_STRING "r"
  242. #endif
  243. #ifndef WRITE_TXTFILE_STRING
  244. #define WRITE_TXTFILE_STRING "w"
  245. #endif
  246. #ifndef APPEND_TXTFILE_STRING
  247. #define APPEND_TXTFILE_STRING "a"
  248. #endif
  249. /* The output file format used if the user doesn't specify one */
  250. #ifndef DEFAULT_OUTPUT_FORMAT
  251. #define DEFAULT_OUTPUT_FORMAT 't'
  252. #endif
  253. /* System specific image format like BMP for Windows or PICT for Mac */
  254. #ifndef READ_SYS_IMAGE
  255. #define READ_SYS_IMAGE(i,n) Read_Targa_Image((i),(n))
  256. #endif
  257. #ifndef GET_SYS_FILE_HANDLE
  258. #define GET_SYS_FILE_HANDLE Get_Targa_File_Handle
  259. #endif
  260. #ifndef SYS_DEF_EXT
  261. #define SYS_DEF_EXT ".tga"
  262. #endif
  263. /* Functions to delete and rename a file */
  264. #ifndef DELETE_FILE_ERR
  265. #define DELETE_FILE_ERR -1
  266. #endif
  267. #ifndef DELETE_FILE
  268. #define DELETE_FILE(name) unlink(name)
  269. #endif
  270. #ifndef RENAME_FILE_ERR
  271. #define RENAME_FILE_ERR -1
  272. #endif
  273. #ifndef RENAME_FILE
  274. #define RENAME_FILE(orig,new) rename(orig,new)
  275. #endif
  276. #ifndef MAX_BUFSIZE /* The maximum size of the output file buffer */
  277. #define MAX_BUFSIZE INT_MAX
  278. #endif
  279. /*
  280. * The TIME macros are used when displaying the rendering time for the user.
  281. * These are called in such a manner that STOP_TIME can be called multiple
  282. * times for a givn START_TIME in order to get intermediate TIME_ELAPSED
  283. * values. TIME_ELAPSED is often defined as (tstop - tstart).
  284. */
  285. #ifndef START_TIME
  286. #define START_TIME time(&tstart);
  287. #endif
  288. #ifndef STOP_TIME
  289. #define STOP_TIME time(&tstop);
  290. #endif
  291. #ifndef TIME_ELAPSED
  292. #define TIME_ELAPSED difftime (tstop, tstart);
  293. #endif
  294. #ifndef SPLIT_TIME
  295. #define SPLIT_TIME(d,h,m,s) POV_Std_Split_Time ((d),(h),(m),(s))
  296. #endif
  297. /*
  298. * The PRECISION_TIMER macros are used in generating histogram images on
  299. * systems that have very accurate timers (usually in the microsecond range).
  300. */
  301. #ifndef PRECISION_TIMER_AVAILABLE
  302. #define PRECISION_TIMER_AVAILABLE 0
  303. #endif
  304. #ifndef PRECISION_TIMER_INIT /* Called once to initialize the timer */
  305. #define PRECISION_TIMER_INIT
  306. #endif
  307. #ifndef PRECISION_TIMER_START
  308. #define PRECISION_TIMER_START ;
  309. #endif
  310. #ifndef PRECISION_TIMER_STOP
  311. #define PRECISION_TIMER_STOP
  312. #endif
  313. #ifndef PRECISION_TIMER_COUNT /* The difference between START and STOP times */
  314. #define PRECISION_TIMER_COUNT 0
  315. #endif
  316. /*
  317. * The COOPERATE macros are used on co-operative multi-tasking systems to
  318. * return control to the GUI or OS. COOPERATE is the old form, and one
  319. * or both of COOPERATE_0 and COOPERATE_1 should be defined instead.
  320. */
  321. #ifdef COOPERATE
  322. #define COOPERATE_0 COOPERATE
  323. #define COOPERATE_1 COOPERATE
  324. #endif
  325. #ifndef COOPERATE_0 /* Called less frequently */
  326. #define COOPERATE_0
  327. #endif
  328. #ifndef COOPERATE_1 /* Called more frequently */
  329. #define COOPERATE_1
  330. #endif
  331. /* How to get input from the user */
  332. #ifndef TEST_ABORT
  333. #define TEST_ABORT
  334. #endif
  335. #ifndef WAIT_FOR_KEYPRESS
  336. #define WAIT_FOR_KEYPRESS
  337. #else
  338. #define WAIT_FOR_KEYPRESS_EXISTS
  339. #endif
  340. #ifndef GET_KEY /* Gets a keystroke from the user without waiting */
  341. #define GET_KEY
  342. #else
  343. #define GET_KEY_EXISTS
  344. #endif
  345. /*
  346. * Functions that write text for the user to see. These functions will
  347. * usually be customized for GUI environments so that POV outputs its
  348. * messages to a status bar or popup window.
  349. */
  350. #ifndef POV_BANNER
  351. #define POV_BANNER(s) POV_Std_Banner(s)
  352. #endif
  353. #ifndef POV_WARNING
  354. #define POV_WARNING(s) POV_Std_Warning(s)
  355. #endif
  356. #ifndef POV_RENDER_INFO
  357. #define POV_RENDER_INFO(s) POV_Std_Render_Info(s)
  358. #endif
  359. #ifndef POV_STATUS_INFO
  360. #define POV_STATUS_INFO(s) POV_Std_Status_Info(s)
  361. #endif
  362. #ifndef POV_DEBUG_INFO
  363. #define POV_DEBUG_INFO(s) POV_Std_Debug_Info(s)
  364. #endif
  365. #ifndef POV_FATAL
  366. #define POV_FATAL(s) POV_Std_Fatal(s)
  367. #endif
  368. #ifndef POV_STATISTICS
  369. #define POV_STATISTICS(s) POV_Std_Statistics(s)
  370. #endif
  371. /*
  372. * Functions that handle the graphical display preview. These functions
  373. * will be customeized for all versions of POV that want to do any sort
  374. * of rendering preview. The default functions will create a 80x25 text
  375. * "rendering" using crude ASCII graphics.
  376. */
  377. #ifndef POV_DISPLAY_INIT /* Initializes display for each frame rendered */
  378. #define POV_DISPLAY_INIT(w,h) POV_Std_Display_Init((w),(h));
  379. #endif
  380. #ifndef POV_DISPLAY_FINISHED /* Waits for user input after rendering done */
  381. #define POV_DISPLAY_FINISHED POV_Std_Display_Finished();
  382. #endif
  383. #ifndef POV_DISPLAY_CLOSE /* Closes the display window after each frame */
  384. #define POV_DISPLAY_CLOSE POV_Std_Display_Close();
  385. #endif
  386. #ifndef POV_DISPLAY_PLOT /* Plots a single pixel */
  387. #define POV_DISPLAY_PLOT(x,y,r,g,b,a) POV_Std_Display_Plot((x),(y),(r),(g),(b),(a));
  388. #endif
  389. #ifndef POV_DISPLAY_PLOT_RECT /* Plots a filled rectangle */
  390. #define POV_DISPLAY_PLOT_RECT(x1,y1,x2,y2,r,g,b,a) POV_Std_Display_Plot_Rect((x1),(y1),(x2),(y2),(r),(g),(b),(a));
  391. #endif
  392. #ifndef POV_DISPLAY_PLOT_BOX /* Plots a hollow box */
  393. #define POV_DISPLAY_PLOT_BOX(x1,y1,x2,y2,r,g,b,a) POV_Std_Display_Plot_Box((x1),(y1),(x2),(y2),(r),(g),(b),(a));
  394. #endif
  395. #ifndef POV_GET_FULL_PATH /* returns full pathspec */
  396. #define POV_GET_FULL_PATH(f,p,b) if (b) strcpy(b,p);
  397. #endif
  398. #ifndef POV_WRITE_LINE /* write the current line to something */
  399. #define POV_WRITE_LINE(line,y)
  400. #endif
  401. #ifndef POV_ASSIGN_PIXEL /* assign the colour of a pixel */
  402. #define POV_ASSIGN_PIXEL(x,y,colour)
  403. #endif
  404. /* The next two are palette modes, for normal and grayscale display */
  405. #ifndef NORMAL
  406. #define NORMAL '0'
  407. #endif
  408. #ifndef GREY
  409. #define GREY 'G'
  410. #endif
  411. /*
  412. * The DEFAULT_DISPLAY_GAMMA is used when there isn't one specified by the
  413. * user in the POVRAY.INI. For those systems that are very savvy, this
  414. * could be a function which returns the current display gamma. The
  415. * DEFAULT_ASSUMED_GAMMA should be left alone.
  416. */
  417. #ifndef DEFAULT_DISPLAY_GAMMA
  418. #define DEFAULT_DISPLAY_GAMMA 2.2
  419. #endif
  420. #ifndef DEFAULT_ASSUMED_GAMMA
  421. #define DEFAULT_ASSUMED_GAMMA 1.0
  422. #endif
  423. /*****************************************************************************
  424. *
  425. * MEMIO.C Memory macros
  426. *
  427. *****************************************************************************/
  428. #ifndef __FILE__
  429. #define __FILE__ ""
  430. #endif
  431. #ifndef __LINE__
  432. #define __LINE__ (-1)
  433. #endif
  434. /*
  435. * These functions define macros which do checking for memory allocation,
  436. * and can also do other things. Check mem.c before you change them, since
  437. * they aren't simply replacements for malloc, calloc, realloc, and free.
  438. */
  439. #ifndef POV_MALLOC
  440. #define POV_MALLOC(size,msg) pov_malloc ((size), __FILE__, __LINE__, (msg))
  441. #endif
  442. #ifndef POV_CALLOC
  443. #define POV_CALLOC(nitems,size,msg) pov_calloc ((nitems), (size), __FILE__, __LINE__, (msg))
  444. #endif
  445. #ifndef POV_REALLOC
  446. #define POV_REALLOC(ptr,size,msg) pov_realloc ((ptr), (size), __FILE__, __LINE__, (msg))
  447. #endif
  448. #ifndef POV_FREE
  449. #define POV_FREE(ptr) pov_free ((void *)(ptr), __FILE__, __LINE__)
  450. #endif
  451. #ifndef POV_MEM_INIT
  452. #define POV_MEM_INIT() mem_init()
  453. #endif
  454. #ifndef POV_MEM_RELEASE_ALL
  455. #define POV_MEM_RELEASE_ALL(log) mem_release_all(log)
  456. #endif
  457. #ifndef POV_STRDUP
  458. #define POV_STRDUP(str) pov_strdup(str)
  459. #endif
  460. /* For those systems that don't have memmove, this can also be pov_memmove */
  461. #ifndef POV_MEMMOVE
  462. #define POV_MEMMOVE(dst,src,len) memmove((dst),(src),(len))
  463. #endif
  464. /*
  465. * Functions which invoke external programs to do work for POV, generally
  466. * at the request of the user.
  467. */
  468. #ifndef POV_SHELLOUT
  469. #define POV_SHELLOUT(string) pov_shellout(string)
  470. #endif
  471. #ifndef POV_MAX_CMD_LENGTH
  472. #define POV_MAX_CMD_LENGTH 250
  473. #endif
  474. #ifndef POV_SYSTEM
  475. #define POV_SYSTEM(string) system(string)
  476. #endif
  477. /*****************************************************************************
  478. *
  479. * Typedefs that need to be known here.
  480. *
  481. *****************************************************************************/
  482. typedef struct Object_Struct OBJECT;
  483. typedef struct Ray_Struct RAY;
  484. typedef struct istack_struct ISTACK;
  485. typedef struct istk_entry INTERSECTION;
  486. /*****************************************************************************
  487. *
  488. * Scalar, color and vector stuff.
  489. *
  490. *****************************************************************************/
  491. typedef DBL UV_VECT [2];
  492. typedef DBL VECTOR [3];
  493. typedef DBL VECTOR_4D [4];
  494. typedef DBL MATRIX [4][4];
  495. typedef DBL EXPRESS [5];
  496. typedef COLC COLOUR [5];
  497. typedef COLC RGB [3];
  498. typedef short WORD;
  499. /* Stuff for bounding boxes. */
  500. #define BBOX_VAL SNGL
  501. typedef BBOX_VAL BBOX_VECT[3];
  502. #define Assign_BBox_Vect(d,s) \
  503. { \
  504. (d)[X] = (s)[X]; \
  505. (d)[Y] = (s)[Y]; \
  506. (d)[Z] = (s)[Z]; \
  507. }
  508. #define Make_BBox(BBox, llx, lly, llz, lex, ley, lez) \
  509. { \
  510. (BBox).Lower_Left[X] = (BBOX_VAL)(llx); \
  511. (BBox).Lower_Left[Y] = (BBOX_VAL)(lly); \
  512. (BBox).Lower_Left[Z] = (BBOX_VAL)(llz); \
  513. (BBox).Lengths[X] = (BBOX_VAL)(lex); \
  514. (BBox).Lengths[Y] = (BBOX_VAL)(ley); \
  515. (BBox).Lengths[Z] = (BBOX_VAL)(lez); \
  516. }
  517. #define Make_BBox_from_min_max(BBox, mins, maxs) \
  518. { \
  519. (BBox).Lower_Left[X] = (BBOX_VAL)(mins[X]); \
  520. (BBox).Lower_Left[Y] = (BBOX_VAL)(mins[Y]); \
  521. (BBox).Lower_Left[Z] = (BBOX_VAL)(mins[Z]); \
  522. (BBox).Lengths[X] = (BBOX_VAL)(maxs[X]-mins[X]); \
  523. (BBox).Lengths[Y] = (BBOX_VAL)(maxs[Y]-mins[Y]); \
  524. (BBox).Lengths[Z] = (BBOX_VAL)(maxs[Z]-mins[Z]); \
  525. }
  526. #define Make_min_max_from_BBox(mins, maxs, BBox) \
  527. { \
  528. (mins)[X] = (BBox).Lower_Left[X]; \
  529. (mins)[Y] = (BBox).Lower_Left[Y]; \
  530. (mins)[Z] = (BBox).Lower_Left[Z]; \
  531. (maxs)[X] = (mins)[X] + (BBox).Lengths[X]; \
  532. (maxs)[Y] = (mins)[Y] + (BBox).Lengths[Y]; \
  533. (maxs)[Z] = (mins)[Z] + (BBox).Lengths[Z]; \
  534. }
  535. /* Stuff for SNGL vectors. */
  536. typedef SNGL SNGL_VECT[3];
  537. #define Assign_SNGL_Vect(d,s) \
  538. { \
  539. (d)[X] = (s)[X]; \
  540. (d)[Y] = (s)[Y]; \
  541. (d)[Z] = (s)[Z]; \
  542. }
  543. /* Vector array elements. */
  544. #define U 0
  545. #define V 1
  546. #define X 0
  547. #define Y 1
  548. #define Z 2
  549. #define T 3
  550. /* Colour array elements. */
  551. #define RED 0
  552. #define GREEN 1
  553. #define BLUE 2
  554. #define FILTER 3
  555. #define TRANSM 4
  556. /* Macros to manipulate scalars, vectors, and colors. */
  557. #define Destroy_Float(x) if ((x)!=NULL) POV_FREE(x)
  558. #define Assign_Vector(d,s) memcpy((d),(s),sizeof(VECTOR))
  559. #define Destroy_Vector(x) if ((x)!=NULL) POV_FREE(x)
  560. #define Assign_UV_Vect(d,s) memcpy((d),(s),sizeof(UV_VECT))
  561. #define Destroy_UV_Vect(x) if ((x)!=NULL) POV_FREE(x)
  562. #define Assign_Vector_4D(d,s) memcpy((d),(s),sizeof(VECTOR_4D))
  563. #define Destroy_Vector_4D(x) if ((x)!=NULL) POV_FREE(x)
  564. #define Assign_Colour(d,s) memcpy((d),(s),sizeof(COLOUR))
  565. #define Make_Colour(c,r,g,b) {(c)[RED]=(r);(c)[GREEN]=(g);(c)[BLUE]=(b);(c)[FILTER]=0.0;(c)[TRANSM]=0.0;}
  566. #define Make_ColourA(c,r,g,b,a,t) {(c)[RED]=(r);(c)[GREEN]=(g);(c)[BLUE]=(b);(c)[FILTER]=(a);(c)[TRANSM]=t;}
  567. #define Make_Vector(v,a,b,c) { (v)[X]=(a);(v)[Y]=(b);(v)[Z]=(c); }
  568. #define Destroy_Colour(x) if ((x)!=NULL) POV_FREE(x)
  569. #define Make_RGB(c,r,g,b) {(c)[RED]=(r);(c)[GREEN]=(g);(c)[BLUE]=(b);}
  570. /*****************************************************************************
  571. *
  572. * Hi-resolution counter.
  573. *
  574. *****************************************************************************/
  575. /* Define counter resolution. */
  576. #define LOW_RESOLUTION 1
  577. #define HIGH_RESOLUTION 2
  578. #ifndef COUNTER_RESOLUTION
  579. #define COUNTER_RESOLUTION HIGH_RESOLUTION
  580. #endif
  581. #if COUNTER_RESOLUTION == HIGH_RESOLUTION
  582. /* 64bit counter. */
  583. typedef struct Counter_Struct COUNTER;
  584. struct Counter_Struct
  585. {
  586. unsigned long high, low;
  587. };
  588. #define DBL_Counter(x) ( (x).low + Sqr(65536.0)*(DBL)(x).high )
  589. #define Long_To_Counter(i,x) { (x).low = i; (x).high = 0; }
  590. #define Init_Counter(x) { (x).high = (x).low = 0L; }
  591. #define Test_Zero_Counter(x) (((x).low == 0L) && ((x).high == 0L))
  592. #define Increase_Counter(x) { if ((++(x).low) == 0L) { (x).high++; } }
  593. #define Add_Counter(x, a, b) \
  594. { \
  595. (x).low = (a).low + (b).low; \
  596. \
  597. if (((x).low < (a).low) || ((x).low < (b).low)) \
  598. { \
  599. /* add with carry */ \
  600. (x).high = (a).high + (b).high + 1; \
  601. } \
  602. else \
  603. { \
  604. /* add without carry */ \
  605. (x).high = (a).high + (b).high; \
  606. } \
  607. }
  608. #else
  609. /* 32bit counter. */
  610. typedef unsigned long COUNTER;
  611. #define DBL_Counter(x) ( (DBL)(x) )
  612. #define Long_To_Counter(i,x) { (x) = i; }
  613. #define Init_Counter(x) { (x) = 0L; }
  614. #define Increase_Counter(x) { (x)++; }
  615. #define Test_Zero_Counter(x) ((x) == 0L)
  616. #define Add_Counter(x, a, b) { (x) = (a) + (b); }
  617. #endif
  618. /*****************************************************************************
  619. *
  620. * Bounding box stuff (see also BOUND.H).
  621. *
  622. *****************************************************************************/
  623. typedef struct Bounding_Box_Struct BBOX;
  624. struct Bounding_Box_Struct
  625. {
  626. BBOX_VECT Lower_Left, Lengths;
  627. };
  628. /*****************************************************************************
  629. *
  630. * Transformation stuff.
  631. *
  632. *****************************************************************************/
  633. typedef struct Transform_Struct TRANSFORM;
  634. struct Transform_Struct
  635. {
  636. MATRIX matrix;
  637. MATRIX inverse;
  638. };
  639. #define Destroy_Transform(x) if ((x)!=NULL) POV_FREE(x)
  640. /*****************************************************************************
  641. *
  642. * Color map stuff.
  643. *
  644. *****************************************************************************/
  645. #define MAX_BLEND_MAP_ENTRIES 256
  646. typedef struct Blend_Map_Entry BLEND_MAP_ENTRY;
  647. typedef struct Blend_Map_Struct BLEND_MAP;
  648. typedef struct Pattern_Struct TPATTERN;
  649. typedef struct Texture_Struct TEXTURE;
  650. typedef struct Pigment_Struct PIGMENT;
  651. typedef struct Tnormal_Struct TNORMAL;
  652. typedef struct Finish_Struct FINISH;
  653. typedef struct Turb_Struct TURB;
  654. typedef struct Warps_Struct WARP;
  655. struct Blend_Map_Entry
  656. {
  657. SNGL value;
  658. unsigned char Same;
  659. union
  660. {
  661. COLOUR Colour;
  662. PIGMENT *Pigment;
  663. TNORMAL *Tnormal;
  664. TEXTURE *Texture;
  665. UV_VECT Point_Slope;
  666. } Vals;
  667. };
  668. struct Blend_Map_Struct
  669. {
  670. short Number_Of_Entries, Transparency_Flag, Type;
  671. long Users;
  672. BLEND_MAP_ENTRY *Blend_Map_Entries;
  673. };
  674. #define Make_Blend_Map_Entry(entry,v,s,r,g,b,a,t) \
  675. { \
  676. (entry).value = (v); \
  677. (entry).Same = (s); \
  678. Make_ColourA((entry).Vals.Colour, r, g, b, a, t); \
  679. }
  680. /*****************************************************************************
  681. *
  682. * Media stuff.
  683. *
  684. *****************************************************************************/
  685. typedef struct Media_Struct IMEDIA;
  686. struct Media_Struct
  687. {
  688. int Type;
  689. int Intervals;
  690. int Min_Samples;
  691. int Max_Samples;
  692. int is_constant;
  693. DBL Eccentricity,sc_ext;
  694. int use_absorption;
  695. int use_emission;
  696. int use_extinction;
  697. int use_scattering;
  698. COLOUR Absorption;
  699. COLOUR Emission;
  700. COLOUR Extinction;
  701. COLOUR Scattering;
  702. DBL Ratio;
  703. DBL Confidence;
  704. DBL Variance;
  705. DBL *Sample_Threshold;
  706. PIGMENT *Density;
  707. IMEDIA *Next_Media;
  708. };
  709. /*****************************************************************************
  710. *
  711. * Interior stuff.
  712. *
  713. *****************************************************************************/
  714. typedef struct Interior_Struct INTERIOR;
  715. struct Interior_Struct
  716. {
  717. long References;
  718. int hollow;
  719. SNGL IOR;
  720. SNGL Caustics, Old_Refract;
  721. SNGL Fade_Distance, Fade_Power;
  722. IMEDIA *IMedia;
  723. };
  724. /*****************************************************************************
  725. *
  726. * IFF file stuff.
  727. *
  728. *****************************************************************************/
  729. #ifndef IFF_SWITCH_CAST
  730. #define IFF_SWITCH_CAST (int)
  731. #endif
  732. typedef struct Image_Colour_Struct IMAGE_COLOUR;
  733. typedef struct Image_Line_Struct IMAGE_LINE;
  734. struct Image_Colour_Struct
  735. {
  736. unsigned short Red, Green, Blue, Filter, Transmit;
  737. };
  738. struct Image_Line_Struct
  739. {
  740. unsigned char *red, *green, *blue, *transm;
  741. };
  742. /*****************************************************************************
  743. *
  744. * Image stuff.
  745. *
  746. *****************************************************************************/
  747. /* Legal image attributes. */
  748. #define NO_FILE 0x0000
  749. #define GIF_FILE 0x0001
  750. #define POT_FILE 0x0002
  751. #define SYS_FILE 0x0004
  752. #define IFF_FILE 0x0008
  753. #define TGA_FILE 0x0010
  754. #define GRAD_FILE 0x0020
  755. #define PGM_FILE 0x0040
  756. #define PPM_FILE 0x0080
  757. #define PNG_FILE 0x0100
  758. #define IMAGE_FTYPE 0x0400
  759. #define HF_FTYPE 0x0800
  760. #define HIST_FTYPE 0x1000
  761. #define GRAY_FTYPE 0x2000
  762. #define NORMAL_FTYPE 0x4000
  763. #define MATERIAL_FTYPE 0x8000
  764. /* Image types. */
  765. #define IMAGE_FILE IMAGE_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE
  766. #define NORMAL_FILE NORMAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE
  767. #define MATERIAL_FILE MATERIAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE
  768. #define HF_FILE HF_FTYPE+GIF_FILE+POT_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE
  769. typedef struct Image_Struct IMAGE;
  770. struct Image_Struct
  771. {
  772. int References; /* Keeps track of number of pointers to this structure */
  773. int Map_Type;
  774. int File_Type;
  775. int Image_Type; /* What this image is being used for */
  776. int Interpolation_Type;
  777. short Once_Flag;
  778. short Use_Colour_Flag;
  779. VECTOR Gradient;
  780. SNGL width, height;
  781. int iwidth, iheight;
  782. short Colour_Map_Size;
  783. IMAGE_COLOUR *Colour_Map;
  784. union
  785. {
  786. IMAGE_LINE *rgb_lines;
  787. unsigned char **map_lines;
  788. } data;
  789. };
  790. #define PIGMENT_TYPE 0
  791. #define NORMAL_TYPE 1
  792. #define PATTERN_TYPE 2
  793. #define TEXTURE_TYPE 4
  794. #define COLOUR_TYPE 5
  795. #define SLOPE_TYPE 6
  796. #define DENSITY_TYPE 7
  797. /*****************************************************************************
  798. *
  799. * Pigment, Tnormal, Finish, Texture & Warps stuff.
  800. *
  801. *****************************************************************************/
  802. typedef struct Density_file_Struct DENSITY_FILE;
  803. typedef struct Density_file_Data_Struct DENSITY_FILE_DATA;
  804. struct Density_file_Struct
  805. {
  806. int Interpolation;
  807. DENSITY_FILE_DATA *Data;
  808. };
  809. struct Density_file_Data_Struct
  810. {
  811. int References;
  812. char *Name;
  813. int Sx, Sy, Sz;
  814. unsigned char ***Density;
  815. };
  816. #define TPATTERN_FIELDS \
  817. unsigned short Type, Wave_Type, Flags; \
  818. int References; \
  819. SNGL Frequency, Phase; \
  820. SNGL Exponent; \
  821. WARP *Warps; \
  822. TPATTERN *Next; \
  823. BLEND_MAP *Blend_Map; \
  824. union { \
  825. DENSITY_FILE *Density_File; \
  826. IMAGE *Image; \
  827. VECTOR Gradient; \
  828. SNGL Agate_Turb_Scale; \
  829. short Num_of_Waves; \
  830. short Iterations; \
  831. short Arms; \
  832. struct {SNGL Mortar; VECTOR Size;} Brick; \
  833. struct {SNGL Control0, Control1; } Quilted; \
  834. } Vals;
  835. struct Pattern_Struct
  836. {
  837. TPATTERN_FIELDS
  838. };
  839. struct Pigment_Struct
  840. {
  841. TPATTERN_FIELDS
  842. COLOUR Colour;
  843. };
  844. struct Tnormal_Struct
  845. {
  846. TPATTERN_FIELDS
  847. SNGL Amount;
  848. };
  849. #define TEXTURE_FIELDS \
  850. TPATTERN_FIELDS \
  851. TEXTURE *Next_Material;
  852. struct Texture_Struct
  853. {
  854. TEXTURE_FIELDS
  855. PIGMENT *Pigment;
  856. TNORMAL *Tnormal;
  857. FINISH *Finish;
  858. TEXTURE *Materials;
  859. int Num_Of_Mats;
  860. };
  861. struct Finish_Struct
  862. {
  863. SNGL Diffuse, Brilliance;
  864. SNGL Specular, Roughness;
  865. SNGL Phong, Phong_Size;
  866. SNGL Irid, Irid_Film_Thickness, Irid_Turb;
  867. SNGL Crand, Metallic;
  868. SNGL Temp_Caustics, Temp_IOR, Temp_Refract, Reflect_Exp;
  869. RGB Ambient, Reflection;
  870. };
  871. #define WARP_FIELDS unsigned short Warp_Type; WARP *Next_Warp;
  872. struct Warps_Struct
  873. {
  874. WARP_FIELDS
  875. };
  876. struct Turb_Struct
  877. {
  878. WARP_FIELDS
  879. VECTOR Turbulence;
  880. int Octaves;
  881. SNGL Lambda, Omega;
  882. };
  883. #define Destroy_Finish(x) if ((x)!=NULL) POV_FREE(x)
  884. typedef struct Material_Struct MATERIAL;
  885. struct Material_Struct
  886. {
  887. TEXTURE *Texture;
  888. INTERIOR *Interior;
  889. };
  890. /*****************************************************************************
  891. *
  892. * Object stuff (see also OBJECTS.H and primitive include files).
  893. *
  894. *****************************************************************************/
  895. #define All_Intersections(x,y,z) ((*((x)->Methods->All_Intersections_Method)) (x,y,z))
  896. #define Inside(x,y) ((*((y)->Methods->Inside_Method)) (x,y))
  897. #define Normal(x,y,z) ((*((y)->Methods->Normal_Method)) (x,y,z))
  898. #define Copy(x) ((*((x)->Methods->Copy_Method)) (x))
  899. #define Translate(x,y,z) ((*((x)->Methods->Translate_Method)) (x,y,z))
  900. #define Scale(x,y,z) ((*((x)->Methods->Scale_Method)) (x,y,z))
  901. #define Rotate(x,y,z) ((*((x)->Methods->Rotate_Method)) (x,y,z))
  902. #define Transform(x,y) ((*((x)->Methods->Transform_Method)) (x,y))
  903. #define Invert(x) ((*((x)->Methods->Invert_Method)) (x))
  904. #define Destroy(x) ((*((x)->Methods->Destroy_Method)) (x))
  905. typedef struct Method_Struct METHODS;
  906. typedef int (*ALL_INTERSECTIONS_METHOD)(OBJECT *, RAY *, ISTACK *);
  907. typedef int (*INSIDE_METHOD)(VECTOR , OBJECT *);
  908. typedef void (*NORMAL_METHOD)(VECTOR, OBJECT *, INTERSECTION *);
  909. typedef void *(*COPY_METHOD)(OBJECT *);
  910. typedef void (*TRANSLATE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
  911. typedef void (*ROTATE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
  912. typedef void (*SCALE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
  913. typedef void (*TRANSFORM_METHOD)(OBJECT *, TRANSFORM *);
  914. typedef void (*INVERT_METHOD)(OBJECT *);
  915. typedef void (*DESTROY_METHOD)(OBJECT *);
  916. /* These fields are common to all objects. */
  917. #define OBJECT_FIELDS \
  918. METHODS *Methods; \
  919. int Type; \
  920. OBJECT *Sibling; \
  921. TEXTURE *Texture; \
  922. INTERIOR *Interior; \
  923. OBJECT *Bound; \
  924. OBJECT *Clip; \
  925. BBOX BBox; \
  926. unsigned long Flags;
  927. /* These fields are common to all compound objects */
  928. #define COMPOUND_FIELDS \
  929. OBJECT_FIELDS \
  930. OBJECT *Children;
  931. #define INIT_OBJECT_FIELDS(o,t,m) \
  932. o->Type = t; \
  933. o->Methods = m; \
  934. o->Sibling = NULL; \
  935. o->Texture = NULL; \
  936. o->Bound = NULL; \
  937. o->Clip = NULL; \
  938. o->Interior = NULL; \
  939. o->Flags = 0; \
  940. Make_BBox(o->BBox, -BOUND_HUGE/2.0, -BOUND_HUGE/2.0, -BOUND_HUGE/2.0, \
  941. BOUND_HUGE, BOUND_HUGE, BOUND_HUGE);
  942. struct Method_Struct
  943. {
  944. ALL_INTERSECTIONS_METHOD All_Intersections_Method;
  945. INSIDE_METHOD Inside_Method;
  946. NORMAL_METHOD Normal_Method;
  947. COPY_METHOD Copy_Method;
  948. TRANSLATE_METHOD Translate_Method;
  949. ROTATE_METHOD Rotate_Method;
  950. SCALE_METHOD Scale_Method;
  951. TRANSFORM_METHOD Transform_Method;
  952. INVERT_METHOD Invert_Method;
  953. DESTROY_METHOD Destroy_Method;
  954. };
  955. /* This is an abstract structure that is never actually used.
  956. All other objects are descendents of this primative type */
  957. struct Object_Struct
  958. {
  959. OBJECT_FIELDS
  960. };
  961. /*****************************************************************************
  962. *
  963. * Intersection stack stuff.
  964. *
  965. *****************************************************************************/
  966. struct istk_entry
  967. {
  968. DBL Depth;
  969. VECTOR IPoint;
  970. VECTOR INormal;
  971. OBJECT *Object;
  972. /*
  973. * [DB 8/94]
  974. *
  975. * Pass additional values from the intersection function to other functions
  976. * (normal calculation). 2 ints and 2 DBLS seem enough.
  977. */
  978. int i1, i2;
  979. DBL d1, d2;
  980. /* Arbitrary pointer that can be passed. */
  981. void *Pointer;
  982. };
  983. struct istack_struct
  984. {
  985. struct istack_struct *next;
  986. struct istk_entry *istack;
  987. unsigned int top_entry;
  988. };
  989. #define itop(i) (i->istack[i->top_entry])
  990. /* Macros to push intersection onto stack. */
  991. #define push_entry(d,v,o,i) \
  992. itop(i).Depth = d; \
  993. itop(i).Object = o; \
  994. Assign_Vector(itop(i).IPoint,v); \
  995. incstack(i);
  996. #define push_normal_entry(d,v,n,o,i) \
  997. itop(i).Depth = d; \
  998. itop(i).Object = o; \
  999. Assign_Vector(itop(i).IPoint,v); \
  1000. Assign_Vector(itop(i).INormal,n); \
  1001. incstack(i);
  1002. /* Use these macros to push additional parameters onto the stack. [DB 8/94] */
  1003. #define push_entry_pointer(d,v,o,a,i) \
  1004. itop(i).Depth = d; \
  1005. itop(i).Object = o; \
  1006. itop(i).Pointer = (void *)(a); \
  1007. Assign_Vector(itop(i).IPoint,v); \
  1008. incstack(i);
  1009. #define push_entry_i1(d,v,o,a,i) \
  1010. itop(i).Depth = d; \
  1011. itop(i).Object = o; \
  1012. itop(i).i1 = a; \
  1013. Assign_Vector(itop(i).IPoint,v); \
  1014. incstack(i);
  1015. #define push_entry_d1(d,v,o,a,i) \
  1016. itop(i).Depth = d; \
  1017. itop(i).Object = o; \
  1018. itop(i).d1 = a; \
  1019. Assign_Vector(itop(i).IPoint,v); \
  1020. incstack(i);
  1021. #define push_entry_i1_i2(d,v,o,a,b,i) \
  1022. itop(i).Depth = d; \
  1023. itop(i).Object = o; \
  1024. itop(i).i1 = a; \
  1025. itop(i).i2 = b; \
  1026. Assign_Vector(itop(i).IPoint,v); \
  1027. incstack(i);
  1028. #define push_entry_i1_d1(d,v,o,a,b,i) \
  1029. itop(i).Depth = d; \
  1030. itop(i).Object = o; \
  1031. itop(i).i1 = a; \
  1032. itop(i).d1 = b; \
  1033. Assign_Vector(itop(i).IPoint,v); \
  1034. incstack(i);
  1035. #define push_entry_i1_i2_d1(d,v,o,a,b,c,i) \
  1036. itop(i).Depth = d; \
  1037. itop(i).Object = o; \
  1038. itop(i).i1 = a; \
  1039. itop(i).i2 = b; \
  1040. itop(i).d1 = c; \
  1041. Assign_Vector(itop(i).IPoint,v); \
  1042. incstack(i);
  1043. #define push_copy(i,e) itop(i)= *e; incstack(i);
  1044. #define pop_entry(i) (i->top_entry > 0)?&(i->istack[--i->top_entry]):NULL
  1045. /*****************************************************************************
  1046. *
  1047. * Ray stuff (see also RAY.H).
  1048. *
  1049. *****************************************************************************/
  1050. #define MAX_CONTAINING_OBJECTS 100
  1051. struct Ray_Struct
  1052. {
  1053. VECTOR Initial;
  1054. VECTOR Direction;
  1055. int Index;
  1056. INTERIOR *Interiors[MAX_CONTAINING_OBJECTS];
  1057. };
  1058. /*****************************************************************************
  1059. *
  1060. * Frame tracking information
  1061. *
  1062. *****************************************************************************/
  1063. typedef enum
  1064. {
  1065. FT_SINGLE_FRAME,
  1066. FT_MULTIPLE_FRAME
  1067. } FRAMETYPE;
  1068. #define INT_VALUE_UNSET (-1)
  1069. #define DBL_VALUE_UNSET (-1.0)
  1070. typedef struct
  1071. {
  1072. FRAMETYPE FrameType;
  1073. DBL Clock_Value; /* May change between frames of an animation */
  1074. int FrameNumber; /* May change between frames of an animation */
  1075. int InitialFrame;
  1076. DBL InitialClock;
  1077. int FinalFrame;
  1078. int FrameNumWidth;
  1079. DBL FinalClock;
  1080. int SubsetStartFrame;
  1081. DBL SubsetStartPercent;
  1082. int SubsetEndFrame;
  1083. DBL SubsetEndPercent;
  1084. unsigned Field_Render_Flag;
  1085. unsigned Odd_Field_Flag;
  1086. } FRAMESEQ;
  1087. /*****************************************************************************
  1088. *
  1089. * Miscellaneous stuff.
  1090. *
  1091. *****************************************************************************/
  1092. typedef struct Chunk_Header_Struct CHUNK_HEADER;
  1093. typedef struct Data_File_Struct DATA_FILE;
  1094. typedef struct complex_block complex;
  1095. typedef struct file_handle_struct FILE_HANDLE;
  1096. typedef int TOKEN;
  1097. typedef struct Reserved_Word_Struct RESERVED_WORD;
  1098. struct Reserved_Word_Struct
  1099. {
  1100. TOKEN Token_Number;
  1101. char *Token_Name;
  1102. };
  1103. typedef struct Sym_Table_Entry SYM_ENTRY;
  1104. struct Sym_Table_Entry
  1105. {
  1106. SYM_ENTRY *next;
  1107. char *Token_Name;
  1108. void *Data;
  1109. TOKEN Token_Number;
  1110. };
  1111. struct Chunk_Header_Struct
  1112. {
  1113. long name;
  1114. long size;
  1115. };
  1116. struct Data_File_Struct
  1117. {
  1118. FILE *File;
  1119. int Line_Number,R_Flag;
  1120. char *Filename;
  1121. };
  1122. struct complex_block
  1123. {
  1124. DBL r, c;
  1125. };
  1126. #define READ_MODE 0
  1127. #define WRITE_MODE 1
  1128. #define APPEND_MODE 2
  1129. struct file_handle_struct
  1130. {
  1131. char *filename;
  1132. int mode;
  1133. int width, height;
  1134. int buffer_size;
  1135. char *buffer;
  1136. FILE *file;
  1137. int file_type; /* What format the output file is */
  1138. int (*Open_File_p) (struct file_handle_struct *handle,
  1139. char *name, int *width, int *height, int buffer_size, int mode);
  1140. void (*Write_Line_p) (struct file_handle_struct *handle,
  1141. COLOUR *line_data, int line_number);
  1142. int (*Read_Line_p) (struct file_handle_struct *handle,
  1143. COLOUR *line_data, int *line_number);
  1144. void (*Read_Image_p) (IMAGE *Image, char *filename);
  1145. void (*Close_File_p) (struct file_handle_struct *handle);
  1146. };
  1147. #define Open_File(h,n,wd,ht,sz,m) ((*((h)->Open_File_p)) (h,n,wd,ht,sz,m))
  1148. #define Write_Line(h,l,n) ((*((h)->Write_Line_p)) (h, l, n))
  1149. #define Read_Line(h,l,n) ((*((h)->Read_Line_p)) (h, l, n))
  1150. #define Read_Image(h,i) ((*((h)->Read_Image_p)) (h, i))
  1151. #define Close_File(h) ((*((h)->Close_File_p)) (h))
  1152. #endif