Graphics functions

All 3-D graphics classes have bounds. The bounds of a graphic are defined by the smallest TGBox3D that encloses the geometry of the graphic. Figure 150 shows the MGraphic3D functions for finding the bounds. GetGeometricBounds does not take into account the attribute information when calculating the bounds, but GetLooseFitBounds does.

NOTE At the present time, there are no 3-D attributes that affect the size of the returned TGBox3D, which means that there is currently no difference between GetGeometricBounds and GetLooseFitBounds.

NOTE For a loop or curve geometry, the bounds enclose the control points.

Computing the bounds of a graphic can happen frequently and use a lot of resources. You may want to cache graphics for efficiency. You can cache 3-D graphics by drawing them into a picture. Caching is described in Chapter 9.

You might use these functions for a number of reasons depending on your program requirements. The most common is to determine whether a graphic is selected (hit or picked).


GetGeometricBounds

GetGeometricBounds returns the smallest TGBox3D that fully encloses the geometry. It uses only the geometry information to compute the bounding box (the bundle information is not taken into account).

    TGBox3D MGraphic3D::GetGeometricBounds() = 0;

GetLooseFitBounds

GetLooseFitBounds returns a
TGBox3D that encloses the entire graphic taking into account the bundle information. Bundle attributes are described in Chapter 16. It uses the drawing attribute information to compute the bounding box. GetLooseFitBounds returns a bounding box that is either the same or larger than the GetGeometricBounds box. GetLooseFitBounds can return infinite bounds.

    TGBox3D MGraphic3D::GetLooseFitBounds() const = 0;
NOTE Because the implementation for GetLooseFitBounds calls GetBounds on the geometry first, there can be a small amount of inaccuracy. The returned TGBox3D might enclose extra points beyond the graphic and its bundle information. However, at the present time, there are no 3-D attributes that affect the size of the returned TGBox3D, which means that there is currently no difference between GetGeometricBounds and GetLooseFitBounds.

Speed and accuracy

GetGeometricBounds and GetLooseFitBounds are fast and suitable when speed is more important than accuracy. For example, you could use either one for quick rejection during clipping operations. However, if accuracy is more important than speed use TBoundsMaker, which is described in Chapter 3. Also see the heading "Hit detection Example" on page 256 for a hit detection example on a 3-D graphic using TBoundsMaker.

Figure 151 shows the bounds returned with either GetGeometricBounds or GetLooseFitBounds.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker