1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dxfentrd.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <dxfgrprd.hxx>
39 typedef std::deque
< Point
> DXFPointArray
;
41 //------------------------------------------------------------------------------
42 //------------------------- Art eines Entity -----------------------------------
43 //------------------------------------------------------------------------------
66 //------------------------------------------------------------------------------
67 //---------------------- Basisklasse fuer ein Entity ---------------------------
68 //------------------------------------------------------------------------------
70 class DXFBasicEntity
{
74 DXFBasicEntity
* pSucc
;
75 // Zeiger auf naechstes Entity (in der Liste DXFEntities.pFirst)
78 // Art des Entitys (Linie oder Kreis oder was)
80 // Eigenschaftenm, die alle Entities besitzen, jeweils
81 // durch den Gruppencode kommentiert:
82 char sLayer
[DXF_MAX_STRING_LEN
+1]; // 8
83 char sLineType
[DXF_MAX_STRING_LEN
+1]; // 6
84 double fElevation
; // 38
85 double fThickness
; // 39
88 DXFVector aExtrusion
; // 210,220,230
92 DXFBasicEntity(DXFEntityType eThisType
);
93 // Konstruktoren der Entities initialiseren immer mit Defaultwerten.
97 virtual ~DXFBasicEntity();
98 virtual void Read(DXFGroupReader
& rDGR
);
99 // Liest die Prameter ein, bis zur naechten 0-Gruppe
103 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
104 // Diese Methode wird durch Read() fuer jeden Parameter (bzw. fuer jede
105 // Gruppe) aufgerufen.
106 // Sofern der Gruppencode dem Entity bekannt ist, wird der entsprechende
111 //------------------------------------------------------------------------------
112 //---------------- die verschiedenen Arten von Entyties ------------------------
113 //------------------------------------------------------------------------------
115 //--------------------------Line------------------------------------------------
117 class DXFLineEntity
: public DXFBasicEntity
{
121 DXFVector aP0
; // 10,20,30
122 DXFVector aP1
; // 11,21,31
128 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
131 //--------------------------Point-----------------------------------------------
133 class DXFPointEntity
: public DXFBasicEntity
{
137 DXFVector aP0
; // 10,20,30
143 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
146 //--------------------------Circle----------------------------------------------
148 class DXFCircleEntity
: public DXFBasicEntity
{
152 DXFVector aP0
; // 10,20,30
153 double fRadius
; // 40
159 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
162 //--------------------------Arc-------------------------------------------------
164 class DXFArcEntity
: public DXFBasicEntity
{
168 DXFVector aP0
; // 10,20,30
169 double fRadius
; // 40
177 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
180 //--------------------------Trace-----------------------------------------------
182 class DXFTraceEntity
: public DXFBasicEntity
{
186 DXFVector aP0
; // 10,20,30
187 DXFVector aP1
; // 11,21,31
188 DXFVector aP2
; // 12,22,32
189 DXFVector aP3
; // 13,23,33
195 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
198 //--------------------------Solid-----------------------------------------------
200 class DXFSolidEntity
: public DXFBasicEntity
{
204 DXFVector aP0
; // 10,20,30
205 DXFVector aP1
; // 11,21,31
206 DXFVector aP2
; // 12,22,32
207 DXFVector aP3
; // 13,23,33
213 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
216 //--------------------------Text------------------------------------------------
218 class DXFTextEntity
: public DXFBasicEntity
{
222 DXFVector aP0
; // 10,20,30
223 double fHeight
; // 40
224 char sText
[DXF_MAX_STRING_LEN
+1]; // 1
225 double fRotAngle
; // 50
226 double fXScale
; // 41
227 double fOblAngle
; // 42
228 char sStyle
[DXF_MAX_STRING_LEN
+1]; // 7
229 long nGenFlags
; // 71
230 long nHorzJust
; // 72
231 long nVertJust
; // 73
232 DXFVector aAlign
; // 11,21,31
238 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
241 //--------------------------Shape-----------------------------------------------
243 class DXFShapeEntity
: public DXFBasicEntity
{
247 DXFVector aP0
; // 10,20,30
249 char sName
[DXF_MAX_STRING_LEN
+1]; // 2
250 double fRotAngle
; // 50
251 double fXScale
; // 41
252 double fOblAngle
; // 51
258 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
261 //--------------------------Insert----------------------------------------------
263 class DXFInsertEntity
: public DXFBasicEntity
{
267 long nAttrFlag
; // 66
268 char sName
[DXF_MAX_STRING_LEN
+1]; // 2
269 DXFVector aP0
; // 10,20,30
270 double fXScale
; // 41
271 double fYScale
; // 42
272 double fZScale
; // 43
273 double fRotAngle
; // 50
274 long nColCount
; // 70
275 long nRowCount
; // 71
276 double fColSpace
; // 44
277 double fRowSpace
; // 45
283 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
286 //--------------------------AttDef----------------------------------------------
288 class DXFAttDefEntity
: public DXFBasicEntity
{
292 DXFVector aP0
; // 10,20,30
293 double fHeight
; // 40
294 char sDefVal
[DXF_MAX_STRING_LEN
+1]; // 1
295 char sPrompt
[DXF_MAX_STRING_LEN
+1]; // 3
296 char sTagStr
[DXF_MAX_STRING_LEN
+1]; // 2
297 long nAttrFlags
; // 70
298 long nFieldLen
; // 73
299 double fRotAngle
; // 50
300 double fXScale
; // 41
301 double fOblAngle
; // 51
302 char sStyle
[DXF_MAX_STRING_LEN
+1]; // 7
303 long nGenFlags
; // 71
304 long nHorzJust
; // 72
305 long nVertJust
; // 74
306 DXFVector aAlign
; // 11,21,31
312 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
315 //--------------------------Attrib----------------------------------------------
317 class DXFAttribEntity
: public DXFBasicEntity
{
321 DXFVector aP0
; // 10,20,30
322 double fHeight
; // 40
323 char sText
[DXF_MAX_STRING_LEN
+1]; // 1
324 char sTagStr
[DXF_MAX_STRING_LEN
+1]; // 2
325 long nAttrFlags
; // 70
326 long nFieldLen
; // 73
327 double fRotAngle
; // 50
328 double fXScale
; // 41
329 double fOblAngle
; // 51
330 char sStyle
[DXF_MAX_STRING_LEN
+1]; // 7
331 long nGenFlags
; // 71
332 long nHorzJust
; // 72
333 long nVertJust
; // 74
334 DXFVector aAlign
; // 11,21,31
340 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
343 //--------------------------PolyLine--------------------------------------------
345 class DXFPolyLineEntity
: public DXFBasicEntity
{
349 double fElevation
; // 30
351 double fSWidth
; // 40
352 double fEWidth
; // 41
353 long nMeshMCount
; // 71
354 long nMeshNCount
; // 72
355 long nMDensity
; // 73
356 long nNDensity
; // 74
363 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
366 class DXFLWPolyLineEntity
: public DXFBasicEntity
372 sal_Int32 nCount
; // 90
373 sal_Int32 nFlags
; // 70 1 = closed, 128 = plinegen
374 double fConstantWidth
; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used)
375 double fStartWidth
; // 40
376 double fEndWidth
; // 41
380 DXFLWPolyLineEntity();
381 ~DXFLWPolyLineEntity();
385 virtual void EvaluateGroup( DXFGroupReader
& rDGR
);
389 //-------------------------- Hatch ---------------------------------------------
395 virtual ~DXFEdgeType(){};
396 virtual sal_Bool
EvaluateGroup( DXFGroupReader
& /*rDGR*/ ){ return sal_True
; };
400 DXFEdgeType( sal_Int32 EdgeType
):nEdgeType(EdgeType
){};
402 struct DXFEdgeTypeLine
: public DXFEdgeType
404 DXFVector aStartPoint
; // 10,20
405 DXFVector aEndPoint
; // 11,21
407 virtual ~DXFEdgeTypeLine();
408 virtual sal_Bool
EvaluateGroup( DXFGroupReader
& rDGR
);
410 struct DXFEdgeTypeCircularArc
: public DXFEdgeType
412 DXFVector aCenter
; // 10,20
413 double fRadius
; // 40
414 double fStartAngle
; // 50
415 double fEndAngle
; // 51
416 sal_Int32 nIsCounterClockwiseFlag
; // 73
417 DXFEdgeTypeCircularArc();
418 virtual ~DXFEdgeTypeCircularArc();
419 virtual sal_Bool
EvaluateGroup( DXFGroupReader
& rDGR
);
421 struct DXFEdgeTypeEllipticalArc
: public DXFEdgeType
423 DXFVector aCenter
; // 10,20
424 DXFVector aEndPoint
; // 11,21
425 double fLength
; // 40
426 double fStartAngle
; // 50
427 double fEndAngle
; // 51
428 sal_Int32 nIsCounterClockwiseFlag
; // 73
430 DXFEdgeTypeEllipticalArc();
431 virtual ~DXFEdgeTypeEllipticalArc();
432 virtual sal_Bool
EvaluateGroup( DXFGroupReader
& rDGR
);
434 struct DXFEdgeTypeSpline
: public DXFEdgeType
436 sal_Int32 nDegree
; // 94
437 sal_Int32 nRational
; // 73
438 sal_Int32 nPeriodic
; // 74
439 sal_Int32 nKnotCount
; // 75
440 sal_Int32 nControlCount
; // 76
443 virtual ~DXFEdgeTypeSpline();
444 virtual sal_Bool
EvaluateGroup( DXFGroupReader
& rDGR
);
447 typedef std::deque
< DXFEdgeType
* > DXFEdgeTypeArray
;
449 struct DXFBoundaryPathData
451 sal_Int32 nFlags
; // 92
452 sal_Int32 nHasBulgeFlag
; // 72
453 sal_Int32 nIsClosedFlag
; // 73
454 sal_Int32 nPointCount
; // 93
456 sal_Int32 nSourceBoundaryObjects
; // 97
457 sal_Int32 nEdgeCount
; // 93
459 sal_Bool bIsPolyLine
;
460 sal_Int32 nPointIndex
;
463 DXFEdgeTypeArray aEdges
;
465 DXFBoundaryPathData();
466 ~DXFBoundaryPathData();
468 sal_Bool
EvaluateGroup( DXFGroupReader
& rDGR
);
471 class DXFHatchEntity
: public DXFBasicEntity
473 sal_Bool bIsInBoundaryPathContext
;
474 sal_Int32 nCurrentBoundaryPathIndex
;
478 DXFVector aElevationPoint
;
479 sal_Int32 nFlags
; // 70 (solid fill = 1, pattern fill = 0)
480 sal_Int32 nAssociativityFlag
; // 71 (assoiciative = 1, non-associative = 0)
481 sal_Int32 nBoundaryPathCount
; // 91
482 sal_Int32 nHatchStyle
; // 75 (odd parity = 0, outmost area = 1, entire area = 2 )
483 sal_Int32 nHatchPatternType
; // 76 (user defined = 0, predefined = 1, custom = 2)
484 double fHatchPatternAngle
; // 52 (pattern fill only)
485 double fHatchPatternScale
; // 41 (pattern fill only:scale or spacing)
486 sal_Int32 nHatchDoubleFlag
; // 77 (pattern fill only:double = 1, not double = 0)
487 sal_Int32 nHatchPatternDefinitionLines
; // 78
488 double fPixelSize
; // 47
489 sal_Int32 nNumberOfSeedPoints
; // 98
491 DXFBoundaryPathData
* pBoundaryPathData
;
498 virtual void EvaluateGroup( DXFGroupReader
& rDGR
);
502 //--------------------------Vertex----------------------------------------------
504 class DXFVertexEntity
: public DXFBasicEntity
{
508 DXFVector aP0
; // 10,20,30
509 double fSWidth
; // 40 (Wenn <0.0, dann gilt DXFPolyLine::fSWidth)
510 double fEWidth
; // 41 (Wenn <0.0, dann gilt DXFPolyLine::fEWidth)
513 double fCFTDir
; // 50
519 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
522 //--------------------------SeqEnd----------------------------------------------
524 class DXFSeqEndEntity
: public DXFBasicEntity
{
531 //--------------------------3DFace----------------------------------------------
533 class DXF3DFaceEntity
: public DXFBasicEntity
{
537 DXFVector aP0
; // 10,20,30
538 DXFVector aP1
; // 11,21,31
539 DXFVector aP2
; // 12,22,32
540 DXFVector aP3
; // 13,23,33
547 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
550 //--------------------------Dimension-------------------------------------------
552 class DXFDimensionEntity
: public DXFBasicEntity
{
556 char sPseudoBlock
[DXF_MAX_STRING_LEN
+1]; // 2
558 DXFDimensionEntity();
562 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
565 //------------------------------------------------------------------------------
566 //----------- Eine Menge von Entities lesen und repraesentieren ----------------
567 //------------------------------------------------------------------------------
576 DXFBasicEntity
* pFirst
; // Liste von Entities, READ ONLY!
578 void Read(DXFGroupReader
& rDGR
);
579 // Liest Entitis per rGDR aus einer DXF-Datei bis zu
580 // einem ENDBLK, ENDSEC oder EOF (der Gruppe 0).
581 // (Alle unbekannten Dinge werden uebersprungen)
584 // Loescht alle Entities
587 //------------------------------------------------------------------------------
588 //--------------------------------- inlines ------------------------------------
589 //------------------------------------------------------------------------------
591 inline DXFEntities::DXFEntities()
597 inline DXFEntities::~DXFEntities()