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