InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMBezierCurve Class Reference

#include <PMBezierCurve.h>

Public Types

enum  { kBezierAdjustReflectedp1 = 1, kBezierAdjustReflectedp2 = 2, kBezierAdjustRotatedp1 = 4, kBezierAdjustRotatedp2 = 8 }
 
typedef base_type data_type
 

Public Member Functions

 PMBezierCurve ()
 
 PMBezierCurve (const PMPoint &p0, const PMPoint &p1, const PMPoint &p2, const PMPoint &p3)
 
 PMBezierCurve (const PMPoint &p0p1, const PMPoint &p2p3)
 
 PMBezierCurve (const PMPoint &p)
 
const PMPointGetP0 () const
 
const PMPointGetP1 () const
 
const PMPointGetP2 () const
 
const PMPointGetP3 () const
 
const PMPointGetNthPoint (int32 n) const
 
void SetP0 (const PMPoint &p)
 
void SetP1 (const PMPoint &p)
 
void SetP2 (const PMPoint &p)
 
void SetP3 (const PMPoint &p)
 
void SetNthPoint (int32 n, const PMPoint &p)
 
PMRect GetCtrlPtBounds () const
 
PMRect GetPathBounds () const
 
void TransformPoints (const PMMatrix &xForm)
 
bool16 FindParameter (const PMPoint &p, const PMReal &hitzone, PMReal *retU) const
 
PMPoint Evaluate (const PMReal &u) const
 
PMPoint EvaluateSlope (const PMReal &u) const
 
void EvaluatePointAndSlope (const PMReal &u, PMPoint *outP, PMPoint *outSlope) const
 
int32 GetStepSize (const PMReal &flatness) const
 
void FlattenCurve (PMPoint *pts, int32 stepSize)
 
int32 FindMinMax (PMReal *uResult) const
 
void SubDivide (const PMReal &u, PMBezierCurve *bezLeft, PMBezierCurve *bezRight) const
 
void SubSegment (const PMReal &begU, const PMReal &endU, PMBezierCurve *subSegment) const
 
void DivideIntoPathPoints (const PMReal u, PMPathPoint *ptBefore, PMPathPoint *ptAt, PMPathPoint *ptAfter)
 
void ReadWrite (IPMStream *iPMStream)
 
void operator*= (const PMReal &a)
 
void operator/= (const PMReal &a)
 
PMBezierCurveoperator= (const PMBezierCurve &rhs)
 
PMReal PrivateFindParameter (const PMReal &startP, const PMReal &endP, const PMReal &coord, bool16 isXCoord, bool16 *oneCrossing) const
 
PMReal FindParameterByAverage (PMReal t0, PMReal t1, const PMPoint &p) const
 
bool16 HitTest (const PMRect &r) const
 
int16 AdjustToPassThroughPoint (const PMPoint &p, const PMReal &t)
 
bool16 PreAdjustCurve (const PMReal &t, PMPoint &t0, PMPoint &t3, PMPoint &c, PMPoint &d, PMPoint &e) const
 
int16 DoAdjustCurve (const PMPoint &m, const PMReal &t, const PMPoint &t0, const PMPoint &t3, const PMPoint &c, const PMPoint &d, const PMPoint &e, bool16 parallel)
 

Static Public Member Functions

static void Reduce (PMPoint *P, const PMPoint &A, const PMPoint &B, const PMReal &u)
 

Protected Attributes

PMPoint fP0
 
PMPoint fP1
 
PMPoint fP2
 
PMPoint fP3
 

Friends

PMBezierCurve operator* (const PMReal &c, const PMBezierCurve &pt)
 
PMBezierCurve operator/ (const PMBezierCurve &numer, const PMReal &denom)
 
bool16 operator== (const PMBezierCurve &a, const PMBezierCurve &b)
 
bool16 operator!= (const PMBezierCurve &a, const PMBezierCurve &b)
 

Detailed Description

A C++ class for Bezier curve. The Bezier curve is defined by 4 points.

Member Enumeration Documentation

anonymous enum

Defines the return values for AdjustThroughPoint
Enumerator
kBezierAdjustReflectedp2 

same slope, but opposite side of p0

kBezierAdjustRotatedp1 

same slope, but opposite side of p3

kBezierAdjustRotatedp2 

p0 to p1 has different slope

Constructor & Destructor Documentation

PMBezierCurve::PMBezierCurve ()

Constructs an empty Bezier.

PMBezierCurve::PMBezierCurve (const PMPointp0,
const PMPointp1,
const PMPointp2,
const PMPointp3 
)

Contructs a Bezier from four points.

Parameters
P0is the first point.
P1is the second point.
P2is the third point.
P3is the fourth point.
PMBezierCurve::PMBezierCurve (const PMPointp0p1,
const PMPointp2p3 
)

Constructs a Bezier from two points. This will make p0 = p1 and p2 = p3

Parameters
p0p1the first point.
p2p3is the second point.
PMBezierCurve::PMBezierCurve (const PMPointp)

Construct a degenerate curve where p0 = p1 = p2 = p3

Parameters
pis the point.

Member Function Documentation

void PMBezierCurve::DivideIntoPathPoints (const PMReal u,
PMPathPointptBefore,
PMPathPointptAt,
PMPathPointptAfter 
)

Divide the curve at u and return the path points representing the curve.

PMPoint PMBezierCurve::Evaluate (const PMRealu) const

Evaluate the curve at the given parameter.

Parameters
uis the parameter where 0 <= u <= 1.0
void PMBezierCurve::EvaluatePointAndSlope (const PMRealu,
PMPointoutP,
PMPointoutSlope 
) const

This is faster than calling Evaluate and EvaluateSlope separately.

PMPoint PMBezierCurve::EvaluateSlope (const PMRealu) const

Find the slope at the given u.

Parameters
u
int32 PMBezierCurve::FindMinMax (PMRealuResult) const

Find the min and max paramesters. Returns the number of paramesters found. Max is 4. FindMinMax does not check param == 0.0 or param == 1.0

Parameters
uResultcontains the resulting parameters.
Returns
the number of paramesters.
bool16 PMBezierCurve::FindParameter (const PMPointp,
const PMRealhitzone,
PMRealretU 
) const

Returns whether the point is within hit zone of the curve. If so, it fills out the parameter location.

Parameters
pis the point to check.
hitzoneis the hit zone.
retU?
Returns
true if point is within the hit zone of the curve.
void PMBezierCurve::FlattenCurve (PMPointpts,
int32 stepSize 
)

Convert the Bezier to (1 << stepSize) + 1 number of points.

Parameters
ptsis the resulting points.
stepSizeis the step size.
PMRect PMBezierCurve::GetCtrlPtBounds () const

Return the bounding box of the curve including control points. If a single point the bbox is empty centered on the point.

Returns
the bounding box of the curve.
const PMPoint& PMBezierCurve::GetNthPoint (int32 n) const

Return the point at the given index, 0 <= n <= 3

Parameters
nis the index.
const PMPoint& PMBezierCurve::GetP0 () const
inline
Returns
the first point.
const PMPoint& PMBezierCurve::GetP1 () const
inline
Returns
the second point.
const PMPoint& PMBezierCurve::GetP2 () const
inline
Returns
the third point.
const PMPoint& PMBezierCurve::GetP3 () const
inline
Returns
the fourth point.
PMRect PMBezierCurve::GetPathBounds () const

Returns the bounds of the path. This does not include the control points

Returns
the bounding box of the path not including control points.
int32 PMBezierCurve::GetStepSize (const PMRealflatness) const

Returns a step value that when passed into FlattenCurve will result in the given flatness.

Parameters
flatnessis the desired flatness, where 0 < flatness <= 1.0
bool16 PMBezierCurve::HitTest (const PMRectr) const

Returns whether the given rectangle intersects the curve.

Parameters
ris the rectangle to test.
Returns
true if given rectangle intersects the curve.
void PMBezierCurve::ReadWrite (IPMStreamiPMStream)

Read/Write bezier from/to given stream.

Parameters
iPMStreamis the stream.
static void PMBezierCurve::Reduce (PMPointP,
const PMPointA,
const PMPointB,
const PMRealu 
)
static

Reduce the Bezier. The equation for this method is P = A*(1-u) + B*u

void PMBezierCurve::SetNthPoint (int32 n,
const PMPointp 
)

Sets the nth point to p.

Parameters
nis the index of the point.
pis the new point.
void PMBezierCurve::SetP0 (const PMPointp)
inline

Sets the first point to p.

Parameters
pspecifies the new first point.
void PMBezierCurve::SetP1 (const PMPointp)
inline

Sets the second point to p.

Parameters
pspecifies the new second point.
void PMBezierCurve::SetP2 (const PMPointp)
inline

Sets the third point to p.

Parameters
pspecifies the new third point.
void PMBezierCurve::SetP3 (const PMPointp)
inline

Sets the fourth point to p.

Parameters
pspecifies the new fourth point.
void PMBezierCurve::SubDivide (const PMRealu,
PMBezierCurvebezLeft,
PMBezierCurvebezRight 
) const

Subdivide curve into two other curves at the given parameter.

Parameters
uis the parameter.
bezLeftis the resulting left bezier.
bezRightis the resulting right bezier.
void PMBezierCurve::SubSegment (const PMRealbegU,
const PMRealendU,
PMBezierCurvesubSegment 
) const

Take a segment from begU to endU.

Parameters
begU
endU
subSegmentis the resulting bezier from begU and endU.
void PMBezierCurve::TransformPoints (const PMMatrixxForm)

Transform the curve with the given matrix

Parameters
xFormis the matrix to transform by.

Friends And Related Function Documentation

bool16 operator!= (const PMBezierCurvea,
const PMBezierCurveb 
)
friend

Compare two PMBezierCurve

Parameters
ais one beszier curve.
bis the other bezier curve.
Returns
true it a and b are not equal.
bool16 operator== (const PMBezierCurvea,
const PMBezierCurveb 
)
friend

Compare two PMBezierCurve

Parameters
ais one beszier curve.
bis the other bezier curve.
Returns
true it a and b are equal.