An Example Clipper
One of the difficult aspects of clipping is fitting it into a clean conceptual model. Here we'll consider how I added clipping to our Triangle class.

    public void Draw(Raster raster) {
      int flag = 0;

      v0 = vlist[v[0]];
      v1 = vlist[v[1]];
      v2 = vlist[v[2]];

      float near = Vertex3D.getNear();
      if (v0.z > Raster.MAXZ) flag += 1;
      if (v1.z > Raster.MAXZ) flag += 2;
      if (v2.z > Raster.MAXZ) flag += 4;
	
This first segment of code computes our outcodes.
Lecture 12   Slide 16   6.837 Fall '00