1 //////////////////////////////////////////////////////////////////////
2 //
3 //                             Pixie
4 //
5 // Copyright � 1999 - 2003, Okan Arikan
6 //
7 // Contact: okan@cs.utexas.edu
8 //
9 //	This library is free software; you can redistribute it and/or
10 //	modify it under the terms of the GNU Lesser General Public
11 //	License as published by the Free Software Foundation; either
12 //	version 2.1 of the License, or (at your option) any later version.
13 //
14 //	This library is distributed in the hope that it will be useful,
15 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
16 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 //	Lesser General Public License for more details.
18 //
19 //	You should have received a copy of the GNU Lesser General Public
20 //	License along with this library; if not, write to the Free Software
21 //	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 //
23 ///////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////
25 //
26 //  File				:	debug.h
27 //  Classes				:	Various classes/functions to help debugging
28 //  Description			:
29 //
30 ////////////////////////////////////////////////////////////////////////
31 #ifndef DEBUGFILE_H
32 #define DEBUGFILE_H
33 
34 #include "common/global.h"
35 #include "common/algebra.h"
36 #include "common/os.h"
37 #include "gui/opengl.h"
38 
39 
40 ///////////////////////////////////////////////////////////////////////
41 // Class				:	CDebugView
42 // Description			:	This class is used to draw various things
43 // Comments				:
44 class	CDebugView : public CView {
45 public:
46 								CDebugView(const char *fileName,int append=FALSE);
47 								CDebugView(FILE *in,const char *fileName);
48 								~CDebugView();
49 
point(const float * P)50 				void			point(const float *P)	{
51 									addBox(bmin,bmax,P);
52 									int	i	=	0;
53 									fwrite(&i,sizeof(int),1,file);
54 									fwrite(P,sizeof(float),3,file);
55 								}
56 
line(const float * P1,const float * P2)57 				void			line(const float *P1,const float *P2) {
58 									addBox(bmin,bmax,P1);
59 									addBox(bmin,bmax,P2);
60 									int	i	=	1;
61 									fwrite(&i,sizeof(int),1,file);
62 									fwrite(P1,sizeof(float),3,file);
63 									fwrite(P2,sizeof(float),3,file);
64 								}
65 
triangle(const float * P1,const float * P2,const float * P3)66 				void			triangle(const float *P1,const float *P2,const float *P3) {
67 									addBox(bmin,bmax,P1);
68 									addBox(bmin,bmax,P2);
69 									addBox(bmin,bmax,P3);
70 									int	i	=	2;
71 									fwrite(&i,sizeof(int),1,file);
72 									fwrite(P1,sizeof(float),3,file);
73 									fwrite(P2,sizeof(float),3,file);
74 									fwrite(P3,sizeof(float),3,file);
75 								}
76 
quad(const float * P1,const float * P2,const float * P3,const float * P4)77 				void			quad(const float *P1,const float *P2,const float *P3,const float *P4) {
78 									addBox(bmin,bmax,P1);
79 									addBox(bmin,bmax,P2);
80 									addBox(bmin,bmax,P3);
81 									int	i	=	3;
82 									fwrite(&i,sizeof(int),1,file);
83 									fwrite(P1,sizeof(float),3,file);
84 									fwrite(P2,sizeof(float),3,file);
85 									fwrite(P3,sizeof(float),3,file);
86 									fwrite(P4,sizeof(float),3,file);
87 								}
88 
89 				// Stuff inherited from CView
90 				void			draw();
91 				void			bound(float *bmin,float *bmax);
keyDown(int key)92 				int				keyDown(int key) { return FALSE;	}
93 private:
94 				vector			bmin,bmax;
95 				int				writing;
96 				FILE			*file;
97 				const char		*fileName;
98 };
99 
100 #endif
101 
102