Scissor operations class.
Currently this class implements Cohen-Sutherland line clipping.
Not following the Pimpl idiom here as there are no hidden members in this class for the outside world.
Definition at line 22 of file PureScissor.h.
|
static CS_RGNCODE | ComputeCode (int x, int y, int xmin, int xmax, int ymin, int ymax) |
| Determines the region code for the given (x,y) point.
|
|
static void | IntersectLeft (int &x0, int &y0, int &x1, int &y1, int xmin) |
| Calculates intersection point of left clipping line and user line.
|
|
static void | IntersectRight (int &x0, int &y0, int &x1, int &y1, int xmax) |
| Calculates intersection point of right clipping line and user line.
|
|
static void | IntersectTop (int &x0, int &y0, int &x1, int &y1, int ymax) |
| Calculates intersection point of top clipping line and user line.
|
|
static void | IntersectBottom (int &x0, int &y0, int &x1, int &y1, int ymin) |
| Calculates intersection point of bottom clipping line and user line.
|
|
static void | Swap (int &a, int &b) |
|
static bool | canTrivialReject (PUREScissor::CS_RGNCODE cp0, PUREScissor::CS_RGNCODE cp1) |
| Based on the given region codes of 2 points, tells if the line defined by the 2 points can be trivially rejected or not.
|
|
static bool | canTrivialAccept (PUREScissor::CS_RGNCODE cp0, PUREScissor::CS_RGNCODE cp1) |
| Based on the given region codes of 2 points, tells if the line defined by the 2 points can be trivially accepted or not.
|
|
bool PUREScissor::DoScissor |
( |
int & | x0, |
|
|
int & | y0, |
|
|
int & | x1, |
|
|
int & | y1, |
|
|
int | xmin, |
|
|
int | xmax, |
|
|
int | ymin, |
|
|
int | ymax ) |
|
static |
Runs the scissoring algorithm for the given user line.
User line is defined by P0(x0,y0) and P1(x1,y1) points. P0 and P1 points might be updated by this function. A point can be updated after intersection calculation and it may be also swapped with the other point. This means that input P0 and P1 might be updated as:
- P0' and P1,
- P1' and P0 (swapped order compared to input), where P0' and P1' are calculated points of user line intersecting with a clipping line.
- Parameters
-
x0 | X-position of P0 point of user line. |
y0 | Y-position of P0 point of user line. |
x1 | X-position of P1 point of user line. |
y1 | Y-position of P1 point of user line. |
xmin | X-position of left vertical clipping line. |
ymin | Y-position of bottom horizontal clipping line. |
xmax | X-position of right vertical clipping line. |
ymax | Y-position of top horizontal clipping line.
|
- Returns
- True if user line or part of it needs draw i.e. falls within the inside region (0000), false otherwise. If true, P0 and P1 points might be updated so they fit into the inside clipping region.
Definition at line 64 of file PUREScissor.cpp.
void PUREScissor::IntersectBottom |
( |
int & | x0, |
|
|
int & | y0, |
|
|
int & | x1, |
|
|
int & | y1, |
|
|
int | ymin ) |
|
staticprivate |
Calculates intersection point of bottom clipping line and user line.
User line is defined by P0(x0,y0) and P1(x1,y1) points. Intersection point will be updated in (x0,y0).
- Parameters
-
x0 | X-position of P0 point of user line. |
y0 | Y-position of P0 point of user line. |
x1 | X-position of P1 point of user line. |
y1 | Y-position of P1 point of user line. |
ymin | Y-position of bottom clipping line. |
Definition at line 202 of file PUREScissor.cpp.
void PUREScissor::IntersectLeft |
( |
int & | x0, |
|
|
int & | y0, |
|
|
int & | x1, |
|
|
int & | y1, |
|
|
int | xmin ) |
|
staticprivate |
Calculates intersection point of left clipping line and user line.
User line is defined by P0(x0,y0) and P1(x1,y1) points. Intersection point will be updated in (x0,y0).
- Parameters
-
x0 | X-position of P0 point of user line. |
y0 | Y-position of P0 point of user line. |
x1 | X-position of P1 point of user line. |
y1 | Y-position of P1 point of user line. |
xmin | X-position of left clipping line. |
Definition at line 150 of file PUREScissor.cpp.
void PUREScissor::IntersectRight |
( |
int & | x0, |
|
|
int & | y0, |
|
|
int & | x1, |
|
|
int & | y1, |
|
|
int | xmax ) |
|
staticprivate |
Calculates intersection point of right clipping line and user line.
User line is defined by P0(x0,y0) and P1(x1,y1) points. Intersection point will be updated in (x0,y0).
- Parameters
-
x0 | X-position of P0 point of user line. |
y0 | Y-position of P0 point of user line. |
x1 | X-position of P1 point of user line. |
y1 | Y-position of P1 point of user line. |
xmax | X-position of right clipping line. |
Definition at line 168 of file PUREScissor.cpp.
void PUREScissor::IntersectTop |
( |
int & | x0, |
|
|
int & | y0, |
|
|
int & | x1, |
|
|
int & | y1, |
|
|
int | ymax ) |
|
staticprivate |
Calculates intersection point of top clipping line and user line.
User line is defined by P0(x0,y0) and P1(x1,y1) points. Intersection point will be updated in (x0,y0).
- Parameters
-
x0 | X-position of P0 point of user line. |
y0 | Y-position of P0 point of user line. |
x1 | X-position of P1 point of user line. |
y1 | Y-position of P1 point of user line. |
ymax | Y-position of top clipping line. |
Definition at line 184 of file PUREScissor.cpp.