Go to the documentation of this file.
4 #ifndef tools_zb_buffer
5 #define tools_zb_buffer
19 static ZReal ZREAL_HUGE() {
return DBL_MAX;}
90 ZReal zpoint = (ZReal)a_z;
188 if(!a_width||!a_height)
return false;
232 unsigned int& a_height)
const {
243 for(col=
m_begX;col<=
m_endX;col++,zimage++) *zimage = a_pixel;
255 *zbuff = - ZREAL_HUGE();
277 m_endX = a_x + a_width - 1;
278 m_endY = a_y + a_height - 1;
303 for(
int count=1;count<a_number;count++) {
304 WriteLine(a_list[count-1],a_list[count],pw);
310 int segment_number = a_number/2;
311 for(
int count=0;count<segment_number;count++) {
312 WriteLine(a_list[2*count],a_list[2*count+1],pw);
317 for(
int count=0;count<a_number;count++){
318 const point& p = a_list[count];
328 if(a_number<3)
return;
465 if((a_y<a_buffer.
m_begY) || (a_y>a_buffer.
m_endY))
return;
466 if(a_end<=a_beg)
return;
468 if(a_beg>a_buffer.
m_endX)
return;
469 if(a_end<a_buffer.
m_begX)
return;
472 int beg =
mx(a_beg,(
int)a_buffer.
m_begX);
475 unsigned long offset = a_y * a_buffer.
m_zbw + beg;
476 ZReal* zbuff = a_buffer.
m_zbuffer + offset;
480 for(
int x=beg;x<=
end;x++){
487 if((zpoint>=(*zbuff))
506 ZPos dx = a_end.
x - a_beg.
x;
507 ZPos dy = a_end.
y - a_beg.
y;
508 ZZ dz = a_end.
z - a_beg.
z;
519 if( (dx==0) && (dy==0) ) {
520 a_writer.
write(a_beg.
x,a_beg.
y,a_beg.
z);
521 a_writer.
write(a_end.
x,a_end.
y,a_end.
z);
525 ScanLine ( a_beg.
y, a_beg.
x,a_beg.
z, dy, dx, dz,sw2);
527 ScanLine ( a_end.
y, a_end.
x,a_end.
z,-dy, dx,-dz,sw2);
530 if((0<=dy) && (dy<=dx))
531 ScanLine ( a_beg.
x, a_beg.
y,a_beg.
z, dx, dy, dz,sw1);
533 ScanLine ( a_beg.
y, a_beg.
x,a_beg.
z, dy, dx, dz,sw2);
534 else if((-dx<=dy) && (dy<0) )
535 ScanLine ( a_beg.
x, a_beg.
y,a_beg.
z, dx,-dy, dz,sw3);
537 ScanLine ( a_end.
y, a_end.
x,a_end.
z,-dy, dx,-dz,sw4);
540 if((0<=dy) && (dy<=-dx))
541 ScanLine ( a_end.
x, a_end.
y,a_end.
z,-dx, dy,-dz,sw3);
543 ScanLine ( a_beg.
y, a_beg.
x,a_beg.
z, dy,-dx, dz,sw4);
544 else if((dx<=dy) && (dy<0) )
545 ScanLine ( a_end.
x, a_end.
y,a_end.
z,-dx,-dy,-dz,sw1);
547 ScanLine ( a_end.
y, a_end.
x,a_end.
z,-dy,-dx,-dz,sw2);
560 ZZ incz = a_dz/(
ZZ)a_dx;
562 a_proc.
write(a_x,a_y,a_z,beg);
566 a_proc.
write(a_x,a_y,a_z,beg);
568 }
else if(a_dy==a_dx) {
569 a_proc.
write(a_x,a_y,a_z,beg);
574 a_proc.
write(a_x,a_y,a_z,beg);
577 ZPos d = 2 * a_dy - a_dx;
578 ZPos incrE = 2 * a_dy;
579 ZPos incrNE = 2 * ( a_dy - a_dx);
580 a_proc.
write(a_x,a_y,a_z,beg);
591 a_proc.
write(a_x,a_y,a_z,beg);