API Documentation
Loading...
Searching...
No Matches
DXFReader.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: CAD
28File: DXFReader
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include "EntityCodes.h"
35#include "CADEntityStreamer.h"
36#include "Base/Headers/String.h"
37#include <functional>
38namespace NDEVR
39{
40 class TranslatedString;
41 class File;
42 class Scanner;
43 class DXFValueManager;
44 class BinaryFile;
46 {
47 public:
48 explicit DXFReader(CADEntityStreamer& entity_streamer, ProgressInfo* log);
49 ~DXFReader();
50 void readFile(File& file);
51 bool isBinaryFile(File& file) const;
52 void setWarningCallback(const std::function<void(const TranslatedString&)>& callback) { m_warning_callback = callback; }
53 protected:
54 void readBinaryFile(File& file);
55 void readAsciiFile(File& file);
56 bool readNextLinePair(Scanner& scan);
57 bool readNextPair(BinaryFile& scan);
58
59 bool processDXFGroup(uint04 group_code);
60 void addSetting();
61 void addLayer();
62 void addLinetype();
63 void addBlock();
64 void addMaterial();
65 void addBlockRecord();
66 void addTextStyle();
67 void endBlock();
68 void addPoint();
69 void addLine();
70 void addXLine();
71 void addRay();
72 void addSection();
73 void addLWPolyline();
74 void addPolyline();
75 void addVertex();
76
77 void addSpline();
78 void addMesh();
79 void addArc();
80 void addCircle();
81 void addEllipse();
82 void addInsert();
83
84 void addTrace();
85 void add3dFace(bool is_solid);
86 void addLeader();
87 void addMText();
88 void addText();
89 void addGroup();
90 void addAttribute();
91 void addAttributeDefinition();
92
93 void addDimLinear();
94 void addDimAligned();
95 void addDimRadial();
96 void addDimDiametric();
97 void addDimAngular();
98 void addDimAngular3P();
99 void addDimOrdinate();
100 const PaperSpace& paperspace() const { return m_paper_space; }
101 /*void addLeader();
102
103 void addHatch();
104 void addHatchLoop();
105 void addHatchEdge();
106 bool handleHatchData();
107
108 void addImage();*/
109 void addImageDef();
110
111 void addDictionary();
112
113 bool handleXRecordData();
114 bool handleDictionaryData();
115 bool handleGroupData();
116
117 bool handleXData();
118 bool handleMTextData();
119 bool handleLWPolylineData();
120 bool handleMeshData();
121 bool handleSplineData();
122 bool handleLeaderData();
123 bool handleLinetypeData();
124 bool handleMatrixData();
125 void endEntity();
126 void endSequence();
127 void addHandleInfo(HandleData& data);
128 void addEntityInfo(EntityData& data);
129 void addDimensionInfo(DimensionData& data);
130 private:
131 Vector<3, fltp08> getExtrusion() const;
132 DXFValueManager* m_value_manager;
133 uint04 m_current_line;
134 String m_polyline_layer;
135 Buffer<Vector<4, fltp08>> m_vertices;
136 enum class MeshProperty
137 {
138 e_none
139 , e_face
140 , e_edge
141 , e_sub_entity_count
142 , e_property_type
143 };
144 CADMeshData m_mesh_data;
145 CADDictionaryObject m_dictionary;
146 MeshProperty m_current_mesh_property;
147
148 Buffer<fltp08> m_knots;
149 Buffer<fltp08> m_weights;
150
151 Buffer<Vector<3, fltp08>> m_control_points;
152 Buffer<Vector<3, fltp08>> m_fit_points;
153
154 bool m_first_hatch_loop;
155 HatchEdgeData m_hatch_edge;
156 DXFGroup m_group_data;
157 Buffer<Buffer<HatchEdgeData>> m_hatch_edges;
158 PaperSpace m_paper_space;
159 String m_x_record_handle;
160 bool m_x_recordValues;
161 bool m_complex_object;
162 uint04 m_group_code;
163 uint04 m_matrix_count = 0;
164 Matrix<fltp08> m_matrix = Matrix<fltp08>(1.0);
165 // Current entity type
166 DXFEntityCodes m_current_object_type;
167 // Value of the current setting
168 String m_setting_value;
169 // Key of the current setting (e.g. "$ACADVER")
170 String m_setting_key;
171 CADEntityStreamer& m_entity_streamer;
172 ProgressInfo* m_log;
173 std::function<void(const TranslatedString&)> m_warning_callback;
174 };
175}
#define NDEVR_CAD_API
Definition DLLInfo.h:79
Definition BinaryFile.h:51
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition CADEntityStreamer.h:42
Definition DXFReader.h:46
const PaperSpace & paperspace() const
Definition DXFReader.h:100
void setWarningCallback(const std::function< void(const TranslatedString &)> &callback)
Definition DXFReader.h:52
Definition DXFValueManager.h:42
Definition File.h:47
Definition ProgressInfo.hpp:43
Definition Scanner.h:41
Definition String.h:40
Definition TranslatedString.h:9
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
Definition CADEntities.h:515
Definition CADEntities.h:139
Definition CADEntities.h:133
Definition CADEntities.h:49