BRL-CAD
optical.h
Go to the documentation of this file.
1 /* O P T I C A L . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup liboptical */
21 /** @{ */
22 /** @file optical.h
23  *
24  * @brief
25  * Header file for the BRL-CAD Optical Library, LIBOPTICAL.
26  *
27  */
28 
29 #ifndef OPTICAL_H
30 #define OPTICAL_H
31 
32 #include "common.h"
33 
34 #include "bu/vls.h"
35 #include "shadefuncs.h"
36 #include "shadework.h"
37 
39 
40 #ifndef OPTICAL_EXPORT
41 # if defined(OPTICAL_DLL_EXPORTS) && defined(OPTICAL_DLL_IMPORTS)
42 # error "Only OPTICAL_DLL_EXPORTS or OPTICAL_DLL_IMPORTS can be defined, not both."
43 # elif defined(OPTICAL_DLL_EXPORTS)
44 # define OPTICAL_EXPORT __declspec(dllexport)
45 # elif defined(OPTICAL_DLL_IMPORTS)
46 # define OPTICAL_EXPORT __declspec(dllimport)
47 # else
48 # define OPTICAL_EXPORT
49 # endif
50 #endif
51 
52 /**
53  * this function sets the provided mfuncs head pointer to the list of
54  * available shaders. the provided mfuncs head pointer should point
55  * to MF_NULL prior to getting passed to optical_shader_init() so that
56  * the same shader list may be returned repeatably.
57  */
58 OPTICAL_EXPORT extern void optical_shader_init(struct mfuncs **headp);
59 
60 /* stub functions useful for debugging */
61 /* defined in sh_text.c */
62 OPTICAL_EXPORT extern int mlib_zero(struct application *, const struct partition *, struct shadework *, void *);
63 OPTICAL_EXPORT extern int mlib_one(struct region *, struct bu_vls *, void **, const struct mfuncs *, struct rt_i *);
64 OPTICAL_EXPORT extern void mlib_void(struct region *, void *);
65 
66 
67 /* defined in refract.c */
68 OPTICAL_EXPORT extern int
69 rr_render(struct application *app, const struct partition *pp, struct shadework *swp);
70 
71 /* defined in shade.c */
72 OPTICAL_EXPORT extern void
73 shade_inputs(struct application *app, const struct partition *pp, struct shadework *swp, int want);
74 
75 /* defined in wray.c */
76 OPTICAL_EXPORT extern void
77 wray(struct partition *pp, struct application *app, FILE *fp, const vect_t inormal);
78 
79 OPTICAL_EXPORT extern void
80 wraypts(vect_t in, vect_t inorm, vect_t out, int id, struct application *app, FILE *fp);
81 
82 OPTICAL_EXPORT extern void
83 wraypaint(vect_t start, vect_t norm, int paint, struct application *app, FILE *fp);
84 
85 /* defined in shade.c */
86 OPTICAL_EXPORT extern int
87 viewshade(struct application *app, const struct partition *pp, struct shadework *swp);
88 
89 /* defined in vers.c */
90 OPTICAL_EXPORT extern const char *optical_version(void);
91 
92 /* for libmultispectral */
93 
94 /* FIXME: these should not need to be declared for libmultispectral.
95  * breaks encapsulation/modularity of shaders if we have to list them
96  * in more than one place. maybe give multispectral arrays their own
97  * suffix so as not to conflict.
98  */
99 
100 OPTICAL_EXPORT extern struct mfuncs camo_mfuncs[];
101 OPTICAL_EXPORT extern struct mfuncs light_mfuncs[];
102 OPTICAL_EXPORT extern struct mfuncs stk_mfuncs[];
103 OPTICAL_EXPORT extern struct mfuncs phg_mfuncs[];
104 OPTICAL_EXPORT extern struct mfuncs noise_mfuncs[];
105 OPTICAL_EXPORT extern struct bn_table *spectrum;
106 
107 OPTICAL_EXPORT extern int rdebug;
108 
109 /* When in production mode, no debug checking is performed, hence the
110  * R_DEBUG define causes sections of debug code to go "poof"
111  */
112 #ifdef NO_DEBUG_CHECKING
113 # define R_DEBUG 0
114 #else
115 # define R_DEBUG rdebug
116 #endif
117 
118 /*
119  * Debugging flags for thr RT program itself.
120  * These flags follow the "-X" (cap X) option to the RT program.
121  * librt debugging is separately controlled.
122  */
123 
124 /* These definitions are each for one bit */
125 /* Should be reorganized to put most useful ones first */
126 #define RDEBUG_HITS 0x00000001 /* 1 Print hits used by view() */
127 #define RDEBUG_MATERIAL 0x00000002 /* 2 Material properties */
128 #define RDEBUG_SHOWERR 0x00000004 /* 3 Colorful markers on errors */
129 #define RDEBUG_RTMEM 0x00000008 /* 4 Debug librt mem after startup */
130 #define RDEBUG_SHADE 0x00000010 /* 5 Shading calculation */
131 #define RDEBUG_PARSE 0x00000020 /* 6 Command parsing */
132 #define RDEBUG_LIGHT 0x00000040 /* 7 Debug lighting */
133 #define RDEBUG_REFRACT 0x00000080 /* 8 Debug reflection & refraction */
134 
135 #define RDEBUG_STATS 0x00000200 /* 10 Print more statistics */
136 #define RDEBUG_RTMEM_END 0x00000400 /* 11 Print librt mem use on 'clean' */
137 
138 /* These will cause binary debugging output */
139 #define RDEBUG_MISSPLOT 0x20000000 /* 30 plot(5) missed rays to stdout */
140 #define RDEBUG_RAYWRITE 0x40000000 /* 31 Ray(5V) view rays to stdout */
141 #define RDEBUG_RAYPLOT 0x80000000 /* 32 plot(5) rays to stdout */
142 
143 /* Format string for rt_printb() */
144 #define RDEBUG_FORMAT \
145 "\020\040RAYPLOT\037RAYWRITE\036MISSPLOT\
146 \013RTMEM_END\
147 \012STATS\010REFRACT\
148 \7LIGHT\6PARSE\5SHADE\4RTMEM\3SHOWERR\2MATERIAL\1HITS"
149 
150 
151 /*
152  * A Bit vector to determine how much stuff rt prints when not in
153  * debugging mode.
154  *
155  */
156 OPTICAL_EXPORT extern int rt_verbosity;
157 /* flag_name value prints */
158 #define VERBOSE_LIBVERSIONS 0x00000001 /* Library version strings */
159 #define VERBOSE_MODELTITLE 0x00000002 /* model title */
160 #define VERBOSE_TOLERANCE 0x00000004 /* model tolerance */
161 #define VERBOSE_STATS 0x00000008 /* stats about rt_gettrees() */
162 #define VERBOSE_FRAMENUMBER 0x00000010 /* current frame number */
163 #define VERBOSE_VIEWDETAIL 0x00000020 /* view specifications */
164 #define VERBOSE_LIGHTINFO 0x00000040 /* scene lights */
165 #define VERBOSE_INCREMENTAL 0x00000080 /* progressive/incremental state */
166 #define VERBOSE_MULTICPU 0x00000100 /* # of CPU's to be used */
167 #define VERBOSE_OUTPUTFILE 0x00000200 /* name of output image */
168 
169 #define VERBOSE_FORMAT \
170 "\012OUTPUTFILE\011MULTICPU\010INCREMENTAL\7LIGHTINFO\6VIEWDETAIL\
171 \5FRAMENUMBER\4STATS\3TOLERANCE\2MODELTITLE\1LIBVERSIONS"
172 
173 OPTICAL_EXPORT extern double AmbientIntensity;
174 #ifdef RT_MULTISPECTRAL
175 OPTICAL_EXPORT extern struct bn_tabdata *background;
176 #else
177 OPTICAL_EXPORT extern vect_t background;
178 #endif
179 
180 /* defined in sh_text.c */
181 OPTICAL_EXPORT extern struct region env_region; /* environment map region */
182 
183 /* defined in refract.c */
184 OPTICAL_EXPORT extern int max_bounces;
185 OPTICAL_EXPORT extern int max_ireflect;
186 
187 struct floatpixel {
188  double ff_dist; /**< @brief range to ff_hitpt[], <-INFINITY for miss */
189  float ff_hitpt[3];
190  struct region *ff_regp;
191  int ff_frame; /**< @brief >= 0 means pixel was reprojected */
192  short ff_x; /**< @brief screen x, y coords of first location */
193  short ff_y;
194  char ff_color[3];
195 };
196 
198 
199 #endif /* OPTICAL_H */
200 
201 /** @} */
202 /*
203  * Local Variables:
204  * mode: C
205  * tab-width: 8
206  * indent-tabs-mode: t
207  * c-file-style: "stroustrup"
208  * End:
209  * ex: shiftwidth=4 tabstop=8
210  */
void mlib_void(struct region *, void *)
Definition: sh_text.c:956
vect_t background
Definition: init.c:46
void wraypts(vect_t in, vect_t inorm, vect_t out, int id, struct application *app, FILE *fp)
Definition: wray.c:154
int viewshade(struct application *app, const struct partition *pp, struct shadework *swp)
Definition: shade.c:259
int ff_frame
>= 0 means pixel was reprojected
Definition: optical.h:191
struct mfuncs light_mfuncs[]
Definition: sh_light.c:65
Header file for the BRL-CAD common definitions.
int max_bounces
Definition: refract.c:45
const char * optical_version(void)
Definition: vers.c:32
struct mfuncs phg_mfuncs[]
Definition: sh_plastic.c:83
struct region env_region
Definition: init.c:50
int mlib_zero(struct application *, const struct partition *, struct shadework *, void *)
Definition: sh_text.c:936
struct region * ff_regp
Definition: optical.h:190
void optical_shader_init(struct mfuncs **headp)
Definition: init.c:61
#define __BEGIN_DECLS
Definition: common.h:73
float ff_hitpt[3]
Definition: optical.h:189
double ff_dist
range to ff_hitpt[], <-INFINITY for miss
Definition: optical.h:188
int rt_verbosity
Definition: init.c:38
char ff_color[3]
Definition: optical.h:194
void wraypaint(vect_t start, vect_t norm, int paint, struct application *app, FILE *fp)
Definition: wray.c:182
void wray(struct partition *pp, struct application *app, FILE *fp, const vect_t inormal)
Definition: wray.c:117
goto out
Definition: nmg_mod.c:3846
struct mfuncs camo_mfuncs[]
Definition: sh_camo.c:157
void shade_inputs(struct application *app, const struct partition *pp, struct shadework *swp, int want)
Definition: shade.c:118
int mlib_one(struct region *, struct bu_vls *, void **, const struct mfuncs *, struct rt_i *)
Definition: sh_text.c:948
int max_ireflect
Definition: refract.c:44
struct mfuncs noise_mfuncs[]
Definition: sh_noise.c:453
short ff_y
Definition: optical.h:193
short ff_x
screen x, y coords of first location
Definition: optical.h:192
#define __END_DECLS
Definition: common.h:74
struct bn_table * spectrum
Definition: init.c:41
int rr_render(struct application *app, const struct partition *pp, struct shadework *swp)
struct mfuncs stk_mfuncs[]
Definition: sh_stack.c:43
Definition: vls.h:56
int rdebug
Definition: init.c:39
double AmbientIntensity
Definition: init.c:40