1 /* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY! */
2 /* generated from the file: ./geom.scm */
3
4 #include <string.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include "ctlgeom-types.h"
8
9 #ifdef CXX_CTL_IO
10 using namespace ctlio;
11 #endif
12
13
14 #include "geom-ctl-io-defaults.c"
15 #if 0
16
17 integer dimensions;
18 SCM default_material;
19 vector3 geometry_center;
20 lattice geometry_lattice;
21 geometric_object_list geometry;
22 boolean ensure_periodicity;
23
24 #endif
25
26
27 /******* class copy functions *******/
28
29 void
lattice_copy(const lattice * o0,lattice * o)30 lattice_copy(const lattice * o0, lattice * o)
31 {
32 o->basis1 = o0->basis1;
33 o->basis2 = o0->basis2;
34 o->basis3 = o0->basis3;
35 o->size = o0->size;
36 o->basis_size = o0->basis_size;
37 o->b1 = o0->b1;
38 o->b2 = o0->b2;
39 o->b3 = o0->b3;
40 o->basis = o0->basis;
41 o->metric = o0->metric;
42 }
43
44 void
ellipsoid_copy(const ellipsoid * o0,ellipsoid * o)45 ellipsoid_copy(const ellipsoid * o0, ellipsoid * o)
46 {
47 o->inverse_semi_axes = o0->inverse_semi_axes;
48 }
49
50 void
prism_copy(const prism * o0,prism * o)51 prism_copy(const prism * o0, prism * o)
52 {
53 {
54 int i_t;
55 o->vertices.num_items = o0->vertices.num_items;
56 o->vertices.items = ((vector3 *) malloc(sizeof(vector3) * (o->vertices.num_items)));
57 for (i_t = 0; i_t < o->vertices.num_items; i_t++) {
58 o->vertices.items[i_t] = o0->vertices.items[i_t];
59 }
60 }
61 o->height = o0->height;
62 o->axis = o0->axis;
63 o->sidewall_angle = o0->sidewall_angle;
64 {
65 int i_t;
66 o->vertices_p.num_items = o0->vertices_p.num_items;
67 o->vertices_p.items = ((vector3 *) malloc(sizeof(vector3) * (o->vertices_p.num_items)));
68 for (i_t = 0; i_t < o->vertices_p.num_items; i_t++) {
69 o->vertices_p.items[i_t] = o0->vertices_p.items[i_t];
70 }
71 }
72 {
73 int i_t;
74 o->top_polygon_diff_vectors_p.num_items = o0->top_polygon_diff_vectors_p.num_items;
75 o->top_polygon_diff_vectors_p.items = ((vector3 *) malloc(sizeof(vector3) * (o->top_polygon_diff_vectors_p.num_items)));
76 for (i_t = 0; i_t < o->top_polygon_diff_vectors_p.num_items; i_t++) {
77 o->top_polygon_diff_vectors_p.items[i_t] = o0->top_polygon_diff_vectors_p.items[i_t];
78 }
79 }
80 {
81 int i_t;
82 o->top_polygon_diff_vectors_scaled_p.num_items = o0->top_polygon_diff_vectors_scaled_p.num_items;
83 o->top_polygon_diff_vectors_scaled_p.items = ((vector3 *) malloc(sizeof(vector3) * (o->top_polygon_diff_vectors_scaled_p.num_items)));
84 for (i_t = 0; i_t < o->top_polygon_diff_vectors_scaled_p.num_items; i_t++) {
85 o->top_polygon_diff_vectors_scaled_p.items[i_t] = o0->top_polygon_diff_vectors_scaled_p.items[i_t];
86 }
87 }
88 {
89 int i_t;
90 o->vertices_top_p.num_items = o0->vertices_top_p.num_items;
91 o->vertices_top_p.items = ((vector3 *) malloc(sizeof(vector3) * (o->vertices_top_p.num_items)));
92 for (i_t = 0; i_t < o->vertices_top_p.num_items; i_t++) {
93 o->vertices_top_p.items[i_t] = o0->vertices_top_p.items[i_t];
94 }
95 }
96 {
97 int i_t;
98 o->vertices_top.num_items = o0->vertices_top.num_items;
99 o->vertices_top.items = ((vector3 *) malloc(sizeof(vector3) * (o->vertices_top.num_items)));
100 for (i_t = 0; i_t < o->vertices_top.num_items; i_t++) {
101 o->vertices_top.items[i_t] = o0->vertices_top.items[i_t];
102 }
103 }
104 o->centroid = o0->centroid;
105 {
106 int i_t;
107 o->workspace.num_items = o0->workspace.num_items;
108 o->workspace.items = ((number *) malloc(sizeof(number) * (o->workspace.num_items)));
109 for (i_t = 0; i_t < o->workspace.num_items; i_t++) {
110 o->workspace.items[i_t] = o0->workspace.items[i_t];
111 }
112 }
113 o->m_c2p = o0->m_c2p;
114 o->m_p2c = o0->m_p2c;
115 }
116
117 void
block_copy(const block * o0,block * o)118 block_copy(const block * o0, block * o)
119 {
120 o->e1 = o0->e1;
121 o->e2 = o0->e2;
122 o->e3 = o0->e3;
123 o->size = o0->size;
124 o->projection_matrix = o0->projection_matrix;
125 if (o0->which_subclass == ELLIPSOID) {
126 o->which_subclass = ELLIPSOID;
127 o->subclass.ellipsoid_data = ((ellipsoid *) malloc(sizeof(ellipsoid)));
128 ellipsoid_copy(o0->subclass.ellipsoid_data, o->subclass.ellipsoid_data);
129 } else
130 o->which_subclass = BLOCK_SELF;
131 }
132
133 void
sphere_copy(const sphere * o0,sphere * o)134 sphere_copy(const sphere * o0, sphere * o)
135 {
136 o->radius = o0->radius;
137 }
138
139 void
wedge_copy(const wedge * o0,wedge * o)140 wedge_copy(const wedge * o0, wedge * o)
141 {
142 o->wedge_angle = o0->wedge_angle;
143 o->wedge_start = o0->wedge_start;
144 o->e1 = o0->e1;
145 o->e2 = o0->e2;
146 }
147
148 void
cone_copy(const cone * o0,cone * o)149 cone_copy(const cone * o0, cone * o)
150 {
151 o->radius2 = o0->radius2;
152 }
153
154 void
cylinder_copy(const cylinder * o0,cylinder * o)155 cylinder_copy(const cylinder * o0, cylinder * o)
156 {
157 o->axis = o0->axis;
158 o->radius = o0->radius;
159 o->height = o0->height;
160 if (o0->which_subclass == WEDGE) {
161 o->which_subclass = WEDGE;
162 o->subclass.wedge_data = ((wedge *) malloc(sizeof(wedge)));
163 wedge_copy(o0->subclass.wedge_data, o->subclass.wedge_data);
164 } else if (o0->which_subclass == CONE) {
165 o->which_subclass = CONE;
166 o->subclass.cone_data = ((cone *) malloc(sizeof(cone)));
167 cone_copy(o0->subclass.cone_data, o->subclass.cone_data);
168 } else
169 o->which_subclass = CYLINDER_SELF;
170 }
171
172 void
compound_geometric_object_copy(const compound_geometric_object * o0,compound_geometric_object * o)173 compound_geometric_object_copy(const compound_geometric_object * o0, compound_geometric_object * o)
174 {
175 {
176 int i_t;
177 o->component_objects.num_items = o0->component_objects.num_items;
178 o->component_objects.items = ((geometric_object *) malloc(sizeof(geometric_object) * (o->component_objects.num_items)));
179 for (i_t = 0; i_t < o->component_objects.num_items; i_t++) {
180 geometric_object_copy(&o0->component_objects.items[i_t], &o->component_objects.items[i_t]);
181 }
182 }
183 }
184
185 void
geometric_object_copy(const geometric_object * o0,geometric_object * o)186 geometric_object_copy(const geometric_object * o0, geometric_object * o)
187 {
188 o->material = o0->material;
189 o->center = o0->center;
190 if (o0->which_subclass == PRISM) {
191 o->which_subclass = PRISM;
192 o->subclass.prism_data = ((prism *) malloc(sizeof(prism)));
193 prism_copy(o0->subclass.prism_data, o->subclass.prism_data);
194 } else if (o0->which_subclass == BLOCK) {
195 o->which_subclass = BLOCK;
196 o->subclass.block_data = ((block *) malloc(sizeof(block)));
197 block_copy(o0->subclass.block_data, o->subclass.block_data);
198 } else if (o0->which_subclass == SPHERE) {
199 o->which_subclass = SPHERE;
200 o->subclass.sphere_data = ((sphere *) malloc(sizeof(sphere)));
201 sphere_copy(o0->subclass.sphere_data, o->subclass.sphere_data);
202 } else if (o0->which_subclass == CYLINDER) {
203 o->which_subclass = CYLINDER;
204 o->subclass.cylinder_data = ((cylinder *) malloc(sizeof(cylinder)));
205 cylinder_copy(o0->subclass.cylinder_data, o->subclass.cylinder_data);
206 } else if (o0->which_subclass == COMPOUND_GEOMETRIC_OBJECT) {
207 o->which_subclass = COMPOUND_GEOMETRIC_OBJECT;
208 o->subclass.compound_geometric_object_data = ((compound_geometric_object *) malloc(sizeof(compound_geometric_object)));
209 compound_geometric_object_copy(o0->subclass.compound_geometric_object_data, o->subclass.compound_geometric_object_data);
210 } else
211 o->which_subclass = GEOMETRIC_OBJECT_SELF;
212 }
213
214 /******* class equal functions *******/
215
216 boolean
lattice_equal(const lattice * o0,const lattice * o)217 lattice_equal(const lattice * o0, const lattice * o)
218 {
219 if (!vector3_equal(o->basis1, o0->basis1))
220 return 0;
221 if (!vector3_equal(o->basis2, o0->basis2))
222 return 0;
223 if (!vector3_equal(o->basis3, o0->basis3))
224 return 0;
225 if (!vector3_equal(o->size, o0->size))
226 return 0;
227 if (!vector3_equal(o->basis_size, o0->basis_size))
228 return 0;
229 if (!vector3_equal(o->b1, o0->b1))
230 return 0;
231 if (!vector3_equal(o->b2, o0->b2))
232 return 0;
233 if (!vector3_equal(o->b3, o0->b3))
234 return 0;
235 if (!matrix3x3_equal(o->basis, o0->basis))
236 return 0;
237 if (!matrix3x3_equal(o->metric, o0->metric))
238 return 0;
239 ;
240 return 1;
241 }
242
243 boolean
ellipsoid_equal(const ellipsoid * o0,const ellipsoid * o)244 ellipsoid_equal(const ellipsoid * o0, const ellipsoid * o)
245 {
246 if (!vector3_equal(o->inverse_semi_axes, o0->inverse_semi_axes))
247 return 0;
248 ;
249 return 1;
250 }
251
252 boolean
prism_equal(const prism * o0,const prism * o)253 prism_equal(const prism * o0, const prism * o)
254 {
255 {
256 int i_t;
257 if (o->vertices.num_items != o0->vertices.num_items)
258 return 0;
259 for (i_t = 0; i_t < o->vertices.num_items; i_t++) {
260 if (!vector3_equal(o->vertices.items[i_t], o0->vertices.items[i_t]))
261 return 0;
262 }
263 }
264 if (o->height != o0->height)
265 return 0;
266 if (!vector3_equal(o->axis, o0->axis))
267 return 0;
268 if (o->sidewall_angle != o0->sidewall_angle)
269 return 0;
270 {
271 int i_t;
272 if (o->vertices_p.num_items != o0->vertices_p.num_items)
273 return 0;
274 for (i_t = 0; i_t < o->vertices_p.num_items; i_t++) {
275 if (!vector3_equal(o->vertices_p.items[i_t], o0->vertices_p.items[i_t]))
276 return 0;
277 }
278 }
279 {
280 int i_t;
281 if (o->top_polygon_diff_vectors_p.num_items != o0->top_polygon_diff_vectors_p.num_items)
282 return 0;
283 for (i_t = 0; i_t < o->top_polygon_diff_vectors_p.num_items; i_t++) {
284 if (!vector3_equal(o->top_polygon_diff_vectors_p.items[i_t], o0->top_polygon_diff_vectors_p.items[i_t]))
285 return 0;
286 }
287 }
288 {
289 int i_t;
290 if (o->top_polygon_diff_vectors_scaled_p.num_items != o0->top_polygon_diff_vectors_scaled_p.num_items)
291 return 0;
292 for (i_t = 0; i_t < o->top_polygon_diff_vectors_scaled_p.num_items; i_t++) {
293 if (!vector3_equal(o->top_polygon_diff_vectors_scaled_p.items[i_t], o0->top_polygon_diff_vectors_scaled_p.items[i_t]))
294 return 0;
295 }
296 }
297 {
298 int i_t;
299 if (o->vertices_top_p.num_items != o0->vertices_top_p.num_items)
300 return 0;
301 for (i_t = 0; i_t < o->vertices_top_p.num_items; i_t++) {
302 if (!vector3_equal(o->vertices_top_p.items[i_t], o0->vertices_top_p.items[i_t]))
303 return 0;
304 }
305 }
306 {
307 int i_t;
308 if (o->vertices_top.num_items != o0->vertices_top.num_items)
309 return 0;
310 for (i_t = 0; i_t < o->vertices_top.num_items; i_t++) {
311 if (!vector3_equal(o->vertices_top.items[i_t], o0->vertices_top.items[i_t]))
312 return 0;
313 }
314 }
315 if (!vector3_equal(o->centroid, o0->centroid))
316 return 0;
317 {
318 int i_t;
319 if (o->workspace.num_items != o0->workspace.num_items)
320 return 0;
321 for (i_t = 0; i_t < o->workspace.num_items; i_t++) {
322 if (o->workspace.items[i_t] != o0->workspace.items[i_t])
323 return 0;
324 }
325 }
326 if (!matrix3x3_equal(o->m_c2p, o0->m_c2p))
327 return 0;
328 if (!matrix3x3_equal(o->m_p2c, o0->m_p2c))
329 return 0;
330 ;
331 return 1;
332 }
333
334 boolean
block_equal(const block * o0,const block * o)335 block_equal(const block * o0, const block * o)
336 {
337 if (!vector3_equal(o->e1, o0->e1))
338 return 0;
339 if (!vector3_equal(o->e2, o0->e2))
340 return 0;
341 if (!vector3_equal(o->e3, o0->e3))
342 return 0;
343 if (!vector3_equal(o->size, o0->size))
344 return 0;
345 if (!matrix3x3_equal(o->projection_matrix, o0->projection_matrix))
346 return 0;
347 if (o0->which_subclass != o->which_subclass)
348 return 0;
349 if (o0->which_subclass == ELLIPSOID) {
350 if (!ellipsoid_equal(o0->subclass.ellipsoid_data, o->subclass.ellipsoid_data))
351 return 0;
352 } else;
353 return 1;
354 }
355
356 boolean
sphere_equal(const sphere * o0,const sphere * o)357 sphere_equal(const sphere * o0, const sphere * o)
358 {
359 if (o->radius != o0->radius)
360 return 0;
361 ;
362 return 1;
363 }
364
365 boolean
wedge_equal(const wedge * o0,const wedge * o)366 wedge_equal(const wedge * o0, const wedge * o)
367 {
368 if (o->wedge_angle != o0->wedge_angle)
369 return 0;
370 if (!vector3_equal(o->wedge_start, o0->wedge_start))
371 return 0;
372 if (!vector3_equal(o->e1, o0->e1))
373 return 0;
374 if (!vector3_equal(o->e2, o0->e2))
375 return 0;
376 ;
377 return 1;
378 }
379
380 boolean
cone_equal(const cone * o0,const cone * o)381 cone_equal(const cone * o0, const cone * o)
382 {
383 if (o->radius2 != o0->radius2)
384 return 0;
385 ;
386 return 1;
387 }
388
389 boolean
cylinder_equal(const cylinder * o0,const cylinder * o)390 cylinder_equal(const cylinder * o0, const cylinder * o)
391 {
392 if (!vector3_equal(o->axis, o0->axis))
393 return 0;
394 if (o->radius != o0->radius)
395 return 0;
396 if (o->height != o0->height)
397 return 0;
398 if (o0->which_subclass != o->which_subclass)
399 return 0;
400 if (o0->which_subclass == WEDGE) {
401 if (!wedge_equal(o0->subclass.wedge_data, o->subclass.wedge_data))
402 return 0;
403 } else if (o0->which_subclass == CONE) {
404 if (!cone_equal(o0->subclass.cone_data, o->subclass.cone_data))
405 return 0;
406 } else;
407 return 1;
408 }
409
410 boolean
compound_geometric_object_equal(const compound_geometric_object * o0,const compound_geometric_object * o)411 compound_geometric_object_equal(const compound_geometric_object * o0, const compound_geometric_object * o)
412 {
413 {
414 int i_t;
415 if (o->component_objects.num_items != o0->component_objects.num_items)
416 return 0;
417 for (i_t = 0; i_t < o->component_objects.num_items; i_t++) {
418 if (!geometric_object_equal(&o0->component_objects.items[i_t], &o->component_objects.items[i_t]))
419 return 0;
420 }
421 }
422 ;
423 return 1;
424 }
425
426 boolean
geometric_object_equal(const geometric_object * o0,const geometric_object * o)427 geometric_object_equal(const geometric_object * o0, const geometric_object * o)
428 {
429 if (o->material != o0->material)
430 return 0;
431 if (!vector3_equal(o->center, o0->center))
432 return 0;
433 if (o0->which_subclass != o->which_subclass)
434 return 0;
435 if (o0->which_subclass == PRISM) {
436 if (!prism_equal(o0->subclass.prism_data, o->subclass.prism_data))
437 return 0;
438 } else if (o0->which_subclass == BLOCK) {
439 if (!block_equal(o0->subclass.block_data, o->subclass.block_data))
440 return 0;
441 } else if (o0->which_subclass == SPHERE) {
442 if (!sphere_equal(o0->subclass.sphere_data, o->subclass.sphere_data))
443 return 0;
444 } else if (o0->which_subclass == CYLINDER) {
445 if (!cylinder_equal(o0->subclass.cylinder_data, o->subclass.cylinder_data))
446 return 0;
447 } else if (o0->which_subclass == COMPOUND_GEOMETRIC_OBJECT) {
448 if (!compound_geometric_object_equal(o0->subclass.compound_geometric_object_data, o->subclass.compound_geometric_object_data))
449 return 0;
450 } else;
451 return 1;
452 }
453
454 /******* class destruction functions *******/
455
456 void
lattice_destroy(lattice o)457 lattice_destroy(lattice o)
458 {
459 }
460
461 void
ellipsoid_destroy(ellipsoid o)462 ellipsoid_destroy(ellipsoid o)
463 {
464 }
465
466 void
prism_destroy(prism o)467 prism_destroy(prism o)
468 {
469 {
470 int index_t;
471 for (index_t = 0; index_t < o.vertices.num_items; index_t++) {
472 }
473 }
474 free(o.vertices.items);
475 {
476 int index_t;
477 for (index_t = 0; index_t < o.vertices_p.num_items; index_t++) {
478 }
479 }
480 free(o.vertices_p.items);
481 {
482 int index_t;
483 for (index_t = 0; index_t < o.top_polygon_diff_vectors_p.num_items; index_t++) {
484 }
485 }
486 free(o.top_polygon_diff_vectors_p.items);
487 {
488 int index_t;
489 for (index_t = 0; index_t < o.top_polygon_diff_vectors_scaled_p.num_items; index_t++) {
490 }
491 }
492 free(o.top_polygon_diff_vectors_scaled_p.items);
493 {
494 int index_t;
495 for (index_t = 0; index_t < o.vertices_top_p.num_items; index_t++) {
496 }
497 }
498 free(o.vertices_top_p.items);
499 {
500 int index_t;
501 for (index_t = 0; index_t < o.vertices_top.num_items; index_t++) {
502 }
503 }
504 free(o.vertices_top.items);
505 {
506 int index_t;
507 for (index_t = 0; index_t < o.workspace.num_items; index_t++) {
508 }
509 }
510 free(o.workspace.items);
511 }
512
513 void
block_destroy(block o)514 block_destroy(block o)
515 {
516 if (o.which_subclass == ELLIPSOID) {
517 ellipsoid_destroy(*o.subclass.ellipsoid_data);
518 free(o.subclass.ellipsoid_data);
519 } else {
520 }
521 }
522
523 void
sphere_destroy(sphere o)524 sphere_destroy(sphere o)
525 {
526 }
527
528 void
wedge_destroy(wedge o)529 wedge_destroy(wedge o)
530 {
531 }
532
533 void
cone_destroy(cone o)534 cone_destroy(cone o)
535 {
536 }
537
538 void
cylinder_destroy(cylinder o)539 cylinder_destroy(cylinder o)
540 {
541 if (o.which_subclass == WEDGE) {
542 wedge_destroy(*o.subclass.wedge_data);
543 free(o.subclass.wedge_data);
544 } else if (o.which_subclass == CONE) {
545 cone_destroy(*o.subclass.cone_data);
546 free(o.subclass.cone_data);
547 } else {
548 }
549 }
550
551 void
compound_geometric_object_destroy(compound_geometric_object o)552 compound_geometric_object_destroy(compound_geometric_object o)
553 {
554 {
555 int index_t;
556 for (index_t = 0; index_t < o.component_objects.num_items; index_t++) {
557 geometric_object_destroy(o.component_objects.items[index_t]);
558 }
559 }
560 free(o.component_objects.items);
561 }
562
563 void
geometric_object_destroy(geometric_object o)564 geometric_object_destroy(geometric_object o)
565 {
566 if (o.which_subclass == PRISM) {
567 prism_destroy(*o.subclass.prism_data);
568 free(o.subclass.prism_data);
569 } else if (o.which_subclass == BLOCK) {
570 block_destroy(*o.subclass.block_data);
571 free(o.subclass.block_data);
572 } else if (o.which_subclass == SPHERE) {
573 sphere_destroy(*o.subclass.sphere_data);
574 free(o.subclass.sphere_data);
575 } else if (o.which_subclass == CYLINDER) {
576 cylinder_destroy(*o.subclass.cylinder_data);
577 free(o.subclass.cylinder_data);
578 } else if (o.which_subclass == COMPOUND_GEOMETRIC_OBJECT) {
579 compound_geometric_object_destroy(*o.subclass.compound_geometric_object_data);
580 free(o.subclass.compound_geometric_object_data);
581 } else {
582 }
583 }
584