Skip to content

Commit f4ca36b

Browse files
committed
IO_DXF: WIP1
1 parent 32400bc commit f4ca36b

File tree

8 files changed

+764
-683
lines changed

8 files changed

+764
-683
lines changed

src/io_dxf/dxf.cpp

Lines changed: 122 additions & 136 deletions
Large diffs are not rendered by default.

src/io_dxf/dxf.h

Lines changed: 92 additions & 543 deletions
Large diffs are not rendered by default.

src/io_dxf/dxf_entity_variant.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/****************************************************************************
2+
** Copyright (c) 2026, Fougue Ltd. <https://www.fougue.pro>
3+
** All rights reserved.
4+
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
5+
****************************************************************************/
6+
7+
#pragma once
8+
9+
#include <functional>
10+
#include <variant>
11+
12+
#include "dxf_format_common.h"
13+
14+
struct Dxf_3DFACE;
15+
struct Dxf_ARC;
16+
struct Dxf_CIRCLE;
17+
struct Dxf_ELLIPSE;
18+
struct Dxf_INSERT;
19+
struct Dxf_LINE;
20+
struct Dxf_LWPOLYLINE;
21+
struct Dxf_MTEXT;
22+
struct Dxf_POINT;
23+
struct Dxf_POLYLINE;
24+
struct Dxf_SOLID;
25+
struct Dxf_SPLINE;
26+
struct Dxf_TEXT;
27+
28+
using Dxf_EntityVariant = std::variant<
29+
std::monostate,
30+
std::reference_wrapper<const Dxf_3DFACE>,
31+
std::reference_wrapper<const Dxf_ARC>,
32+
std::reference_wrapper<const Dxf_CIRCLE>,
33+
std::reference_wrapper<const Dxf_ELLIPSE>,
34+
std::reference_wrapper<const Dxf_INSERT>,
35+
std::reference_wrapper<const Dxf_LINE>,
36+
std::reference_wrapper<const Dxf_LWPOLYLINE>,
37+
std::reference_wrapper<const Dxf_MTEXT>,
38+
std::reference_wrapper<const Dxf_POINT>,
39+
std::reference_wrapper<const Dxf_POLYLINE>,
40+
std::reference_wrapper<const Dxf_SOLID>,
41+
std::reference_wrapper<const Dxf_SPLINE>,
42+
std::reference_wrapper<const Dxf_TEXT>
43+
>;

src/io_dxf/dxf_format_blocks.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/****************************************************************************
2+
** Copyright (c) 2026, Fougue Ltd. <https://www.fougue.pro>
3+
** All rights reserved.
4+
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
5+
****************************************************************************/
6+
7+
#pragma once
8+
9+
#include "dxf_entity_variant.h"
10+
#include "dxf_format_common.h"
11+
12+
#include <vector>
13+
14+
struct Dxf_BLOCK {
15+
// Code: 2 or 3
16+
DxfStringRef name;
17+
// Code: 8
18+
DxfStringRef layerName;
19+
// Code: 10, 20, 30
20+
DxfCoords basePoint = {};
21+
// Code: 70
22+
unsigned flags = 0;
23+
// Code: 1
24+
DxfStringRef xrefPathName;
25+
// Code: 4
26+
DxfStringRef description;
27+
28+
std::vector<Dxf_EntityVariant> entities;
29+
};

src/io_dxf/dxf_format_common.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/****************************************************************************
2+
** Copyright (c) 2026, Fougue Ltd. <https://www.fougue.pro>
3+
** All rights reserved.
4+
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
5+
****************************************************************************/
6+
7+
#pragma once
8+
9+
#include <string_view>
10+
11+
enum class DxfUnit {
12+
Unspecified = 0, // Unspecified (No units)
13+
Inches,
14+
Feet,
15+
Miles,
16+
Millimeters,
17+
Centimeters,
18+
Meters,
19+
Kilometers,
20+
Microinches,
21+
Mils,
22+
Yards,
23+
Angstroms,
24+
Nanometers,
25+
Microns,
26+
Decimeters,
27+
Dekameters,
28+
Hectometers,
29+
Gigameters,
30+
AstronomicalUnits,
31+
LightYears,
32+
Parsecs
33+
};
34+
35+
enum class DxfVersion {
36+
RUnknown,
37+
ROlder,
38+
R10,
39+
R11_12,
40+
R13,
41+
R14,
42+
R2000,
43+
R2004,
44+
R2007,
45+
R2010,
46+
R2013,
47+
R2018,
48+
RNewer
49+
};
50+
51+
struct DxfCoords {
52+
double x; double y; double z;
53+
};
54+
55+
struct DxfScale {
56+
double x; double y; double z;
57+
};
58+
59+
using DxfStringRef = std::string_view;
60+
using DxfColorIndex = int;
61+
constexpr DxfColorIndex dxfColorByLayer = 256;
62+
constexpr DxfColorIndex dxfColorByBlock = 0;

0 commit comments

Comments
 (0)