forked from solvespace/libdxfrw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drw_entities.h
1572 lines (1394 loc) · 53.1 KB
/
drw_entities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011-2015 José F. Soriano, [email protected] **
** **
** This library is free software, licensed under the terms of the GNU **
** General Public License as published by the Free Software Foundation, **
** either version 2 of the License, or (at your option) any later version. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DRW_ENTITIES_H
#define DRW_ENTITIES_H
#include <string>
#include <vector>
#include <list>
#include "drw_base.h"
class dxfReader;
class dwgBuffer;
class DRW_Polyline;
namespace DRW {
//! Entity's type.
enum ETYPE {
E3DFACE,
// E3DSOLID, //encripted propietry data
// ACAD_PROXY_ENTITY,
ARC,
// ATTDEF,
// ATTRIB,
BLOCK,// and ENDBLK
// BODY, //encripted propietry data
CIRCLE,
DIMENSION,
DIMALIGNED,
DIMLINEAR,
DIMRADIAL,
DIMDIAMETRIC,
DIMANGULAR,
DIMANGULAR3P,
DIMORDINATE,
ELLIPSE,
HATCH,
// HELIX,
IMAGE,
INSERT,
LEADER,
// LIGHT,
LINE,
LWPOLYLINE,
// MESH,
// MLINE,
// MLEADERSTYLE,
// MLEADER,
MTEXT,
// OLEFRAME,
// OLE2FRAME,
POINT,
POLYLINE,
RAY,
// REGION, //encripted propietry data
// SECTION,
// SEQEND,//not needed?? used in polyline and insert/attrib and dwg
// SHAPE,
SOLID,
SPLINE,
// SUN,
// SURFACE, //encripted propietry data can be four types
// TABLE,
TEXT,
// TOLERANCE,
TRACE,
UNDERLAY,
VERTEX,
VIEWPORT,
// WIPEOUT, //WIPEOUTVARIABLE
XLINE,
UNKNOWN
};
}
//only in DWG: MINSERT, 5 types of vertex, 4 types of polylines: 2d, 3d, pface & mesh
//shape, dictionary, MLEADER, MLEADERSTYLE
#define SETENTFRIENDS friend class dxfRW; \
friend class dwgReader;
//! Base class for entities
/*!
* Base class for entities
* @author Rallaz
*/
class DRW_Entity {
SETENTFRIENDS
public:
//initializes default values
DRW_Entity() {
eType = DRW::UNKNOWN;
handle = parentHandle = DRW::NoHandle; //no handle (0)
lineType = "BYLAYER";
color = DRW::ColorByLayer; // default BYLAYER (256)
ltypeScale = 1.0;
visible = true;
layer = "0";
lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29)
space = DRW::ModelSpace; // default ModelSpace (0)
haveExtrusion = false;
color24 = -1; //default -1 not set
numProxyGraph = 0;
shadow = DRW::CastAndReceieveShadows;
material = DRW::MaterialByLayer;
plotStyle = DRW::DefaultPlotStyle;
transparency = DRW::Opaque;
nextEntLink = prevEntLink = 0;
numReactors = xDictFlag = 0;
curr = NULL;
ownerHandle= false;
}
DRW_Entity(const DRW_Entity& e) {
eType = e.eType;
handle = e.handle;
parentHandle = e.parentHandle; //no handle (0)
lineType = e.lineType;
color = e.color; // default BYLAYER (256)
ltypeScale = e.ltypeScale;
visible = e.visible;
layer = e.layer;
lWeight = e.lWeight;
space = e.space;
haveExtrusion = e.haveExtrusion;
color24 = e.color24; //default -1 not set
numProxyGraph = e.numProxyGraph;
shadow = e.shadow;
material = e.material;
plotStyle = e.plotStyle;
transparency = e.transparency;
nextEntLink = e.nextEntLink;
prevEntLink = e.prevEntLink;
numReactors = e.numReactors;
xDictFlag = e.xDictFlag;
curr = NULL;
ownerHandle= false;
// curr = e.curr;
for (std::vector<DRW_Variant*>::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){
extData.push_back(new DRW_Variant(*(*it)));
}
}
virtual ~DRW_Entity() {
for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it)
delete *it;
extData.clear();
}
void reset(){
for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it)
delete *it;
extData.clear();
}
virtual void applyExtrusion() = 0;
void setWidthMm(double millimeters) {
if(millimeters < 0.0) {
lWeight = DRW_LW_Conv::widthByLayer;
return;
}
if(millimeters > 2.11) millimeters = 2.11;
lWeight = DRW_LW_Conv::dxfInt2lineWidth(int(floor(millimeters * 100.0)));
}
protected:
//parses dxf pair to read entity
bool parseCode(int code, dxfReader *reader);
//calculates extrusion axis (normal vector)
void calculateAxis(DRW_Coord extPoint);
//apply extrusion to @extPoint and return data in @point
void extrudePoint(DRW_Coord extPoint, DRW_Coord *point);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0)=0;
//parses dwg common start part to read entity
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0);
//parses dwg common handles part to read entity
bool parseDwgEntHandle(DRW::Version version, dwgBuffer *buf);
//parses dxf 102 groups to read entity
bool parseDxfGroups(int code, dxfReader *reader);
public:
enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */
duint32 handle; /*!< entity identifier, code 5 */
std::list<std::list<DRW_Variant> > appData; /*!< list of application data, code 102 */
duint32 parentHandle; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
DRW::Space space; /*!< space indicator, code 67*/
UTF8STRING layer; /*!< layer name, code 8 */
UTF8STRING lineType; /*!< line type, code 6 */
duint32 material; /*!< hard pointer id to material object, code 347 */
int color; /*!< entity color, code 62 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */
double ltypeScale; /*!< linetype scale, code 48 */
bool visible; /*!< entity visibility, code 60 */
int numProxyGraph; /*!< Number of bytes in proxy graphics, code 92 */
std::string proxyGraphics; /*!< proxy graphics bytes, code 310 */
int color24; /*!< 24-bit color, code 420 */
std::string colorName; /*!< color name, code 430 */
int transparency; /*!< transparency, code 440 */
int plotStyle; /*!< hard pointer id to plot style object, code 390 */
DRW::ShadowMode shadow; /*!< shadow mode, code 284 */
bool haveExtrusion; /*!< set to true if the entity have extrusion*/
std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/
protected: //only for read dwg
duint8 haveNextLinks; //aka nolinks //B
duint8 plotFlags; //presence of plot style //BB
duint8 ltFlags; //presence of linetype handle //BB
duint8 materialFlag; //presence of material handle //BB
duint8 shadowFlag; //presence of shadow handle ?? (in dwg may be plotflag)//RC
dwgHandle lTypeH;
dwgHandle layerH;
duint32 nextEntLink;
duint32 prevEntLink;
bool ownerHandle;
duint8 xDictFlag;
dint32 numReactors; //
duint32 objSize; //RL 32bits object data size in bits
dint16 oType;
private:
DRW_Coord extAxisX;
DRW_Coord extAxisY;
DRW_Variant* curr;
};
//! Class to handle point entity
/*!
* Class to handle point entity
* @author Rallaz
*/
class DRW_Point : public DRW_Entity {
SETENTFRIENDS
public:
DRW_Point() {
eType = DRW::POINT;
basePoint.z = extPoint.x = extPoint.y = 0;
extPoint.z = 1;
thickness = 0;
}
virtual void applyExtrusion(){}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */
double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
// TNick: we're not handling code 50 - Angle of the X axis for
// the UCS in effect when the point was drawn
};
//! Class to handle line entity
/*!
* Class to handle line entity
* @author Rallaz
*/
class DRW_Line : public DRW_Point {
SETENTFRIENDS
public:
DRW_Line() {
eType = DRW::LINE;
secPoint.z = 0;
}
virtual void applyExtrusion(){}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */
};
//! Class to handle ray entity
/*!
* Class to handle ray entity
* @author Rallaz
*/
class DRW_Ray : public DRW_Line {
SETENTFRIENDS
public:
DRW_Ray() {
eType = DRW::RAY;
}
protected:
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
};
//! Class to handle xline entity
/*!
* Class to handle xline entity
* @author Rallaz
*/
class DRW_Xline : public DRW_Ray {
public:
DRW_Xline() {
eType = DRW::XLINE;
}
};
//! Class to handle circle entity
/*!
* Class to handle circle entity
* @author Rallaz
*/
class DRW_Circle : public DRW_Point {
SETENTFRIENDS
public:
DRW_Circle() {
eType = DRW::CIRCLE;
}
virtual void applyExtrusion();
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
double radious; /*!< radius, code 40 */
};
//! Class to handle arc entity
/*!
* Class to handle arc entity
* @author Rallaz
*/
class DRW_Arc : public DRW_Circle {
SETENTFRIENDS
public:
DRW_Arc() {
eType = DRW::ARC;
isccw = 1;
}
virtual void applyExtrusion();
//! center point in OCS
const DRW_Coord & center() { return basePoint; }
//! the radius of the circle
double radius() { return radious; }
//! start angle in radians
double startAngle() { return staangle; }
//! end angle in radians
double endAngle() { return endangle; }
//! thickness
double thick() { return thickness; }
//! extrusion
const DRW_Coord & extrusion() { return extPoint; }
protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
double staangle; /*!< start angle, code 50 in radians*/
double endangle; /*!< end angle, code 51 in radians */
int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
};
//! Class to handle ellipse entity
/*!
* Class to handle ellipse and elliptic arc entity
* Note: start/end parameter are in radians for ellipse entity but
* for hatch boundary are in degrees
* @author Rallaz
*/
class DRW_Ellipse : public DRW_Line {
SETENTFRIENDS
public:
DRW_Ellipse() {
eType = DRW::ELLIPSE;
isccw = 1;
}
void toPolyline(DRW_Polyline *pol, int parts = 128);
virtual void applyExtrusion();
protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
private:
void correctAxis();
public:
double ratio; /*!< ratio, code 40 */
double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/
double endparam; /*!< end parameter, code 42, 2*PI for full ellipse */
int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
};
//! Class to handle trace entity
/*!
* Class to handle trace entity
* @author Rallaz
*/
class DRW_Trace : public DRW_Line {
SETENTFRIENDS
public:
DRW_Trace() {
eType = DRW::TRACE;
thirdPoint.z = 0;
fourPoint.z = 0;
}
virtual void applyExtrusion();
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
DRW_Coord fourPoint; /*!< four point, code 13, 23 & 33 */
};
//! Class to handle solid entity
/*!
* Class to handle solid entity
* @author Rallaz
*/
class DRW_Solid : public DRW_Trace {
SETENTFRIENDS
public:
DRW_Solid() {
eType = DRW::SOLID;
}
protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
//! first corner (2D)
const DRW_Coord & firstCorner() { return basePoint; }
//! second corner (2D)
const DRW_Coord & secondCorner() { return secPoint; }
//! third corner (2D)
const DRW_Coord & thirdCorner() { return thirdPoint; }
//! fourth corner (2D)
const DRW_Coord & fourthCorner() { return thirdPoint; }
//! thickness
double thick() { return thickness; }
//! elevation
double elevation() { return basePoint.z; }
//! extrusion
const DRW_Coord & extrusion() { return extPoint; }
};
//! Class to handle 3dface entity
/*!
* Class to handle 3dface entity
* @author Rallaz
*/
class DRW_3Dface : public DRW_Trace {
SETENTFRIENDS
public:
enum InvisibleEdgeFlags {
NoEdge = 0x00,
FirstEdge = 0x01,
SecodEdge = 0x02,
ThirdEdge = 0x04,
FourthEdge = 0x08,
AllEdges = 0x0F
};
DRW_3Dface() {
eType = DRW::E3DFACE;
invisibleflag = 0;
}
virtual void applyExtrusion(){}
//! first corner in WCS
const DRW_Coord & firstCorner() { return basePoint; }
//! second corner in WCS
const DRW_Coord & secondCorner() { return secPoint; }
//! third corner in WCS
const DRW_Coord & thirdCorner() { return thirdPoint; }
//! fourth corner in WCS
const DRW_Coord & fourthCorner() { return fourPoint; }
//! edge visibility flags
InvisibleEdgeFlags edgeFlags() { return (InvisibleEdgeFlags)invisibleflag; }
protected:
//! interpret code in dxf reading process or dispatch to inherited class
void parseCode(int code, dxfReader *reader);
//! interpret dwg data (was already determined to be part of this object)
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
int invisibleflag; /*!< invisible edge flag, code 70 */
};
//! Class to handle block entries
/*!
* Class to handle block entries
* @author Rallaz
*/
class DRW_Block : public DRW_Point {
SETENTFRIENDS
public:
DRW_Block() {
eType = DRW::BLOCK;
layer = "0";
flags = 0;
name = "*U0";
isEnd = false;
}
virtual void applyExtrusion(){}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
UTF8STRING name; /*!< block name, code 2 */
int flags; /*!< block type, code 70 */
private:
bool isEnd; //for dwg parsing
};
//! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Insert : public DRW_Point {
SETENTFRIENDS
public:
DRW_Insert() {
eType = DRW::INSERT;
xscale = 1;
yscale = 1;
zscale = 1;
angle = 0;
colcount = 1;
rowcount = 1;
colspace = 0;
rowspace = 0;
}
virtual void applyExtrusion(){DRW_Point::applyExtrusion();}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
UTF8STRING name; /*!< block name, code 2 */
double xscale; /*!< x scale factor, code 41 */
double yscale; /*!< y scale factor, code 42 */
double zscale; /*!< z scale factor, code 43 */
double angle; /*!< rotation angle in radians, code 50 */
int colcount; /*!< column count, code 70 */
int rowcount; /*!< row count, code 71 */
double colspace; /*!< column space, code 44 */
double rowspace; /*!< row space, code 45 */
public: //only for read dwg
dwgHandle blockRecH;
dwgHandle seqendH; //RLZ: on implement attrib remove this handle from obj list (see pline/vertex code)
};
//! Class to handle lwpolyline entity
/*!
* Class to handle lwpolyline entity
* @author Rallaz
*/
class DRW_LWPolyline : public DRW_Entity {
SETENTFRIENDS
public:
DRW_LWPolyline() {
eType = DRW::LWPOLYLINE;
elevation = thickness = width = 0.0;
flags = 0;
extPoint.x = extPoint.y = 0;
extPoint.z = 1;
vertex = NULL;
}
DRW_LWPolyline(const DRW_LWPolyline& p):DRW_Entity(p){
this->eType = DRW::LWPOLYLINE;
this->elevation = p.elevation;
this->thickness = p.thickness;
this->width = p.width;
this->flags = p.flags;
this->extPoint = p.extPoint;
this->vertex = NULL;
for (unsigned i=0; i<p.vertlist.size(); i++)// RLZ ok or new
this->vertlist.push_back( new DRW_Vertex2D( *(p.vertlist.at(i)) ) );
this->vertex = NULL;
}
~DRW_LWPolyline() {
for(DRW_Vertex2D *item : vertlist) delete item;
}
virtual void applyExtrusion();
void addVertex (DRW_Vertex2D v) {
DRW_Vertex2D *vert = new DRW_Vertex2D();
vert->x = v.x;
vert->y = v.y;
vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth;
vert->bulge = v.bulge;
vertlist.push_back(vert);
}
DRW_Vertex2D *addVertex () {
DRW_Vertex2D *vert = new DRW_Vertex2D();
vert->stawidth = 0;
vert->endwidth = 0;
vert->bulge = 0;
vertlist.push_back(vert);
return vert;
}
protected:
void parseCode(int code, dxfReader *reader);
bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
public:
int vertexnum; /*!< number of vertex, code 90 */
int flags; /*!< polyline flag, code 70, default 0 */
double width; /*!< constant width, code 43 */
double elevation; /*!< elevation, code 38 */
double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
DRW_Vertex2D *vertex; /*!< current vertex to add data */
std::vector<DRW_Vertex2D *> vertlist; /*!< vertex list */
};
//! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Text : public DRW_Line {
SETENTFRIENDS
public:
//! Vertical alignments.
enum VAlign {
VBaseLine = 0, /*!< Top = 0 */
VBottom, /*!< Bottom = 1 */
VMiddle, /*!< Middle = 2 */
VTop /*!< Top = 3 */
};
//! Horizontal alignments.
enum HAlign {
HLeft = 0, /*!< Left = 0 */
HCenter, /*!< Centered = 1 */
HRight, /*!< Right = 2 */
HAligned, /*!< Aligned = 3 (if VAlign==0) */
HMiddle, /*!< middle = 4 (if VAlign==0) */
HFit /*!< fit into point = 5 (if VAlign==0) */
};
DRW_Text() {
eType = DRW::TEXT;
angle = 0;
widthscale = 1;
oblique = 0;
style = "STANDARD";
textgen = 0;
alignH = HLeft;
alignV = VBaseLine;
}
virtual void applyExtrusion(){} //RLZ TODO
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
double height; /*!< height text, code 40 */
UTF8STRING text; /*!< text string, code 1 */
double angle; /*!< rotation angle in degrees (360), code 50 */
double widthscale; /*!< width factor, code 41 */
double oblique; /*!< oblique angle, code 51 */
UTF8STRING style; /*!< style name, code 7 */
int textgen; /*!< text generation, code 71 */
enum HAlign alignH; /*!< horizontal align, code 72 */
enum VAlign alignV; /*!< vertical align, code 73 */
dwgHandle styleH; /*!< handle for text style */
};
//! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_MText : public DRW_Text {
SETENTFRIENDS
public:
//! Attachments.
enum Attach {
TopLeft = 1,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
};
DRW_MText() {
eType = DRW::MTEXT;
interlin = 1;
alignV = (VAlign)TopLeft;
textgen = 1;
haveXAxis = false; //if true needed to recalculate angle
}
protected:
void parseCode(int code, dxfReader *reader);
void updateAngle(); //recalculate angle if 'haveXAxis' is true
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
double interlin; /*!< width factor, code 44 */
private:
bool haveXAxis;
};
//! Class to handle vertex
/*!
* Class to handle vertex for polyline entity
* @author Rallaz
*/
class DRW_Vertex : public DRW_Point {
SETENTFRIENDS
public:
DRW_Vertex() {
eType = DRW::VERTEX;
stawidth = endwidth = bulge = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0;
}
DRW_Vertex(double sx, double sy, double sz, double b) {
stawidth = endwidth = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0;
basePoint.x = sx;
basePoint.y =sy;
basePoint.z =sz;
bulge = b;
}
protected:
void parseCode(int code, dxfReader *reader);
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0, double el=0);
virtual bool parseDwg(DRW::Version version, dwgBuffer* buf, duint32 bs=0){
DRW_UNUSED(version); DRW_UNUSED(buf); DRW_UNUSED(bs); return true;}
public:
double stawidth; /*!< Start width, code 40 */
double endwidth; /*!< End width, code 41 */
double bulge; /*!< bulge, code 42 */
int flags; /*!< vertex flag, code 70, default 0 */
double tgdir; /*!< curve fit tangent direction, code 50 */
int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */
int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */
int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */
int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */
int identifier; /*!< vertex identifier, code 91, default 0 */
};
//! Class to handle polyline entity
/*!
* Class to handle polyline entity
* @author Rallaz
*/
class DRW_Polyline : public DRW_Point {
SETENTFRIENDS
public:
DRW_Polyline() {
eType = DRW::POLYLINE;
defstawidth = defendwidth = 0.0;
basePoint.x = basePoint.y = 0.0;
flags = vertexcount = facecount = 0;
smoothM = smoothN = curvetype = 0;
}
DRW_Polyline(const DRW_Polyline& p) : DRW_Point(p) {
flags = p.flags ;
defstawidth = p.defstawidth;
defendwidth = p.defendwidth;
vertexcount = p.vertexcount;
facecount = p.facecount ;
smoothM = p.smoothM ;
smoothN = p.smoothN ;
curvetype = p.curvetype ;
for (unsigned i=0; i<p.vertlist.size(); i++)// RLZ ok or new
this->vertlist.push_back( new DRW_Vertex( *(p.vertlist.at(i)) ) );
}
~DRW_Polyline() {
for(DRW_Vertex *item : vertlist) delete item;
}
void addVertex (DRW_Vertex v) {
DRW_Vertex *vert = new DRW_Vertex();
vert->basePoint.x = v.basePoint.x;
vert->basePoint.y = v.basePoint.y;
vert->basePoint.z = v.basePoint.z;
vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth;
vert->bulge = v.bulge;
vertlist.push_back(vert);
}
void appendVertex (DRW_Vertex *v) {
vertlist.push_back(v);
}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
int flags; /*!< polyline flag, code 70, default 0 */
double defstawidth; /*!< Start width, code 40, default 0 */
double defendwidth; /*!< End width, code 41, default 0 */
int vertexcount; /*!< polygon mesh M vertex or polyface vertex num, code 71, default 0 */
int facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */
int smoothM; /*!< smooth surface M density, code 73, default 0 */
int smoothN; /*!< smooth surface M density, code 74, default 0 */
int curvetype; /*!< curves & smooth surface type, code 75, default 0 */
std::vector<DRW_Vertex *> vertlist; /*!< vertex list */
private:
std::list<duint32>hadlesList; //list of handles, only in 2004+
duint32 firstEH; //handle of first entity, only in pre-2004
duint32 lastEH; //handle of last entity, only in pre-2004
dwgHandle seqEndH; //handle of SEQEND entity
};
//! Class to handle spline entity
/*!
* Class to handle spline entity
* @author Rallaz
*/
class DRW_Spline : public DRW_Entity {
SETENTFRIENDS
public:
DRW_Spline() {
eType = DRW::SPLINE;
flags = nknots = ncontrol = nfit = 0;
tolknot = tolcontrol = tolfit = 0.0000001;
}
DRW_Spline(const DRW_Spline& p):DRW_Entity(p){
eType = DRW::SPLINE;
normalVec = p.normalVec ;
tgStart = p.tgStart ;
tgEnd = p.tgEnd ;
flags = p.flags ;
degree = p.degree ;
nknots = p.nknots ;
ncontrol = p.ncontrol ;
nfit = p.nfit ;
tolknot = p.tolknot ;
tolcontrol = p.tolcontrol;
tolfit = p.tolfit ;
for(double v : p.knotslist) knotslist.push_back(v);
for(double v : p.weightlist) weightlist.push_back(v);
for(DRW_Coord *v : p.controllist) controllist.push_back(new DRW_Coord(*v));
for(DRW_Coord *v : p.fitlist) fitlist.push_back(new DRW_Coord(*v));
}
~DRW_Spline() {
for(DRW_Coord *item : controllist) delete item;
for(DRW_Coord *item : fitlist) delete item;
}
virtual void applyExtrusion(){}
protected:
void parseCode(int code, dxfReader *reader);
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
public:
// double ex; /*!< normal vector x coordinate, code 210 */
// double ey; /*!< normal vector y coordinate, code 220 */
// double ez; /*!< normal vector z coordinate, code 230 */
DRW_Coord normalVec; /*!< normal vector, code 210, 220, 230 */
DRW_Coord tgStart; /*!< start tangent, code 12, 22, 32 */
// double tgsx; /*!< start tangent x coordinate, code 12 */
// double tgsy; /*!< start tangent y coordinate, code 22 */
// double tgsz; /*!< start tangent z coordinate, code 32 */
DRW_Coord tgEnd; /*!< end tangent, code 13, 23, 33 */
// double tgex; /*!< end tangent x coordinate, code 13 */
// double tgey; /*!< end tangent y coordinate, code 23 */
// double tgez; /*!< end tangent z coordinate, code 33 */
int flags; /*!< spline flag, code 70 */
int degree; /*!< degree of the spline, code 71 */
dint32 nknots; /*!< number of knots, code 72, default 0 */
dint32 ncontrol; /*!< number of control points, code 73, default 0 */
dint32 nfit; /*!< number of fit points, code 74, default 0 */
double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */
double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */
double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */
std::vector<double> knotslist; /*!< knots list, code 40 */
std::vector<double> weightlist; /*!< weight list, code 41 */
std::vector<DRW_Coord *> controllist; /*!< control points list, code 10, 20 & 30 */
std::vector<DRW_Coord *> fitlist; /*!< fit points list, code 11, 21 & 31 */
private:
DRW_Coord *controlpoint; /*!< current control point to add data */
DRW_Coord *fitpoint; /*!< current fit point to add data */
};
//! Class to handle hatch loop
/*!
* Class to handle hatch loop
* @author Rallaz
*/
class DRW_HatchLoop {
public:
DRW_HatchLoop(int t) {
type = t;
numedges = 0;
}
~DRW_HatchLoop() {
// for(DRW_LWPolyline *item : pollist) delete item;
for(DRW_Entity *item : objlist) delete item;
}
void update() {
numedges = (int)objlist.size();
}
public:
int type; /*!< boundary path type, code 92, polyline=2, default=0 */
int numedges; /*!< number of edges (if not a polyline), code 93 */
//TODO: store lwpolylines as entities
// std::vector<DRW_LWPolyline *> pollist; /*!< polyline list */
std::vector<DRW_Entity *> objlist; /*!< entities list */
};
//! Class to handle hatch entity
/*!
* Class to handle hatch entity
* @author Rallaz
*/
//TODO: handle lwpolylines, splines and ellipses
class DRW_Hatch : public DRW_Point {
SETENTFRIENDS
public:
DRW_Hatch() {
eType = DRW::HATCH;
angle = scale = 0.0;
basePoint.x = basePoint.y = basePoint.z = 0.0;
loopsnum = hstyle = associative = 0;
solid = hpattern = 1;
deflines = doubleflag = 0;
loop = NULL;
clearEntities();
}
~DRW_Hatch() {
for(DRW_HatchLoop *item : looplist) delete item;