Segment and Window Clipping
Segment and Window Clipping
• Subdivision of picture.
• Visualization of particular part of picture.
• Scaling, rotation and translation of picture.
Cont..
3. Deleting a Segment :
To delete a particular segment from display file, we must just
delete that one segment without destroying or reforming the
entire display and recover space occupied by this segment.
Use this space for some other segment.
The method to achieve this depends upon the data structure
used to represent display file. In case of arrays, the gap left by
deleted segment is filled by shifting up all the segments
following it.
Cont..
Cont..
Algorithm :
1. Read the name of the segment to be deleted.
2. If segment name is not valid, give error message : “Segment name
is not a valid name” and go to step 8.
3. If the segment is open, give error message : “Can’t delete an open
segment” and go to step 8.
4. If size of segment is less than 0, no processing is required and go to
step 8.
5. The segments which follow the deleted segment are shifted by its
size.
6. Recover deleted space by resetting index of next free instruction.
7. The starting position of shifted segments is adjusted by subtracting
the size of deleted segment from it.
8. Stop.
Cont..
4. Renaming a Segment :
This is done to achieve Double Buffering i.e. the idea of storing
two images, one to show and other to create, alter and for
animation.
Algorithm :
1. If both old and new segment names are not valid, give error
message : “Segment names are not valid names” and go to step
6.
2. If any of two segments is open, give error message : “Segments
are still open” and go to step 6.
3. If new segment name given already exists in the display list, give
error message : “Segment name already exists” and go to step 6.
4. The old segment table entry are copied into new position.
5. Delete the old segment.
6. Stop.
Cont..
Line Clipping
• The concept of line clipping is same as point clipping. In line
clipping, we will cut the portion of line which is outside of
window and keep only the portion that is inside the window.
• It is performed by using the line clipping algorithm.
• It is used for clipping line. The line is divided in two parts. Mid
points of line is obtained by dividing it in two short segments.
Again division is done, by finding midpoint. This process is
continued until line of visible and invisible category is
obtained.
• Let (xi,yi) are midpoint
Cont..