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 <config_options.h>
23 #include <basegfx/polygon/b2dpolygon.hxx>
25 #include <basegfx/basegfxdllapi.h>
28 namespace basegfx
{ class B2DPolyPolygon
; }
29 namespace basegfx
{ class B2DPoint
; }
33 // class to hold a single trapezoid
34 class UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC
) B2DTrapezoid
37 // Geometry data. YValues are down-oriented, this means bottom should
38 // be bigger than top to be below it. The constructor implementation
41 // - mfBottomY >= mfTopY
42 // - mfTopXRight >= mfTopXLeft
43 // - mfBottomXRight >= mfBottomXLeft
48 double mfBottomXRight
;
54 const double& rfTopXLeft
,
55 const double& rfTopXRight
,
57 const double& rfBottomXLeft
,
58 const double& rfBottomXRight
,
59 const double& rfBottomY
);
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::utils
80 // convert SourcePolyPolygon to trapezoids. The trapezoids will be appended to
81 // ro_Result. ro_Result will not be cleared. If SourcePolyPolygon contains curves,
82 // it's default AdaptiveSubdivision will be used.
83 // CAUTION: Trapezoids are orientation-dependent in the sense that the upper and lower
84 // lines have to be parallel to the X-Axis, thus this subdivision is NOT simply usable
85 // for primitive decompositions. To use it, the shear and rotate parts of the
86 // involved transformations HAVE to be taken into account.
87 BASEGFX_DLLPUBLIC
void trapezoidSubdivide(
88 B2DTrapezoidVector
& ro_Result
,
89 const B2DPolyPolygon
& rSourcePolyPolygon
);
91 // directly create trapezoids from given edge. Depending on the given geometry,
92 // none up to three trapezoids will be created
93 void createLineTrapezoidFromEdge(
94 B2DTrapezoidVector
& ro_Result
,
95 const B2DPoint
& rPointA
,
96 const B2DPoint
& rPointB
,
99 // create trapezoids for all edges of the given polygon. The closed state of
100 // the polygon is taken into account. If curves are contained, the default
101 // AdaptiveSubdivision will be used.
102 void createLineTrapezoidFromB2DPolygon(
103 B2DTrapezoidVector
& ro_Result
,
104 const B2DPolygon
& rPolygon
,
106 } // end of namespace basegfx::utils
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */