Creating sweeps
The sweep classes are designed so that you can easily create and use them. The rounded box sweep shown in Figure 169, is created in one line of code, and drawn in one more line. See the headings beginning with "Cone sweep" on page 293 for information on creating specific kinds of sweeps.
TRoundedBox3D box( 200, 200, 20 );
box.Draw( thePort );
All sweep classes, except TSweep3D, can be created and drawn just as easily. It takes a little more effort to create a sweep using TSweep3D. All TSweep3D constructor parameters except contour, trajectory, and initialContourXDirection provide default values. The code fragment below creates the simple sweep shown in Figure 170. See the heading "TSweep3D" on page 286 for a discussion of all constructor parameters.
TGLoop contour( TGEllipse( TGRect( 0, 0, 200, 200 ) ) );
contour.ReverseDirection();
TGCurve3D trajectory( TGPoint3D( 100, 0, 100 ),
TGPoint3D( 100, 50, 100 ),
TGPoint3D( 100, 75, 100),
TGPoint3D( 100, 100, 100 ) );
TSweep3D simpleSweep( contour, trajectory, TGPoint3D( 1, 0, 0 ) );
simpleSweep.Draw( port );
NOTE
Because the contour is created from an ellipse, the direction of the ellipse must be reversed with the ReverseDirection() statement because 2-D areaenclosing geometries are drawn in a counter-clockwise direction, while the contour has to go in a clockwise direction. Without the ReverseDirection function call, the sweep draws inside out as shown on the right side of Figure 170. The sweep on the left has a pink interior and a gray exterior. The sweep on the right is inside out with its pink interior on the outside and the gray exterior on the inside. The colors are, of course, easier to see online.
To make the cylinder above rectangular, contruct the contour loop directly from the rectangle without passing the rectangle to an ellipse. However, you need to call the TGLoop::CloseLoop function on the loop to get a closed sweep; otherwise, the sweep is considered open and only three sides of the rectangle are swept.
[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