]> git.saurik.com Git - wxWidgets.git/blame - samples/opengl/penguin/dxfrenderer.h
Update files.bkl to match the changes Stefan made to Makefile.in earlier, to update...
[wxWidgets.git] / samples / opengl / penguin / dxfrenderer.h
CommitLineData
4b764db3
JS
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
15struct 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
22struct DXFEntity
23{
24 enum Type { Line, Face } type;
25 int colour;
26};
27
28struct DXFLine: public DXFEntity
29{
30 DXFLine() { type = Line; }
31 DXFVector v0;
32 DXFVector v1;
33};
34
35struct 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
46struct DXFLayer
47{
48 DXFLayer() { colour = -1; }
49 wxString name;
50 int colour;
51};
52
53WX_DECLARE_LIST(DXFEntity, DXFEntityList);
54WX_DECLARE_LIST(DXFLayer, DXFLayerList);
55
56class DXFRenderer
57{
58public:
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
67private:
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_