1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <sal/types.h>
24 #include <vcl/lineinfo.hxx>
47 DXFLineInfo(const DXFLineInfo
& x
) :
50 nDashCount(x
.nDashCount
),
52 nDotCount(x
.nDotCount
),
54 fDistance(x
.fDistance
) {}
59 //------------------------------------------------------------------------------
60 //---------------------------- DXFVector ---------------------------------------
61 //------------------------------------------------------------------------------
62 // common 3D vector with doubles
68 double fx
,fy
,fz
; // public ! - why not?
70 inline DXFVector(double fX
=0.0, double fY
=0.0, double fZ
=0.0);
71 inline DXFVector(const DXFVector
& rV
);
73 // summation/subtraktion:
74 DXFVector
& operator += (const DXFVector
& rV
);
75 DXFVector
operator + (const DXFVector
& rV
) const;
76 DXFVector
& operator -= (const DXFVector
& rV
);
77 DXFVector
operator - (const DXFVector
& rV
) const;
80 DXFVector
operator * (const DXFVector
& rV
) const;
83 double SProd(const DXFVector
& rV
) const;
85 // multiplication with scalar:
86 DXFVector
& operator *= (double fs
);
87 DXFVector
operator * (double fs
) const;
92 // vector with same direction and a length of 1:
93 DXFVector
Unit() const;
95 // equivalence or net:
96 sal_Bool
operator == (const DXFVector
& rV
) const;
97 sal_Bool
operator != (const DXFVector
& rV
) const;
100 //------------------------------------------------------------------------------
101 //---------------------------- DXFTransform ------------------------------------
102 //------------------------------------------------------------------------------
103 // a transformation matrice specialized for our problem
110 // destination coordinate = source coordinate
112 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
113 const DXFVector
& rShift
);
114 // dest coordinate = translate(scale(source coordinate))
116 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
118 const DXFVector
& rShift
);
119 // dest coordinate = translate(rotate(scale(source coordinate)))
120 // rotation around z-axis, fRotAngle in degrees.
122 DXFTransform(const DXFVector
& rExtrusion
);
123 // Transformation "ECS->WCS" via "Entity Extrusion Direction"
124 // ant the "Arbitrary Axis Algorithm"
125 // (See DXF-Docu from AutoDesk)
127 DXFTransform(const DXFVector
& rViewDir
, const DXFVector
& rViewTarget
);
128 // Transformation object space->picture space on the basis of direction
129 // destination point of a viewport
130 // (See DXF-Docu from AutoDesk: VPORT)
132 DXFTransform(const DXFTransform
& rT1
, const DXFTransform
& rT2
);
133 // destination coordinate = rT2(rT1(source coordinate))
136 void Transform(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
137 // Transformation from DXFVector to DXFVector
139 void Transform(const DXFVector
& rSrc
, Point
& rTgt
) const;
140 // Transformation from DXFVector to SvPoint
142 void TransDir(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
143 // Transformation of a relative vector (so no translation)
145 sal_Bool
TransCircleToEllipse(double fRadius
, double & rEx
, double & rEy
) const;
146 // Attemp to transform a circle (in xy plane) so that it results
147 // in an aligned ellipse. If the does not work because a ellipse of
148 // arbitrary position would be created, sal_False is returned.
149 // (The center point will not be transformed, use Transform(..))
151 sal_uLong
TransLineWidth(double fW
) const;
152 // Transforms the thickness of a line (as good as possible)
154 double CalcRotAngle() const;
155 // Calculates the rotation angle around z-axis (in degrees)
157 sal_Bool
Mirror() const;
158 // Returns sal_True, if the matrice represents a left-handed coordinate system
160 LineInfo
Transform(const DXFLineInfo
& aDXFLineInfo
) const;
161 // Transform to LineInfo
170 //------------------------------------------------------------------------------
171 //------------------------------- inlines --------------------------------------
172 //------------------------------------------------------------------------------
175 inline DXFVector::DXFVector(double fX
, double fY
, double fZ
)
181 inline DXFVector::DXFVector(const DXFVector
& rV
)
183 fx
=rV
.fx
; fy
=rV
.fy
; fz
=rV
.fz
;
187 inline DXFVector
& DXFVector::operator += (const DXFVector
& rV
)
189 fx
+=rV
.fx
; fy
+=rV
.fy
; fz
+=rV
.fz
;
194 inline DXFVector
DXFVector::operator + (const DXFVector
& rV
) const
196 return DXFVector(fx
+rV
.fx
, fy
+rV
.fy
, fz
+rV
.fz
);
200 inline DXFVector
& DXFVector::operator -= (const DXFVector
& rV
)
202 fx
-=rV
.fx
; fy
-=rV
.fy
; fz
-=rV
.fz
;
207 inline DXFVector
DXFVector::operator - (const DXFVector
& rV
) const
209 return DXFVector(fx
-rV
.fx
, fy
-rV
.fy
, fz
-rV
.fz
);
213 inline DXFVector
DXFVector::operator * (const DXFVector
& rV
) const
216 fy
* rV
.fz
- fz
* rV
.fy
,
217 fz
* rV
.fx
- fx
* rV
.fz
,
218 fx
* rV
.fy
- fy
* rV
.fx
223 inline double DXFVector::SProd(const DXFVector
& rV
) const
225 return fx
*rV
.fx
+ fy
*rV
.fy
+ fz
*rV
.fz
;
229 inline DXFVector
& DXFVector::operator *= (double fs
)
231 fx
*=fs
; fy
*=fs
; fz
*=fs
;
236 inline DXFVector
DXFVector::operator * (double fs
) const
238 return DXFVector(fx
*fs
,fy
*fs
,fz
*fs
);
242 inline sal_Bool
DXFVector::operator == (const DXFVector
& rV
) const
244 if (fx
==rV
.fx
&& fy
==rV
.fy
&& fz
==rV
.fz
) return sal_True
;
245 else return sal_False
;
249 inline sal_Bool
DXFVector::operator != (const DXFVector
& rV
) const
251 if (fx
!=rV
.fx
|| fy
!=rV
.fy
|| fz
!=rV
.fz
) return sal_True
;
252 else return sal_False
;
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */