📄 stlreader.h
字号:
#ifndef _STLREADER_H_
#define _STLREADER_H_
#include <cstdio>
#define BUFFER_SIZE 512
typedef struct _CPoint3D
{//点
double x;
double y;
double z;
} CPoint3D, CVector3D;
typedef struct _CTriangle
{//三角形
CPoint3D vertexs[3];
CVector3D normal;
} CTriangle;
class CModel3D
{//一个简单的模型
public:
struct _CBBox
{//包围盒
CPoint3D min;
CPoint3D max;
};
public:
unsigned m_nTriangles;
CTriangle* m_pTriangles;
CPoint3D m_stCenter;
_CBBox m_stBox;
double m_dbDiagonal;
char m_strFileName[BUFFER_SIZE];
char m_strModelName[BUFFER_SIZE];
bool m_bIsWired;
bool m_bIsShaded;
float m_fColor[4];
public:
CModel3D();
~CModel3D();
bool readFromSTL(char* fileName);
void renderModel();
void showInfo();
private:
void clearModel();
void doCount(FILE* pModelFile);
void readData(FILE* pModelFile);
void computeBoundBox();
void computeNormal();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -