NDEVR
API Documentation
DXFReader.h
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 <NDEVR/String.h>
37#include <functional>
38namespace NDEVR
39{
40 class TranslatedString;
41 class File;
42 class Scanner;
43 class DXFValueManager;
44 class BinaryFile;
49 class NDEVR_CAD_API DXFReader
50 {
51 public:
52 explicit DXFReader(CADEntityStreamer& entity_streamer, ProgressInfo& progress, CancelInfo& cancel);
53 ~DXFReader();
54 void readFile(File file);
55 bool isBinaryFile(File& file) const;
56 void setWarningCallback(const std::function<void(const TranslatedString&)>& callback) { m_warning_callback = callback; }
57 protected:
58 void readBinaryFile(File& file);
59 void readAsciiFile(File& file);
60 bool readNextLinePair(Scanner& scan);
61 bool readNextPair(BinaryFile& scan);
62
63 bool processDXFGroup(uint04 group_code);
64 void addSetting();
65 void addLayer();
66 void addLinetype();
67 void addBlock();
68 void addMaterial();
69 void addBlockRecord();
70 void addTextStyle();
71 void endBlock();
72 void addPoint();
73 void addLine();
74 void addXLine();
75 void addRay();
76 void addSection();
77 void addLWPolyline();
78 void addPolyline();
79 void addVertex();
80
81 void addSpline();
82 void addMesh();
83 void addArc();
84 void addCircle();
85 void addEllipse();
86 void addInsert();
87
88 void addTrace();
89 void add3dFace(bool is_solid);
90 void addLeader();
91 void addMText();
92 void addText();
93 void addTableEntry();
94 void addViewport();
95 void addVPort();
96 void addGroup();
97 void addAttribute();
98 void addAttributeDefinition();
99
100 void addDimLinear();
101 void addDimAligned();
102 void addDimRadial();
103 void addDimDiametric();
104 void addDimAngular();
105 void addDimAngular3P();
106 void addDimOrdinate();
107 const PaperSpace& paperspace() const { return m_paper_space; }
108 /*void addLeader();
109
110 void addHatch();
111 void addHatchLoop();
112 void addHatchEdge();
113 bool handleHatchData();
114
115 void addImage();*/
116 void addImageDef();
117
118 void addDictionary();
119
120 bool handleXRecordData();
121 bool handleDictionaryData();
122 bool handleGroupData();
123
124 bool handleXData();
125 bool handleMTextData();
126 bool handleLWPolylineData();
127 bool handleMeshData();
128 bool handleSplineData();
129 bool handleLeaderData();
130 bool handleLinetypeData();
131 bool handleMatrixData();
132 void endEntity();
133 void endSequence();
134 void addHandleInfo(HandleData& data);
135 void addEntityInfo(EntityData& data);
136 void addDimensionInfo(DimensionData& data);
137 private:
138 Vector<3, fltp08> getExtrusion() const;
139 DXFValueManager* m_value_manager;
140 uint04 m_current_line;
141 String m_polyline_layer;
142 Buffer<Vector<4, fltp08>> m_vertices;
144 enum class MeshProperty
145 {
146 e_none
147 , e_face
148 , e_edge
149 , e_sub_entity_count
150 , e_property_type
151 };
152 CADMeshData m_mesh_data;
153 CADDictionaryObject m_dictionary;
154 MeshProperty m_current_mesh_property;
155
156 Buffer<fltp08> m_knots;
157 Buffer<fltp08> m_weights;
158
159 Buffer<Vector<3, fltp08>> m_control_points;
160 Buffer<Vector<3, fltp08>> m_fit_points;
161
162 bool m_first_hatch_loop;
163 HatchEdgeData m_hatch_edge;
164 DXFGroup m_group_data;
165 Buffer<Buffer<HatchEdgeData>> m_hatch_edges;
166 PaperSpace m_paper_space;
167 String m_x_record_handle;
168 bool m_x_recordValues;
169 bool m_complex_object;
170 uint04 m_group_code;
171 uint04 m_matrix_count = 0;
172 Matrix<fltp08> m_matrix = Matrix<fltp08>(1.0);
173 // Current entity type
174 DXFEntityCodes m_current_object_type;
175 // Value of the current setting
176 String m_setting_value;
177 // Key of the current setting (e.g. "$ACADVER")
178 String m_setting_key;
179 CADEntityStreamer& m_entity_streamer;
180 ProgressInfo& m_progress;
181 CancelInfo& m_cancel;
182 std::function<void(const TranslatedString&)> m_warning_callback;
183 };
184}
Logic for reading or writing to a binary file including logic for compressing or decompressing the fi...
Definition BinaryFile.h:136
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A base-class for streaming out CAD entities from a file or CAD program memory.
Used with InfoPipe to signal that the process can be cancelled.
DXF streams store data in a large numbered index structure.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
Used with InfoPipe to signal that the system will be using progress.
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic.
Definition Scanner.h:47
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
DXFEntityCodes
Types of CAD entities natively supported by the NDEVR API.
Definition EntityCodes.h:73
@ e_none
No defined value type.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ file
The source file path associated with this object.
A container for information pointing to a CAD dictionary in CAD memory.
Stores mesh data in a way optimized for CAD.
A type of entity in CAD representing several entities grouped together.
Dimensional measurements stored in a CAD-friendly way.
An entity in CAD which has a layer and other handle information.
A handle used to reference an object in CAD.
Stores information about the edge of a CAD hatch pattern.
Stores CAD details about PaperSpace or 2D document space.
Definition CADEntities.h:55