Line data Source code
1 : /*******************************************************************************
2 : * Project: libopencad
3 : * Purpose: OpenSource CAD formats support library
4 : * Author: Alexandr Borzykh, mush3d at gmail.com
5 : * Author: Dmitry Baryshnikov, bishop.dev@gmail.com
6 : * Language: C++
7 : *******************************************************************************
8 : * The MIT License (MIT)
9 : *
10 : * Copyright (c) 2016 Alexandr Borzykh
11 : * Copyright (c) 2016-2018 NextGIS, <info@nextgis.com>
12 : *
13 : * SPDX-License-Identifier: MIT
14 : *******************************************************************************/
15 :
16 : #ifndef CADOBJECTS_H
17 : #define CADOBJECTS_H
18 :
19 : #include "cadheader.h"
20 :
21 : #ifndef CPL_NON_FINAL
22 : #define CPL_NON_FINAL
23 : #endif
24 :
25 : /*
26 : * @brief Class which basically implements implements 3D vertex
27 : */
28 : class OCAD_EXTERN CADVector
29 : {
30 : public:
31 : CADVector();
32 : CADVector( double dx, double dy );
33 : CADVector( double dx, double dy, double dz );
34 : CADVector( const CADVector& other );
35 : friend bool operator==( const CADVector& first, const CADVector& second );
36 : CADVector& operator=( const CADVector& second );
37 : double getX() const;
38 : void setX( double value );
39 :
40 : double getY() const;
41 : void setY( double value );
42 :
43 : double getZ() const;
44 : void setZ( double value );
45 :
46 : bool getBHasZ() const;
47 : void setBHasZ( bool value );
48 :
49 : protected:
50 : inline static bool fcmp( double x, double y );
51 : protected:
52 : double X;
53 : double Y;
54 : double Z;
55 : bool bHasZ;
56 : };
57 :
58 : typedef struct _Eed
59 : {
60 : short dLength = 0;
61 : CADHandle hApplication;
62 : std::vector<unsigned char> acData;
63 : } CADEed;
64 :
65 : typedef std::vector<CADHandle> CADHandleArray;
66 : typedef std::vector<CADEed> CADEedArray;
67 :
68 : /**
69 : * @brief The base CAD object class
70 : */
71 205 : class OCAD_EXTERN CADObject
72 : {
73 : public:
74 : enum ObjectType
75 : {
76 : UNUSED = 0x0, // 0
77 : TEXT = 0x1, // 1
78 : ATTRIB = 0x2, // 2
79 : ATTDEF = 0x3, // 3
80 : BLOCK = 0x4, // 4
81 : ENDBLK = 0x5, // 5
82 : SEQEND = 0x6, // 6
83 : INSERT = 0x7, // 7
84 : MINSERT1 = 0x8, // 8
85 : MINSERT2 = 0x9, // 9
86 : VERTEX2D = 0x0A, // 10
87 : VERTEX3D = 0x0B, // 11
88 : VERTEX_MESH = 0x0C, // 12
89 : VERTEX_PFACE = 0x0D, // 13
90 : VERTEX_PFACE_FACE = 0x0E, // 14
91 : POLYLINE2D = 0x0F, // 15
92 : POLYLINE3D = 0x10, // 16
93 : ARC = 0x11, // 17
94 : CIRCLE = 0x12, // 18
95 : LINE = 0x13, // 19
96 : DIMENSION_ORDINATE = 0x14, // 20
97 : DIMENSION_LINEAR = 0x15, // 21
98 : DIMENSION_ALIGNED = 0x16, // 22
99 : DIMENSION_ANG_3PT = 0x17, // 23
100 : DIMENSION_ANG_2LN = 0x18, // 24
101 : DIMENSION_RADIUS = 0x19, // 25
102 : DIMENSION_DIAMETER = 0x1A, // 26
103 : POINT = 0x1B, // 27
104 : FACE3D = 0x1C, // 28
105 : POLYLINE_PFACE = 0x1D, // 29
106 : POLYLINE_MESH = 0x1E, // 30
107 : SOLID = 0x1F, // 31
108 : TRACE = 0x20, // 32
109 : SHAPE = 0x21, // 33
110 : VIEWPORT = 0x22, // 34
111 : ELLIPSE = 0x23, // 35
112 : SPLINE = 0x24, // 36
113 : REGION = 0x25, // 37
114 : SOLID3D = 0x26, // 38
115 : BODY = 0x27, // 39
116 : RAY = 0x28, // 40
117 : XLINE = 0x29, // 41
118 : DICTIONARY = 0x2A, // 42
119 : OLEFRAME = 0x2B, // 43
120 : MTEXT = 0x2C, // 44
121 : LEADER = 0x2D, // 45
122 : TOLERANCE = 0x2E, // 46
123 : MLINE = 0x2F, // 47
124 : BLOCK_CONTROL_OBJ = 0x30, // 48
125 : BLOCK_HEADER = 0x31, // 49
126 : LAYER_CONTROL_OBJ = 0x32, // 50
127 : LAYER = 0x33, // 51
128 : STYLE_CONTROL_OBJ = 0x34, // 52
129 : STYLE1 = 0x35, // 53
130 : STYLE2 = 0x36, // 54
131 : STYLE3 = 0x37, // 55
132 : LTYPE_CONTROL_OBJ = 0x38, // 56
133 : LTYPE1 = 0x39, // 57
134 : LTYPE2 = 0x3A, // 58
135 : LTYPE3 = 0x3B, // 59
136 : VIEW_CONTROL_OBJ = 0x3C, // 60
137 : VIEW = 0x3D, // 61
138 : UCS_CONTROL_OBJ = 0x3E, // 62
139 : UCS = 0x3F, // 63
140 : VPORT_CONTROL_OBJ = 0x40, // 64
141 : VPORT = 0x41, // 65
142 : APPID_CONTROL_OBJ = 0x42, // 66
143 : APPID = 0x43, // 67
144 : DIMSTYLE_CONTROL_OBJ = 0x44, // 68
145 : DIMSTYLE = 0x45, // 69
146 : VP_ENT_HDR_CTRL_OBJ = 0x46, // 70
147 : VP_ENT_HDR = 0x47, // 71
148 : GROUP = 0x48, // 72
149 : MLINESTYLE = 0x49, // 73
150 : OLE2FRAME = 0x4A, // 74
151 : DUMMY = 0x4B, // 75
152 : LONG_TRANSACTION = 0x4C, // 76
153 : LWPOLYLINE = 0x4D, // 77
154 : HATCH = 0x4E, // 78
155 : XRECORD = 0x4F, // 79
156 : ACDBPLACEHOLDER = 0x50, // 80
157 : VBA_PROJECT = 0x51, // 81
158 : LAYOUT = 0x52, // 82
159 : // Codes below aren't fixed, libopencad uses it for reading, in writing it will be different!
160 : CELLSTYLEMAP = 0x53, // 83
161 : DBCOLOR = 0x54, // 84
162 : DICTIONARYVAR = 0x55, // 85
163 : DICTIONARYWDFLT = 0x56, // 86
164 : FIELD = 0x57, // 87
165 : GROUP_UNFIXED = 0x58, // 88
166 : HATCH_UNFIXED = 0x59, // 89
167 : IDBUFFER = 0x5A, // 90
168 : IMAGE = 0x5B, // 91
169 : IMAGEDEF = 0x5C, // 92
170 : IMAGEDEFREACTOR = 0x5D, // 93
171 : LAYER_INDEX = 0x5E, // 94
172 : LAYOUT_UNFIXED = 0x5F, // 95
173 : LWPOLYLINE_UNFIXED = 0x60, // 96
174 : MATERIAL = 0x61, // 97
175 : MLEADER = 0x62, // 98
176 : MLEADERSTYLE = 0x63, // 99
177 : OLE2FRAME_UNFIXED = 0x64, // 100
178 : PLACEHOLDER = 0x65, // 101
179 : PLOTSETTINGS = 0x66, // 102
180 : RASTERVARIABLES = 0x67, // 103
181 : SCALE = 0x68, // 104
182 : SORTENTSTABLE = 0x69, // 105
183 : SPATIAL_FILTER = 0x6A, // 106
184 : SPATIAL_INDEX = 0x6B, // 107
185 : TABLEGEOMETRY = 0x6C, // 108
186 : TABLESTYLES = 0x6D, // 109
187 : VBA_PROJECT_UNFIXED = 0x6E, // 110
188 : VISUALSTYLE = 0x6F, // 111
189 : WIPEOUTVARIABLE = 0x70, // 112
190 : XRECORD_UNFIXED = 0x71, // 113
191 : WIPEOUT = 0x72 // 114
192 : };
193 :
194 : virtual ~CADObject();
195 :
196 : ObjectType getType() const;
197 : long getSize() const;
198 :
199 : void setSize( long value );
200 :
201 : short getCRC() const;
202 : void setCRC(unsigned short value );
203 :
204 : protected:
205 : long size;
206 : ObjectType type;
207 : unsigned short CRC;
208 :
209 205 : explicit CADObject(ObjectType typeIn) : size(0), type(typeIn), CRC(0) {}
210 : };
211 :
212 : std::string getNameByType( CADObject::ObjectType eType );
213 : bool isCommonEntityType( short nType );
214 : bool isSupportedGeometryType( short nType );
215 :
216 : /**
217 : * @brief The CADCommonED struct
218 : */
219 : struct CADCommonED
220 : {
221 : long nObjectSizeInBits;
222 : CADHandle hObjectHandle;
223 : CADEedArray aEED;
224 :
225 : bool bGraphicsPresented;
226 : std::vector<char> abyGraphicsData;
227 :
228 : unsigned char bbEntMode;
229 : long nNumReactors;
230 :
231 : bool bNoXDictionaryHandlePresent;
232 : bool bBinaryDataPresent;
233 :
234 : bool bIsByLayerLT; // R13-14 only
235 :
236 : bool bNoLinks;
237 : short nCMColor;
238 :
239 : double dfLTypeScale;
240 : unsigned char bbLTypeFlags;
241 : unsigned char bbPlotStyleFlags;
242 : char bbMaterialFlags;
243 : char nShadowFlags;
244 :
245 : short nInvisibility;
246 : unsigned char nLineWeight;
247 :
248 70 : CADCommonED() :
249 : nObjectSizeInBits(0),
250 : bGraphicsPresented(false),
251 : bbEntMode(0),
252 : nNumReactors(0),
253 : bNoXDictionaryHandlePresent(false),
254 : bBinaryDataPresent(false),
255 : bIsByLayerLT(false),
256 : bNoLinks(false),
257 : nCMColor(0),
258 : dfLTypeScale(0.0),
259 : bbLTypeFlags(0),
260 : bbPlotStyleFlags(0),
261 : bbMaterialFlags(0),
262 : nShadowFlags(0),
263 : nInvisibility(0),
264 70 : nLineWeight(0)
265 : {
266 70 : }
267 : };
268 :
269 : /**
270 : * @brief The CADCommonEHD struct
271 : */
272 : struct CADCommonEHD
273 : {
274 : CADHandle hOwner; // depends on entmode.
275 : CADHandleArray hReactors;
276 : CADHandle hXDictionary;
277 : CADHandle hLayer;
278 : CADHandle hLType;
279 :
280 : CADHandle hPrevEntity;
281 : CADHandle hNextEntity;
282 :
283 : CADHandle hColorBookHandle;
284 :
285 : CADHandle hMaterial;
286 : CADHandle hPlotStyle;
287 :
288 : CADHandle hFullVisualStyle;
289 : CADHandle hFaceVisualStyle;
290 : CADHandle hEdgeVisualStyle;
291 : };
292 :
293 : /*
294 : * @brief The abstract class, which contains data common to all entities
295 : */
296 53 : class CADEntityObject CPL_NON_FINAL: public CADObject
297 : {
298 : public:
299 35 : explicit CADEntityObject(ObjectType typeIn): CADObject(typeIn) {}
300 :
301 : ~CADEntityObject() override;
302 : struct CADCommonED stCed;
303 : struct CADCommonEHD stChed;
304 : };
305 :
306 : /**
307 : * @brief The CAD Text Object class
308 : */
309 8 : class CADTextObject final: public CADEntityObject
310 : {
311 : public:
312 : CADTextObject();
313 : ~CADTextObject() override;
314 :
315 : unsigned char DataFlags;
316 : double dfElevation;
317 : CADVector vertInsetionPoint;
318 : CADVector vertAlignmentPoint;
319 : CADVector vectExtrusion;
320 : double dfThickness;
321 : double dfObliqueAng;
322 : double dfRotationAng;
323 : double dfHeight;
324 : double dfWidthFactor;
325 : std::string sTextValue;
326 : short dGeneration;
327 : short dHorizAlign;
328 : short dVertAlign;
329 :
330 : CADHandle hStyle;
331 : };
332 :
333 : /**
334 : * @brief The CAD Attribute Object class
335 : */
336 5 : class CADAttribObject CPL_NON_FINAL: public CADEntityObject
337 : {
338 : public:
339 : explicit CADAttribObject( ObjectType typeIn = ATTRIB );
340 : ~CADAttribObject() override;
341 :
342 : unsigned char DataFlags;
343 : double dfElevation;
344 : CADVector vertInsetionPoint;
345 : CADVector vertAlignmentPoint;
346 : CADVector vectExtrusion;
347 : double dfThickness;
348 : double dfObliqueAng;
349 : double dfRotationAng;
350 : double dfHeight;
351 : double dfWidthFactor;
352 : std::string sTextValue;
353 : short dGeneration;
354 : short dHorizAlign;
355 : short dVertAlign;
356 : char dVersion; // R2010+
357 : std::string sTag;
358 : short nFieldLength;
359 : unsigned char nFlags;
360 : bool bLockPosition;
361 :
362 : CADHandle hStyle;
363 : };
364 :
365 : /**
366 : * @brief The CAD Attribute definition Object class
367 : */
368 10 : class CADAttdefObject final: public CADAttribObject
369 : {
370 : public:
371 : CADAttdefObject();
372 : ~CADAttdefObject() override;
373 : std::string sPrompt;
374 : };
375 :
376 : /**
377 : * @brief The CAD Block Object class
378 : */
379 0 : class CADBlockObject final: public CADEntityObject
380 : {
381 : public:
382 : CADBlockObject();
383 : ~CADBlockObject() override;
384 : std::string sBlockName;
385 : };
386 :
387 : /**
388 : * @brief The CAD End block Object class
389 : */
390 : //TODO: do we need this class? Maybe CADEntityObject is enough?
391 0 : class CADEndblkObject final: public CADEntityObject
392 : {
393 : public:
394 : CADEndblkObject();
395 : ~CADEndblkObject() override;
396 : // it actually has nothing more than CED and CEHD.
397 : };
398 :
399 : /**
400 : * @brief The CADSeqendObject class
401 : */
402 : //TODO: do we need this class? Maybe CADEntityObject is enough?
403 0 : class CADSeqendObject final: public CADEntityObject
404 : {
405 : public:
406 : CADSeqendObject();
407 : ~CADSeqendObject() override;
408 : // it actually has nothing more than CED and CEHD.
409 : };
410 :
411 : /**
412 : * @brief The CADInsertObject class
413 : */
414 0 : class CADInsertObject final: public CADEntityObject
415 : {
416 : public:
417 : explicit CADInsertObject( ObjectType typeIn = INSERT );
418 : ~CADInsertObject() override;
419 : CADVector vertInsertionPoint;
420 : CADVector vertScales;
421 : double dfRotation;
422 : CADVector vectExtrusion;
423 : bool bHasAttribs;
424 : long nObjectsOwned;
425 :
426 : CADHandle hBlockHeader;
427 : CADHandleArray hAttribs;
428 : CADHandle hSeqend; // if bHasAttribs == true
429 : };
430 :
431 : /**
432 : * @brief The CADMInsertObject class
433 : */
434 0 : class CADMInsertObject final: public CADEntityObject
435 : {
436 : public:
437 : CADMInsertObject();
438 : ~CADMInsertObject() override;
439 : CADVector vertInsertionPoint;
440 : CADVector vertScales;
441 : double dfRotation;
442 : CADVector vectExtrusion;
443 : bool bHasAttribs;
444 : long nObjectsOwned;
445 :
446 : short nNumCols;
447 : short nNumRows;
448 : short nColSpacing;
449 : short nRowSpacing;
450 :
451 : CADHandle hBlockHeader;
452 : CADHandleArray hAtrribs;
453 : CADHandle hSeqend; // if bHasAttribs == true
454 : };
455 :
456 : /**
457 : * @brief The CADVertex2DObject class
458 : */
459 0 : class CADVertex2DObject final: public CADEntityObject
460 : {
461 : public:
462 : CADVertex2DObject();
463 : ~CADVertex2DObject() override;
464 : CADVector vertPosition; // Z must be taken from 2d polyline elevation.
465 : double dfStartWidth;
466 : double dfEndWidth;
467 : double dfBulge;
468 : long nVertexID;
469 : double dfTangentDir;
470 :
471 : /* NOTES: Neither elevation nor thickness are present in the 2D VERTEX data.
472 : * Both should be taken from the 2D POLYLINE entity (15)
473 : */
474 : };
475 :
476 : /**
477 : * @brief The CADVertex3DObject class
478 : */
479 : // TODO: do we need so many identical classes. Maybe CADVector(enum ObjectType eType)
480 : // for all cases?
481 0 : class CADVertex3DObject final: public CADEntityObject
482 : {
483 : public:
484 : CADVertex3DObject();
485 : ~CADVertex3DObject() override;
486 : CADVector vertPosition;
487 : };
488 :
489 : /**
490 : * @brief The CADVertexMesh class
491 : */
492 0 : class CADVertexMeshObject final: public CADEntityObject
493 : {
494 : public:
495 : CADVertexMeshObject();
496 : ~CADVertexMeshObject() override;
497 : CADVector vertPosition;
498 : };
499 :
500 : /**
501 : * @brief The CADVertexPFaceObject class
502 : */
503 0 : class CADVertexPFaceObject final: public CADEntityObject
504 : {
505 : public:
506 : CADVertexPFaceObject();
507 : ~CADVertexPFaceObject() override;
508 : CADVector vertPosition;
509 : };
510 :
511 : /**
512 : * @brief The CADVertexPFaceFaceObject class
513 : */
514 0 : class CADVertexPFaceFaceObject final: public CADEntityObject
515 : {
516 : public:
517 : CADVertexPFaceFaceObject();
518 : ~CADVertexPFaceFaceObject() override;
519 : // TODO: check DXF ref to get info what does it mean.
520 : short iVertexIndex1;
521 : short iVertexIndex2;
522 : short iVertexIndex3;
523 : short iVertexIndex4;
524 : };
525 :
526 : /**
527 : * @brief The CADPolyline2DObject class
528 : */
529 0 : class CADPolyline2DObject final: public CADEntityObject
530 : {
531 : public:
532 : CADPolyline2DObject();
533 : ~CADPolyline2DObject() override;
534 : short dFlags;
535 : short dCurveNSmoothSurfType;
536 : double dfStartWidth;
537 : double dfEndWidth;
538 : double dfThickness;
539 : double dfElevation;
540 : CADVector vectExtrusion;
541 :
542 : long nObjectsOwned;
543 :
544 : CADHandleArray hVertices; // content really depends on DWG version.
545 :
546 : CADHandle hSeqend;
547 : };
548 :
549 : /**
550 : * @brief The CADPolyline3DObject class
551 : */
552 0 : class CADPolyline3DObject final: public CADEntityObject
553 : {
554 : public:
555 : CADPolyline3DObject();
556 : ~CADPolyline3DObject() override;
557 : unsigned char SplinedFlags;
558 : unsigned char ClosedFlags;
559 :
560 : long nObjectsOwned;
561 :
562 : CADHandleArray hVertices; // content really depends on DWG version.
563 :
564 : CADHandle hSeqend;
565 : };
566 :
567 : /**
568 : * @brief The CADArc class
569 : */
570 0 : class CADArcObject final: public CADEntityObject
571 : {
572 : public:
573 : CADArcObject();
574 : ~CADArcObject() override;
575 : CADVector vertPosition;
576 : double dfRadius;
577 : double dfThickness;
578 : CADVector vectExtrusion;
579 : double dfStartAngle;
580 : double dfEndAngle;
581 : };
582 :
583 : /**
584 : * @brief The CADCircleObject class
585 : */
586 6 : class CADCircleObject final: public CADEntityObject
587 : {
588 : public:
589 : CADCircleObject();
590 : ~CADCircleObject() override;
591 : CADVector vertPosition;
592 : double dfRadius;
593 : double dfThickness;
594 : CADVector vectExtrusion;
595 : };
596 :
597 : /**
598 : * @brief The CADLineObject class
599 : */
600 2 : class CADLineObject final: public CADEntityObject
601 : {
602 : public:
603 : CADLineObject();
604 : ~CADLineObject() override;
605 : CADVector vertStart;
606 : CADVector vertEnd;
607 : double dfThickness;
608 : CADVector vectExtrusion;
609 : };
610 :
611 : /**
612 : * @brief The CADBaseControlObject class
613 : */
614 170 : class CADBaseControlObject CPL_NON_FINAL: public CADObject
615 : {
616 : public:
617 : ~CADBaseControlObject() override;
618 : long nObjectSizeInBits;
619 : CADHandle hObjectHandle;
620 : CADEedArray aEED;
621 : long nNumReactors;
622 : bool bNoXDictionaryPresent;
623 :
624 : protected:
625 : explicit CADBaseControlObject(ObjectType typeIn);
626 : };
627 :
628 : /**
629 : * @brief The CADBlockControlObject class
630 : */
631 0 : class CADBlockControlObject final: public CADBaseControlObject
632 : {
633 : public:
634 : CADBlockControlObject();
635 : ~CADBlockControlObject() override;
636 : long nNumEntries; // doesn't count MODELSPACE and PAPERSPACE
637 : CADHandle hNull;
638 : CADHandle hXDictionary;
639 : CADHandleArray hBlocks; // ends with modelspace and paperspace handles.
640 : };
641 :
642 : /**
643 : * @brief The CADBlockHeaderObject class
644 : */
645 16 : class CADBlockHeaderObject final: public CADBaseControlObject
646 : {
647 : public:
648 : CADBlockHeaderObject();
649 : ~CADBlockHeaderObject() override;
650 : std::string sEntryName;
651 : bool b64Flag;
652 : short dXRefIndex;
653 : bool bXDep;
654 : bool bAnonymous;
655 : bool bHasAtts;
656 : bool bBlkisXRef;
657 : bool bXRefOverlaid;
658 : bool bLoadedBit;
659 : long nOwnedObjectsCount;
660 : CADVector vertBasePoint;
661 : std::string sXRefPName;
662 : std::vector<unsigned char> adInsertCount; // TODO: ???
663 : std::string sBlockDescription;
664 : long nSizeOfPreviewData;
665 : std::vector<unsigned char> abyBinaryPreviewData;
666 : short nInsertUnits;
667 : bool bExplodable;
668 : char dBlockScaling;
669 : CADHandle hBlockControl;
670 : std::vector<CADHandle> hReactors;
671 : CADHandle hXDictionary;
672 : CADHandle hNull;
673 : CADHandle hBlockEntity;
674 : CADHandleArray hEntities;
675 : CADHandle hEndBlk;
676 : CADHandleArray hInsertHandles;
677 : CADHandle hLayout;
678 : };
679 :
680 : /**
681 : * @brief The CADLayerControlObject class
682 : */
683 16 : class CADLayerControlObject final: public CADBaseControlObject
684 : {
685 : public:
686 : CADLayerControlObject();
687 : ~CADLayerControlObject() override;
688 :
689 : long nNumEntries; // counts layer "0"
690 : CADHandle hNull;
691 : CADHandle hXDictionary;
692 : CADHandleArray hLayers;
693 : };
694 :
695 : /**
696 : * @brief The CADLayerObject class
697 : */
698 20 : class CADLayerObject final: public CADBaseControlObject
699 : {
700 : public:
701 : CADLayerObject();
702 : ~CADLayerObject() override;
703 :
704 : std::string sLayerName;
705 : bool b64Flag;
706 : short dXRefIndex;
707 : bool bXDep;
708 : bool bFrozen;
709 : bool bOn;
710 : bool bFrozenInNewVPORT;
711 : bool bLocked;
712 : bool bPlottingFlag;
713 : short dLineWeight;
714 : short dCMColor;
715 :
716 : CADHandle hLayerControl;
717 : CADHandleArray hReactors;
718 : CADHandle hXDictionary;
719 : CADHandle hExternalRefBlockHandle;
720 : CADHandle hPlotStyle;
721 : CADHandle hMaterial;
722 : CADHandle hLType;
723 : CADHandle hUnknownHandle;
724 : };
725 :
726 : /**
727 : * @brief The CADLineTypeControlObject class
728 : */
729 0 : class CADLineTypeControlObject final: public CADBaseControlObject
730 : {
731 : public:
732 : CADLineTypeControlObject();
733 : ~CADLineTypeControlObject() override;
734 :
735 : long nNumEntries; // doesn't count BYBLOCK / BYLAYER.
736 : CADHandle hNull;
737 : CADHandle hXDictionary;
738 : CADHandleArray hLTypes;
739 : };
740 :
741 : typedef struct _dash
742 : {
743 : double dfLength;
744 : short dComplexShapecode;
745 : double dfXOffset;
746 : double dfYOffset;
747 : double dfScale;
748 : double dfRotation;
749 : short dShapeflag;
750 : } CADDash;
751 :
752 : /**
753 : * @brief The CADLineTypeObject class
754 : */
755 0 : class CADLineTypeObject final: public CADBaseControlObject
756 : {
757 : public:
758 : CADLineTypeObject();
759 : ~CADLineTypeObject() override;
760 :
761 : std::string sEntryName;
762 : bool b64Flag;
763 : short dXRefIndex;
764 : bool bXDep;
765 : std::string sDescription;
766 : double dfPatternLen;
767 : unsigned char dAlignment;
768 : unsigned char nNumDashes;
769 : std::vector<CADDash> astDashes;
770 : std::vector<unsigned char> abyTextArea; // TODO: what is it?
771 : CADHandle hLTControl;
772 : CADHandleArray hReactors;
773 : CADHandle hXDictionary;
774 : CADHandle hXRefBlock;
775 : CADHandleArray hShapefiles; // TODO: one for each dash?
776 : };
777 :
778 : /**
779 : * @brief The CADPointObject class
780 : */
781 2 : class CADPointObject final: public CADEntityObject
782 : {
783 : public:
784 : CADPointObject();
785 : ~CADPointObject() override;
786 :
787 : CADVector vertPosition;
788 : double dfThickness;
789 : CADVector vectExtrusion;
790 : double dfXAxisAng;
791 : };
792 :
793 : /**
794 : * @brief The CADSolidObject class
795 : */
796 0 : class CADSolidObject final: public CADEntityObject
797 : {
798 : public:
799 : CADSolidObject();
800 : ~CADSolidObject() override;
801 :
802 : double dfThickness;
803 : double dfElevation;
804 : std::vector<CADVector> avertCorners;
805 : CADVector vectExtrusion;
806 : };
807 :
808 : /**
809 : * @brief The CADEllipseObject class
810 : */
811 2 : class CADEllipseObject final: public CADEntityObject
812 : {
813 : public:
814 : CADEllipseObject();
815 : ~CADEllipseObject() override;
816 :
817 : CADVector vertPosition;
818 : CADVector vectSMAxis;
819 : CADVector vectExtrusion;
820 : double dfAxisRatio;
821 : double dfBegAngle;
822 : double dfEndAngle;
823 : };
824 :
825 : /**
826 : * @brief The CADRayObject class
827 : */
828 0 : class CADRayObject final: public CADEntityObject
829 : {
830 : public:
831 : CADRayObject();
832 : ~CADRayObject() override;
833 :
834 : CADVector vertPosition;
835 : CADVector vectVector;
836 : };
837 :
838 : /**
839 : * @brief The CADXLineObject class
840 : */
841 0 : class CADXLineObject final: public CADEntityObject
842 : {
843 : public:
844 : CADXLineObject();
845 : ~CADXLineObject() override;
846 :
847 : CADVector vertPosition;
848 : CADVector vectVector;
849 : };
850 :
851 : /**
852 : * @brief The CADDictionaryObject class
853 : */
854 240 : class CADDictionaryObject final: public CADBaseControlObject
855 : {
856 : public:
857 : CADDictionaryObject();
858 : ~CADDictionaryObject() override;
859 :
860 : long nNumItems;
861 : short dCloningFlag;
862 : unsigned char dHardOwnerFlag;
863 :
864 : std::vector<std::string> sItemNames;
865 :
866 : CADHandle hParentHandle;
867 : CADHandleArray hReactors;
868 : CADHandle hXDictionary;
869 : CADHandleArray hItemHandles;
870 : };
871 :
872 : /**
873 : * @brief The CADLWPolylineObject class
874 : */
875 0 : class CADLWPolylineObject final: public CADEntityObject
876 : {
877 : public:
878 : CADLWPolylineObject();
879 : ~CADLWPolylineObject() override;
880 :
881 : bool bClosed;
882 : double dfConstWidth;
883 : double dfElevation;
884 : double dfThickness;
885 : CADVector vectExtrusion;
886 : std::vector<CADVector> avertVertices;
887 : std::vector<double> adfBulges;
888 : std::vector<short> adVerticesID;
889 : std::vector<std::pair<double, double>> astWidths; // start, end.
890 : };
891 :
892 : /**
893 : * @brief The CADSplineObject class
894 : */
895 0 : class CADSplineObject final: public CADEntityObject
896 : {
897 : public:
898 : CADSplineObject();
899 : ~CADSplineObject() override;
900 :
901 : long dScenario;
902 : long dSplineFlags; // 2013+
903 : long dKnotParameter; // 2013+
904 :
905 : long dDegree;
906 : double dfFitTol;
907 : CADVector vectBegTangDir;
908 : CADVector vectEndTangDir;
909 : long nNumFitPts;
910 :
911 : bool bRational;
912 : bool bClosed;
913 : bool bPeriodic;
914 : double dfKnotTol;
915 : double dfCtrlTol;
916 : long nNumKnots;
917 : long nNumCtrlPts;
918 : bool bWeight;
919 :
920 : std::vector<double> adfKnots;
921 : std::vector<double> adfCtrlPointsWeight;
922 : std::vector<CADVector> avertCtrlPoints;
923 : std::vector<CADVector> averFitPoints;
924 : };
925 :
926 : /**
927 : * @brief Common Dimensional Data structure
928 : */
929 : struct CADCommonDimensionData
930 : {
931 : char dVersion;
932 : CADVector vectExtrusion;
933 : CADVector vertTextMidPt;
934 : double dfElevation;
935 : unsigned char dFlags;
936 : std::string sUserText;
937 : double dfTextRotation;
938 : double dfHorizDir;
939 : double dfInsXScale;
940 : double dfInsYScale;
941 : double dfInsZScale;
942 : double dfInsRotation;
943 :
944 : short dAttachmentPoint;
945 : short dLineSpacingStyle;
946 : double dfLineSpacingFactor;
947 : double dfActualMeasurement;
948 :
949 : bool bUnknown;
950 : bool bFlipArrow1;
951 : bool bFlipArrow2;
952 :
953 : CADVector vert12Pt;
954 :
955 0 : CADCommonDimensionData() :
956 : dVersion(0),
957 : dfElevation(0.0),
958 : dFlags(0),
959 : dfTextRotation(0.0),
960 : dfHorizDir(0.0),
961 : dfInsXScale(0.0),
962 : dfInsYScale(0.0),
963 : dfInsZScale(0.0),
964 : dfInsRotation(0.0),
965 : dAttachmentPoint(0),
966 : dLineSpacingStyle(0),
967 : dfLineSpacingFactor(0.0),
968 : dfActualMeasurement(0.0),
969 : bUnknown(false),
970 : bFlipArrow1(false),
971 0 : bFlipArrow2(false)
972 : {
973 0 : }
974 : };
975 :
976 : /**
977 : * @brief The CADDimensionObject class
978 : */
979 0 : class CADDimensionObject CPL_NON_FINAL: public CADEntityObject
980 : {
981 : public:
982 0 : explicit CADDimensionObject( ObjectType typeIn ) : CADEntityObject(typeIn) {}
983 : ~CADDimensionObject() override;
984 : CADCommonDimensionData cdd;
985 : CADVector vert10pt;
986 : CADHandle hDimstyle;
987 : CADHandle hAnonymousBlock;
988 : };
989 :
990 : /**
991 : * @brief The CADDimensionOrdinateObject class
992 : */
993 0 : class CADDimensionOrdinateObject final: public CADDimensionObject
994 : {
995 : public:
996 : CADDimensionOrdinateObject();
997 : ~CADDimensionOrdinateObject() override;
998 : CADVector vert13pt, vert14pt;
999 : unsigned char Flags2;
1000 : };
1001 :
1002 : /**
1003 : * @brief The CADDimensionLinearObject class
1004 : */
1005 0 : class CADDimensionLinearObject final: public CADDimensionObject
1006 : {
1007 : public:
1008 : CADDimensionLinearObject();
1009 : ~CADDimensionLinearObject() override;
1010 : CADVector vert13pt, vert14pt;
1011 :
1012 : double dfExtLnRot;
1013 : double dfDimRot;
1014 : };
1015 :
1016 : /**
1017 : * @brief The CADDimensionAlignedObject class
1018 : */
1019 0 : class CADDimensionAlignedObject final: public CADDimensionObject
1020 : {
1021 : public:
1022 : CADDimensionAlignedObject();
1023 : ~CADDimensionAlignedObject() override;
1024 : CADVector vert13pt, vert14pt;
1025 :
1026 : double dfExtLnRot;
1027 : };
1028 :
1029 : /**
1030 : * @brief The CADDimensionAngular3PtObject class
1031 : */
1032 0 : class CADDimensionAngular3PtObject CPL_NON_FINAL: public CADDimensionObject
1033 : {
1034 : public:
1035 : explicit CADDimensionAngular3PtObject(ObjectType typeIn = DIMENSION_ANG_3PT);
1036 : ~CADDimensionAngular3PtObject() override;
1037 : CADVector vert13pt, vert14pt;
1038 : CADVector vert15pt;
1039 : };
1040 :
1041 : /**
1042 : * @brief The CADDimensionAngular2LnObject class
1043 : */
1044 0 : class CADDimensionAngular2LnObject final: public CADDimensionAngular3PtObject
1045 : {
1046 : public:
1047 : CADDimensionAngular2LnObject();
1048 : ~CADDimensionAngular2LnObject() override;
1049 :
1050 : CADVector vert16pt;
1051 : };
1052 :
1053 : /**
1054 : * @brief The CADDimensionRadiusObject class
1055 : */
1056 0 : class CADDimensionRadiusObject CPL_NON_FINAL: public CADDimensionObject
1057 : {
1058 : public:
1059 : explicit CADDimensionRadiusObject(ObjectType typeIn = DIMENSION_RADIUS);
1060 : ~CADDimensionRadiusObject() override;
1061 :
1062 : CADVector vert15pt;
1063 : double dfLeaderLen;
1064 : };
1065 :
1066 : /**
1067 : * @brief The CADDimensionDiameterObject class
1068 : */
1069 0 : class CADDimensionDiameterObject final: public CADDimensionRadiusObject
1070 : {
1071 : public:
1072 : CADDimensionDiameterObject();
1073 : ~CADDimensionDiameterObject() override;
1074 : };
1075 :
1076 : /**
1077 : * @brief The CADImageObject class
1078 : */
1079 0 : class CADImageObject final: public CADEntityObject
1080 : {
1081 : public:
1082 : CADImageObject();
1083 : ~CADImageObject() override;
1084 :
1085 : long dClassVersion;
1086 : CADVector vertInsertion;
1087 : CADVector vectUDirection;
1088 : CADVector vectVDirection;
1089 : double dfSizeX;
1090 : double dfSizeY;
1091 : /* display properties (bit coded), 1==show image,
1092 : 2==show image when not aligned with screen, 4==use
1093 : clipping boundary, 8==transparency on */
1094 : short dDisplayProps;
1095 :
1096 : bool bClipping;
1097 : unsigned char dBrightness;
1098 : unsigned char dContrast;
1099 : unsigned char dFade;
1100 : bool bClipMode; // R2010+
1101 :
1102 : short dClipBoundaryType;
1103 :
1104 : long nNumberVerticesInClipPolygon;
1105 : std::vector<CADVector> avertClippingPolygonVertices;
1106 :
1107 : CADHandle hImageDef;
1108 : CADHandle hImageDefReactor;
1109 : };
1110 :
1111 : /**
1112 : * @brief The CADImageDefReactorObject class
1113 : */
1114 0 : class CADImageDefReactorObject CPL_NON_FINAL: public CADBaseControlObject
1115 : {
1116 : public:
1117 : explicit CADImageDefReactorObject(ObjectType typeIn = IMAGEDEFREACTOR);
1118 : ~CADImageDefReactorObject() override;
1119 :
1120 : long dClassVersion;
1121 : CADHandle hParentHandle;
1122 : std::vector<CADHandle> hReactors;
1123 : CADHandle hXDictionary;
1124 : };
1125 :
1126 : /**
1127 : * @brief The CADImageDefObject class
1128 : */
1129 0 : class CADImageDefObject final: public CADImageDefReactorObject
1130 : {
1131 : public:
1132 : CADImageDefObject();
1133 : ~CADImageDefObject() override;
1134 :
1135 : double dfXImageSizeInPx;
1136 : double dfYImageSizeInPx;
1137 : std::string sFilePath;
1138 : bool bIsLoaded;
1139 : unsigned char dResUnits; // 0 == none, 2 == centimeters, 5 == inches
1140 : double dfXPixelSize; // size of 1 pixel in autocad units
1141 : double dfYPixelSize;
1142 : };
1143 :
1144 : /**
1145 : * @brief The CADMTextObject class
1146 : */
1147 4 : class CADMTextObject final: public CADEntityObject
1148 : {
1149 : public:
1150 : CADMTextObject();
1151 : ~CADMTextObject() override;
1152 :
1153 : CADVector vertInsertionPoint;
1154 : CADVector vectExtrusion;
1155 : CADVector vectXAxisDir;
1156 : double dfRectWidth;
1157 : double dfTextHeight;
1158 : short dAttachment; // TODO: meaning unknown
1159 : short dDrawingDir;
1160 : double dfExtents; // TODO: meaning unknown
1161 : double dfExtentsWidth; // TODO: meaning unknown
1162 : std::string sTextValue;
1163 : short dLineSpacingStyle;
1164 : double dLineSpacingFactor;
1165 : bool bUnknownBit;
1166 : long dBackgroundFlags;
1167 : long dBackgroundScaleFactor;
1168 : short dBackgroundColor;
1169 : long dBackgroundTransparency;
1170 : CADHandle hStyle;
1171 : };
1172 :
1173 : /**
1174 : * @brief Linestyle data structure
1175 : */
1176 : typedef struct _linestyle
1177 : {
1178 : short nNumSegParams;
1179 : std::vector<double> adfSegparms;
1180 : short nAreaFillParams;
1181 : std::vector<double> adfAreaFillParameters;
1182 : } CADLineStyle;
1183 :
1184 : /**
1185 : * @brief MLine vertex data structure
1186 : */
1187 : typedef struct _mlinevertex
1188 : {
1189 : CADVector vertPosition;
1190 : CADVector vectDirection;
1191 : CADVector vectMIterDirection;
1192 : std::vector<CADLineStyle> astLStyles;
1193 : } CADMLineVertex;
1194 :
1195 : /**
1196 : * @brief The CADMLineObject class
1197 : */
1198 0 : class CADMLineObject final: public CADEntityObject
1199 : {
1200 : public:
1201 : CADMLineObject();
1202 : ~CADMLineObject() override;
1203 :
1204 : double dfScale;
1205 : unsigned char dJust;
1206 : CADVector vertBasePoint;
1207 : CADVector vectExtrusion;
1208 : short dOpenClosed; // 1 open, 3 closed
1209 : unsigned char nLinesInStyle;
1210 : short nNumVertices;
1211 :
1212 : std::vector<CADMLineVertex> avertVertices;
1213 :
1214 : CADHandle hMLineStyle;
1215 : };
1216 :
1217 : /**
1218 : * @brief The CAD3DFaceObject class
1219 : */
1220 0 : class CAD3DFaceObject final: public CADEntityObject
1221 : {
1222 : public:
1223 : CAD3DFaceObject();
1224 : ~CAD3DFaceObject() override;
1225 :
1226 : bool bHasNoFlagInd; // 2000+
1227 : bool bZZero;
1228 : std::vector<CADVector> avertCorners;
1229 : short dInvisFlags;
1230 : };
1231 :
1232 : /**
1233 : * @brief The CADPolylinePFaceObject class
1234 : */
1235 0 : class CADPolylinePFaceObject final: public CADEntityObject
1236 : {
1237 : public:
1238 : CADPolylinePFaceObject();
1239 : ~CADPolylinePFaceObject() override;
1240 :
1241 : short nNumVertices;
1242 : short nNumFaces;
1243 : long nObjectsOwned;
1244 : std::vector<CADHandle> hVertices; // content really depends on DWG version.
1245 : CADHandle hSeqend;
1246 : };
1247 :
1248 : #ifdef TODO
1249 : /**
1250 : * @brief The CADHatchObject class TODO: not completed
1251 : */
1252 : class CADHatchObject final: public CADEntityObject
1253 : {
1254 : public:
1255 : typedef struct
1256 : {
1257 : double dfUnknowndouble;
1258 : short dUnknownshort;
1259 : long dRGBColor;
1260 : char dIgnoredColorByte;
1261 : } _gradient_color;
1262 :
1263 : CADHatchObject();
1264 : ~CADHatchObject() override;
1265 :
1266 : long dIsGradientFill; // 2004+
1267 : long dReserved;
1268 : double dfGradientAngle;
1269 : double dfGradientShift;
1270 : long dSingleColorGrad;
1271 : double dfGradientTint;
1272 : long nGradientColors;
1273 : std::vector<_gradient_color> astGradientColors;
1274 :
1275 : std::string sGradientName;
1276 :
1277 : double dfZCoord; // always X = Y = 0.0
1278 : CADVector vectExtrusion;
1279 : std::string sHatchName;
1280 : bool bSolidFill;
1281 : bool bAssociative;
1282 : long nNumPaths;
1283 :
1284 : typedef struct
1285 : {
1286 : char dPathTypeStatus;
1287 : CADVector vectPt0;
1288 : CADVector vectPt1;
1289 : } _path_segment;
1290 : };
1291 : #endif
1292 :
1293 : /**
1294 : * @brief The CADXRecordObject class
1295 : */
1296 48 : class CADXRecordObject final: public CADBaseControlObject
1297 : {
1298 : public:
1299 : CADXRecordObject();
1300 : ~CADXRecordObject() override;
1301 :
1302 : long nNumDataBytes;
1303 : std::vector<char> abyDataBytes;
1304 : short dCloningFlag;
1305 : std::vector<std::pair<short, std::vector<char> > > astXRecordData;
1306 : CADHandle hParentHandle;
1307 : std::vector<CADHandle> hReactors;
1308 : CADHandle hXDictionary;
1309 : std::vector<CADHandle> hObjIdHandles;
1310 : };
1311 :
1312 : #endif //CADOBJECTS_H
|