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;
45 /**--------------------------------------------------------------------------------------------------
46 \brief Logic for reading from a DXF stream of data. Data is streamed to a given CADEntityStreamer to
47 be handled by the NDEVR API.
48 **/
50 {
51 public:
52 explicit DXFReader(CADEntityStreamer& entity_streamer, ProgressInfo* log);
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);
62
63 bool processDXFGroup(uint04 group_code);
64 void addSetting();
65 void addLayer();
67 void addBlock();
71 void endBlock();
72 void addPoint();
73 void addLine();
74 void addXLine();
75 void addRay();
76 void addSection();
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 addGroup();
96
104 const PaperSpace& paperspace() const { return m_paper_space; }
105 /*void addLeader();
106
107 void addHatch();
108 void addHatchLoop();
109 void addHatchEdge();
110 bool handleHatchData();
111
112 void addImage();*/
114
116
120
129 void endEntity();
134 private:
135 Vector<3, fltp08> getExtrusion() const;
136 DXFValueManager* m_value_manager;
137 uint04 m_current_line;
138 String m_polyline_layer;
139 Buffer<Vector<4, fltp08>> m_vertices;
140 enum class MeshProperty
141 {
142 e_none
143 , e_face
144 , e_edge
145 , e_sub_entity_count
146 , e_property_type
147 };
148 CADMeshData m_mesh_data;
149 CADDictionaryObject m_dictionary;
150 MeshProperty m_current_mesh_property;
151
152 Buffer<fltp08> m_knots;
153 Buffer<fltp08> m_weights;
154
155 Buffer<Vector<3, fltp08>> m_control_points;
156 Buffer<Vector<3, fltp08>> m_fit_points;
157
158 bool m_first_hatch_loop;
159 HatchEdgeData m_hatch_edge;
160 DXFGroup m_group_data;
161 Buffer<Buffer<HatchEdgeData>> m_hatch_edges;
162 PaperSpace m_paper_space;
163 String m_x_record_handle;
164 bool m_x_recordValues;
165 bool m_complex_object;
166 uint04 m_group_code;
167 uint04 m_matrix_count = 0;
168 Matrix<fltp08> m_matrix = Matrix<fltp08>(1.0);
169 // Current entity type
170 DXFEntityCodes m_current_object_type;
171 // Value of the current setting
172 String m_setting_value;
173 // Key of the current setting (e.g. "$ACADVER")
174 String m_setting_key;
175 CADEntityStreamer& m_entity_streamer;
176 ProgressInfo* m_log;
177 std::function<void(const TranslatedString&)> m_warning_callback;
178 };
179}
#define NDEVR_CAD_API
Definition DLLInfo.h:58
Logic for reading or writing to a binary file including logic for.
Definition BinaryFile.h:59
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A base-class for streaming out CAD entities from a file or CAD program memory.
Definition CADEntityStreamer.h:45
Logic for reading from a DXF stream of data. Data is streamed to a given CADEntityStreamer to be hand...
Definition DXFReader.h:50
bool processDXFGroup(uint04 group_code)
const PaperSpace & paperspace() const
Definition DXFReader.h:104
bool handleMTextData()
bool handleGroupData()
bool handleLWPolylineData()
void setWarningCallback(const std::function< void(const TranslatedString &)> &callback)
Definition DXFReader.h:56
bool handleSplineData()
void addEntityInfo(EntityData &data)
bool handleLinetypeData()
void readFile(File &file)
void addDimDiametric()
void readBinaryFile(File &file)
bool readNextLinePair(Scanner &scan)
void add3dFace(bool is_solid)
bool handleXRecordData()
DXFReader(CADEntityStreamer &entity_streamer, ProgressInfo *log)
bool readNextPair(BinaryFile &scan)
bool isBinaryFile(File &file) const
bool handleMatrixData()
void addHandleInfo(HandleData &data)
void readAsciiFile(File &file)
void addAttributeDefinition()
bool handleDictionaryData()
bool handleLeaderData()
void addDimensionInfo(DimensionData &data)
void addDimAngular3P()
DXF streams store data in a large numbered index structure. This class optimally stores this data so ...
Definition DXFValueManager.h:46
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Definition Matrix.hpp:176
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
Contains methods for easily reading objects in an ascii stream.
Definition Scanner.h:45
The core String class for the NDEVR API.
Definition String.h:69
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Definition ACIColor.h:37
DXFEntityCodes
Types of CAD entities natively supported by the NDEVR API.
Definition EntityCodes.h:65
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
A container for information pointing to a CAD dictionary in CAD memory.
Definition CADEntities.h:614
Stores mesh data in a way optimized for CAD.
Definition CADEntities.h:379
A type of entity in CAD representing several entities grouped together.
Definition CADEntities.h:1031
Dimensional measurements stored in a CAD-friendly way.
Definition CADEntities.h:549
An entity in CAD which has a layer and other handle information.
Definition CADEntities.h:158
A handle used to reference an object in CAD.
Definition CADEntities.h:148
Stores information about the edge of a CAD hatch pattern.
Definition CADEntities.h:775
Stores CAD details about PaperSpace or 2D document space.
Definition CADEntities.h:55