void render_list_of_attributes(leaflist_t attrlist, text_t result) { int upper = attrlist->buffersize; for(int c = 0; c < upper; ++c) { if(attrlist->list[c] != NULL) { text_add_text(result, constant_str_space); render_leaf(attrlist->list[c],result); } } }
//kd-tree rendern void gx_kdtree::render() { glPointSize(2.0f); if(leaf) { render_leaf(); return; } if(!leaf && children) { children[0].render(); children[1].render(); } }
void clip_leaf (struct msscene *ms, struct surface *current_surface, double fine_pixel, struct leaf *lf) { int j, k, n, nx, nw, i, used0, used1, nused; double t, xsmin, sangle; double base[3], xpnts[2][3], vect[3]; double clip_center[3], clip_axis[3]; struct circle *cir; struct arc *al; struct leaf *lfcut; struct lax *xsptr, *xsend, *xsp; struct lax laxes[MAX_LAX]; /* count double number of clipping planes */ n = 0; if (ms -> clipping) n += 2; if (n <= 0 || !(current_surface -> clipping)) { lf -> clip_ep = 0; render_leaf (ms, current_surface, fine_pixel, lf); return; } /* determine accessibility of endpoints of leaf */ for (j = 0; j < 2; j++) lf -> when[j] = !(current_surface -> clipping && clipped (ms, lf -> ends[j])); /* create arc for leaf */ al = leaf_to_arc (lf); cir = lf -> cir; for (k = 0; k < 3; k++) base[k] = lf -> ends[0][k] - cir -> center[k]; normalize (base); /* determine intersection points between leaf and clipping planes */ xsptr = &(laxes[0]); if (ms -> clipping) { for (k = 0; k < 3; k++) { clip_center[k] = ms -> clip_center[k]; clip_axis[k] = ms -> clip_axis[k]; } /* call arc-plane intersection function */ nx = arc_plane (al, clip_center, clip_axis, xpnts); if (nx < 0) return; /* if (nx == 0) continue; no intersections */ /* fill data into list */ /* figure out enter or exit */ for (i = 0; i < nx; i++) { if (xsptr - &(laxes[0]) >= n) { ms -> n_missing_leaves++; return; } for (k = 0; k < 3; k++) xsptr -> co[k] = xpnts[i][k]; for (k = 0; k < 3; k++) vect[k] = xsptr -> co[k] - al -> cir -> center[k]; t = triple_product (al -> cir -> axis, clip_axis, vect); xsptr -> ent = (t > 0); /* or reverse? */ xsptr -> used = 0; xsptr++; } } xsend = xsptr; /* mark end of list of intersection points */ nx = xsend - &(laxes[0]); /* compute number of intersection points */ /* error checking */ if ((lf -> when[0] == lf -> when[1]) == (nx % 2)) { /* parity check fails, flag leaf to check clipping of every pixel of leaf */ ms -> n_clip_parity++; lf -> clip_ep = 1; render_leaf (ms, current_surface, fine_pixel, lf); if (error()) return; lf -> clip_ep = 0; frearc (al); return; } /* check for no intersection points */ if (nx == 0) { if (lf -> when[0] == CLIPPED) { /* entire leaf clipped: nothing to render */ /* free temporary memory */ frearc (al); return; } /* entire leaf unclipped: render entire leaf */ render_leaf (ms, current_surface, fine_pixel, lf); if (error()) return; /* free temporary memory */ frearc (al); return; } /* calculate angles for transitions between unclipped and clipped */ for (xsptr = &(laxes[0]); xsptr < xsend; xsptr++) { for (k = 0; k < 3; k++) vect[k] = xsptr -> co[k] - cir -> center[k]; normalize (vect); xsptr -> angle = positive_angle (base, vect, cir -> axis); } /* initialization */ used0 = 0; used1 = 0; nused = 0; nw = 0; /* count number of unclipped endpoints of originial leaf */ for (j = 0; j < 2; j++) if (lf -> when[j]) nw++; /* create new leaves */ while (nused < nx + nw) { /* get starting point */ if (!used0 && lf -> when[0] == UNCLIPPED) { /* start at original endpoint */ used0 = 1; /* first originial endpoint used */ nused++; /* increment number used */ lfcut = duplicate_leaf (lf); /* duplicate leaf */ sangle = 0.0; /* starting angle */ } else { /* look for unused cut vertex */ xsmin = 4 * PI; xsp = NULL; for (xsptr = &(laxes[0]); xsptr < xsend; xsptr++) { if (xsptr -> used) continue; if (xsptr -> angle < xsmin) { xsmin = xsptr -> angle; xsp = xsptr; } } if (xsp == NULL) { if (lf -> when[1] == CLIPPED) break; ms -> n_missing_leaves++; return; } if (!xsp -> ent) { ms -> n_missing_leaves++; return; } xsp -> used = 1; /* mark as used */ nused++; /* increment number used */ sangle = xsp -> angle; /* starting angle */ lfcut = duplicate_leaf (lf); /* duplicate leaf */ for (k = 0; k < 3; k++) lfcut -> ends[0][k] = xsp -> co[k]; } /* get ending point */ /* initialization */ xsmin = 4 * PI; xsp = NULL; for (xsptr = &(laxes[0]); xsptr < xsend; xsptr++) { if (xsptr -> used) continue; /* already used */ if (xsptr -> angle < sangle) continue; /* end after start */ if (xsptr -> angle < xsmin) { /* best so far, save */ xsmin = xsptr -> angle; xsp = xsptr; } } if (xsp == NULL) { if (used1 || lf -> when[1] == CLIPPED) { ms -> n_missing_leaves++; return; } /* use East */ used1 = 1; /* mark East original endpoint used */ nused++; /* increment number used */ for (k = 0; k < 3; k++) lfcut -> ends[1][k] = lf -> ends[1][k]; } else { /* use cut point */ for (k = 0; k < 3; k++) lfcut -> ends[1][k] = xsp -> co[k]; xsp -> used = 1; /* mark as used */ nused++; /* increment number used */ } /* we have a cut leaf */ /* clip and render leaf */ render_leaf (ms, current_surface, fine_pixel, lfcut); if (error()) return; free_leaf (lfcut); /* free temporary memory */ } /* free temporary memory */ frearc (al); return; }