Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

canvas3d.h

Go to the documentation of this file.
00001 
00010 #ifndef CANVAS3D_H
00011 #define CANVAS3D_H
00012 
00013 #include "haconst.h"
00014 
00015 // These values set the sizes of the sphere rendering
00016 // tables. The first value, maxrad, is the maximum
00017 // sphere radius and the second value is the table
00018 // size = (maxrad*(maxrad+1))/2 + 1
00019 //
00020 
00021 
00022 // #define MAXRAD    120   256   
00023 // #define MAXTABLE  7261  32897 
00024 
00025 typedef uint_4 Pixel_RS;
00026 
00027 //#if defined(SIXTEENBIT)
00028 //   typedef unsigned short Pixel_RS;
00029 
00030    
00031 
00032 
00033 #define MAXRAD    255
00034 #define MAXTABLE  32641
00035 
00036 
00037    class Knot 
00038    {
00039    public:
00040            int px, py, pz;      
00041            int tx, ty, tz;      
00042            int hnx, hny, hnz;   
00043            int vnx, vny, vnz;   
00044            int dx, dy, dz;      
00045            int wx, wy, wz;      
00046            char hinten;         
00047            char vinten;         
00048            short hsize;         
00049            short vsize;         
00050            short wide;          
00051    };
00052    
00053 #define MAXVERT 10
00054    
00055    class Edge 
00056    {
00057    public:
00058            Long dx,dz;
00059            Long dr,dg,db;
00060            Long x,z;
00061            Long r,g,b;
00062    };
00063 
00064    class Vert
00066    {
00067    public:
00068        int x, y, z; 
00069        int inten;   
00070    };
00071 
00072    class Poly
00074    {
00075    public:
00076            Vert v[MAXVERT]; 
00077            int count; 
00078    };
00079 
00080 
00081    class ArcEntry
00082    {
00083    public:
00084                 short dx,dy,dz;
00085                 short inten;
00086                 Long offset;
00087    };
00088 
00089 
00090 
00091 typedef struct {
00092         Pixel_RS  *fbuf;     /* Pixels of the image       */
00093         short  *dbuf;        /* z-coordinates of the points of the image used so  
00094                                         points with smaller z will not be plotted */
00095         int xmax, ymax;
00096         int yskip;
00097     } ViewStruct; /*  Structure with picture to be filled by pixel utils  */
00098 
00099 #define ZValid(z)     ((!m_UseSlabPlane) || ((z) < m_SlabValue))   
00100 #define XValid(x)     (((x)>=0)&&((x)<View.xmax))   
00101 #define YValid(y)     (((y)>=0)&&((y)<View.ymax))    
00102 
00103 const int LutSize = 20000;
00104 
00105 const double DefaultAmbient = 0.4;  
00106 const int    ColourDepth    = 32;   
00107 const int    ColourMask     = 31;   
00108 const int    LastShade      = 500;  
00109 
00110 const int SlabReject  =  0x00;
00111 const int SlabHalf    =  0x01;
00112 const int SlabHollow  =  0x02;
00113 const int SlabFinal   =  0x03;
00114 const int SlabClose   =  0x04;
00115 const int SlabSection =  0x05;
00116 
00117 const int ColBits    =  24;
00118 
00119 #define RComp(x)   (((x)>>16)&0xff)  
00120 #define GComp(x)   (((x)>>8)&0xff)   
00121 #define BComp(x)   ((x)&0xff)        
00122 
00123 
00124 
00125 class Canvas3D
00127 {
00128 public:
00129 
00130         Canvas3D();
00131         ~Canvas3D();
00132 
00133         void resize(int new_XRange, int new_YRange);
00134         Pixel_RS* AllocImage();
00135         void DestroyImage();
00136         short* AllocDBuffer();
00137         void DestroyDBuffer();
00138 
00139         Pixel_RS  *FBuffer;  
00140         short  *DBuffer;     
00141 
00142         int FBClear; 
00143         int DBClear; 
00144 
00145         ViewStruct View; 
00146 
00147 
00148         static unsigned int pixel_size;        
00149 
00150         static Pixel_RS Lut[LutSize]; 
00151 
00152         int m_FontSize;
00153         int m_SplineCount;
00154         int m_UseSlabPlane;
00155         int m_SlabValue;
00156         int m_SlabMode;
00157         int m_SlabInten;
00158         int m_SliceValue;
00159         int m_ImageSize;    
00160         int m_ImageRadius;  
00161         int m_ZOffset;      
00162 
00163         static Byte *LookUp[MAXRAD]; 
00164         static Byte Array[MAXTABLE]; 
00165 
00166 
00167 
00168         
00169         static unsigned int ColConstTable[MAXRAD];
00170         static unsigned int *ColConst;
00171 
00172         int XRange() const { return m_XRange; }
00173         int YRange() const { return m_YRange; }
00174         int HRange() const { return m_XRange/2; }
00175         int WRange() const { return m_YRange/2; }
00176         int Range () const { return MinFun(m_XRange,m_YRange); }
00177 
00178         static void SetLutEntry( int i, int r, int g, int b ); 
00179 
00180         void PlotDeepPoint( int x, int y, int z, int col);
00181         void ClipDeepPoint( int x, int y, int z, int col );
00182         void DrawTwinLine( int x1,int y1,int z1,int x2,int y2,int z2, int col1,int col2 );
00183         void ClipTwinLine( int x1,int y1,int z1,int x2,int y2,int z2, int col1,int col2 );
00184         void DrawTwinVector( int x1,int y1,int z1,int x2,int y2,int z2, int col1,int col2 );
00185         void ClipTwinVector( int x1,int y1,int z1,int x2,int y2,int z2, int col1,int col2 );
00186         void ClipDashVector( int x1,int y1,int z1,int x2,int y2,int z2, int col1,int col2 );
00187 
00188         void DrawCylinder( int x1,int y1,int z1,int x2,int y2,int z2,int c1,int c2,int rad);
00189         void ClipCylinder( int x1,int y1,int z1,int x2,int y2,int z2,int c1,int c2,int rad );
00190         void DashRibbon( Knot* src, Knot* dst, int col1, int col2 );
00191         void StrandRibbon( Knot* src, Knot* dst, int col1, int col2 );
00192         void SolidRibbon2( Knot* src, Knot* dst, int col1, int col2 );
00193         void SolidRibbon( Knot* src, Knot* dst, int col );
00194         void RectRibbon ( Knot* src, Knot* dst, int col );
00195         void DrawSphere( int x,int y,int z,int rad,int col );
00196         void ClipSphere( int x,int y,int z,int rad,int col );
00197 
00198         void SetFontSize( int size );
00199         void DisplayTextString( int x, int y, int z, const char* label, int col  ); 
00200 
00201 protected:
00202 
00203         int m_XRange, m_YRange; 
00204         char FontDimen[23];   
00205 
00206         int OutCode(int x, int y, int z);
00207         void PlotPoint(int x,int y,int z,int col);
00208         void ClipPoint(int x, int y,  int z, int col);
00209         void ClipVector(int x1,int y1,int z1,
00210                                         int x2,int y2,int z2,int col);
00211         void ClipLine(int x1,int y1,int z1,int x2,int y2,int z2,int col);
00212 public:
00213 //      void OutLinePolygon( Poly* p );
00214 //      void DrawPolygon( Poly* p );
00215         void ClipPolygon( Poly* p ); 
00216 protected:
00217         int TestSphere( int x, int y, int z, int rad );
00218         void DrawArcAc(short* dbase, Pixel_RS* fbase, int z, int c);
00219         void DrawArcDn( short* dbase, Pixel_RS* fbase, int z, int c);
00220         void DrawCylinderCaps( int x1,int y1,int z1, 
00221                                                           int x2, int y2, int z2, 
00222                                                           int c1, int c2, int rad );
00223         int TestCylinder( int x1, int y1, int z1,
00224                                           int x2, int y2, int z2, int rad );
00225         void ClipArcAc( short* dbase, Pixel_RS* fbase,
00226                                         int x, int y, int z, int c);
00227         void ClipArcDn( short* dbase, Pixel_RS* fbase,
00228                                         int x, int y, int z, int c);
00229         void ClipCharacter( int x, int y, int z, int glyph, int col );
00230 
00231 
00232 };
00233 
00234 
00235 
00236 #endif /* !CANVAS3D_H */

Generated on Tue Feb 17 02:03:02 2004 for harlem by doxygen 1.3.6