Tips for Efficient Use of Curve and Surface Evaluators

To gain the maximum efficiency from the curve and surface evaluators, you should reuse the AcGePointOnCurve2d, AcGePointOnCurve3d, and AcGePointOnSurface objects as much as possible when you are performing many evaluations on the same curve or surface. For example, suppose that func1 and func2 both perform evaluations on the same surface srf and func1 calls func2. Then the AcGePointOnSurface object that func1 uses for evaluations should be passed to func2:

void func1 (const AcGeSurface& srf)
{
    AcGePointOnSurface	  pntOnSrf (srf);
    .
    .  // Evaluate some points and derivatives.
    .
    func2 ( pntOnSrf );
    .
    .
    .
}
void func2 (AcGePointOnSurface& pntOnSrf)
{
    // Evaluate some points and derivatives using pntOnSrf
    // passed in from func1.
}

By passing pntOnSrf to func2, the evaluator can continue to use the same data area that was used for all the evaluations in func1. If func1 does not pass the AcGePointOnSurface object to func2, then func2 must declare a new AcGePointOnSurface object, which will create a new data area and recompute data that was computed in func1. The following code executes correctly; however, it is less efficient than the previous code:

void func1 (const AcGeSurface& srf)
{
    AcGePointOnSurface	  pntOnSrf (srf);
    ...
    func2 (srf);
    ...
}
void func2 (const AcGeSurface& srf)
{
    AcGePointOnSurface	   pntOnSrf (srf);
    .
    .   // Evaluate some points and derivatives, using new 
        // pntOnSrf declared above.
    .
}

Reusing the same AcGePointOnSurface object is important for evaluator-intensive applications, such as surface-surface intersectors or finite-element mesh generators. In the case of a surface-surface intersector, the top-level function should declare two AcGePointOnSurface objects (one for each surface) and pass these objects down through all of the lower-level routines. In this way, the application obtains maximum use of data that is saved between evaluations and obtains the maximum efficiency from its surface evaluators.

To obtain the best use of the AcGePointOnCurve2d, AcGePointOnCurve3d, and AcGePointOnSurface classes, a large number of these objects should never be in scope at the same time for the same curve or surface. In most situations, only one of these objects should be in scope for a particular curve or surface.