1 /****************************************************************************
2  *                  isosurf.h
3  *
4  * This module contains all defines, typedefs, and prototypes for isosurf.cpp.
5  *
6  * This module was written by D.Skarda & T.Bily and modified by R.Suzuki.
7  * Ported to POV-Ray 3.5 by Thorsten Froehlich.
8  *
9  * from Persistence of Vision(tm) Ray Tracer version 3.6.
10  * Copyright 1991-2003 Persistence of Vision Team
11  * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.
12  *---------------------------------------------------------------------------
13  * NOTICE: This source code file is provided so that users may experiment
14  * with enhancements to POV-Ray and to port the software to platforms other
15  * than those supported by the POV-Ray developers. There are strict rules
16  * regarding how you are permitted to use this file. These rules are contained
17  * in the distribution and derivative versions licenses which should have been
18  * provided with this file.
19  *
20  * These licences may be found online, linked from the end-user license
21  * agreement that is located at http://www.povray.org/povlegal.html
22  *---------------------------------------------------------------------------
23  * This program is based on the popular DKB raytracer version 2.12.
24  * DKBTrace was originally written by David K. Buck.
25  * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
26  *---------------------------------------------------------------------------
27  *
28  *===========================================================================
29  * This file is part of MegaPOV, a modified and unofficial version of POV-Ray
30  * For more information on MegaPOV visit our website:
31  * http://megapov.inetart.net/
32  *===========================================================================
33  *
34  * $RCSfile: isosurf.h,v $
35  * $Revision: 1.8 $
36  * $Author: chris $
37  *
38  *****************************************************************************/
39 
40 
41 #ifndef ISOSURF_H
42 #define ISOSURF_H
43 
44 #include "function.h"
45 
46 BEGIN_POV_NAMESPACE
47 
48 /*****************************************************************************
49 * Global preprocessor defines
50 ******************************************************************************/
51 
52 #define ISOSURFACE_OBJECT      (BASIC_OBJECT)
53 #define ISOSURFACE_MAXTRACE    10
54 
55 #define OK_X         1
56 #define OK_Y         2
57 #define OK_Z         4
58 #define OK_R         8
59 #define OK_S        16
60 #define OK_T        32
61 #define OK_U        64
62 #define OK_V       128
63 
64 
65 /*****************************************************************************
66 * Global variables
67 ******************************************************************************/
68 
69 extern METHODS IsoSurface_Methods;
70 
71 
72 /*****************************************************************************
73 * Global typedefs
74 ******************************************************************************/
75 
76 typedef struct IsoSurface_Struct ISOSURFACE;
77 typedef struct { DBL t,f; } ISO_Pair;
78 typedef struct
79 {
80 	unsigned int refcnt;
81 	DBL max_gradient, gradient;
82 	DBL eval_max, eval_cnt, eval_gradient_sum, eval_var;
83 	#ifdef MESSAGE_PATCH
84 		unsigned char message;
85 	#endif
86 } ISO_Max_Gradient;
87 
88 struct IsoSurface_Struct
89 {
90 	OBJECT_FIELDS
91 	FUNCTION_PTR Function;
92 	DBL max_gradient;
93 	DBL gradient;
94 	DBL threshold;
95 	DBL accuracy;
96 	DBL eval_param[3];
97 	int max_trace;
98 	int Inv3;
99 	bool closed;
100 	bool eval;
101 
102 	int container_shape;
103 	union
104 	{
105 		struct
106 		{
107 			VECTOR center;
108 			DBL radius;
109 		} sphere;
110 		struct
111 		{
112 			VECTOR corner1;
113 			VECTOR corner2;
114 		} box;
115 	} container;
116 
117 	// internal use only
118 	VECTOR P,D;
119 	DBL Vlength;
120 	DBL tl;
121 	DBL fmax;
122 	ISO_Max_Gradient *mginfo;
123 	bool cache;
124 };
125 
126 
127 /*****************************************************************************
128 * Global functions
129 ******************************************************************************/
130 
131 ISOSURFACE *Create_IsoSurface (void);
132 void Destroy_IsoSurface (OBJECT *Object);
133 void *Copy_IsoSurface (OBJECT *Object);
134 void Compute_IsoSurface_BBox (ISOSURFACE *Box);
135 
136 END_POV_NAMESPACE
137 
138 #endif
139