SMIL  1.0.4
Bresenham Class Reference

Bresenham Class. More...

Detailed Description

Bresenham Class.

Find intermediate points forming a line between two end points, using the Bresenham Line Draw Algorithm - 2D or 3D lines

Example

import smilPython as sp
# first and last points in a 3D image
pi = sp.IntPoint(0, 0, 0)
pf = sp.IntPoint(60, 50, 10)
line = sp.Bresenham(pi, pf)
# grab each point and print it
for i in range(0, line.nbPoints()):
pt = line.getPoint(i)
print(" {:2d} - {:3d} {:3d} {:3d}".format(i, pt.x, pt.y, pt.z))
# get a vector of points and set them in an image
im = sp.Image(64, 64, 12)
pts = line.getPoints()
for i in range(0, len(pts)):
im.setPixel(pts[i].x, pts[i].y, pts[i].z, 255)
im.show()
See also

#include <DImageDraw.h>

+ Inheritance diagram for Bresenham:
+ Collaboration diagram for Bresenham:

Public Member Functions

 Bresenham (const IntPoint &pi, const IntPoint &pf)
 Constructor : build a line (2D or 3D) with extremities pi and pf More...
 
 Bresenham (const IntPoint &pf)
 Constructor : build a line (2D or 3D) with extremities the origin and pf More...
 
 Bresenham (int xi, int yi, int zi, int xf, int yf, int zf)
 Constructor : build a 3D line defined by the coordinates of extremities. More...
 
 Bresenham (int xi, int yi, int xf, int yf)
 Constructor : build a 2D line defined by the coordinates of extremities. More...
 
vector< IntPointgetPoints () const
 getPoints() - access a vector with the points of the line More...
 
IntPoint getPoint (UINT i)
 getPoint() - More...
 
size_t nbPoints ()
 nbPoints() - the number of pixels in the line More...
 
double length ()
 length() - length of the line (Euclidean distance between extremities) More...
 
void printSelf (ostream &os=std::cout, string indent="")
 
- Public Member Functions inherited from BaseObject
 BaseObject (const char *_className, bool _register=true)
 
 BaseObject (const BaseObject &rhs, bool _register=true)
 
BaseObjectoperator= (const BaseObject &rhs)
 
CoregetCoreInstance ()
 
virtual const char * getInfoString (const char *="") const
 
virtual void printSelf (ostream &=std::cout, string="") const
 
virtual const char * getClassName () const
 
virtual void setName (const char *_name)
 
virtual const char * getName () const
 
virtual size_t getAllocatedSize () const
 

Private Member Functions

void addPoint (IntPoint &p)
 
void doBresenham3D (int x1, int y1, int z1, int x2, int y2, int z2)
 

Private Attributes

IntPoint pi
 
IntPoint pf
 
vector< IntPointpts
 

Additional Inherited Members

- Public Types inherited from BaseObject
typedef void parentClass
 
typedef void(BaseObject::* voidMemberFunc) ()
 
- Public Attributes inherited from BaseObject
bool triggerEvents
 
- Protected Attributes inherited from BaseObject
bool registered
 
string className
 
string name
 

Constructor & Destructor Documentation

◆ Bresenham() [1/4]

Bresenham ( const IntPoint pi,
const IntPoint pf 
)
inline

Constructor : build a line (2D or 3D) with extremities pi and pf

Parameters
[in]pi: initial point
[in]pf: final point

◆ Bresenham() [2/4]

Bresenham ( const IntPoint pf)
inline

Constructor : build a line (2D or 3D) with extremities the origin and pf

Parameters
[in]pf: final point

◆ Bresenham() [3/4]

Bresenham ( int  xi,
int  yi,
int  zi,
int  xf,
int  yf,
int  zf 
)
inline

Constructor : build a 3D line defined by the coordinates of extremities.

Parameters
[in]xi,yi,zi: coordinates of initial point
[in]xf,yf,zf: coordinates of final point

◆ Bresenham() [4/4]

Bresenham ( int  xi,
int  yi,
int  xf,
int  yf 
)
inline

Constructor : build a 2D line defined by the coordinates of extremities.

Parameters
[in]xi,yi: coordinates of initial point
[in]xf,yf: coordinates of final point

Member Function Documentation

◆ getPoints()

vector<IntPoint> getPoints ( ) const
inline

getPoints() - access a vector with the points of the line

Returns
a vector with the points of the line

◆ getPoint()

IntPoint getPoint ( UINT  i)
inline

getPoint() -

Parameters
[in]i: the index of the point to be accessed

◆ nbPoints()

size_t nbPoints ( )
inline

nbPoints() - the number of pixels in the line

Returns
- the number of pixels

◆ length()

double length ( )
inline

length() - length of the line (Euclidean distance between extremities)

Returns
line length

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