Graphics and geometry classes

The graphics and geometry classes provide functionality for every area of graphics programming. You can use graphics and geometry classes together, or use the geometry classes by themselves. You can also extend the graphics classes by creating your own graphics class. You can design your own class to use as many geometry classes as you want.

The geometry classes provide many ways to construct the shape because the geometry is constructed first and then used to construct the graphic. The graphics classes constructors give you the option of including an attribute bundle.

When you use a graphic class to create a shape, you get the following:

WIth graphics classes you can use the
TBoundsMaker class to return a tight bounding box that fits snuggly against the graphic's geometry. This bounding box can be used, for example, to determine whether a graphic has been selected. Other methods return a bounding box that does not have a tight fit.

The 2-D and 3-D graphics classes are described first followed by the geometry classes. Because the 2-D and 3-D graphics classes consist of a number of concrete class that descend from MDrawable, the class architecture for graphics is described under the heading "Graphics class architecture" on page 12. This section provides a description of the kinds of graphics classes available.

2D graphics

The 2-D graphics classes provide basic 2-D geometric shapes, high-level curve functionality, the ability to create arbitrary shapes, and classes that let you work with more than one shape as a unit.

2D lines, polylines, ellipses, and polygons: Classes that define 2D graphics, 2D geometries, and common 2D graphic behavior (drawing, attributes, transformations, and hit detection).

2D curves and loops: Curve and loop classes that create open and closed NURB shapes. Curves and loops can represent the geometry of all 2D geometry classes. The 2D curve geometry takes any 2D geometry in its constructor.

2D images (bitmaps): 2D graphic class that converts basic geometry from worldcoordinate units to pixels. 2D attribute bundles have special properties for determining the color of the image (transfer modes) and for specifying filters to control the appearance of an image when it has been enlarged or shrunk.

2-D Text: A class for displaying a text string that can be moved, rotated, or scaled.

2D attributes bundles: Classes that define the appearance of a 2D graphic when it is drawn. Examples of 2D attributes include fill and frame colors and patterns.

2D cached graphics: Classes for improving the drawing speed of 2D graphics.

2D picture: A class for making a 2D composite drawing of 2D and 3D graphics that is transformed as a unit.

2D group: A class for combining 2D graphics into a unit that is treated as a whole. You can transform the entire group, and you can transform any individual graphic in the group by itself.

Constructive area geometry (CAG): Area classes that let you perform operations on a set of basic 2D geometry to create an arbitrary 2D shape.

3D graphics

The 3-D graphics classes provide basic 3-D geometric shapes, high-level curve functionality, classes that let you work with more than one shape as a unit, sweep for creating surface shapes from curve input, and shaders for defining the appearance of the inside and outside surface colors of a 3-D shape.

3D lines and polylines: Classes that define 3D graphics, 3D geometries, and common 3D graphic behavior (drawing, attributes, transformations, and hit detection).

3D curve: Curve classes that create NRUB curve shapes and that can represent the geometry of all 2D and 3D geometry classes. The 3D curve geometry takes any 3D geometry in its constructor, plus a 2D curve geometry. This design lets you convert any 2D geometry to a 3D geometry.

3D surfaces: Classes for creating quadrilateral shapes such as cylinders, spheres, and tori.

3D sweeps: Wrapper Classes for creating surfaces that do not require you to understand the details of surface geometry.

3D attributes bundles: Classes that define the appearance of a 3D graphic when it is drawn. Examples of 3D attributes include the interior and exterior surface colors and shaders.

3D scene bundle: Classes that define the light, camera, and atmosphere (effect of fog, clouds, and haze) that affect the appearance of all graphics in a scene.

3D groups: A class for combining 3D graphics into a unit that is treated as a whole. You can transform the entire group, and you can transform any individual graphic in the group by itself.

Graphics classes that combine

The following classes from the discussions above let you combine simpler shapes into complex shapes.

2-D picture

2-D and 3-D groups

2-D image

2-D constructive area geometry

2-D geometry classes

The 2-D geometry classes provide basic geometric shapes for 2-D modeling.

TGLine: A line segment defined by a starting point and an ending point.

TGPolyline: A set of points connected by straight lines.

TGCurve: Free-form curves, arcs, and path geometry.

TGEllipse: Elliptical shapes including circles.

TGLoop: A closed curve that can be filled as well as framed.

TGPolygon: A closed polyline that can be filled as well as framed.

TGArea: An arbitrary shape created from Boolean operations on one or more 2D geometries.

TGGlyphRun: A specialized text string for creating local text layout systems only.

TGImage: A pixel-based graphic.

3-D geometry classes

The3-D geometry classes provide basic geometric shapes for 3-D modeling.

TGLine3D: A line segment defined in 3-D space by two endpoints.

TGPolyline3D: A set of points in 3-D space connected by straight lines.

TGCurve3D: Free-form curves, arcs, and path geometry in 3-D space.

TGSurface3D: Common quadratic shapes such as cones, cylinders, spheres, tori, rotation surfaces, linear surfaces, rounded boxes, rounded cylinders, and simple flat surfaces.

3-D Sampled surface: TSampledSurface3D does not descend from MGraphic. It is a geometry class that is created from a user-defined geometry class. It lets you implement your own algorithm to divide a 3-D surface into discrete points. See Chapter 14 for details on TSampledSurface3D.

Corresponding classes

The graphics classes have a corresponding geometry class as shown below. Refer to the online Class and Member function descriptions to see the many ways in which the geometry classes can be created. Although some geometry classes can be created from other geometry classes, all geometry classes are ultimately based on the underlying 2-D and 3-D geometry classes summarized in the next heading.

Graphics class Corresponding geometry class
2-D TLine TGLine
TPolyline TGPolyline
TCurve TGCurve
TEllipse TGEllipse
TLoop TGLoop
TPolygon TGPolygon
TArea TGArea
TImage TGImage
3-D TLine3D TGLine3D
TPolyline3D TGPolyline3D
TCurve3D TGCurve3D
TSurface3D TGSurface3D
Sweep classes TGSurface3D

Underlying 2-D geometry classes

The underlying 2-D geometry classes are described in Chapter 2. These classes are used for 2-D geometric calculations and as building blocks for other 2-D geometry classes.

TGPoint: Represents a 2-D point.

TGRPoint: Represents rational (homogeneous) 2-D points.

TGPointArray: Represents an extensible array of 2-D points used in cases where an array or list of points is needed.

TGRPointArray: Represents an extensible array of 2-D rational (homogeneous) points used in cases where an array or list of points is needed.

TGInfiniteLine: Used for 2-D geometric calculations and as a basic building block for other 2-D geometry classes.

TGRect: Used for 2-D geometric calculations and as a basic building block for other 2-D geometry classes. This is the only underlying 2-D geometry class that can be sent directly t to the drawing port for rendering. It is used to construct ellipses and polygons.

Underlying 3-D geometry classes

The underlying 3-D geometry classes are described in Chapter 12. These classes are used for 3-D geometric calculations and as building blocks for other 3-D geometry classes.

TGPoint3D: Represents a 3-D point.

TGRPoint3D: Represents rational (homogeneous) 3-D points.

TGPointArray3D: Represents an extensible array of 3-D points used in cases where an array or list of points is needed.

TGRPointArray3D: Represents an extensible array of 3-D rational (homogeneous) points used in cases where an array or list of points is needed.

TGBox3D: Used for 3-D geometric calculations and as a basic building block for other 3-D geometry classes. This is the only underlying 3-D geometry class that can be sent directly t to the drawing port for fast wireframe rendering.


[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