LibreOffice Module basegfx (master) 1
Public Member Functions | Private Attributes | List of all members
basegfx::B2DCubicBezier Class Reference

#include <b2dcubicbezier.hxx>

Collaboration diagram for basegfx::B2DCubicBezier:
[legend]

Public Member Functions

 B2DCubicBezier ()
 
 B2DCubicBezier (const B2DCubicBezier &rBezier)
 
 B2DCubicBezier (const B2DPoint &rStart, const B2DPoint &rControlPointA, const B2DPoint &rControlPointB, const B2DPoint &rEnd)
 
B2DCubicBezieroperator= (const B2DCubicBezier &rBezier)
 
bool operator== (const B2DCubicBezier &rBezier) const
 
bool operator!= (const B2DCubicBezier &rBezier) const
 
bool equal (const B2DCubicBezier &rBezier) const
 
bool isBezier () const
 
void testAndSolveTrivialBezier ()
 
double getLength (double fDeviation=0.01) const
 get length of edge More...
 
SAL_DLLPRIVATE double getEdgeLength () const
 
SAL_DLLPRIVATE double getControlPolygonLength () const
 
const B2DPointgetStartPoint () const
 
void setStartPoint (const B2DPoint &rValue)
 
const B2DPointgetEndPoint () const
 
void setEndPoint (const B2DPoint &rValue)
 
const B2DPointgetControlPointA () const
 
void setControlPointA (const B2DPoint &rValue)
 
const B2DPointgetControlPointB () const
 
void setControlPointB (const B2DPoint &rValue)
 
B2DVector getTangent (double t) const
 get the tangent in point t More...
 
SAL_DLLPRIVATE void adaptiveSubdivideByAngle (B2DPolygon &rTarget, double fAngleBound) const
 adaptive subdivide by angle criteria no start point is added, but all necessary created edges and the end point #i37443# allow the criteria to get unsharp in recursions More...
 
SAL_DLLPRIVATE void adaptiveSubdivideByCount (B2DPolygon &rTarget, sal_uInt32 nCount) const
 #i37443# adaptive subdivide by nCount subdivisions no start point is added, but all necessary created edges and the end point More...
 
void adaptiveSubdivideByDistance (B2DPolygon &rTarget, double fDistanceBound, int nRecurseLimit=30) const
 Subdivide cubic bezier segment. More...
 
B2DPoint interpolatePoint (double t) const
 
SAL_DLLPRIVATE double getSmallestDistancePointToBezierSegment (const B2DPoint &rTestPoint, double &rCut) const
 
void split (double t, B2DCubicBezier *pBezierA, B2DCubicBezier *pBezierB) const
 
SAL_DLLPRIVATE B2DCubicBezier snippet (double fStart, double fEnd) const
 
B2DRange getRange () const
 
SAL_DLLPRIVATE bool getMinimumExtremumPosition (double &rfResult) const
 Get the minimum extremum position t. More...
 
SAL_DLLPRIVATE void getAllExtremumPositions (::std::vector< double > &rResults) const
 Get all extremum pos of this segment. More...
 
void transform (const basegfx::B2DHomMatrix &rMatrix)
 apply transformation given in matrix form More...
 
SAL_DLLPRIVATE void fround ()
 fround content More...
 

Private Attributes

B2DPoint maStartPoint
 
B2DPoint maEndPoint
 
B2DPoint maControlPointA
 
B2DPoint maControlPointB
 

Detailed Description

Definition at line 33 of file b2dcubicbezier.hxx.

Constructor & Destructor Documentation

◆ B2DCubicBezier() [1/3]

basegfx::B2DCubicBezier::B2DCubicBezier ( )
default

◆ B2DCubicBezier() [2/3]

basegfx::B2DCubicBezier::B2DCubicBezier ( const B2DCubicBezier rBezier)
default

◆ B2DCubicBezier() [3/3]

basegfx::B2DCubicBezier::B2DCubicBezier ( const B2DPoint rStart,
const B2DPoint rControlPointA,
const B2DPoint rControlPointB,
const B2DPoint rEnd 
)

Definition at line 332 of file b2dcubicbezier.cxx.

References maEndPoint, and maStartPoint.

Member Function Documentation

◆ adaptiveSubdivideByAngle()

void basegfx::B2DCubicBezier::adaptiveSubdivideByAngle ( B2DPolygon rTarget,
double  fAngleBound 
) const

adaptive subdivide by angle criteria no start point is added, but all necessary created edges and the end point #i37443# allow the criteria to get unsharp in recursions

Definition at line 528 of file b2dcubicbezier.cxx.

References basegfx::deg2rad(), getEndPoint(), isBezier(), maControlPointA, maControlPointB, maEndPoint, maStartPoint, and rTarget.

Referenced by basegfx::utils::adaptiveSubdivideByAngle().

◆ adaptiveSubdivideByCount()

void basegfx::B2DCubicBezier::adaptiveSubdivideByCount ( B2DPolygon rTarget,
sal_uInt32  nCount 
) const

#i37443# adaptive subdivide by nCount subdivisions no start point is added, but all necessary created edges and the end point

Definition at line 599 of file b2dcubicbezier.cxx.

References a, getEndPoint(), interpolatePoint(), nCount, and rTarget.

Referenced by getSmallestDistancePointToBezierSegment().

◆ adaptiveSubdivideByDistance()

void basegfx::B2DCubicBezier::adaptiveSubdivideByDistance ( B2DPolygon rTarget,
double  fDistanceBound,
int  nRecurseLimit = 30 
) const

Subdivide cubic bezier segment.

This function adaptively subdivides the bezier segment into as much straight line segments as necessary, such that the maximal orthogonal distance from any of the segments to the true curve is less than the given error value. No start point is added, but all necessary created edges and the end point

Parameters
rPolyOutput polygon. The subdivided bezier segment is added to this polygon via B2DPolygon::append().
rCurveThe cubic bezier curve to subdivide
fDistanceBoundBound on the maximal distance of the approximation to the true curve.
nRecurseLimitBound on recursion for the bezier case.

Definition at line 613 of file b2dcubicbezier.cxx.

References getEndPoint(), isBezier(), maControlPointA, maControlPointB, maEndPoint, maStartPoint, and rTarget.

Referenced by basegfx::utils::adaptiveSubdivideByDistance().

◆ equal()

bool basegfx::B2DCubicBezier::equal ( const B2DCubicBezier rBezier) const

◆ fround()

void basegfx::B2DCubicBezier::fround ( )

◆ getAllExtremumPositions()

void basegfx::B2DCubicBezier::getAllExtremumPositions ( ::std::vector< double > &  rResults) const

Get all extremum pos of this segment.

This method will calculate all extremum positions of the segment and add them to rResults if they are in the range ]0.0 .. 1.0[

Parameters
rResultsThe vector of doubles where the results will be added. Evtl. existing contents will be removed since an empty vector is a necessary result to express that there are no extreme positions anymore. Since there is an upper maximum of 4 values, it makes sense to use reserve(4) at the vector as preparation.

Definition at line 923 of file b2dcubicbezier.cxx.

References basegfx::fTools::equalZero(), basegfx::Tuple2D< TYPE >::getX(), basegfx::Tuple2D< TYPE >::getY(), maControlPointA, maControlPointB, maEndPoint, and maStartPoint.

Referenced by getMinimumExtremumPosition().

◆ getControlPointA()

const B2DPoint & basegfx::B2DCubicBezier::getControlPointA ( ) const
inline

◆ getControlPointB()

const B2DPoint & basegfx::B2DCubicBezier::getControlPointB ( ) const
inline

◆ getControlPolygonLength()

double basegfx::B2DCubicBezier::getControlPolygonLength ( ) const

◆ getEdgeLength()

double basegfx::B2DCubicBezier::getEdgeLength ( ) const

◆ getEndPoint()

const B2DPoint & basegfx::B2DCubicBezier::getEndPoint ( ) const
inline

◆ getLength()

double basegfx::B2DCubicBezier::getLength ( double  fDeviation = 0.01) const

get length of edge

This method handles beziers and simple edges. For beziers, the deviation describes the maximum allowed deviation from the real edge length. The default allows a deviation of 1% from the correct length.

For beziers, there is no direct way to get the length, thus this method may subdivide the bezier edge and may not be cheap.

Parameters
fDeviationThe maximal allowed deviation between correct length and bezier edge length
Returns
The length of the edge

Definition at line 489 of file b2dcubicbezier.cxx.

References getEndPoint(), basegfx::B2DVector::getLength(), getStartPoint(), and isBezier().

Referenced by basegfx::utils::getEdgeLength(), and basegfx::utils::getLength().

◆ getMinimumExtremumPosition()

bool basegfx::B2DCubicBezier::getMinimumExtremumPosition ( double &  rfResult) const

Get the minimum extremum position t.

Parameters
rfResultWill be changed and might possibly be set to a found split value, which should be in the range [0.0 .. 1.0]. It will be the smallest current extremum; there may be more
Returns
Returns true if there was at least one extremum found

Definition at line 881 of file b2dcubicbezier.cxx.

References getAllExtremumPositions(), and nCount.

◆ getRange()

B2DRange basegfx::B2DCubicBezier::getRange ( ) const

◆ getSmallestDistancePointToBezierSegment()

double basegfx::B2DCubicBezier::getSmallestDistancePointToBezierSegment ( const B2DPoint rTestPoint,
double &  rCut 
) const

◆ getStartPoint()

const B2DPoint & basegfx::B2DCubicBezier::getStartPoint ( ) const
inline

◆ getTangent()

B2DVector basegfx::B2DCubicBezier::getTangent ( double  t) const

get the tangent in point t

This method handles all the exceptions, e.g. when control point A is equal to start point and/or control point B is equal to end point

Parameters
tThe bezier index in the range [0.0 .. 1.0]. It will be truncated.
Returns
The tangent vector in point t

Definition at line 542 of file b2dcubicbezier.cxx.

References basegfx::Tuple2D< TYPE >::equalZero(), getControlPointA(), getControlPointB(), getEndPoint(), getStartPoint(), basegfx::fTools::lessOrEqual(), basegfx::fTools::moreOrEqual(), split(), and t.

Referenced by basegfx::utils::createAreaGeometry(), basegfx::utils::getTangentEnteringPoint(), and basegfx::utils::getTangentLeavingPoint().

◆ interpolatePoint()

B2DPoint basegfx::B2DCubicBezier::interpolatePoint ( double  t) const

◆ isBezier()

bool basegfx::B2DCubicBezier::isBezier ( ) const

◆ operator!=()

bool basegfx::B2DCubicBezier::operator!= ( const B2DCubicBezier rBezier) const

Definition at line 354 of file b2dcubicbezier.cxx.

References maControlPointA, maControlPointB, maEndPoint, and maStartPoint.

◆ operator=()

B2DCubicBezier & basegfx::B2DCubicBezier::operator= ( const B2DCubicBezier rBezier)
default

References equal(), operator!=(), and operator==().

◆ operator==()

bool basegfx::B2DCubicBezier::operator== ( const B2DCubicBezier rBezier) const

Definition at line 344 of file b2dcubicbezier.cxx.

References maControlPointA, maControlPointB, maEndPoint, and maStartPoint.

◆ setControlPointA()

void basegfx::B2DCubicBezier::setControlPointA ( const B2DPoint rValue)
inline

◆ setControlPointB()

void basegfx::B2DCubicBezier::setControlPointB ( const B2DPoint rValue)
inline

◆ setEndPoint()

void basegfx::B2DCubicBezier::setEndPoint ( const B2DPoint rValue)
inline

◆ setStartPoint()

void basegfx::B2DCubicBezier::setStartPoint ( const B2DPoint rValue)
inline

◆ snippet()

B2DCubicBezier basegfx::B2DCubicBezier::snippet ( double  fStart,
double  fEnd 
) const

◆ split()

void basegfx::B2DCubicBezier::split ( double  t,
B2DCubicBezier pBezierA,
B2DCubicBezier pBezierB 
) const

◆ testAndSolveTrivialBezier()

void basegfx::B2DCubicBezier::testAndSolveTrivialBezier ( )

◆ transform()

void basegfx::B2DCubicBezier::transform ( const basegfx::B2DHomMatrix rMatrix)

apply transformation given in matrix form

Definition at line 993 of file b2dcubicbezier.cxx.

References basegfx::B2DHomMatrix::isIdentity(), maControlPointA, maControlPointB, maEndPoint, and maStartPoint.

Member Data Documentation

◆ maControlPointA

B2DPoint basegfx::B2DCubicBezier::maControlPointA
private

◆ maControlPointB

B2DPoint basegfx::B2DCubicBezier::maControlPointB
private

◆ maEndPoint

B2DPoint basegfx::B2DCubicBezier::maEndPoint
private

◆ maStartPoint

B2DPoint basegfx::B2DCubicBezier::maStartPoint
private

The documentation for this class was generated from the following files: