-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDFXOutputDevice.cpp
More file actions
129 lines (99 loc) · 2.32 KB
/
DFXOutputDevice.cpp
File metadata and controls
129 lines (99 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// DXFOutputDevice.cpp: implementation of the CDXFOutputDevice class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <assert.h>
#include "aerofoil.h"
#include "DXFOutputDevice.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDXFOutputDevice::CDXFOutputDevice(const char* path)
{
os.open(path);
writeHeader();
}
CDXFOutputDevice::~CDXFOutputDevice()
{
writeFooter();
os.close();
}
void CDXFOutputDevice::MoveTo(int iStream, const PointT& pt)
{
assert(this);
assert(iStream == 0 || iStream == 1);
lastStream = iStream;
last[iStream] = pt;
}
void CDXFOutputDevice::LineTo(int iStream, const PointT& pt)
{
assert(this);
assert(iStream == 0 || iStream == 1);
os << 0 << endl;
os << "LINE" << endl;
os << 8 << endl; // layer
os << ((iStream == 0) ? "root" : "tip") << endl;
os << 10 << endl; // start X
os << last[iStream].fx << endl;
os << 20 << endl; // start Y
os << last[iStream].fy << endl;
os << 11 << endl; // end X
os << pt.fx << endl;
os << 21 << endl; // end Y
os << pt.fy << endl;
lastStream = iStream;
last[iStream] = pt;
}
void CDXFOutputDevice::Label(int iStream, const char* psz)
{
assert(this);
}
void CDXFOutputDevice::Home()
{
assert(this);
last[0] = last[1] = PointT(0,0);
lastStream = 0;
}
void CDXFOutputDevice::Flush()
{
assert(this);
}
///////////////////////////////////////////////////////////////////////////////
void CDXFOutputDevice::writeHeader()
{
assert(this);
os << 999 << endl;
os << "DXF File created by Aerofoil" << endl;
os << 0 << endl;
os << "SECTION" << endl;
os << 2 << endl;
os << "HEADER" << endl;
os << 0 << endl;
os << "ENDSEC" << endl;
os << 0 << endl;
os << "SECTION" << endl;
os << 2 << endl;
os << "BLOCKS" << endl;
os << 0 << endl;
os << "ENDSEC" << endl;
os << 0 << endl;
os << "SECTION" << endl;
os << 2 << endl;
os << "ENTITIES" << endl;
// Need to write out (geometric) entities ....
}
void CDXFOutputDevice::writeFooter()
{
assert(this);
// terminate entities section
os << 0 << endl;
os << "ENDSEC" << endl;
os << 0 << endl;
os << "EOF" << endl;
}