Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -19,7 +19,7 @@ class buffer {
|
||||
static ZReal ZREAL_HUGE() {return DBL_MAX;}
|
||||
|
||||
public:
|
||||
typedef unsigned int ZPixel;
|
||||
typedef unsigned int ZPixel;
|
||||
//NOTE : with X11, bits_per_pixel can't be > 32.
|
||||
protected:
|
||||
|
||||
@@ -27,7 +27,7 @@ protected:
|
||||
public:
|
||||
virtual void write(ZPos,ZPos,ZZ) = 0;
|
||||
public:
|
||||
writer(ZPixel a_pixel):m_pixel(a_pixel){}
|
||||
writer(ZPixel a_pixel):m_pixel(a_pixel){}
|
||||
virtual ~writer(){}
|
||||
public:
|
||||
writer(const writer& a_from):m_pixel(a_from.m_pixel){}
|
||||
@@ -114,19 +114,19 @@ protected:
|
||||
virtual void write(ZPos a_x,ZPos a_y,ZZ) {
|
||||
if((a_x<m_buffer.m_begX) || (a_x>m_buffer.m_endX)) return;
|
||||
if((a_y<m_buffer.m_begY) || (a_y>m_buffer.m_endY)) return;
|
||||
|
||||
|
||||
// Computing must be the same as in WriteScanLine routine.
|
||||
ZReal zpoint =
|
||||
(ZReal)(- m_buffer.m_planeDC
|
||||
(ZReal)(- m_buffer.m_planeDC
|
||||
- m_buffer.m_planeAC * a_x
|
||||
- m_buffer.m_planeBC * a_y);
|
||||
|
||||
|
||||
// for edge plane quite perpandicular to screen
|
||||
//if((zpoint<m_buffer.m_zmin)||(zpoint>m_buffer.m_zmax)) return;
|
||||
|
||||
|
||||
unsigned long offset = a_y * m_buffer.m_zbw + a_x;
|
||||
ZReal* zbuff = m_buffer.m_zbuffer + offset;
|
||||
|
||||
|
||||
if(m_buffer.m_depth_test) {if(zpoint<*zbuff) return;}
|
||||
|
||||
ZPixel* zimage = m_buffer.m_zimage + offset;
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
m_zbh = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Init buffer done by further call to ZBufferErase.
|
||||
/*
|
||||
unsigned int size = m_zbw * m_zbh;
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
*zbuffer = - ZREAL_HUGE();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
set_clip_region(0,0,m_zbw,m_zbh);
|
||||
m_polygon.clear();
|
||||
return true;
|
||||
@@ -467,7 +467,7 @@ protected:
|
||||
|
||||
if(a_beg>a_buffer.m_endX) return;
|
||||
if(a_end<a_buffer.m_begX) return;
|
||||
|
||||
|
||||
// border clip :
|
||||
int beg = mx(a_beg,(int)a_buffer.m_begX);
|
||||
int end = mn(a_end,(int)a_buffer.m_endX);
|
||||
@@ -479,14 +479,14 @@ protected:
|
||||
ZReal zpoint;
|
||||
for(int x=beg;x<=end;x++){
|
||||
// Computing must be the same as in edge_point_writer routine.
|
||||
zpoint =
|
||||
(ZReal)(- a_buffer.m_planeDC
|
||||
zpoint =
|
||||
(ZReal)(- a_buffer.m_planeDC
|
||||
- a_buffer.m_planeAC * x
|
||||
- a_buffer.m_planeBC * a_y);
|
||||
- a_buffer.m_planeBC * a_y);
|
||||
if(a_buffer.m_depth_test) {
|
||||
if((zpoint>=(*zbuff))
|
||||
// &&(zpoint>=a_buffer.m_zmin) //for plane quite perpandicular to screen.
|
||||
// &&(zpoint<=a_buffer.m_zmax)
|
||||
// &&(zpoint<=a_buffer.m_zmax)
|
||||
){
|
||||
*zbuff = zpoint;
|
||||
*zimage = a_buffer.m_scan_pixel;
|
||||
@@ -508,7 +508,7 @@ protected:
|
||||
ZZ dz = a_end.z - a_beg.z;
|
||||
|
||||
// 6 2
|
||||
// 5 1
|
||||
// 5 1
|
||||
// 7 3
|
||||
// 8 4
|
||||
scan_writer_1 sw1(a_writer);
|
||||
@@ -516,7 +516,7 @@ protected:
|
||||
scan_writer_3 sw3(a_writer);
|
||||
scan_writer_4 sw4(a_writer);
|
||||
|
||||
if( (dx==0) && (dy==0) ) {
|
||||
if( (dx==0) && (dy==0) ) {
|
||||
a_writer.write(a_beg.x,a_beg.y,a_beg.z);
|
||||
a_writer.write(a_end.x,a_end.y,a_end.z);
|
||||
|
||||
@@ -557,8 +557,8 @@ protected:
|
||||
|
||||
ZPos end = a_x + a_dx;
|
||||
ZPos beg = a_y;
|
||||
ZZ incz = a_dz/(ZZ)a_dx;
|
||||
if(a_dy==0) {
|
||||
ZZ incz = a_dz/(ZZ)a_dx;
|
||||
if(a_dy==0) {
|
||||
a_proc.write(a_x,a_y,a_z,beg);
|
||||
while(a_x<end){
|
||||
a_x++;
|
||||
|
||||
@@ -43,7 +43,7 @@ inline void InsertEdgeInET (
|
||||
*/
|
||||
pPrevSLL = &ET->scanlines;
|
||||
pSLL = pPrevSLL->next;
|
||||
while (pSLL && (pSLL->scanline < scanline))
|
||||
while (pSLL && (pSLL->scanline < scanline))
|
||||
{
|
||||
pPrevSLL = pSLL;
|
||||
pSLL = pSLL->next;
|
||||
@@ -52,9 +52,9 @@ inline void InsertEdgeInET (
|
||||
/*
|
||||
* reassign pSLL (pointer to ScanLineList) if necessary
|
||||
*/
|
||||
if ( (pSLL==NULL) || (pSLL->scanline > scanline))
|
||||
if ( (pSLL==NULL) || (pSLL->scanline > scanline))
|
||||
{
|
||||
if (*iSLLBlock > SLLSPERBLOCK-1)
|
||||
if (*iSLLBlock > SLLSPERBLOCK-1)
|
||||
{
|
||||
tmpSLLBlock = cmem_alloc<ScanLineListBlock>(1);
|
||||
(*SLLBlock)->next = tmpSLLBlock;
|
||||
@@ -75,7 +75,7 @@ inline void InsertEdgeInET (
|
||||
*/
|
||||
prev = (EdgeTableEntry *)NULL;
|
||||
start = pSLL->edgelist;
|
||||
while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
|
||||
while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
|
||||
{
|
||||
prev = start;
|
||||
start = start->next;
|
||||
@@ -102,7 +102,7 @@ inline void CreateETandAET (
|
||||
* CreateEdgeTable
|
||||
*
|
||||
* This routine creates the edge table for
|
||||
* scan converting polygons.
|
||||
* scan converting polygons.
|
||||
* The Edge Table (ET) looks like:
|
||||
*
|
||||
* EdgeTable
|
||||
@@ -155,19 +155,19 @@ inline void CreateETandAET (
|
||||
* In this loop we are dealing with two vertices at
|
||||
* a time -- these make up one edge of the polygon.
|
||||
*/
|
||||
while (count--)
|
||||
while (count--)
|
||||
{
|
||||
CurrPt = pts++;
|
||||
|
||||
/*
|
||||
* find out which point is above and which is below.
|
||||
*/
|
||||
if (PrevPt->y > CurrPt->y)
|
||||
if (PrevPt->y > CurrPt->y)
|
||||
{
|
||||
bottom = PrevPt, top = CurrPt;
|
||||
pETEs->ClockWise = 0;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
bottom = CurrPt, top = PrevPt;
|
||||
pETEs->ClockWise = 1;
|
||||
@@ -176,7 +176,7 @@ inline void CreateETandAET (
|
||||
/*
|
||||
* don't add horizontal edges to the Edge table.
|
||||
*/
|
||||
if (bottom->y != top->y)
|
||||
if (bottom->y != top->y)
|
||||
{
|
||||
pETEs->ymax = (int)(bottom->y-1); /* -1 so we don't get last scanline */
|
||||
|
||||
@@ -212,7 +212,7 @@ inline void LoadAET(EdgeTableEntry* AET,EdgeTableEntry* ETEs) {
|
||||
pPrevAET = AET;
|
||||
AET = AET->next;
|
||||
while(ETEs) {
|
||||
while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
|
||||
while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
|
||||
{
|
||||
pPrevAET = AET;
|
||||
AET = AET->next;
|
||||
@@ -235,13 +235,13 @@ inline void ComputeWAET(EdgeTableEntry* AET) {
|
||||
*
|
||||
* This routine links the AET by the
|
||||
* nextWETE (winding EdgeTableEntry) link for
|
||||
* use by the winding number rule. The final
|
||||
* use by the winding number rule. The final
|
||||
* Active Edge Table (AET) might look something
|
||||
* like:
|
||||
*
|
||||
* AET
|
||||
* ---------- --------- ---------
|
||||
* |ymax | |ymax | |ymax |
|
||||
* |ymax | |ymax | |ymax |
|
||||
* | ... | |... | |... |
|
||||
* |next |->|next |->|next |->...
|
||||
* |nextWETE| |nextWETE| |nextWETE|
|
||||
@@ -264,7 +264,7 @@ inline void ComputeWAET(EdgeTableEntry* AET) {
|
||||
isInside--;
|
||||
|
||||
if (( (inside==0) && (isInside==0) ) ||
|
||||
( (inside!=0) && (isInside!=0) ))
|
||||
( (inside!=0) && (isInside!=0) ))
|
||||
{
|
||||
pWETE->nextWETE = AET;
|
||||
pWETE = AET;
|
||||
@@ -294,7 +294,7 @@ inline int InsertAndSort(EdgeTableEntry* AET) {
|
||||
pETEchase = pETEchase->back;
|
||||
|
||||
AET = AET->next;
|
||||
if (pETEchase != pETEinsert)
|
||||
if (pETEchase != pETEinsert)
|
||||
{
|
||||
pETEchaseBackTMP = pETEchase->back;
|
||||
pETEinsert->back->next = AET;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#ifndef tools_zb_line
|
||||
#define tools_zb_line
|
||||
|
||||
|
||||
/* from X/poly.h */
|
||||
|
||||
/*
|
||||
@@ -140,7 +140,7 @@ typedef struct {
|
||||
* the polygon by incrementing the y coordinate. We
|
||||
* keep a list of edges which the current scanline crosses,
|
||||
* sorted by x. This list is called the Active Edge Table (AET)
|
||||
* As we change the y-coordinate, we update each entry in
|
||||
* As we change the y-coordinate, we update each entry in
|
||||
* in the active edge table to reflect the edges new xcoord.
|
||||
* This list must be sorted at each scanline in case
|
||||
* two edges intersect.
|
||||
@@ -167,7 +167,7 @@ typedef struct {
|
||||
* for the winding number rule
|
||||
*/
|
||||
//#define CLOCKWISE 1
|
||||
//#define COUNTERCLOCKWISE -1
|
||||
//#define COUNTERCLOCKWISE -1
|
||||
|
||||
typedef struct _EdgeTableEntry {
|
||||
int ymax; /* ycoord at which we exit this edge. */
|
||||
@@ -256,6 +256,6 @@ typedef struct _ScanLineListBlock {
|
||||
pAET = pAET->next; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#ifndef tools_zb_point
|
||||
#define tools_zb_point
|
||||
|
||||
|
||||
namespace tools {
|
||||
namespace zb {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
POINTBLOCK* curPtBlock;
|
||||
cmem_free(m_pETEs);
|
||||
m_pETEn = 0;
|
||||
for(curPtBlock = m_FirstPtBlock.next; --m_numAllocPtBlocks >= 0;){
|
||||
for(curPtBlock = m_FirstPtBlock.next; --m_numAllocPtBlocks >= 0;){
|
||||
POINTBLOCK* tmpPtBlock;
|
||||
tmpPtBlock = curPtBlock->next;
|
||||
cmem_free(curPtBlock);
|
||||
@@ -82,14 +82,14 @@ public:
|
||||
((pts[0].x == pts[1].x) &&
|
||||
(pts[1].y == pts[2].y) &&
|
||||
(pts[2].x == pts[3].x) &&
|
||||
(pts[3].y == pts[0].y))))
|
||||
(pts[3].y == pts[0].y))))
|
||||
{
|
||||
int xmin,xmax,ymin,ymax;
|
||||
xmin = (int)mn(pts[0].x, pts[2].x);
|
||||
ymin = (int)mn(pts[0].y, pts[2].y);
|
||||
xmax = (int)mx(pts[0].x, pts[2].x);
|
||||
ymax = (int)mx(pts[0].y, pts[2].y);
|
||||
if ((xmin != xmax) && (ymin != ymax))
|
||||
if ((xmin != xmax) && (ymin != ymax))
|
||||
{
|
||||
for(y=ymin;y<=ymax;y++) a_proc(a_tag,xmin ,xmax ,y);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
cmem_free(m_pETEs);
|
||||
m_pETEn = Count;
|
||||
m_pETEs = cmem_alloc<EdgeTableEntry>(m_pETEn);
|
||||
if(m_pETEs==NULL)
|
||||
if(m_pETEs==NULL)
|
||||
{
|
||||
m_pETEn = 0;
|
||||
return;
|
||||
@@ -114,9 +114,9 @@ public:
|
||||
|
||||
curPtBlock = &m_FirstPtBlock;
|
||||
pts = m_FirstPtBlock.pts;
|
||||
|
||||
|
||||
if (rule==0)
|
||||
|
||||
if (rule==0)
|
||||
{
|
||||
/*
|
||||
* for each scanline
|
||||
@@ -126,14 +126,14 @@ public:
|
||||
* Add a new edge to the active edge table when we
|
||||
* get to the next edge.
|
||||
*/
|
||||
if (pSLL != NULL && y == pSLL->scanline)
|
||||
if (pSLL != NULL && y == pSLL->scanline)
|
||||
{
|
||||
LoadAET(&AET, pSLL->edgelist);
|
||||
pSLL = pSLL->next;
|
||||
}
|
||||
pPrevAET = &AET;
|
||||
pAET = AET.next;
|
||||
|
||||
|
||||
/*
|
||||
* for each active edge
|
||||
*/
|
||||
@@ -142,12 +142,12 @@ public:
|
||||
pts->y = y;
|
||||
pts++;
|
||||
iPts++;
|
||||
|
||||
|
||||
/*
|
||||
* send out the buffer
|
||||
*/
|
||||
if (iPts == NUMPTSTOBUFFER)
|
||||
{
|
||||
if (iPts == NUMPTSTOBUFFER)
|
||||
{
|
||||
if(numFullPtBlocks < m_numAllocPtBlocks)
|
||||
{
|
||||
curPtBlock = curPtBlock->next;
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
else
|
||||
{
|
||||
POINTBLOCK* tmpPtBlock = cmem_alloc<POINTBLOCK>(1);
|
||||
if(tmpPtBlock==NULL)
|
||||
if(tmpPtBlock==NULL)
|
||||
{
|
||||
FreeStorage(SLLBlock.next);
|
||||
return;
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
(void) InsertAndSort(&AET);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/*
|
||||
* for each scanline
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
* Add a new edge to the active edge table when we
|
||||
* get to the next edge.
|
||||
*/
|
||||
if (pSLL != NULL && y == pSLL->scanline)
|
||||
if (pSLL != NULL && y == pSLL->scanline)
|
||||
{
|
||||
LoadAET(&AET, pSLL->edgelist);
|
||||
ComputeWAET(&AET);
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
pPrevAET = &AET;
|
||||
pAET = AET.next;
|
||||
pWETE = pAET;
|
||||
|
||||
|
||||
/*
|
||||
* for each active edge
|
||||
*/
|
||||
@@ -208,12 +208,12 @@ public:
|
||||
pts->y = y;
|
||||
pts++;
|
||||
iPts++;
|
||||
|
||||
|
||||
/*
|
||||
* send out the buffer
|
||||
*/
|
||||
if (iPts == NUMPTSTOBUFFER)
|
||||
{
|
||||
if (iPts == NUMPTSTOBUFFER)
|
||||
{
|
||||
if(numFullPtBlocks < m_numAllocPtBlocks)
|
||||
{
|
||||
curPtBlock = curPtBlock->next;
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
else
|
||||
{
|
||||
POINTBLOCK* tmpPtBlock = cmem_alloc<POINTBLOCK>(1);
|
||||
if(tmpPtBlock==NULL)
|
||||
if(tmpPtBlock==NULL)
|
||||
{
|
||||
FreeStorage(SLLBlock.next);
|
||||
return;
|
||||
@@ -239,19 +239,19 @@ public:
|
||||
}
|
||||
EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* recompute the winding active edge table if
|
||||
* we just resorted or have exited an edge.
|
||||
*/
|
||||
if ( (InsertAndSort(&AET)!=0) || (fixWAET!=0) )
|
||||
if ( (InsertAndSort(&AET)!=0) || (fixWAET!=0) )
|
||||
{
|
||||
ComputeWAET(&AET);
|
||||
fixWAET = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeStorage (SLLBlock.next);
|
||||
FreeStorage (SLLBlock.next);
|
||||
|
||||
ScanPoints (numFullPtBlocks, iPts, &m_FirstPtBlock,a_proc,a_tag);
|
||||
|
||||
@@ -265,11 +265,11 @@ protected:
|
||||
POINTBLOCK* CurPtBlock;
|
||||
int i;
|
||||
CurPtBlock = FirstPtBlock;
|
||||
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--)
|
||||
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--)
|
||||
{
|
||||
/* the loop uses 2 points per iteration */
|
||||
i = numFullPtBlocks!=0 ? NUMPTSTOBUFFER >> 1 : iCurPtBlock >> 1 ;
|
||||
for (pts = CurPtBlock->pts; i--; pts += 2)
|
||||
for (pts = CurPtBlock->pts; i--; pts += 2)
|
||||
{
|
||||
a_proc (a_tag,(int)(pts->x),(int)pts[1].x,(int)pts->y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user