//deal with face that must be clipped bool must_clip_flat_face(int nv,g3s_codes cc) { int i; bool ret=0; g3s_point **bufptr; bufptr = clip_polygon(Vbuf0,Vbuf1,&nv,&cc); if (nv>0 && !(cc.uor&CC_BEHIND) && !cc.uand) { for (i=0;i<nv;i++) { g3s_point *p = bufptr[i]; if (!(p->p3_flags&PF_PROJECTED)) g3_project_point(p); if (p->p3_flags&PF_OVERFLOW) { ret = 1; goto free_points; } Vertex_list[i*2] = p->p3_sx; Vertex_list[i*2+1] = p->p3_sy; } (*flat_drawer_ptr)(nv,(int *)Vertex_list); } else ret=1; //free temp points free_points: ; for (i=0;i<nv;i++) if (Vbuf1[i]->p3_flags & PF_TEMP_POINT) free_temp_point(Vbuf1[i]); // Assert(free_point_num==0); return ret; }
//------------------------------------------------------------------------------ //deal with face that must be clipped bool MustClipFlatFace (int nv, g3sCodes cc) { int i; bool ret=0; g3sPoint **bufptr; bufptr = clip_polygon (Vbuf0, Vbuf1, &nv, &cc); if (nv>0 && ! (cc.or&CC_BEHIND) && !cc.and) { for (i=0;i<nv;i++) { g3sPoint *p = bufptr[i]; if (! (p->p3_flags & PF_PROJECTED)) G3ProjectPoint (p); if (p->p3_flags & PF_OVERFLOW) { ret = 1; goto free_points; } polyVertList[i*2] = p->p3_screen.x; polyVertList[i*2+1] = p->p3_screen.y; } (*flat_drawer_ptr) (nv, (int *)polyVertList); } else ret=1; //D2_FREE temp points free_points: ; for (i=0;i<nv;i++) if (Vbuf1[i]->p3_flags & PF_TEMP_POINT) free_temp_point (Vbuf1[i]); // Assert (free_point_num==0); return ret; }
void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out) { struct tile_data tile_data; int i; bbox((struct coord *)(ib+1), ib->clen/2, &tile_data.item_bbox); tile_data.buffer[0]='\0'; tile_data.tile_depth=tile(&tile_data.item_bbox, NULL, tile_data.buffer, param->max, param->overlap, &tile_data.tile_bbox); if (tile_data.tile_depth == param->max || tile_data.tile_depth >= param->min) { item_bin_write_to_sink(ib, out, &tile_data); return; } for (i = 0 ; i < 4 ; i++) { struct rect clip_rect; tile_data.buffer[tile_data.tile_depth]='a'+i; tile_data.buffer[tile_data.tile_depth+1]='\0'; tile_bbox(tile_data.buffer, &clip_rect, param->overlap); if (ib->type < type_area) clip_line(ib, &clip_rect, param, out); else clip_polygon(ib, &clip_rect, param, out); } }
bool must_clip_tmap_face(int nv,g3s_codes cc,grs_bitmap *bm) { g3s_point **bufptr; int i; bufptr = clip_polygon(Vbuf0,Vbuf1,&nv,&cc); if (nv && !(cc.uor&CC_BEHIND) && !cc.uand) { for (i=0;i<nv;i++) { g3s_point *p = bufptr[i]; if (!(p->p3_flags&PF_PROJECTED)) g3_project_point(p); if (p->p3_flags&PF_OVERFLOW) { Int3(); //should not overflow after clip goto free_points; } } (*tmap_drawer_ptr)(bm,nv,bufptr); } free_points: ; for (i=0;i<nv;i++) if (bufptr[i]->p3_flags & PF_TEMP_POINT) free_temp_point(bufptr[i]); // Assert(free_point_num==0); return 0; }