30 #ifndef _D_IMAGE_DRAW_H
31 #define _D_IMAGE_DRAW_H
36 #include "Core/include/DCommon.h"
37 #include "Core/include/DBaseObject.h"
63 int xMax = 0,
int yMax = 0)
65 vector<IntPoint> points;
86 if ((xMax == 0) || (x >= 0 && x < xMax))
94 else if (p1y == p2y) {
98 if ((yMax == 0) || (y >= 0 && y < yMax))
100 points.push_back(
IntPoint(x, y, 0));
110 int dy2_minus_dx2 = dy2 - dx2;
111 int dy2_plus_dx2 = dy2 + dx2;
122 if ((xMax == 0) || (x >= 0 && x < xMax && y >= 0 && y < yMax))
123 points.push_back(
IntPoint(x, y, 0));
141 if ((xMax == 0) || (x >= 0 && x < xMax && y >= 0 && y < yMax))
142 points.push_back(
IntPoint(x, y, 0));
161 if ((xMax == 0) || (x >= 0 && x < xMax && y >= 0 && y < yMax))
162 points.push_back(
IntPoint(x, y, 0));
180 if ((xMax == 0) || (x >= 0 && x < xMax && y >= 0 && y < yMax))
181 points.push_back(
IntPoint(x, y, 0));
194 std::reverse(points.begin(), points.end());
211 vector<IntPoint>
bresenhamLine(
int p1x,
int p1y,
int p2x,
int p2y);
237 doBresenham3D(pi.x, pi.y, pi.z, pf.x, pf.y, pf.z);
249 doBresenham3D(pi.x, pi.y, pi.z, pf.x, pf.y, pf.z);
259 Bresenham(
int xi,
int yi,
int zi,
int xf,
int yf,
int zf)
269 doBresenham3D(xi, yi, zi, xf, yf, zf);
288 doBresenham3D(xi, yi, 0, xf, yf, 0);
333 void printSelf(ostream &os = std::cout,
string indent =
"")
335 os << indent <<
"Bresenham Line" << endl;
336 os << indent <<
"Class : " << className << endl;
339 for (UINT i = 0; i < pts.size(); i++)
340 os << indent <<
"#" << i + 1 <<
"\t: (" << pts[i].x <<
"," << pts[i].y
341 <<
"," << pts[i].z <<
")" << endl;
348 vector<IntPoint> pts;
355 void doBresenham3D(
int x1,
int y1,
int z1,
int x2,
int y2,
int z2)
360 int xInc, yInc, zInc;
361 int xLen, yLen, zLen;
369 xInc = (dx < 0) ? -1 : 1;
372 yInc = (dy < 0) ? -1 : 1;
375 zInc = (dz < 0) ? -1 : 1;
382 if ((xLen >= yLen) && (xLen >= zLen)) {
383 int err_1 = dy2 - xLen;
384 int err_2 = dz2 - xLen;
385 for (
int i = 0; i < xLen; i++) {
403 if ((yLen >= xLen) && (yLen >= zLen)) {
404 int err_1 = dx2 - yLen;
405 int err_2 = dz2 - yLen;
406 for (
int i = 0; i < yLen; i++) {
424 if ((zLen >= xLen) && (zLen >= yLen)) {
425 int err_1 = dy2 - zLen;
426 int err_2 = dx2 - zLen;
427 for (
int i = 0; i < zLen; i++) {
Base Smil Object.
Definition: DBaseObject.h:52
Bresenham Class.
Definition: DImageDraw.h:225
double length()
length() - length of the line (Euclidean distance between extremities)
Definition: DImageDraw.h:327
vector< IntPoint > getPoints() const
getPoints() - access a vector with the points of the line
Definition: DImageDraw.h:296
Bresenham(int xi, int yi, int zi, int xf, int yf, int zf)
Constructor : build a 3D line defined by the coordinates of extremities.
Definition: DImageDraw.h:259
Bresenham(int xi, int yi, int xf, int yf)
Constructor : build a 2D line defined by the coordinates of extremities.
Definition: DImageDraw.h:279
Bresenham(const IntPoint &pf)
Constructor : build a line (2D or 3D) with extremities the origin and pf
Definition: DImageDraw.h:246
Bresenham(const IntPoint &pi, const IntPoint &pf)
Constructor : build a line (2D or 3D) with extremities pi and pf
Definition: DImageDraw.h:234
size_t nbPoints()
nbPoints() - the number of pixels in the line
Definition: DImageDraw.h:317
IntPoint getPoint(UINT i)
getPoint() -
Definition: DImageDraw.h:306
RES_T sqrt(const Image< T1 > &imIn, Image< T2 > &imOut)
sqrt() - square root of an image
Definition: DImageArith.hpp:926
RES_T pow(const Image< T1 > &imIn, Image< T2 > &imOut, double exponent=2)
pow() - power of an image
Definition: DImageArith.hpp:905
vector< IntPoint > bresenhamPoints(int p1x, int p1y, int p2x, int p2y, int xMax=0, int yMax=0)
Find intermediate points forming a line between two end points, using the Bresenham Line Draw Algorit...
Definition: DImageDraw.h:62
vector< IntPoint > bresenhamLine(int p1x, int p1y, int p2x, int p2y)
Find intermediate points forming a line between two end points, using the Bresenham Line Draw Algorit...
Definition: DDraw.cpp:42