LibreOffice Module basegfx (master) 1
b2dcubicbezier.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
25
26namespace basegfx
27{
28 class B2DPolygon;
29}
30
31namespace basegfx
32{
34 {
35 private:
40
41 public:
44 B2DCubicBezier(const B2DPoint& rStart, const B2DPoint& rControlPointA, const B2DPoint& rControlPointB, const B2DPoint& rEnd);
45
46 // assignment operator
48
49 // compare operators
50 bool operator==(const B2DCubicBezier& rBezier) const;
51 bool operator!=(const B2DCubicBezier& rBezier) const;
52 bool equal(const B2DCubicBezier& rBezier) const;
53
54 // test if vectors are used
55 bool isBezier() const;
56
57 // test if contained bezier is trivial and reset vectors accordingly
58 void testAndSolveTrivialBezier();
59
78 double getLength(double fDeviation = 0.01) const;
79
80 // get distance between start and end point
81 SAL_DLLPRIVATE double getEdgeLength() const;
82
83 // get length of control polygon
84 SAL_DLLPRIVATE double getControlPolygonLength() const;
85
86 // data interface
87 const B2DPoint& getStartPoint() const { return maStartPoint; }
88 void setStartPoint(const B2DPoint& rValue) { maStartPoint = rValue; }
89
90 const B2DPoint& getEndPoint() const { return maEndPoint; }
91 void setEndPoint(const B2DPoint& rValue) { maEndPoint = rValue; }
92
93 const B2DPoint& getControlPointA() const { return maControlPointA; }
94 void setControlPointA(const B2DPoint& rValue) { maControlPointA = rValue; }
95
96 const B2DPoint& getControlPointB() const { return maControlPointB; }
97 void setControlPointB(const B2DPoint& rValue) { maControlPointB = rValue; }
98
111 B2DVector getTangent(double t) const;
112
118 SAL_DLLPRIVATE void adaptiveSubdivideByAngle(B2DPolygon& rTarget, double fAngleBound) const;
119
124 SAL_DLLPRIVATE void adaptiveSubdivideByCount(B2DPolygon& rTarget, sal_uInt32 nCount) const;
125
150 void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound, int nRecurseLimit = 30) const;
151
152 // get point at given relative position
153 B2DPoint interpolatePoint(double t) const;
154
155 // calculate the smallest distance from given point to this cubic bezier segment
156 // and return the value. The relative position on the segment is returned in rCut.
157 SAL_DLLPRIVATE double getSmallestDistancePointToBezierSegment(const B2DPoint& rTestPoint, double& rCut) const;
158
159 // do a split at position t and fill both resulting segments
160 void split(double t, B2DCubicBezier* pBezierA, B2DCubicBezier* pBezierB) const;
161
162 // extract snippet from fStart to fEnd from this bezier
163 SAL_DLLPRIVATE B2DCubicBezier snippet(double fStart, double fEnd) const;
164
165 // get range including control points
166 B2DRange getRange() const;
167
177 SAL_DLLPRIVATE bool getMinimumExtremumPosition(double& rfResult) const;
178
191 SAL_DLLPRIVATE void getAllExtremumPositions(::std::vector< double >& rResults) const;
192
194 void transform(const basegfx::B2DHomMatrix& rMatrix);
195
197 SAL_DLLPRIVATE void fround();
198 };
199} // end of namespace basegfx
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASEGFX_DLLPUBLIC
Definition: basegfxdllapi.h:35
B2DCubicBezier & operator=(const B2DCubicBezier &rBezier)
B2DCubicBezier(const B2DCubicBezier &rBezier)
void setStartPoint(const B2DPoint &rValue)
const B2DPoint & getStartPoint() const
const B2DPoint & getControlPointB() const
void setControlPointA(const B2DPoint &rValue)
void setEndPoint(const B2DPoint &rValue)
void setControlPointB(const B2DPoint &rValue)
const B2DPoint & getEndPoint() const
const B2DPoint & getControlPointA() const
Base Point class with two double values.
Definition: b2dpoint.hxx:42
A two-dimensional interval over doubles.
Definition: b2drange.hxx:54
Base Point class with two double values.
Definition: b2dvector.hxx:40
::basegfx::B2DPoint maStartPoint
::basegfx::B2DPoint maEndPoint
double getLength(const B2DPolygon &rCandidate)
get length of polygon
B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon &rCandidate, double fDistanceBound, int nRecurseLimit)
B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon &rCandidate, double fAngleBound)
double getEdgeLength(const B2DPolygon &rCandidate, sal_uInt32 nIndex)
get length of polygon edge from point nIndex to nIndex + 1
B2DRange getRange(const B2DPolygon &rCandidate)
Get the range of a polygon.
B2IRange fround(const B2DRange &rRange)
Round double to nearest integer for 2D range.
Definition: b2drange.cxx:64
std::vector< OUString > split(std::u16string_view rStr, sal_Unicode cSeparator)
bool equal(Pair const &p1, Pair const &p2)
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)