Open C++ Programmer's Guide > Open C++ Classes > Template / Helper / Math Classes
Template, Helper, and Math Classes
Template Classes
Prior to V18, Open C++ included template classes for character strings
(UgString) and dynamic arrays (UgArray), similar to STL's std::string
and std::vector. In V18, the STL classes replaced and obsoleted them. New
code should use STL directly; the headers ug_vector.hxx/ug_string.hxx are
platform-independent wrappers for the STL headers.
Migrating old code: ug_array.hxx no longer exists in V18 (remove it);
UgArray/UgString no longer exist — replace with std::vector/std::string
(or, if changing code isn't an option, typedef/#define them). A
std::string's C-style pointer (.c_str()) is const — don't write through
it.
Iteration Template Class — UgIterator
UgIterator<T> is a generic template class for cycling through all NX
objects of a given (instantiable) class:
UgIterator < UgFace * > curFace;
while ( !curFace->isFinished ( ) ) {
std::string faceName = (*curFace)->getName ( );
curFace->findNext ( );
}
Three steps: (1) construct a UgIterator<T> naming the specific NX class
(must be instantiable — e.g. UgFace, not a base class like
UgConicObject; optional constructor arg iterates a different part than the
current work part); (2) loop until isFinished() returns true; (3) use *
on the iterator to get a pointer to the current object (findNext() advances
it). The same pattern works for UgPart to iterate all loaded parts, e.g. to
close every non-metric part in the session.
Helper Classes
Helper classes pass data into/out of methods on other classes — e.g.
ThruPoint carries curvature-of-points data for a UgSpline curve:
UgSpline *pSpline; // initialized elsewhere
std::vector<ThruPoint> thruPts;
std::vector<double> params;
bool periodic;
int order;
pSpline->getThruPoints ( &periodic, &order, &thruPts, ¶ms );
Helper classes are not named with the "Ug" prefix (unlike Application/Object classes).
Math Classes
The vmathpp library provides general-purpose math classes — points,
vectors, matrices, coordinate-system objects — for use alongside NX object
classes. Standard math operators are overloaded on these classes, making
geometric code more concise/readable than calling equivalent Open C (UF)
math routines.
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.open_c_plus_plus_program · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)