PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PUREScissor Class Reference

Scissor operations class. More...

Detailed Description

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.

#include <PureScissor.h>

Public Types

typedef int CS_RGNCODE
 

Static Public Member Functions

static bool DoScissor (int &x0, int &y0, int &x1, int &y1, int xmin, int xmax, int ymin, int ymax)
 Runs the scissoring algorithm for the given user line.
 

Static Public Attributes

static const CS_RGNCODE CS_INSIDE = 0
 
static const CS_RGNCODE CS_LEFT = 1
 
static const CS_RGNCODE CS_RIGHT = 2
 
static const CS_RGNCODE CS_BOTTOM = 4
 
static const CS_RGNCODE CS_TOP = 8
 

Private Member Functions

 PUREScissor ()
 
 PUREScissor (const PUREScissor &other)
 
PUREScissoroperator= (const PUREScissor &other)
 
virtual ~PUREScissor ()
 

Static Private Member Functions

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.
 

Member Typedef Documentation

◆ CS_RGNCODE

Definition at line 30 of file PureScissor.h.

Constructor & Destructor Documentation

◆ PUREScissor() [1/2]

PUREScissor::PUREScissor ( )
inlineprivate

Definition at line 49 of file PureScissor.h.

◆ PUREScissor() [2/2]

PUREScissor::PUREScissor ( const PUREScissor & other)
inlineprivate

Definition at line 51 of file PureScissor.h.

◆ ~PUREScissor()

virtual PUREScissor::~PUREScissor ( )
inlineprivatevirtual

Definition at line 59 of file PureScissor.h.

Member Function Documentation

◆ canTrivialAccept()

bool PUREScissor::canTrivialAccept ( PUREScissor::CS_RGNCODE cp0,
PUREScissor::CS_RGNCODE cp1 )
staticprivate

Based on the given region codes of 2 points, tells if the line defined by the 2 points can be trivially accepted or not.

Returns
True if the line can be trivially accepted, otherwise false.

Definition at line 230 of file PUREScissor.cpp.

◆ canTrivialReject()

bool PUREScissor::canTrivialReject ( PUREScissor::CS_RGNCODE cp0,
PUREScissor::CS_RGNCODE cp1 )
staticprivate

Based on the given region codes of 2 points, tells if the line defined by the 2 points can be trivially rejected or not.

Returns
True if the line can be trivially rejected, otherwise false.

Definition at line 220 of file PUREScissor.cpp.

◆ ComputeCode()

PUREScissor::CS_RGNCODE PUREScissor::ComputeCode ( int x,
int y,
int xmin,
int xmax,
int ymin,
int ymax )
staticprivate

Determines the region code for the given (x,y) point.

Parameters
xX-coordinate of the given point.
yY-coordinate of the given point.
xminX-coordinate of the left edge of the clip window.
xmaxX-coordinate of the right edge of the clip window.
yminY-coordinate of the bottom edge of the clip window.
ymaxY-coordinate of the top edge of the clip window.
Returns
Region code for the given (x,y) point.

Definition at line 122 of file PUREScissor.cpp.

◆ DoScissor()

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
x0X-position of P0 point of user line.
y0Y-position of P0 point of user line.
x1X-position of P1 point of user line.
y1Y-position of P1 point of user line.
xminX-position of left vertical clipping line.
yminY-position of bottom horizontal clipping line.
xmaxX-position of right vertical clipping line.
ymaxY-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.

◆ IntersectBottom()

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
x0X-position of P0 point of user line.
y0Y-position of P0 point of user line.
x1X-position of P1 point of user line.
y1Y-position of P1 point of user line.
yminY-position of bottom clipping line.

Definition at line 202 of file PUREScissor.cpp.

◆ IntersectLeft()

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
x0X-position of P0 point of user line.
y0Y-position of P0 point of user line.
x1X-position of P1 point of user line.
y1Y-position of P1 point of user line.
xminX-position of left clipping line.

Definition at line 150 of file PUREScissor.cpp.

◆ IntersectRight()

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
x0X-position of P0 point of user line.
y0Y-position of P0 point of user line.
x1X-position of P1 point of user line.
y1Y-position of P1 point of user line.
xmaxX-position of right clipping line.

Definition at line 168 of file PUREScissor.cpp.

◆ IntersectTop()

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
x0X-position of P0 point of user line.
y0Y-position of P0 point of user line.
x1X-position of P1 point of user line.
y1Y-position of P1 point of user line.
ymaxY-position of top clipping line.

Definition at line 184 of file PUREScissor.cpp.

◆ operator=()

PUREScissor & PUREScissor::operator= ( const PUREScissor & other)
inlineprivate

Definition at line 53 of file PureScissor.h.

◆ Swap()

void PUREScissor::Swap ( int & a,
int & b )
staticprivate

Definition at line 208 of file PUREScissor.cpp.

Member Data Documentation

◆ CS_BOTTOM

const PUREScissor::CS_RGNCODE PUREScissor::CS_BOTTOM = 4
static

Definition at line 35 of file PureScissor.h.

◆ CS_INSIDE

const PUREScissor::CS_RGNCODE PUREScissor::CS_INSIDE = 0
static

Definition at line 32 of file PureScissor.h.

◆ CS_LEFT

const PUREScissor::CS_RGNCODE PUREScissor::CS_LEFT = 1
static

Definition at line 33 of file PureScissor.h.

◆ CS_RIGHT

const PUREScissor::CS_RGNCODE PUREScissor::CS_RIGHT = 2
static

Definition at line 34 of file PureScissor.h.

◆ CS_TOP

const PUREScissor::CS_RGNCODE PUREScissor::CS_TOP = 8
static

Definition at line 36 of file PureScissor.h.


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