1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _DXFENTRD_HXX
25 #define _DXFENTRD_HXX
26
27 #include <dxfgrprd.hxx>
28 #include <dxfvec.hxx>
29
30 #include <deque>
31
32 typedef std::deque< Point > DXFPointArray;
33
34 //------------------------------------------------------------------------------
35 //------------------------- Art eines Entity -----------------------------------
36 //------------------------------------------------------------------------------
37
38 enum DXFEntityType {
39 DXF_LINE,
40 DXF_POINT,
41 DXF_CIRCLE,
42 DXF_ARC,
43 DXF_TRACE,
44 DXF_SOLID,
45 DXF_TEXT,
46 DXF_SHAPE,
47 DXF_INSERT,
48 DXF_ATTDEF,
49 DXF_ATTRIB,
50 DXF_POLYLINE,
51 DXF_VERTEX,
52 DXF_SEQEND,
53 DXF_3DFACE,
54 DXF_DIMENSION,
55 DXF_LWPOLYLINE,
56 DXF_HATCH
57 };
58
59 //------------------------------------------------------------------------------
60 //---------------------- Basisklasse fuer ein Entity ---------------------------
61 //------------------------------------------------------------------------------
62
63 class DXFBasicEntity {
64
65 public:
66
67 DXFBasicEntity * pSucc;
68 // Zeiger auf naechstes Entity (in der Liste DXFEntities.pFirst)
69
70 DXFEntityType eType;
71 // Art des Entitys (Linie oder Kreis oder was)
72
73 // Eigenschaftenm, die alle Entities besitzen, jeweils
74 // durch den Gruppencode kommentiert:
75 char sLayer[DXF_MAX_STRING_LEN+1]; // 8
76 char sLineType[DXF_MAX_STRING_LEN+1]; // 6
77 double fElevation; // 38
78 double fThickness; // 39
79 long nColor; // 62
80 long nSpace; // 67
81 DXFVector aExtrusion; // 210,220,230
82
83 protected:
84
85 DXFBasicEntity(DXFEntityType eThisType);
86 // Konstruktoren der Entities initialiseren immer mit Defaultwerten.
87
88 public:
89
90 virtual ~DXFBasicEntity();
91 virtual void Read(DXFGroupReader & rDGR);
92 // Liest die Prameter ein, bis zur naechten 0-Gruppe
93
94 protected:
95
96 virtual void EvaluateGroup(DXFGroupReader & rDGR);
97 // Diese Methode wird durch Read() fuer jeden Parameter (bzw. fuer jede
98 // Gruppe) aufgerufen.
99 // Sofern der Gruppencode dem Entity bekannt ist, wird der entsprechende
100 // Parameter geholt.
101
102 };
103
104 //------------------------------------------------------------------------------
105 //---------------- die verschiedenen Arten von Entyties ------------------------
106 //------------------------------------------------------------------------------
107
108 //--------------------------Line------------------------------------------------
109
110 class DXFLineEntity : public DXFBasicEntity {
111
112 public:
113
114 DXFVector aP0; // 10,20,30
115 DXFVector aP1; // 11,21,31
116
117 DXFLineEntity();
118
119 protected:
120
121 virtual void EvaluateGroup(DXFGroupReader & rDGR);
122 };
123
124 //--------------------------Point-----------------------------------------------
125
126 class DXFPointEntity : public DXFBasicEntity {
127
128 public:
129
130 DXFVector aP0; // 10,20,30
131
132 DXFPointEntity();
133
134 protected:
135
136 virtual void EvaluateGroup(DXFGroupReader & rDGR);
137 };
138
139 //--------------------------Circle----------------------------------------------
140
141 class DXFCircleEntity : public DXFBasicEntity {
142
143 public:
144
145 DXFVector aP0; // 10,20,30
146 double fRadius; // 40
147
148 DXFCircleEntity();
149
150 protected:
151
152 virtual void EvaluateGroup(DXFGroupReader & rDGR);
153 };
154
155 //--------------------------Arc-------------------------------------------------
156
157 class DXFArcEntity : public DXFBasicEntity {
158
159 public:
160
161 DXFVector aP0; // 10,20,30
162 double fRadius; // 40
163 double fStart; // 50
164 double fEnd; // 51
165
166 DXFArcEntity();
167
168 protected:
169
170 virtual void EvaluateGroup(DXFGroupReader & rDGR);
171 };
172
173 //--------------------------Trace-----------------------------------------------
174
175 class DXFTraceEntity : public DXFBasicEntity {
176
177 public:
178
179 DXFVector aP0; // 10,20,30
180 DXFVector aP1; // 11,21,31
181 DXFVector aP2; // 12,22,32
182 DXFVector aP3; // 13,23,33
183
184 DXFTraceEntity();
185
186 protected:
187
188 virtual void EvaluateGroup(DXFGroupReader & rDGR);
189 };
190
191 //--------------------------Solid-----------------------------------------------
192
193 class DXFSolidEntity : public DXFBasicEntity {
194
195 public:
196
197 DXFVector aP0; // 10,20,30
198 DXFVector aP1; // 11,21,31
199 DXFVector aP2; // 12,22,32
200 DXFVector aP3; // 13,23,33
201
202 DXFSolidEntity();
203
204 protected:
205
206 virtual void EvaluateGroup(DXFGroupReader & rDGR);
207 };
208
209 //--------------------------Text------------------------------------------------
210
211 class DXFTextEntity : public DXFBasicEntity {
212
213 public:
214
215 DXFVector aP0; // 10,20,30
216 double fHeight; // 40
217 char sText[DXF_MAX_STRING_LEN+1]; // 1
218 double fRotAngle; // 50
219 double fXScale; // 41
220 double fOblAngle; // 42
221 char sStyle[DXF_MAX_STRING_LEN+1]; // 7
222 long nGenFlags; // 71
223 long nHorzJust; // 72
224 long nVertJust; // 73
225 DXFVector aAlign; // 11,21,31
226
227 DXFTextEntity();
228
229 protected:
230
231 virtual void EvaluateGroup(DXFGroupReader & rDGR);
232 };
233
234 //--------------------------Shape-----------------------------------------------
235
236 class DXFShapeEntity : public DXFBasicEntity {
237
238 public:
239
240 DXFVector aP0; // 10,20,30
241 double fSize; // 40
242 char sName[DXF_MAX_STRING_LEN+1]; // 2
243 double fRotAngle; // 50
244 double fXScale; // 41
245 double fOblAngle; // 51
246
247 DXFShapeEntity();
248
249 protected:
250
251 virtual void EvaluateGroup(DXFGroupReader & rDGR);
252 };
253
254 //--------------------------Insert----------------------------------------------
255
256 class DXFInsertEntity : public DXFBasicEntity {
257
258 public:
259
260 long nAttrFlag; // 66
261 char sName[DXF_MAX_STRING_LEN+1]; // 2
262 DXFVector aP0; // 10,20,30
263 double fXScale; // 41
264 double fYScale; // 42
265 double fZScale; // 43
266 double fRotAngle; // 50
267 long nColCount; // 70
268 long nRowCount; // 71
269 double fColSpace; // 44
270 double fRowSpace; // 45
271
272 DXFInsertEntity();
273
274 protected:
275
276 virtual void EvaluateGroup(DXFGroupReader & rDGR);
277 };
278
279 //--------------------------AttDef----------------------------------------------
280
281 class DXFAttDefEntity : public DXFBasicEntity {
282
283 public:
284
285 DXFVector aP0; // 10,20,30
286 double fHeight; // 40
287 char sDefVal[DXF_MAX_STRING_LEN+1]; // 1
288 char sPrompt[DXF_MAX_STRING_LEN+1]; // 3
289 char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
290 long nAttrFlags; // 70
291 long nFieldLen; // 73
292 double fRotAngle; // 50
293 double fXScale; // 41
294 double fOblAngle; // 51
295 char sStyle[DXF_MAX_STRING_LEN+1]; // 7
296 long nGenFlags; // 71
297 long nHorzJust; // 72
298 long nVertJust; // 74
299 DXFVector aAlign; // 11,21,31
300
301 DXFAttDefEntity();
302
303 protected:
304
305 virtual void EvaluateGroup(DXFGroupReader & rDGR);
306 };
307
308 //--------------------------Attrib----------------------------------------------
309
310 class DXFAttribEntity : public DXFBasicEntity {
311
312 public:
313
314 DXFVector aP0; // 10,20,30
315 double fHeight; // 40
316 char sText[DXF_MAX_STRING_LEN+1]; // 1
317 char sTagStr[DXF_MAX_STRING_LEN+1]; // 2
318 long nAttrFlags; // 70
319 long nFieldLen; // 73
320 double fRotAngle; // 50
321 double fXScale; // 41
322 double fOblAngle; // 51
323 char sStyle[DXF_MAX_STRING_LEN+1]; // 7
324 long nGenFlags; // 71
325 long nHorzJust; // 72
326 long nVertJust; // 74
327 DXFVector aAlign; // 11,21,31
328
329 DXFAttribEntity();
330
331 protected:
332
333 virtual void EvaluateGroup(DXFGroupReader & rDGR);
334 };
335
336 //--------------------------PolyLine--------------------------------------------
337
338 class DXFPolyLineEntity : public DXFBasicEntity {
339
340 public:
341
342 double fElevation; // 30
343 long nFlags; // 70
344 double fSWidth; // 40
345 double fEWidth; // 41
346 long nMeshMCount; // 71
347 long nMeshNCount; // 72
348 long nMDensity; // 73
349 long nNDensity; // 74
350 long nCSSType; // 75
351
352 DXFPolyLineEntity();
353
354 protected:
355
356 virtual void EvaluateGroup(DXFGroupReader & rDGR);
357 };
358
359 class DXFLWPolyLineEntity : public DXFBasicEntity
360 {
361 sal_Int32 nIndex;
362
363 public :
364
365 sal_Int32 nCount; // 90
366 sal_Int32 nFlags; // 70 1 = closed, 128 = plinegen
367 double fConstantWidth; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used)
368 double fStartWidth; // 40
369 double fEndWidth; // 41
370
371 DXFVector* pP;
372
373 DXFLWPolyLineEntity();
374 ~DXFLWPolyLineEntity();
375
376 protected :
377
378 virtual void EvaluateGroup( DXFGroupReader & rDGR );
379
380 };
381
382 //-------------------------- Hatch ---------------------------------------------
383
384 struct DXFEdgeType
385 {
386 sal_Int32 nEdgeType;
387
~DXFEdgeTypeDXFEdgeType388 virtual ~DXFEdgeType(){};
EvaluateGroupDXFEdgeType389 virtual sal_Bool EvaluateGroup( DXFGroupReader & /*rDGR*/ ){ return sal_True; };
390
391 protected :
392
DXFEdgeTypeDXFEdgeType393 DXFEdgeType( sal_Int32 EdgeType ):nEdgeType(EdgeType){};
394 };
395 struct DXFEdgeTypeLine : public DXFEdgeType
396 {
397 DXFVector aStartPoint; // 10,20
398 DXFVector aEndPoint; // 11,21
399 DXFEdgeTypeLine();
400 virtual ~DXFEdgeTypeLine();
401 virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
402 };
403 struct DXFEdgeTypeCircularArc : public DXFEdgeType
404 {
405 DXFVector aCenter; // 10,20
406 double fRadius; // 40
407 double fStartAngle; // 50
408 double fEndAngle; // 51
409 sal_Int32 nIsCounterClockwiseFlag; // 73
410 DXFEdgeTypeCircularArc();
411 virtual ~DXFEdgeTypeCircularArc();
412 virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
413 };
414 struct DXFEdgeTypeEllipticalArc : public DXFEdgeType
415 {
416 DXFVector aCenter; // 10,20
417 DXFVector aEndPoint; // 11,21
418 double fLength; // 40
419 double fStartAngle; // 50
420 double fEndAngle; // 51
421 sal_Int32 nIsCounterClockwiseFlag; // 73
422
423 DXFEdgeTypeEllipticalArc();
424 virtual ~DXFEdgeTypeEllipticalArc();
425 virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
426 };
427 struct DXFEdgeTypeSpline : public DXFEdgeType
428 {
429 sal_Int32 nDegree; // 94
430 sal_Int32 nRational; // 73
431 sal_Int32 nPeriodic; // 74
432 sal_Int32 nKnotCount; // 75
433 sal_Int32 nControlCount; // 76
434
435 DXFEdgeTypeSpline();
436 virtual ~DXFEdgeTypeSpline();
437 virtual sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
438 };
439
440 typedef std::deque< DXFEdgeType* > DXFEdgeTypeArray;
441
442 struct DXFBoundaryPathData
443 {
444 sal_Int32 nFlags; // 92
445 sal_Int32 nHasBulgeFlag; // 72
446 sal_Int32 nIsClosedFlag; // 73
447 sal_Int32 nPointCount; // 93
448 double fBulge; // 42
449 sal_Int32 nSourceBoundaryObjects; // 97
450 sal_Int32 nEdgeCount; // 93
451
452 sal_Bool bIsPolyLine;
453 sal_Int32 nPointIndex;
454
455 DXFVector* pP;
456 DXFEdgeTypeArray aEdges;
457
458 DXFBoundaryPathData();
459 ~DXFBoundaryPathData();
460
461 sal_Bool EvaluateGroup( DXFGroupReader & rDGR );
462 };
463
464 class DXFHatchEntity : public DXFBasicEntity
465 {
466 sal_Bool bIsInBoundaryPathContext;
467 sal_Int32 nCurrentBoundaryPathIndex;
468
469 public :
470
471 DXFVector aElevationPoint;
472 sal_Int32 nFlags; // 70 (solid fill = 1, pattern fill = 0)
473 sal_Int32 nAssociativityFlag; // 71 (assoiciative = 1, non-associative = 0)
474 sal_Int32 nBoundaryPathCount; // 91
475 sal_Int32 nHatchStyle; // 75 (odd parity = 0, outmost area = 1, entire area = 2 )
476 sal_Int32 nHatchPatternType; // 76 (user defined = 0, predefined = 1, custom = 2)
477 double fHatchPatternAngle; // 52 (pattern fill only)
478 double fHatchPatternScale; // 41 (pattern fill only:scale or spacing)
479 sal_Int32 nHatchDoubleFlag; // 77 (pattern fill only:double = 1, not double = 0)
480 sal_Int32 nHatchPatternDefinitionLines; // 78
481 double fPixelSize; // 47
482 sal_Int32 nNumberOfSeedPoints; // 98
483
484 DXFBoundaryPathData* pBoundaryPathData;
485
486 DXFHatchEntity();
487 ~DXFHatchEntity();
488
489 protected :
490
491 virtual void EvaluateGroup( DXFGroupReader & rDGR );
492 };
493
494
495 //--------------------------Vertex----------------------------------------------
496
497 class DXFVertexEntity : public DXFBasicEntity {
498
499 public:
500
501 DXFVector aP0; // 10,20,30
502 double fSWidth; // 40 (Wenn <0.0, dann gilt DXFPolyLine::fSWidth)
503 double fEWidth; // 41 (Wenn <0.0, dann gilt DXFPolyLine::fEWidth)
504 double fBulge; // 42
505 long nFlags; // 70
506 double fCFTDir; // 50
507
508 DXFVertexEntity();
509
510 protected:
511
512 virtual void EvaluateGroup(DXFGroupReader & rDGR);
513 };
514
515 //--------------------------SeqEnd----------------------------------------------
516
517 class DXFSeqEndEntity : public DXFBasicEntity {
518
519 public:
520
521 DXFSeqEndEntity();
522 };
523
524 //--------------------------3DFace----------------------------------------------
525
526 class DXF3DFaceEntity : public DXFBasicEntity {
527
528 public:
529
530 DXFVector aP0; // 10,20,30
531 DXFVector aP1; // 11,21,31
532 DXFVector aP2; // 12,22,32
533 DXFVector aP3; // 13,23,33
534 long nIEFlags; // 70
535
536 DXF3DFaceEntity();
537
538 protected:
539
540 virtual void EvaluateGroup(DXFGroupReader & rDGR);
541 };
542
543 //--------------------------Dimension-------------------------------------------
544
545 class DXFDimensionEntity : public DXFBasicEntity {
546
547 public:
548
549 char sPseudoBlock[DXF_MAX_STRING_LEN+1]; // 2
550
551 DXFDimensionEntity();
552
553 protected:
554
555 virtual void EvaluateGroup(DXFGroupReader & rDGR);
556 };
557
558 //------------------------------------------------------------------------------
559 //----------- Eine Menge von Entities lesen und repraesentieren ----------------
560 //------------------------------------------------------------------------------
561
562 class DXFEntities {
563
564 public:
565
566 DXFEntities();
567 ~DXFEntities();
568
569 DXFBasicEntity * pFirst; // Liste von Entities, READ ONLY!
570
571 void Read(DXFGroupReader & rDGR);
572 // Liest Entitis per rGDR aus einer DXF-Datei bis zu
573 // einem ENDBLK, ENDSEC oder EOF (der Gruppe 0).
574 // (Alle unbekannten Dinge werden uebersprungen)
575
576 void Clear();
577 // Loescht alle Entities
578 };
579
580 //------------------------------------------------------------------------------
581 //--------------------------------- inlines ------------------------------------
582 //------------------------------------------------------------------------------
583
DXFEntities()584 inline DXFEntities::DXFEntities()
585 {
586 pFirst=NULL;
587 }
588
589
~DXFEntities()590 inline DXFEntities::~DXFEntities()
591 {
592 Clear();
593 }
594
595
596 #endif
597
598
599