00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef CLIP_H
00028 #define CLIP_H
00029
00030
00031 #ifdef __APPLE__
00032 #include <OpenGL/gl.h>
00033 #else
00034 #include <GL/gl.h>
00035 #endif
00036 #include <vector>
00037 #include <cmath>
00038 #include <error.h>
00039
00040
00041 namespace Tools
00042 {
00072 class Clip
00073 {
00074 public:
00075 Clip();
00076 ~Clip();
00077
00080 void enable();
00081
00084 void disable();
00085
00087 void slide(float d);
00088
00092 void rotateWithWorld(float dx, float dy);
00093
00099 void rotateWithScreen(float dx, float dy);
00100
00103 void display(bool use_cross_section=true) const;
00104
00106 void init();
00107
00110 void getPlaneMatrix(float m[]) const;
00111
00113 void setPlaneMatrix(const float m[]);
00114
00115 private:
00118 void correctMatrix();
00119
00121 void drawCrossSection(const float m[]) const;
00122
00124 void drawPlane(const float m[]) const;
00125
00126 static void mult(const float a[], const float b[], float m[]);
00127 static void transp(float m[]);
00128
00130 struct PlaneManager {
00131 PlaneManager();
00132 GLenum allocate();
00133 void free(GLenum);
00134 enum { NBPLANES = 6 };
00135 bool m_planes[NBPLANES];
00136 };
00137
00138 private:
00139 float m_planeMatrix[16];
00140 float m_modelview[16];
00141 GLenum m_planeId;
00142 static PlaneManager* m_planeManager;
00143 };
00144
00145
00146 }
00147
00148 #endif