Clipping must account for all of the viewport's boundaries. The Cohen-Sutherland Method is used to clip lines to a viewport. An outcode is determined by the position of an endpoint and is a 4-bit value indicating whether it is outside of the viewport to the top (MSB), bottom, right, or left (LSB) side(s).
The algorithm can be summarized as follows:
The worst case will iterate four times through the algorithm.
Clipping objects other than straight lines is rather difficult and/or computationally expensive. Clipping polygons involves ownership and adjacency problems as well as dealing with gaps formed when mesh surfaces are created and rotated.
G. Hill Price