1use super::parse_context::*;
2use crate::core::base::*;
3use crate::core::param_set::*;
4use std::cell::RefCell;
5use std::sync::Arc;
6
7pub struct MutipleContext {
8 pub contexts: Vec<Arc<RefCell<dyn ParseContext>>>,
9}
10
11impl MutipleContext {
12 pub fn new() -> Self {
13 MutipleContext {
14 contexts: Vec::new(),
15 }
16 }
17 pub fn add(&mut self, context: Arc<RefCell<dyn ParseContext>>) {
18 self.contexts.push(context);
19 }
20}
21
22impl ParseContext for MutipleContext {
23 fn pbrt_cleanup(&mut self) {
24 for r in self.contexts.iter() {
25 r.borrow_mut().pbrt_cleanup();
26 }
27 }
28
29 fn pbrt_identity(&mut self) {
30 for r in self.contexts.iter() {
31 r.borrow_mut().pbrt_identity();
32 }
33 }
34
35 fn pbrt_translate(&mut self, dx: Float, dy: Float, dz: Float) {
36 for r in self.contexts.iter() {
37 r.borrow_mut().pbrt_translate(dx, dy, dz);
38 }
39 }
40
41 fn pbrt_rotate(&mut self, angle: Float, ax: Float, ay: Float, az: Float) {
42 for r in self.contexts.iter() {
43 r.borrow_mut().pbrt_rotate(angle, ax, ay, az);
44 }
45 }
46
47 fn pbrt_scale(&mut self, sx: Float, sy: Float, sz: Float) {
48 for r in self.contexts.iter() {
49 r.borrow_mut().pbrt_scale(sx, sy, sz);
50 }
51 }
52
53 fn pbrt_look_at(
54 &mut self,
55 ex: Float,
56 ey: Float,
57 ez: Float,
58 lx: Float,
59 ly: Float,
60 lz: Float,
61 ux: Float,
62 uy: Float,
63 uz: Float,
64 ) {
65 for r in self.contexts.iter() {
66 r.borrow_mut()
67 .pbrt_look_at(ex, ey, ez, lx, ly, lz, ux, uy, uz);
68 }
69 }
70
71 fn pbrt_concat_transform(&mut self, transform: &[Float]) {
72 for r in self.contexts.iter() {
73 r.borrow_mut().pbrt_concat_transform(transform);
74 }
75 }
76
77 fn pbrt_transform(&mut self, transform: &[Float]) {
78 for r in self.contexts.iter() {
79 r.borrow_mut().pbrt_transform(transform);
80 }
81 }
82
83 fn pbrt_coordinate_system(&mut self, name: &str) {
84 for r in self.contexts.iter() {
85 r.borrow_mut().pbrt_coordinate_system(name);
86 }
87 }
88
89 fn pbrt_coord_sys_transform(&mut self, name: &str) {
90 for r in self.contexts.iter() {
91 r.borrow_mut().pbrt_coord_sys_transform(name);
92 }
93 }
94
95 fn pbrt_active_transform_all(&mut self) {
96 for r in self.contexts.iter() {
97 r.borrow_mut().pbrt_active_transform_all();
98 }
99 }
100
101 fn pbrt_active_transform_end_time(&mut self) {
102 for r in self.contexts.iter() {
103 r.borrow_mut().pbrt_active_transform_end_time();
104 }
105 }
106
107 fn pbrt_active_transform_start_time(&mut self) {
108 for r in self.contexts.iter() {
109 r.borrow_mut().pbrt_active_transform_start_time();
110 }
111 }
112
113 fn pbrt_transform_times(&mut self, start: Float, end: Float) {
114 for r in self.contexts.iter() {
115 r.borrow_mut().pbrt_transform_times(start, end);
116 }
117 }
118
119 fn pbrt_pixel_filter(&mut self, name: &str, params: &ParamSet) {
120 for r in self.contexts.iter() {
121 r.borrow_mut().pbrt_pixel_filter(name, params);
122 }
123 }
124
125 fn pbrt_film(&mut self, name: &str, params: &ParamSet) {
126 for r in self.contexts.iter() {
127 r.borrow_mut().pbrt_film(name, params);
128 }
129 }
130
131 fn pbrt_sampler(&mut self, name: &str, params: &ParamSet) {
132 for r in self.contexts.iter() {
133 r.borrow_mut().pbrt_sampler(name, params);
134 }
135 }
136
137 fn pbrt_accelerator(&mut self, name: &str, params: &ParamSet) {
138 for r in self.contexts.iter() {
139 r.borrow_mut().pbrt_accelerator(name, params);
140 }
141 }
142
143 fn pbrt_integrator(&mut self, name: &str, params: &ParamSet) {
144 for r in self.contexts.iter() {
145 r.borrow_mut().pbrt_integrator(name, params);
146 }
147 }
148 fn pbrt_camera(&mut self, name: &str, params: &ParamSet) {
149 for r in self.contexts.iter() {
150 r.borrow_mut().pbrt_camera(name, params);
151 }
152 }
153
154 fn pbrt_make_named_medium(&mut self, name: &str, params: &ParamSet) {
155 for r in self.contexts.iter() {
156 r.borrow_mut().pbrt_make_named_medium(name, params);
157 }
158 }
159
160 fn pbrt_medium_interface(&mut self, inside_name: &str, outside_name: &str) {
161 for r in self.contexts.iter() {
162 r.borrow_mut()
163 .pbrt_medium_interface(inside_name, outside_name);
164 }
165 }
166
167 fn pbrt_world_begin(&mut self) {
168 for r in self.contexts.iter() {
169 r.borrow_mut().pbrt_world_begin();
170 }
171 }
172
173 fn pbrt_attribute_begin(&mut self) {
174 for r in self.contexts.iter() {
175 r.borrow_mut().pbrt_attribute_begin();
176 }
177 }
178
179 fn pbrt_attribute_end(&mut self) {
180 for r in self.contexts.iter() {
181 r.borrow_mut().pbrt_attribute_end();
182 }
183 }
184
185 fn pbrt_transform_begin(&mut self) {
186 for r in self.contexts.iter() {
187 r.borrow_mut().pbrt_transform_begin();
188 }
189 }
190
191 fn pbrt_transform_end(&mut self) {
192 for r in self.contexts.iter() {
193 r.borrow_mut().pbrt_transform_end();
194 }
195 }
196
197 fn pbrt_texture(&mut self, name: &str, t: &str, tex_name: &str, params: &ParamSet) {
198 for r in self.contexts.iter() {
199 r.borrow_mut().pbrt_texture(name, t, tex_name, params);
200 }
201 }
202
203 fn pbrt_material(&mut self, name: &str, params: &ParamSet) {
204 for r in self.contexts.iter() {
205 r.borrow_mut().pbrt_material(name, params);
206 }
207 }
208
209 fn pbrt_make_named_material(&mut self, name: &str, params: &ParamSet) {
210 for r in self.contexts.iter() {
211 r.borrow_mut().pbrt_make_named_material(name, params);
212 }
213 }
214
215 fn pbrt_named_material(&mut self, name: &str) {
216 for r in self.contexts.iter() {
217 r.borrow_mut().pbrt_named_material(name);
218 }
219 }
220
221 fn pbrt_light_source(&mut self, name: &str, params: &ParamSet) {
222 for r in self.contexts.iter() {
223 r.borrow_mut().pbrt_light_source(name, params);
224 }
225 }
226
227 fn pbrt_area_light_source(&mut self, name: &str, params: &ParamSet) {
228 for r in self.contexts.iter() {
229 r.borrow_mut().pbrt_area_light_source(name, params);
230 }
231 }
232
233 fn pbrt_shape(&mut self, name: &str, params: &ParamSet) {
234 for r in self.contexts.iter() {
235 r.borrow_mut().pbrt_shape(name, params);
236 }
237 }
238
239 fn pbrt_reverse_orientation(&mut self) {
240 for r in self.contexts.iter() {
241 r.borrow_mut().pbrt_reverse_orientation();
242 }
243 }
244
245 fn pbrt_object_begin(&mut self, name: &str) {
246 for r in self.contexts.iter() {
247 r.borrow_mut().pbrt_object_begin(name);
248 }
249 }
250
251 fn pbrt_object_end(&mut self) {
252 for r in self.contexts.iter() {
253 r.borrow_mut().pbrt_object_end();
254 }
255 }
256 fn pbrt_object_instance(&mut self, name: &str) {
257 for r in self.contexts.iter() {
258 r.borrow_mut().pbrt_object_instance(name);
259 }
260 }
261
262 fn pbrt_world_end(&mut self) {
263 for r in self.contexts.iter() {
264 r.borrow_mut().pbrt_world_end();
265 }
266 }
267
268 fn pbrt_parse_file(&mut self, file_name: &str) {
269 for r in self.contexts.iter() {
270 r.borrow_mut().pbrt_parse_file(file_name);
271 }
272 }
273
274 fn pbrt_parse_string(&mut self, s: &str) {
275 for r in self.contexts.iter() {
276 r.borrow_mut().pbrt_parse_string(s);
277 }
278 }
279
280 fn pbrt_work_dir_begin(&mut self, path: &str) {
281 for r in self.contexts.iter() {
282 r.borrow_mut().pbrt_work_dir_begin(path);
283 }
284 }
285
286 fn pbrt_work_dir_end(&mut self) {
287 for r in self.contexts.iter() {
288 r.borrow_mut().pbrt_work_dir_end();
289 }
290 }
291
292 fn pbrt_include(&mut self, file_name: &str, params: &ParamSet) {
293 for r in self.contexts.iter() {
294 r.borrow_mut().pbrt_include(file_name, params);
295 }
296 }
297}