Object elk_csg_attach(Object left_obj, Object right_obj, Object op_obj) { Object res_obj; CSGTreeRoot *root; CSGOperation op; CSGNodePtr left_child; CSGNodePtr right_child; /* Check that the window exists. */ if ( ! csg_window.shell ) return Void; Check_Type(left_obj, CSGNODE_TYPE); Check_Type(right_obj, CSGNODE_TYPE); Check_Type(op_obj, T_Symbol); if ( EQ(op_obj, Sym_Union) ) op = csg_union_op; else if ( EQ(op_obj, Sym_Intersection) ) op = csg_intersection_op; else if ( EQ(op_obj, Sym_Difference) ) op = csg_difference_op; else Primitive_Error("Invalid CSG Operation: ~s", op_obj); left_child = ELKCSGNODE(left_obj)->csg_node; right_child = ELKCSGNODE(right_obj)->csg_node; if ( ! left_child || ! right_child ) return Void; /* Just check that the left child is a root node. */ root = elk_csg_get_root_node(left_child); if ( ! root ) return Void; /* Right is the root we actually want. */ root = elk_csg_get_root_node(right_child); if ( ! root ) return Void; Delete_Displayed_Tree(root->tree); /* Do the attach. */ right_child->csg_parent = NULL; CSG_Add_Node(right_child, left_child, op, NULL, 0); XawTreeForceLayout(csg_tree_widget); changed_scene = TRUE; res_obj = Alloc_Object(sizeof(Elkcsgnode), CSGNODE_TYPE, 0); ELKCSGNODE(res_obj)->csg_node = left_child->csg_parent; return res_obj; }
Object P_Delay (Object argl) { Object d; GC_Node; GC_Link (argl); d = Alloc_Object (sizeof (struct S_Promise), T_Promise, 0); GC_Unlink; PROMISE(d)->done = 0; PROMISE(d)->env = The_Environment; PROMISE(d)->thunk = Car (argl); return d; }
static Object Internal_Make_Cursor (int finalize, Display *dpy, Cursor cursor) { Object c; if (cursor == None) return Sym_None; c = Find_Object (T_Cursor, (GENERIC)dpy, Match_X_Obj, cursor); if (Nullp (c)) { c = Alloc_Object (sizeof (struct S_Cursor), T_Cursor, 0); CURSOR(c)->tag = Null; CURSOR(c)->cursor = cursor; CURSOR(c)->dpy = dpy; CURSOR(c)->free = 0; Register_Object (c, (GENERIC)dpy, finalize ? P_Free_Cursor : (PFO)0, 0); } return c; }
static Object Internal_Make_Pixmap (int finalize, Display *dpy, Pixmap pix) { Object pm; if (pix == None) return Sym_None; pm = Find_Object (T_Pixmap, (GENERIC)dpy, Match_X_Obj, pix); if (Nullp (pm)) { pm = Alloc_Object (sizeof (struct S_Pixmap), T_Pixmap, 0); PIXMAP(pm)->tag = Null; PIXMAP(pm)->pm = pix; PIXMAP(pm)->dpy = dpy; PIXMAP(pm)->free = 0; Register_Object (pm, (GENERIC)dpy, finalize ? P_Free_Pixmap : (PFO)0, 0); } return pm; }
Object Make_Window (int finalize, Display *dpy, Window win) { Object w; if (win == None) return Sym_None; if (win == PointerRoot) return Intern ("pointer-root"); w = Find_Object (T_Window, (GENERIC)dpy, Match_X_Obj, win); if (Nullp (w)) { w = Alloc_Object (sizeof (struct S_Window), T_Window, 0); WINDOW(w)->tag = Null; WINDOW(w)->win = win; WINDOW(w)->dpy = dpy; WINDOW(w)->free = 0; WINDOW(w)->finalize = finalize; Register_Object (w, (GENERIC)dpy, finalize ? P_Destroy_Window : (PFO)0, 0); } return w; }
/********************************************************************* * * elk_csg_node() finds the csg node associated with a given instance. * * Parameter: obj - the instance to search for. * * Return: An object containing the csg node. * Void if the node is not present. * *********************************************************************/ Object elk_csg_node(Object obj) { Object res_obj; CSGNodePtr result; /* Check that the window exists. */ if ( ! csg_window.shell ) return Void; Check_Type(obj, OBJECT3_TYPE); /* Look for a solution. */ if ( ! ( result = Find_Instance_In_Displayed((ObjectInstancePtr)ELKOBJECT3(obj)->object3))) return Void; res_obj = Alloc_Object(sizeof(Elkcsgnode), CSGNODE_TYPE, 0); ELKCSGNODE(res_obj)->csg_node = result; return res_obj; }