Kernel SDK Developer's Guide > Working with the Ge Library > Working with Curves > Working with Offset Curves
Working with Offset Curves

The Ge library provides a representation for offset curves. An offset curve is produced by offsetting from a base curve by a specified offset distance. Consequently, all points of the offset curve lie a given perpendicular distance from the base curve.

Depending on the space dimension, offset curves can be 2D or 3D and represented in the Ge library by the OdGeOffsetCurve2d and OdGeOffsetCurve3d classes respectively. Every offset curve object contains a pointer to the curve from which it is offset, so modifying the base curve modifies the offset curve, but modifying the offset curve does not modify the base curve.

For a 2D offset curve, the positive direction of offset at each point of the base curve is defined as 90° counterclockwise from the tangent vector at this point.

For a 3D offset curve, the base curve must be planar, and the normal to the plane must be specified. The positive direction of offset at each point of the base curve is the cross product of the plane's normal vector with the tangent vector at that point.

Base curves can be offset in two directions by specifying a positive or negative offset distance value or by reversing the normal vector (for 3D curves). An offset curve with a 0.0 offset distance is an exact replica of the base curve. An offset curve with a non-zero 0.0 offset distance has continuity of one less than that of the base curve. To ensure that the offset curve is a valid curve, the base curve must have a continuity of at least 1.

The interface of the OdGeOffsetCurve2d class is similar to that of OdGeOffsetCurve3d except OdGeOffsetCurve3d has methods for working with the normal vector. This topic describes the base functionality of 3D offset curve objects but the description can be applied to 2D offset curves as well.

To create a 3D offset curve, use the OdGeOffsetCurve3d() constructor which has two signatures:

  • OdGeOffsetCurve3d(const OdGeCurve3d& baseCurve, const OdGeVector3d& planeNormal, double offsetDistance) — Creates an OdGeOffsetCurve3d object using a specified base curve, normal vector of the plane that contains the curve, and the offset distance.
  • OdGeOffsetCurve3d(const OdGeOffsetCurve3d& source) — Creates an OdGeOffsetCurve3d object cloned from the source object.

The curve(), normal(), and offsetDistance() methods are used to get the base curve, the normal, and the offset distance for the 3D offset curve object respectively.

To set the normal and the offset distance for the OdGeOffsetCurve3d object, use the setNormal() and setOffsetDistance() methods respectively.

The setCurve() method resets the base curve to a specified curve not affecting the offset distance:

OdGeOffsetCurve3d offsetCurve1(curve1, OdGeVector3d(0,0,1), 3);
OdGeOffsetCurve3d offsetCurve2(offsetCurve1);
offsetCurve2.setOffsetDistance(-2*offsetCurve1.offsetDistance());
OdGeOffsetCurve3d offsetCurve3(offsetCurve1);
offsetCurve3.setCurve(curve2);

An offset curve may be self-intersecting, even if the base curve is not.

To create offset curves that are not self-intersecting, use the OdGeCurve3d::getTrimmedOffset() method.

Using the setInterval() method for the offset curve, you can create multiple offset curves, each of which represents a separate interval of the base curve. This can be used, for example, for creating an exact copy of the base curve composed of separate curves, if the offset distance is additionally set to 0.0.

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