]> git.saurik.com Git - wxWidgets.git/blob - samples/opengl/penguin/dxfrenderer.h
no changes, just deTAbified and fixed really strange indentation of 'else' statements
[wxWidgets.git] / samples / opengl / penguin / dxfrenderer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dxfrenderer.h
3 // Purpose: DXF reader and renderer
4 // Author: Sandro Sigala
5 // Modified by:
6 // Created: 2005-11-10
7 // RCS-ID: $Id$
8 // Copyright: (c) Sandro Sigala
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _DXFRENDERER_H_
13 #define _DXFRENDERER_H_
14
15 struct DXFVector
16 {
17 DXFVector() { x = y = z = 0.0f; }
18 DXFVector(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }
19 float x, y, z;
20 };
21
22 struct DXFEntity
23 {
24 enum Type { Line, Face } type;
25 int colour;
26 };
27
28 struct DXFLine: public DXFEntity
29 {
30 DXFLine() { type = Line; }
31 DXFVector v0;
32 DXFVector v1;
33 };
34
35 struct DXFFace: public DXFEntity
36 {
37 DXFFace() { type = Face; }
38 void CalculateNormal();
39 DXFVector v0;
40 DXFVector v1;
41 DXFVector v2;
42 DXFVector v3;
43 DXFVector n; // normal
44 };
45
46 struct DXFLayer
47 {
48 DXFLayer() { colour = -1; }
49 wxString name;
50 int colour;
51 };
52
53 WX_DECLARE_LIST(DXFEntity, DXFEntityList);
54 WX_DECLARE_LIST(DXFLayer, DXFLayerList);
55
56 class DXFRenderer
57 {
58 public:
59 DXFRenderer();
60 ~DXFRenderer();
61
62 void Clear();
63 bool Load(wxInputStream& stream);
64 bool IsOk() const { return m_loaded; }
65 void Render() const;
66
67 private:
68 bool ParseHeader(wxInputStream& stream);
69 bool ParseTables(wxInputStream& stream);
70 bool ParseEntities(wxInputStream& stream);
71 int GetLayerColour(const wxString& layer) const;
72 void NormalizeEntities();
73
74 bool m_loaded;
75 DXFLayerList m_layers;
76 DXFEntityList m_entities;
77 };
78
79 #endif // !_DXFRENDERER_H_