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 .
22 #include <sal/types.h>
23 #include <vcl/lineinfo.hxx>
37 eStyle(LineStyle::Solid
),
46 //---------------------------- DXFVector ---------------------------------------
48 // common 3D vector with doubles
54 double fx
,fy
,fz
; // public ! - why not?
56 inline DXFVector(double fX
=0.0, double fY
=0.0, double fZ
=0.0);
58 // summation/subtraktion:
59 DXFVector
& operator += (const DXFVector
& rV
);
60 DXFVector
operator + (const DXFVector
& rV
) const;
61 DXFVector
operator - (const DXFVector
& rV
) const;
64 DXFVector
operator * (const DXFVector
& rV
) const;
67 double SProd(const DXFVector
& rV
) const;
69 // multiplication with scalar:
70 DXFVector
& operator *= (double fs
);
71 DXFVector
operator * (double fs
) const;
76 // vector with same direction and a length of 1:
77 DXFVector
Unit() const;
79 // equivalence or net:
80 bool operator == (const DXFVector
& rV
) const;
84 //---------------------------- DXFTransform ------------------------------------
86 // a transformation matrice specialized for our problem
93 // destination coordinate = source coordinate
95 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
96 const DXFVector
& rShift
);
97 // dest coordinate = translate(scale(source coordinate))
99 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
101 const DXFVector
& rShift
);
102 // dest coordinate = translate(rotate(scale(source coordinate)))
103 // rotation around z-axis, fRotAngle in degrees.
105 DXFTransform(const DXFVector
& rExtrusion
);
106 // Transformation "ECS->WCS" via "Entity Extrusion Direction"
107 // ant the "Arbitrary Axis Algorithm"
108 // (See DXF-Docu from AutoDesk)
110 DXFTransform(const DXFVector
& rViewDir
, const DXFVector
& rViewTarget
);
111 // Transformation object space->picture space on the basis of direction
112 // destination point of a viewport
113 // (See DXF-Docu from AutoDesk: VPORT)
115 DXFTransform(const DXFTransform
& rT1
, const DXFTransform
& rT2
);
116 // destination coordinate = rT2(rT1(source coordinate))
119 void Transform(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
120 // Transformation from DXFVector to DXFVector
122 void Transform(const DXFVector
& rSrc
, Point
& rTgt
) const;
123 // Transformation from DXFVector to SvPoint
125 void TransDir(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
126 // Transformation of a relative vector (so no translation)
128 bool TransCircleToEllipse(double fRadius
, double & rEx
, double & rEy
) const;
129 // Attempt to transform a circle (in xy plane) so that it results
130 // in an aligned ellipse. If the does not work because an ellipse of
131 // arbitrary position would be created, sal_False is returned.
132 // (The center point will not be transformed, use Transform(..))
134 double CalcRotAngle() const;
135 // Calculates the rotation angle around z-axis (in degrees)
138 // Returns sal_True, if the matrice represents a left-handed coordinate system
140 LineInfo
Transform(const DXFLineInfo
& aDXFLineInfo
) const;
141 // Transform to LineInfo
151 //------------------------------- inlines --------------------------------------
154 inline DXFVector::DXFVector(double fX
, double fY
, double fZ
)
160 inline DXFVector
& DXFVector::operator += (const DXFVector
& rV
)
162 fx
+=rV
.fx
; fy
+=rV
.fy
; fz
+=rV
.fz
;
167 inline DXFVector
DXFVector::operator + (const DXFVector
& rV
) const
169 return DXFVector(fx
+rV
.fx
, fy
+rV
.fy
, fz
+rV
.fz
);
173 inline DXFVector
DXFVector::operator - (const DXFVector
& rV
) const
175 return DXFVector(fx
-rV
.fx
, fy
-rV
.fy
, fz
-rV
.fz
);
179 inline DXFVector
DXFVector::operator * (const DXFVector
& rV
) const
182 fy
* rV
.fz
- fz
* rV
.fy
,
183 fz
* rV
.fx
- fx
* rV
.fz
,
184 fx
* rV
.fy
- fy
* rV
.fx
189 inline double DXFVector::SProd(const DXFVector
& rV
) const
191 return fx
*rV
.fx
+ fy
*rV
.fy
+ fz
*rV
.fz
;
195 inline DXFVector
& DXFVector::operator *= (double fs
)
197 fx
*=fs
; fy
*=fs
; fz
*=fs
;
202 inline DXFVector
DXFVector::operator * (double fs
) const
204 return DXFVector(fx
*fs
,fy
*fs
,fz
*fs
);
208 inline bool DXFVector::operator == (const DXFVector
& rV
) const
210 if (fx
==rV
.fx
&& fy
==rV
.fy
&& fz
==rV
.fz
) return true;
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */