API Documentation
Loading...
Searching...
No Matches
DXFWriter.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: DXFWriter
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include "EntityCodes.h"
35#include "CADEntityStreamer.h"
37#include "Base/Headers/String.h"
38#include "Base/Headers/Line.hpp"
40#include <fstream>
41namespace NDEVR
42{
43 class DXFValueManager;
44 class File;
45 class CADHandleManager;
46 class DXFWriter;
47 class XDataWriter : public HandleData
48 {
49 public:
50 std::function<void(DXFWriter& dxf)> write_function;
51 };
53 {
54 public:
55 explicit DXFWriter();
56 const DynamicPointer<CADHandleManager>& handleManager() const { return m_handle_manager; };
57 void setHandleManager(const DynamicPointer<CADHandleManager>& manager);
58 void setFileTarget(File& file);
59 void setVersion(DXFVersion version);
60 void writeAPPIDTable();
61 void writeDimStyleTable();
62 void writeViewTable();
63 void writeStyleTable();
64 void writeUCSTable();
65 void writeClasses();
66 void writeLTypeTable();
67 void writeOptions(const Buffer<CADVariable>& data);
68 void startBlocks(const Buffer<BlockData>& data);
69 void startBlock(const BlockData& data);
70 void endBlock(const BlockData& data);
71 void addDictionary(const String& dictionary_name, const CADDictionaryObject& dictionary);
72 void startEntities();
73 void writeObjects();
74 void writeDictionaries();
75 void writeViewStyleObject();
76 void writeReactors(uint04 dictionary_handle);
77 void writeVariableValue(const CADVariable& variable);
78 void finish();
79 static bool getFileLine(String& s, std::ifstream& in, bool stripSpace = true);
80 void writeAttributesFast(const EntityData& data);
81 bool addColorInfo(const CADColorInfo& data, bool is_off = false);
82 void writeLabel(uint02 value_index);
83 void writeInteger(uint02 value_index);
84 void writeIntegerL(uint04 value_index);
85 void writeIntegerL(sint04 value_index);
86 void writeIntegerS(uint01 value_index);
87 void writeInteger(sint02 value_index);
88 void writeDouble(fltp08 value_index);
89 void writeValue(uint02 value_index, const String& value);
90 void writeHandle(uint02 value_index, const uint04& value);
91 void writeValue(uint02 value_index, const char* const value);
92 void writeValue(uint02 value_index, uint04 value);
93 void writeValueL(uint02 value_index, sint04 value);
94 void writeValueL(uint02 value_index, uint04 value);
95 void writeValueS(uint02 value_index, uint01 value);
96 void writeValue(uint02 value_index, sint04 value);
97 void writeValue(uint02 value_index, fltp08 value);
98 void writeValue(uint02 value_index, fltp04 value);
99 void writeDictionary(const CADDictionaryObject& data);
100 void writeValue(uint02 value_index, const Vector<3, fltp08>& value);
101 void writeViewports(Buffer<ViewportData> cameras);
102 void writeVPortTableEntree(const ViewportData& data);
103 void startLayers(uint04 max_layer_count);
104 void addLayer(const LayerData& data);
105 void addPoint(const PointData& point);
106 void addAttribute(const Attrib& attrib);
107 void startFastPoints();
108 void addFastPoint(const PointData& face);
109 void endFastPoints();
110
111 void addLine(const LineData& line);
112 void addXLine(const LineSegment<3, fltp08>& line);
113 void addRay(const LineSegment<3, fltp08>& line);
114 void addMesh(const CADMeshData& data);
115
116 void addPolyline(const PolylineData& data);
117 void addPolyline(const PolylineData& data, const Polyline<3, fltp08>& poly);
118 void addPolyline(const Polyline<3, fltp08>& poly);
119 void addVertex(const Vector<3, fltp08>& point);
120
121 void addSpline();
122
123 void addArc();
124 void addCircle();
125 void addEllipse();
126 void addInsert(const BlockInsert& insert);
127
128 void cleanupCADName(String& name);
129
130 void addTrace(bool is_solid, const TraceData& face);
131 void add3dFace(bool is_solid, const Triangle<3, fltp08>& tri);
132 void add3dFace(bool is_solid, const TraceData& face);
133 //Use this when writing many 3D faces
134 void startFast3DFaces(bool is_solid);
135 void addFast3dFace(bool is_solid, const TraceData& face);
136 void endFast3DFaces();
137 Buffer<BlockData> defaultBlocks();
138
139 void addText(const TextData& data);
140 void addMText(const TextData& data);
141 uint04 generateTempHandleIndex();
142 uint04 getHandleIndex(const String& handle_name);
143 void addAttribute();
144
145 void addDimLinear();
146 void addDimAligned(const DimAlignedData& alignment);
147 void addDimRadial();
148 void addDimDiametric();
149 void addDimAngular();
150 void addDimAngular3P();
151 void addDimOrdinate();
152
153 /*void addLeader();
154
155 void addHatch();
156 void addHatchLoop();
157 void addHatchEdge();
158 bool handleHatchData();
159
160 void addImage();*/
161 void addImageDef();
162 void addMaterialObject(const DXFMaterial& material);
163 void setBinary(bool is_binary) { m_is_binary = is_binary; }
164 bool handleMTextData();
165 bool handleLWPolylineData();
166 bool handleLinetypeData();
167 void endEntity();
168 void setDecimalPlaces(uint04 decimals) { m_decimal_places = decimals; }
169 void endSequence();
170 XDataWriter createVertexXData(uint04 start_offset, const Buffer<Vertex<3, fltp08>>& vertices);
171 XDataWriter createVertexXData(uint04 start_offset, const Buffer<RGBColor>& vertices);
172 bool writePointers() const { return m_write_pointers; }
173 private:
174 void writeDimensionData(const DimensionData& data);
175 void writeCache();
176 enum VertexMode
177 {
179 , e_3D_mesh
180 };
181 DynamicPointer<CADHandleManager> m_handle_manager;
182 uint04 m_current_line;
183 String m_polyline_layer;
184 Buffer<Vector<4, fltp08>> m_vertices;
185 //bool m_x_recordValues;
186 VertexMode m_vertex_mode;
187 String m_group_code_tmp;
188 uint04 m_group_code;
189 String m_group_value;
190 // Value of the current setting
191 String m_setting_value;
192 // Key of the current setting (e.g. "$ACADVER")
193 String m_setting_key;
194 // app specific dictionary handle:
195 //uint08 m_dictionary_handle;
196 // handle of standard text style, referenced by dimstyle:
197 //uint08 m_style_handle;
198 std::ofstream m_out;
199 String m_fast_data;
200 String m_cache;
201 uint04 m_cache_size;
202
203 bool m_write_pointers = true;
204 bool m_write_parent_pointers = true;
205 bool m_write_classes = true;
206 bool m_write_general_view_style = true;
207 bool m_write_viewports = true;
208 bool m_write_dim_style = true;
209 bool m_has_block_data = false;
210 bool m_is_binary = false;
211 //uint04 m_decimal_places = Constant<uint04>::NaN;
212 uint04 m_decimal_places = 4;
213 DXFVersion m_version = DXFVersion::e_AC1021;
214 Buffer<CADDictionaryObject> m_dictionary_objects;
215 Dictionary<String, CADDictionaryObject> m_named_dictionary_objects;
216 Buffer<XDataWriter> m_xdata_objects;
217 };
218}
#define NDEVR_CAD_API
Definition DLLInfo.h:79
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition DXFWriter.h:53
void setDecimalPlaces(uint04 decimals)
Definition DXFWriter.h:168
bool writePointers() const
Definition DXFWriter.h:172
void setBinary(bool is_binary)
Definition DXFWriter.h:163
const DynamicPointer< CADHandleManager > & handleManager() const
Definition DXFWriter.h:56
Definition Pointer.hpp:303
Definition File.h:47
A line segment represented by two vertices, a start and end.
Definition Line.hpp:55
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
Definition String.h:40
Definition Triangle.hpp:143
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
A vertex.
Definition Vertex.hpp:54
Definition DXFWriter.h:48
std::function< void(DXFWriter &dxf)> write_function
Definition DXFWriter.h:50
Definition ACIColor.h:37
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
DXFVersion
Definition EntityCodes.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
int16_t sint02
-Defines an alias representing a 2 byte, signed integer. -Can represent exact integer values -32767 t...
Definition BaseValues.hpp:66
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
logic for storing a attribue data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:458
Definition CADEntities.h:172
Definition CADEntities.h:502
Definition CADEntities.h:68
Definition CADEntities.h:572
Definition CADEntities.h:366
Definition CADEntities.h:82
Definition CADEntities.h:970
Definition CADEntities.h:553
Definition CADEntities.h:515
Definition CADEntities.h:139
Definition CADEntities.h:133
Definition CADEntities.h:154
Definition CADEntities.h:491
Definition CADEntities.h:509
logic for storing a polyline data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:293
logic for storing a text data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:437
logic for storing a trace data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:337
logic for storing a viewport in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:865