Kernel SDK Developer's Guide > Working with the Ge Library > Working with Surfaces > Working with Tori
Working with Tori

Using the Ge library you can create and modify toruses. A torus is a surface generated by revolving a circular arc about an axis of symmetry, where the plane of the circular arc contains the axis of symmetry.

A torus is defined by the following parameters:

  • The torus center, which is a point on the axis of symmetry
  • The center of the generating circular arc and its radius (minor radius)
  • The distance from the torus center to the center of the generating arc (major radius)

Parameter V is the longitude (about the axis of symmetry), which for a closed torus defaults to the range [-OdaPI, OdaPI). Zero corresponds to the reference axis (which is a vector orthogonal to the axis of symmetry). Applying the right hand rule along the symmetric axis (axisOfSymmetry X refAxis) defines the increasing direction for V if isReverseV() is false, and decreasing direction otherwise.

Parameter U parameterizes the circular tube, which for a closed circle defaults to the range [-OdaPI, OdaPI). Applying the right hand rule along the (reference axis)×(-axisOfSymmetry) defines an increasing direction for U.

The torus can be periodic in either parametric direction, with a period of Oda2PI.

A torus is represented by the OdGeTorus class. To create a torus, use one of the OdGeTorus() constructors:

  • OdGeTorus::OdGeTorus() — Default constructor. Constructs a torus with the center of (0,0,0), reference vector of (1,0,0), axis of symmetry of (0,0,1), major radius of 1.0, and minor radius of 0.5.
  • OdGeTorus::OdGeTorus(double majorRadius, double minorRadius, const OdGePoint3d& center, const OdGeVector3d& axisOfSymmetry) — Creates a torus with the specified major radius, minor radius, center, and axis of symmetry.
  • OdGeTorus::OdGeTorus(double majorRadius, double minorRadius, const OdGePoint3d& center, const OdGeVector3d& axisOfSymmetry, const OdGeVector3d& refAxis, double startAngleU, double endAngleU, double startAngleV, double endAngleV) — Creates a torus with the specified major radius, minor radius, center, axis of symmetry, reference axis, start latitude, end latitude, start longitude, and end longitude.
  • OdGeTorus::OdGeTorus(const OdGeTorus& source) — Creates a torus cloned from the source torus object.

An OdGeTorus object provides methods for working with torus properties:

  • center() — Returns the center.
  • axisOfSymmetry() — Returns the axis of symmetry (rotation).
  • majorRadius() — Returns the major radius.
  • minorRadius() — Returns the minor radius.
  • refAxis() — Returns the reference axis.
  • getAnglesInU() — Returns the start and end longitude.
  • getAnglesInV() — Returns the start and end latitude.
  • isReverseV() — Checks whether V parameter is increasing in clockwise direction around axisOfSymmetry.
  • setReverseV() — Specifies whether V parameter is increasing in clockwise direction around axisOfSymmetry.

To set torus properties, use the corresponding methods: setAnglesInU(), setAnglesInV(), setMajorRadius(), setMinorRadius(). Note that angles along U parameter are reset to the maximum allowed for the established minorRadius and majorRadius when using the setMajorRadius() and setMinorRadius() methods. Also when using the setAnglesInU(), the angles are set as the result of the intersection of the natural interval with the one that is formed from the passed values to the method (for Vortex, Apple, Lemon torus types). To define a set of properties, use the specific set() method. For example:

OdGeTorus torus1;
torus1.set(1.0, 2.0, OdGePoint3d(5.0, 0.0, 0.0), OdGeVector3d(0.0, 1.0, 0.0));
torus1.setMinorRadius(1.5);

OdGeTorus torus2(torus1.majorRadius(), -1 * torus1.minorRadius(), OdGePoint3d(0.0, 0.0, 0.0), OdGeVector3d(0.0, 0.0, 1.0));

Torus types

There are four forms of a torus, which are determined by the magnitude of major radius relative to the magnitude of the minor radius:

  • The torus is a doughnut (normal) type if (majorRadius ≥ |minorRadius| + OdGeContext::gTol.equalVector()).
  • The torus is a vortex if (|majorRadius - |minorRadius|| < OdGeContext::gTol.equalVector()).
  • The torus is an apple if (0 < majorRadius ≤ |minorRadius| - OdGeContext::gTol.equalVector()).
  • The torus is a lemon if (majorRadius ≤ 0).

To check if the torus is of a specific type, use the appropriate method: isDoughnut(), isVortex(), isApple(), or isLemon().

Vortex, apple, and lemon toruses are degenerate; this means that (majorRadius < |minorRadius| + OdGeContext::gTol.equalVector()). To check if the torus is degenerate, use the isDegenerate() method.

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.