Root Classes, primarily implemented in the Standard package, are the classes on which all other Open CASCADE Technology classes are built. They provide:
- Primitive types such as Boolean, Character, Integer or Real
- A memory manager based on reference counting for optimizing the allocation and deallocation of large numbers of small C++ objects
- A base class, Standard_Transient, automating memory management through smart pointers - the OCCT Handle; most of OCCT classes inherit from this base class.
Quantity classes provide the following services:
- Definition of primitive types representing most of mathematical and physical quantities
- Unit conversion tools
- Resources to manage time information such as dates and time periods
- Resources to manage color definition
Exception classes list all the exceptions, which can be raised by any OCCT function. Syntaxes compatible with the ANSI C++ standard allow you to handle abnormal conditions.
Each exception inherits from Standard_Failure either directly or by inheriting from another exception.
String classes provide the following services to manipulate character strings:
- Editing operations on string objects, using a built-in string manager
- Handling of dynamically-sized sequences of characters
OCCT supports both ASCII character types (8-bit) and Unicode character types UTF-8 (8-bit) and utf-16 - UCS-2 (16-bit).
Memory management makes string objects easier to use than ordinary character arrays. Strings may also be manipulated by handles and therefore, can be shared.
These classes are implemented in TCollection and NCollection packages.
Apart from strings, the TCollection package contains classes of dynamically sized aggregates of data. They include a wide range of collections such as:
- Arrays (unidimensional and bidimensional) generally used for quick access to an item. Note that an array is a fixed-sized aggregate
- Sequences and lists which are ordered collections of non-unique objects
- Maps, which provide rapid access time for member items
- Queues and stacks, which are minor structures similar to sequences but with different algorithms to explore them
The TCollection package also offers specific iterators for sequences, maps, and stacks.
It also includes Collection classes. Collection classes are generic (C++ template-like), that is, they can contain a variety of objects which do not necessarily inherit from a unique root class. When you need to use a collection of a given object type, you must instantiate the collection for this specific type. Once the code for this declaration is compiled, all functions available on the generic collection are available on your instantiated class.
If you are not using CDL in your project (CDL compilation under WOK is necessary to instantiate any generic Collection from package TCollection), then you should use the Collections defined in NCollection package. It contains definitions of the same generic collection classes described above, but in a form of C++ templates. Therefore, to instantiate any collection type no additional support is required beyond the ANSI C++ compiler.
Most collections follow value semantics, meaning that an instantiation of a collection is the actual collection, not a handle to it.
Collections of Standard Objects
The collections of standard object classes provide frequently used instantiation of generic classes from the TCollection package with objects from the Standard package, strings from the TCollection package and geometric primitives.
There exists a limitation: OCCT generic classes require compilation of definitions in the CDL language and therefore can only be instantiated in WOK.
The NCollection unit meets the requirements of OCCT community and all end users who do not use WOK development environment in their projects.
The NCollection provides a full replacement of all TCollection generic classes so that any OCCT collection could be instantiated via C++ template definitions. It is used in WOK environment (as nocdlpack development unit) or in any other configuration, since it only uses the standard capabilities of C++ language.
Earlier releases of OCCT offered NCollection classes in the form of macro definitions. Now it is strongly recommended to use C++ template classes instead, as they are more flexible and reliable. The old definitions based on C macros (in the header files NCollection_Define*.hxx) are kept for backward compatibility and no longer supported.