@@ -214,19 +214,24 @@ volume GDSII_vol(const char *fname, int layer, double zmin, double zmax) {
214214 return meep_geom::get_GDSII_volume (fname, layer, zmin, zmax);
215215}
216216
217- ctlio::simple_prism_list get_GDSII_prisms (const char *GDSIIFile, int Layer, double zmin, double zmax) {
217+ /* We have to jump through some hoops here because the geometric_object data type used
218+ in meepgeom (from libctlgeom) is different from the generated ctlio::geometric_object.
219+ So we take the list of prisms from meep_geom::get_GDSII_prisms and return a simple
220+ Scheme list of triples (vertices height axis). meep.scm then defines a higher-level
221+ function get-GDSII-prisms that constructs the actual prism objects again */
222+ SCM get_GDSII_prism_data (const char *GDSIIFile, int Layer, double zmin, double zmax) {
218223 geometric_object_list go = meep_geom::get_GDSII_prisms (NULL , GDSIIFile, Layer, zmin, zmax);
219- ctlio::simple_prism_list res;
220- res.num_items = go.num_items ;
221- res.items = new ctlio::simple_prism[res.num_items ];
222- for (int i = 0 ; i < res.num_items ; ++i) {
224+ SCM res = SCM_EOL;
225+ for (int i = go.num_items - 1 ; i >= 0 ; --i) {
223226 prism *p = go.items [i].subclass .prism_data ;
224- res.items [i].vertices .num_items = p->vertices .num_items ;
225- res.items [i].vertices .items = p->vertices .items ;
226- res.items [i].height = p->height ;
227- res.items [i].axis = p->axis ;
227+ res = scm_cons (scm_list_3 (ctl_convert_list_to_scm (make_vector3_list (p->vertices .num_items , p->vertices .items )),
228+ ctl_convert_number_to_scm (p->height ),
229+ ctl_convert_vector3_to_scm (p->axis )),
230+ res);
231+ free (p->vertices .items );
232+ // fixme: free the rest of the prism data
228233 free (p);
229234 }
230235 delete[] go.items ;
231236 return res;
232- }
237+ }
0 commit comments