-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdxfconv.cpp
More file actions
50 lines (35 loc) · 1.33 KB
/
dxfconv.cpp
File metadata and controls
50 lines (35 loc) · 1.33 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
// dxfconv.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "HDxf.h"
std::wstring output_filepath;
void WritePercentToOutputFile(int percent)
{
// use the output file to update the progress bar
ofstream ofs(output_filepath);
if (!ofs)return;
ofs << percent << "\n";
}
void DoConvert(const wchar_t* in_filepath, const wchar_t* out_filepath)
{
HeeksDxfRead dxf_file(in_filepath, WritePercentToOutputFile);
dxf_file.DoRead(HeeksDxfRead::m_ignore_errors);
printf("file has been read, converting splines... \n");
theApp.SplinesToBiarcs(0.01);
printf("Done!. Splines were converted to arcs\n");
theApp.SaveDXFFile(theApp.GetChildren(), out_filepath);
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3)
{
wprintf(L"not enough arguments to dxfconv, first parameter is input file, second parameter is output file");
}
std::wstring input_filepath(argv[1]);
output_filepath.assign(argv[2]);
wprintf(L"input file is %s\n", input_filepath.c_str());
wprintf(L"output file is %s\n", output_filepath.c_str());
DoConvert(input_filepath.c_str(), output_filepath.c_str());
if(theApp.m_number_of_splines_converted > 0)return 0; // 0 means "all good and some splines converted"
return 1; // non zero means either a problem or no splines converted
}