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 };
52 /**--------------------------------------------------------------------------------------------------
53 \brief Handles writing data to a CAD entity stream.
54 **/
56 {
57 public:
58 explicit DXFWriter();
59 const DynamicPointer<CADHandleManager>& handleManager() const { return m_handle_manager; };
61 void setFileTarget(File& file);
62 void setVersion(DXFVersion version);
71 void startBlocks(const Buffer<BlockData>& data);
72 void startBlock(const BlockData& data);
73 void endBlock(const BlockData& data);
74 void addDictionary(const String& dictionary_name, const CADDictionaryObject& dictionary);
79 void writeReactors(uint04 dictionary_handle);
80 void writeVariableValue(const CADVariable& variable);
81 void finish();
82 static bool getFileLine(String& s, std::ifstream& in, bool stripSpace = true);
84 bool addColorInfo(const CADColorInfo& data, bool is_off = false);
85 void writeLabel(uint02 value_index);
86 void writeInteger(uint02 value_index);
87 void writeIntegerL(uint04 value_index);
88 void writeIntegerL(sint04 value_index);
89 void writeIntegerS(uint01 value_index);
90 void writeInteger(sint02 value_index);
91 void writeDouble(fltp08 value_index);
92 void writeValue(uint02 value_index, const String& value);
93 void writeHandle(uint02 value_index, const uint04& value);
94 void writeValue(uint02 value_index, const char* const value);
95 void writeValue(uint02 value_index, uint04 value);
96 void writeValueL(uint02 value_index, sint04 value);
97 void writeValueL(uint02 value_index, uint04 value);
98 void writeValueS(uint02 value_index, uint01 value);
99 void writeValue(uint02 value_index, sint04 value);
100 void writeValue(uint02 value_index, fltp08 value);
101 void writeValue(uint02 value_index, fltp04 value);
103 void writeValue(uint02 value_index, const Vector<3, fltp08>& value);
106 void startLayers(uint04 max_layer_count);
107 void addLayer(const LayerData& data);
108 void addPoint(const PointData& point);
109 void addAttribute(const Attrib& attrib);
111 void addFastPoint(const PointData& face);
113
114 void addLine(const LineData& line);
117 void addMesh(const CADMeshData& data);
118
119 void addPolyline(const PolylineData& data);
120 void addPolyline(const PolylineData& data, const Polyline<3, fltp08>& poly);
122 void addVertex(const Vector<3, fltp08>& point);
123
124 void addSpline();
125
126 void addArc();
127 void addCircle();
129 void addInsert(const BlockInsert& insert);
130
132
133 void addTrace(bool is_solid, const TraceData& face);
134 void add3dFace(bool is_solid, const Triangle<3, fltp08>& tri);
135 void add3dFace(bool is_solid, const TraceData& face);
136 //Use this when writing many 3D faces
137 void startFast3DFaces(bool is_solid);
138 void addFast3dFace(bool is_solid, const TraceData& face);
141
142 void addText(const TextData& data);
143 void addMText(const TextData& data);
145 uint04 getHandleIndex(const String& handle_name);
147
149 void addDimAligned(const DimAlignedData& alignment);
155
156 /*void addLeader();
157
158 void addHatch();
159 void addHatchLoop();
160 void addHatchEdge();
161 bool handleHatchData();
162
163 void addImage();*/
165 void addMaterialObject(const DXFMaterial& material);
166 void setBinary(bool is_binary) { m_is_binary = is_binary; }
170 void endEntity();
171 void setDecimalPlaces(uint04 decimals) { m_decimal_places = decimals; }
174 XDataWriter createVertexXData(uint04 start_offset, const Buffer<RGBColor>& vertices);
175 bool writePointers() const { return m_write_pointers; }
176 private:
177 void writeDimensionData(const DimensionData& data);
178 void writeCache();
179 enum VertexMode
180 {
182 , e_3D_mesh
183 };
184 DynamicPointer<CADHandleManager> m_handle_manager;
185 uint04 m_current_line;
186 String m_polyline_layer;
187 Buffer<Vector<4, fltp08>> m_vertices;
188 //bool m_x_recordValues;
189 VertexMode m_vertex_mode;
190 String m_group_code_tmp;
191 uint04 m_group_code;
192 String m_group_value;
193 // Value of the current setting
194 String m_setting_value;
195 // Key of the current setting (e.g. "$ACADVER")
196 String m_setting_key;
197 // app specific dictionary handle:
198 //uint08 m_dictionary_handle;
199 // handle of standard text style, referenced by dimstyle:
200 //uint08 m_style_handle;
201 std::ofstream m_out;
202 String m_fast_data;
203 String m_cache;
204 uint04 m_cache_size;
205
206 bool m_write_pointers = true;
207 bool m_write_parent_pointers = true;
208 bool m_write_classes = true;
209 bool m_write_general_view_style = true;
210 bool m_write_viewports = true;
211 bool m_write_dim_style = true;
212 bool m_has_block_data = false;
213 bool m_is_binary = false;
214 //uint04 m_decimal_places = Constant<uint04>::Invalid;
215 uint04 m_decimal_places = 4;
216 DXFVersion m_version = DXFVersion::e_AC1021;
217 Buffer<CADDictionaryObject> m_dictionary_objects;
218 Dictionary<String, CADDictionaryObject> m_named_dictionary_objects;
219 Buffer<XDataWriter> m_xdata_objects;
220 };
221}
#define NDEVR_CAD_API
Definition DLLInfo.h:58
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Handles writing data to a CAD entity stream.
Definition DXFWriter.h:56
void writeViewStyleObject()
void setFileTarget(File &file)
void writeValue(uint02 value_index, fltp08 value)
static bool getFileLine(String &s, std::ifstream &in, bool stripSpace=true)
void addMaterialObject(const DXFMaterial &material)
void addPolyline(const PolylineData &data)
void startBlock(const BlockData &data)
void setDecimalPlaces(uint04 decimals)
Definition DXFWriter.h:171
void add3dFace(bool is_solid, const TraceData &face)
void writeDictionary(const CADDictionaryObject &data)
void writeLTypeTable()
bool handleMTextData()
void writeValue(uint02 value_index, sint04 value)
void writeValue(uint02 value_index, fltp04 value)
bool handleLWPolylineData()
void addDictionary(const String &dictionary_name, const CADDictionaryObject &dictionary)
void writeValue(uint02 value_index, const String &value)
bool writePointers() const
Definition DXFWriter.h:175
void writeOptions(const Buffer< CADVariable > &data)
bool addColorInfo(const CADColorInfo &data, bool is_off=false)
bool handleLinetypeData()
void writeInteger(sint02 value_index)
void startFastPoints()
void addDimDiametric()
void addInsert(const BlockInsert &insert)
void addDimAligned(const DimAlignedData &alignment)
XDataWriter createVertexXData(uint04 start_offset, const Buffer< Vertex< 3, fltp08 > > &vertices)
void endBlock(const BlockData &data)
void writeValue(uint02 value_index, const Vector< 3, fltp08 > &value)
void addPolyline(const PolylineData &data, const Polyline< 3, fltp08 > &poly)
void setVersion(DXFVersion version)
void writeValueL(uint02 value_index, uint04 value)
void addMText(const TextData &data)
void writeDimStyleTable()
void writeIntegerS(uint01 value_index)
void writeVPortTableEntree(const ViewportData &data)
void addXLine(const LineSegment< 3, fltp08 > &line)
void writeIntegerL(uint04 value_index)
void writeVariableValue(const CADVariable &variable)
void cleanupCADName(String &name)
void writeViewports(Buffer< ViewportData > cameras)
void addLine(const LineData &line)
void addAttribute(const Attrib &attrib)
void addPoint(const PointData &point)
void setHandleManager(const DynamicPointer< CADHandleManager > &manager)
void addFastPoint(const PointData &face)
void writeValueL(uint02 value_index, sint04 value)
void setBinary(bool is_binary)
Definition DXFWriter.h:166
void addMesh(const CADMeshData &data)
void addTrace(bool is_solid, const TraceData &face)
void writeAttributesFast(const EntityData &data)
void addText(const TextData &data)
XDataWriter createVertexXData(uint04 start_offset, const Buffer< RGBColor > &vertices)
void writeValue(uint02 value_index, const char *const value)
void writeHandle(uint02 value_index, const uint04 &value)
void addPolyline(const Polyline< 3, fltp08 > &poly)
void addLayer(const LayerData &data)
Buffer< BlockData > defaultBlocks()
void writeValue(uint02 value_index, uint04 value)
void writeInteger(uint02 value_index)
const DynamicPointer< CADHandleManager > & handleManager() const
Definition DXFWriter.h:59
void addFast3dFace(bool is_solid, const TraceData &face)
uint04 generateTempHandleIndex()
void writeReactors(uint04 dictionary_handle)
void writeIntegerL(sint04 value_index)
void writeDictionaries()
void addRay(const LineSegment< 3, fltp08 > &line)
void startBlocks(const Buffer< BlockData > &data)
void writeLabel(uint02 value_index)
void writeAPPIDTable()
void writeStyleTable()
void add3dFace(bool is_solid, const Triangle< 3, fltp08 > &tri)
uint04 getHandleIndex(const String &handle_name)
void addVertex(const Vector< 3, fltp08 > &point)
void writeValueS(uint02 value_index, uint01 value)
void startFast3DFaces(bool is_solid)
void addDimAngular3P()
void startLayers(uint04 max_layer_count)
void writeDouble(fltp08 value_index)
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
A line segment represented by two vertices, a start and end.
Definition Line.hpp:49
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
The core String class for the NDEVR API.
Definition String.h:69
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometr...
Definition Triangle.hpp:138
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
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:64
DXFVersion
Versions of the DXF we support writing out. Lower versions support less features.
Definition EntityCodes.h:40
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
int16_t sint02
-Defines an alias representing a 2 byte, signed integer. -Can represent exact integer values -32767 t...
Definition BaseValues.hpp:57
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:88
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
logic for storing a attribue data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:470
A block structure (Similar to a Model) used to share data with CAD.
Definition CADEntities.h:196
Information for how to place a CAD block within a scene (Similar to Model).
Definition CADEntities.h:528
Stores color information for interfacing with CAD.
Definition CADEntities.h:77
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 variable shared between NDEVR and CAD.
Definition CADEntities.h:94
A DXF friendly material class which contains UV properties similar to a Material object.
Definition CADEntities.h:1015
A CAD measurement similar to AngleMeasurementModel.
Definition CADEntities.h:589
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
Layer information shared with CAD.
Definition CADEntities.h:175
A CAD-friendly way to store line segment information.
Definition CADEntities.h:509
Point data stored in a friendly way for interfacing with CAD.
Definition CADEntities.h:539
logic for storing a polyline data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:317
logic for storing a text data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:451
logic for storing a trace data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:349
logic for storing a viewport in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:901