bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / basegfx / polygon / b2dtrapezoid.hxx
blob6333d2d17876c47dd3e4b3ba9fb21f54c42afda4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_BASEGFX_POLYGON_B2DTRAPEZOID_HXX
21 #define INCLUDED_BASEGFX_POLYGON_B2DTRAPEZOID_HXX
23 #include <basegfx/polygon/b2dpolygon.hxx>
24 #include <vector>
25 #include <basegfx/basegfxdllapi.h>
28 namespace basegfx { class B2DPolyPolygon; }
29 namespace basegfx { class B2DPoint; }
31 namespace basegfx
33 // class to hold a single trapezoid
34 class BASEGFX_DLLPUBLIC B2DTrapezoid
36 private:
37 // Geometry data. YValues are down-oriented, this means bottom should
38 // be bigger than top to be below it. The constructor implementation
39 // guarantees:
41 // - mfBottomY >= mfTopY
42 // - mfTopXRight >= mfTopXLeft
43 // - mfBottomXRight >= mfBottomXLeft
44 double mfTopXLeft;
45 double mfTopXRight;
46 double mfTopY;
47 double mfBottomXLeft;
48 double mfBottomXRight;
49 double mfBottomY;
51 public:
52 // constructor
53 B2DTrapezoid(
54 const double& rfTopXLeft,
55 const double& rfTopXRight,
56 const double& rfTopY,
57 const double& rfBottomXLeft,
58 const double& rfBottomXRight,
59 const double& rfBottomY);
61 // data read access
62 const double& getTopXLeft() const { return mfTopXLeft; }
63 const double& getTopXRight() const { return mfTopXRight; }
64 const double& getTopY() const { return mfTopY; }
65 const double& getBottomXLeft() const { return mfBottomXLeft; }
66 const double& getBottomXRight() const { return mfBottomXRight; }
67 const double& getBottomY() const { return mfBottomY; }
69 // convenience method to get content as Polygon
70 B2DPolygon getB2DPolygon() const;
73 typedef ::std::vector< B2DTrapezoid > B2DTrapezoidVector;
75 } // end of namespace basegfx
78 namespace basegfx
80 namespace utils
82 // convert SourcePolyPolygon to trapezoids. The trapezoids will be appended to
83 // ro_Result. ro_Result will not be cleared. If SourcePolyPolygon contains curves,
84 // it's default AdaptiveSubdivision will be used.
85 // CAUTION: Trapezoids are orientation-dependent in the sense that the upper and lower
86 // lines have to be parallel to the X-Axis, thus this subdivision is NOT simply usable
87 // for primitive decompositions. To use it, the shear and rotate parts of the
88 // involved transformations HAVE to be taken into account.
89 BASEGFX_DLLPUBLIC void trapezoidSubdivide(
90 B2DTrapezoidVector& ro_Result,
91 const B2DPolyPolygon& rSourcePolyPolygon);
93 // directly create trapezoids from given edge. Depending on the given geometry,
94 // none up to three trapezoids will be created
95 BASEGFX_DLLPUBLIC void createLineTrapezoidFromEdge(
96 B2DTrapezoidVector& ro_Result,
97 const B2DPoint& rPointA,
98 const B2DPoint& rPointB,
99 double fLineWidth);
101 // create trapezoids for all edges of the given polygon. The closed state of
102 // the polygon is taken into account. If curves are contained, the default
103 // AdaptiveSubdivision will be used.
104 BASEGFX_DLLPUBLIC void createLineTrapezoidFromB2DPolygon(
105 B2DTrapezoidVector& ro_Result,
106 const B2DPolygon& rPolygon,
107 double fLineWidth);
109 } // end of namespace utils
110 } // end of namespace basegfx
113 #endif // INCLUDED_BASEGFX_POLYGON_B2DTRAPEZOID_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */