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 .
20 #ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFVEC_HXX
21 #define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IDXF_DXFVEC_HXX
23 #include <sal/types.h>
24 #include <vcl/lineinfo.hxx>
38 eStyle(LineStyle::Solid
),
47 //---------------------------- DXFVector ---------------------------------------
49 // common 3D vector with doubles
55 double fx
,fy
,fz
; // public ! - why not?
57 inline DXFVector(double fX
=0.0, double fY
=0.0, double fZ
=0.0);
59 // summation/subtraktion:
60 DXFVector
& operator += (const DXFVector
& rV
);
61 DXFVector
operator + (const DXFVector
& rV
) const;
62 DXFVector
operator - (const DXFVector
& rV
) const;
65 DXFVector
operator * (const DXFVector
& rV
) const;
68 double SProd(const DXFVector
& rV
) const;
70 // multiplication with scalar:
71 DXFVector
& operator *= (double fs
);
72 DXFVector
operator * (double fs
) const;
77 // vector with same direction and a length of 1:
78 DXFVector
Unit() const;
80 // equivalence or net:
81 bool operator == (const DXFVector
& rV
) const;
85 //---------------------------- DXFTransform ------------------------------------
87 // a transformation matrice specialized for our problem
94 // destination coordinate = source coordinate
96 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
97 const DXFVector
& rShift
);
98 // dest coordinate = translate(scale(source coordinate))
100 DXFTransform(double fScaleX
, double fScaleY
, double fScaleZ
,
102 const DXFVector
& rShift
);
103 // dest coordinate = translate(rotate(scale(source coordinate)))
104 // rotation around z-axis, fRotAngle in degrees.
106 DXFTransform(const DXFVector
& rExtrusion
);
107 // Transformation "ECS->WCS" via "Entity Extrusion Direction"
108 // ant the "Arbitrary Axis Algorithm"
109 // (See DXF-Docu from AutoDesk)
111 DXFTransform(const DXFVector
& rViewDir
, const DXFVector
& rViewTarget
);
112 // Transformation object space->picture space on the basis of direction
113 // destination point of a viewport
114 // (See DXF-Docu from AutoDesk: VPORT)
116 DXFTransform(const DXFTransform
& rT1
, const DXFTransform
& rT2
);
117 // destination coordinate = rT2(rT1(source coordinate))
120 void Transform(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
121 // Transformation from DXFVector to DXFVector
123 void Transform(const DXFVector
& rSrc
, Point
& rTgt
) const;
124 // Transformation from DXFVector to SvPoint
126 void TransDir(const DXFVector
& rSrc
, DXFVector
& rTgt
) const;
127 // Transformation of a relative vector (so no translation)
129 bool TransCircleToEllipse(double fRadius
, double & rEx
, double & rEy
) const;
130 // Attempt to transform a circle (in xy plane) so that it results
131 // in an aligned ellipse. If the does not work because an ellipse of
132 // arbitrary position would be created, sal_False is returned.
133 // (The center point will not be transformed, use Transform(..))
135 double CalcRotAngle() const;
136 // Calculates the rotation angle around z-axis (in degrees)
139 // Returns sal_True, if the matrice represents a left-handed coordinate system
141 LineInfo
Transform(const DXFLineInfo
& aDXFLineInfo
) const;
142 // Transform to LineInfo
152 //------------------------------- inlines --------------------------------------
155 inline DXFVector::DXFVector(double fX
, double fY
, double fZ
)
161 inline DXFVector
& DXFVector::operator += (const DXFVector
& rV
)
163 fx
+=rV
.fx
; fy
+=rV
.fy
; fz
+=rV
.fz
;
168 inline DXFVector
DXFVector::operator + (const DXFVector
& rV
) const
170 return DXFVector(fx
+rV
.fx
, fy
+rV
.fy
, fz
+rV
.fz
);
174 inline DXFVector
DXFVector::operator - (const DXFVector
& rV
) const
176 return DXFVector(fx
-rV
.fx
, fy
-rV
.fy
, fz
-rV
.fz
);
180 inline DXFVector
DXFVector::operator * (const DXFVector
& rV
) const
183 fy
* rV
.fz
- fz
* rV
.fy
,
184 fz
* rV
.fx
- fx
* rV
.fz
,
185 fx
* rV
.fy
- fy
* rV
.fx
190 inline double DXFVector::SProd(const DXFVector
& rV
) const
192 return fx
*rV
.fx
+ fy
*rV
.fy
+ fz
*rV
.fz
;
196 inline DXFVector
& DXFVector::operator *= (double fs
)
198 fx
*=fs
; fy
*=fs
; fz
*=fs
;
203 inline DXFVector
DXFVector::operator * (double fs
) const
205 return DXFVector(fx
*fs
,fy
*fs
,fz
*fs
);
209 inline bool DXFVector::operator == (const DXFVector
& rV
) const
211 if (fx
==rV
.fx
&& fy
==rV
.fy
&& fz
==rV
.fz
) return true;
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */