LibreOffice Module basegfx (master) 1
b2dtrapezoid.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <config_options.h>
24#include <vector>
26
27
28namespace basegfx { class B2DPolyPolygon; }
29namespace basegfx { class B2DPoint; }
30
31namespace basegfx
32{
33 // class to hold a single trapezoid
34 class UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) B2DTrapezoid
35 {
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:
40
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;
50
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);
60
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; }
68
69 // convenience method to get content as Polygon
70 B2DPolygon getB2DPolygon() const;
71 };
72
73 typedef ::std::vector< B2DTrapezoid > B2DTrapezoidVector;
74
75} // end of namespace basegfx
76
77
78namespace basegfx::utils
79{
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.
88 B2DTrapezoidVector& ro_Result,
89 const B2DPolyPolygon& rSourcePolyPolygon);
90
91 // directly create trapezoids from given edge. Depending on the given geometry,
92 // none up to three trapezoids will be created
94 B2DTrapezoidVector& ro_Result,
95 const B2DPoint& rPointA,
96 const B2DPoint& rPointB,
97 double fLineWidth);
98
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.
103 B2DTrapezoidVector& ro_Result,
104 const B2DPolygon& rPolygon,
105 double fLineWidth);
106} // end of namespace basegfx::utils
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASEGFX_DLLPUBLIC
Definition: basegfxdllapi.h:35
void createLineTrapezoidFromEdge(B2DTrapezoidVector &ro_Result, const B2DPoint &rPointA, const B2DPoint &rPointB, double fLineWidth)
void trapezoidSubdivide(B2DTrapezoidVector &ro_Result, const B2DPolyPolygon &rSourcePolyPolygon)
void createLineTrapezoidFromB2DPolygon(B2DTrapezoidVector &ro_Result, const B2DPolygon &rPolygon, double fLineWidth)
::std::vector< B2DTrapezoid > B2DTrapezoidVector