+#include <errno.h>
+#include <ir.h>
+
+#define CURR_OBI (OB[obi])
+#define CURR_VBI (VB[vbi])
+#define CURR_CBI (CB[cbi])
+#define IS_SUBCLASS() (CB[cbi].num_subclasses)
+
+//TODO: label and vdat_id
+void
+insert_set()
+{
+ if(IS_SUBCLASS()) //if set is set of subclass
+ OB[obi].class_id = CB[cbi].subclass_list[subclass_index].label; //TODO: specify subclass other than label?
+ else
+ OB[obi].class_id = CB[cbi].label;
+
+ CB[cbi].set_list[set_index].odat_id = obi;
+ CB[cbi].set_list[set_index].parent_id = OB[obi].class_id;
+ //TODO: add ele_stack is created in element_list
+ //TODO: add odat
+
+}
+
+#define CURR_QUAD (OB[obi].ref_list[ref_index])
+void
+insert_ref(int x, int y, int z, int ref)
+{
+ CURR_QUAD.x = x;
+ CURR_QUAD.y = y;
+ CURR_QUAD.z = z;
+ CURR_QUAD.ref = ref;
+}
+
+
+//Insert element into OB and CB
+void
+insert_ele(char* label, int vdat_id)
+{
+
+
+ OB[obi].label = label;
+ OB[obi].vdat_id = vdat_id;
+ //TODO: check set_obi to see if set_map_data exists
+ OB[obi].num_ref = OB[set_obi].num_ref;
+ OB[obi].ref_list = OB[set_obi].ref_list;
+ OB[obi].class_id = cbi;
+
+ if(IS_SUBCLASS())
+ {
+ CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].odat_id = obi;
+ CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].subclass_list[subclass_index].set_index;
+ }
+ else
+ {
+ CB[cbi].set_list[set_index].ele_list[ele_index].odat_id = obi;
+ CB[cbi].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].set_index;
+ }
+
+ obi++;
+}
+
+
+/* fd could be a directory entry */
+int
+insert_fdat(char* label, char direction, int fd)
+{
+ VB[vbi].model_list[VB[vbi].len].label = label;
+ VB[vbi].model_list[VB[vbi].len].fdat_id[(int)direction] = fd;
+}
+
+void
+condense()
+{
+ FILE* vp, op, cp;
+ int v, m;
+ int num_models;
+
+ vp = fopen("vdat_output", w+);
+ if(!vp)
+ perror("vdat_output failed to open\n");
+
+ op = fopen("odat_output", w+);
+ if(!op)
+ perror("odat_output failed to open\n");
+
+ cp = fopen("cdat_output", w+);
+ if(!cp)
+ perror("cdat_output failed to open\n");
+
+
+
+ /* fwrite vdat */
+ for(v = 0; v <= vbi; v++)
+ {
+ num_models = VB[v].num_models; //data duplication for caching
+ for(m = 0; m <= num_models; m++)
+ {
+
+ }
+ }
+
+ /* fwrite odat */
+ /* Convert ref_list to actual offset */
+
+ /* fwrite cdat */
+
+
+}
+