openEmbroider  0.1
an open source embroidery software
OE_curve Class Referenceabstract
Inheritance diagram for OE_curve:
OE_base OE_joincurve OE_pointcurve OE_subcurve

Public Member Functions

 OE_curve ()
 
virtual ~OE_curve ()
 
int getNpts ()
 return the number of points in the curve (control points, without handles)
 
bool getClosed ()
 return true if the curve is set as closed.
 
float getLength (float maxDist)
 return the length of the curve.
 
void setClosed (bool closed)
 set the curve closed attribute.
 
virtual void getBound (float *xMin, float *yMin, float *xMax, float *yMax)
 calculate the curve bounding box More...
 
std::vector< vector_2dsubCurve (float start, float end, bool rev)
 return a segment of the original curve More...
 
std::vector< vector_2ddiscretizeFast (float maxDist)
 discretise a curve using a level of detail approach More...
 
std::vector< vector_2ddiscretizeRegular (float dist)
 discretise a curve using uniform segment lengths More...
 
void reverse ()
 reverse the curve.
 
virtual bool check ()
 check if the curve is valid.
 
virtual void refresh ()=0
 
bool refresh (float dpi)
 refresh the discPts array.
 
- Public Member Functions inherited from OE_base
 OE_base ()
 
virtual ~OE_base ()
 
bool getNeedRefresh ()
 
void setNeedRefresh ()
 
void addDependency (OE_base *object)
 add and remove dependency from the list More...
 
void removeDependency (OE_base *object)
 
virtual void delDependency (OE_base *object)
 the function called by a reference object when he's deleted More...
 
 OE_base ()
 
virtual ~OE_base ()
 
bool getNeedRefresh ()
 
void setNeedRefresh ()
 
void addDependency (OE_base *object)
 add and remove dependency from the list More...
 
void removeDependency (OE_base *object)
 
virtual void delDependency (OE_base *object)
 the function called by a reference object when he's deleted More...
 

Public Attributes

bool controls = false
 is displaying controls.
 
std::vector< vector_2ddiscPts
 the curve array of discretized points
 
std::vector< vector_2dpts
 the bezier curve array of points
 

Protected Member Functions

std::vector< vector_2ddiscretizeCubicBez (vector_2d pt1, vector_2d pt2, vector_2d pt3, vector_2d pt4, float tol, int level)
 discretise a curve segment to display or treating it More...
 
std::vector< vector_2dinterPoint (vector_2d pt1, vector_2d pt2, vector_2d pt3, vector_2d pt4, float t)
 return a segment of the original curve More...
 

Static Protected Member Functions

static float distPtSeg (vector_2d pt, vector_2d seg1, vector_2d seg2)
 calculate the distance beetween a point and a segment More...
 
static bool ptInBounds (vector_2d pt, float *bounds)
 check if a point is in a given bounding box More...
 
static double evalBezier (double t, double p0, double p1, double p2, double p3)
 get the position of a 1D point on a bezier segment More...
 
static void segmentBounds (float *bounds, vector_2d *segment)
 calculate a segment bounding box More...
 
- Static Protected Member Functions inherited from OE_base
static bool ptInBounds (vector_2d pt, float *bounds)
 check if a point is in a given bounding box More...
 
static bool ptInBounds (vector_2d pt, float *bounds)
 check if a point is in a given bounding box More...
 

Protected Attributes

bool closed = false
 Flag indicating if shapes should be treated as closed.
 
- Protected Attributes inherited from OE_base
std::list< OE_base * > objects
 
float bounds [4]
 Tight bounding box of the object [minx,miny,maxx,maxy].
 
bool needRefresh = true
 flag to know who must be refreeshed
 

Static Protected Attributes

static unsigned char lineColor [4] = {0,160,192,255}
 Tight bounding box of the shape [minx,miny,maxx,maxy]. More...
 

Constructor & Destructor Documentation

OE_curve::OE_curve ( )

Default constructor

OE_curve::~OE_curve ( )
virtual

Default destructor

Member Function Documentation

std::vector< vector_2d > OE_curve::discretizeCubicBez ( vector_2d  pt1,
vector_2d  pt2,
vector_2d  pt3,
vector_2d  pt4,
float  tol,
int  level 
)
protected

discretise a curve segment to display or treating it

Parameters
pt1to pt4 -> the bezier points of the curve segment
themaximum distance beetween a discretised point and the real curve
avalue that represent the deep of the discretisation (level of subdivision)
Returns
return an array of point, the segment discretised
std::vector< vector_2d > OE_curve::discretizeFast ( float  maxDist)

discretise a curve using a level of detail approach

Parameters
maxDistis a maximum error distance beetween the discretised curve and the real one
Returns
return an array of point, the curve discretised
std::vector< vector_2d > OE_curve::discretizeRegular ( float  dist)

discretise a curve using uniform segment lengths

Parameters
distis the length of a segment along the curve
Returns
return an array of point, the curve discretised
float OE_curve::distPtSeg ( vector_2d  pt,
vector_2d  seg1,
vector_2d  seg2 
)
staticprotected

calculate the distance beetween a point and a segment

Parameters
pt-> the point to test
seg1and seg2 -> the extremity of the segment
Returns
return the distance
double OE_curve::evalBezier ( double  t,
double  p0,
double  p1,
double  p2,
double  p3 
)
staticprotected

get the position of a 1D point on a bezier segment

Parameters
t-> the value of the position along the segment
p0to p3 -> the 1D points values
Returns
return the position of the 1D point
void OE_curve::getBound ( float *  xMin,
float *  yMin,
float *  xMax,
float *  yMax 
)
virtual

calculate the curve bounding box

Parameters
xMin,yMin,xMax,yMax-> pointers to the bouding box variables to set

Implements OE_base.

std::vector< vector_2d > OE_curve::interPoint ( vector_2d  pt1,
vector_2d  pt2,
vector_2d  pt3,
vector_2d  pt4,
float  t 
)
protected

return a segment of the original curve

Parameters
pt1to pt4 -> the bezier points of the curve segment
t-> the position of the point along the segments
Returns
return an array of 3 point (handle,point,handle)
bool OE_curve::ptInBounds ( vector_2d  pt,
float *  bounds 
)
staticprotected

check if a point is in a given bounding box

Parameters
pt-> the point
bounds-> an array representing the bounding box
Returns
true if the point is inside the bounding box
void OE_curve::segmentBounds ( float *  bounds,
vector_2d segment 
)
staticprotected

calculate a segment bounding box

Parameters
bounds-> a pointer to a bounding box array (float[4])
curve-> the curve to be estimated
std::vector< vector_2d > OE_curve::subCurve ( float  start,
float  end,
bool  rev 
)

return a segment of the original curve

Parameters
start,end-> the position of the start and end point of the curve segment integral value is the segment number and float value the position on this segment (ex:2.3 mean pos 0.3 on segment 2)
revinvert the path
Returns
return an array of point, the curve segment

Member Data Documentation

unsigned char OE_curve::lineColor = {0,160,192,255}
staticprotected

Tight bounding box of the shape [minx,miny,maxx,maxy].

color of the curve


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