GetParentsByIterator

Returns the next parent of the class.
If input parent is zero, the handle will point to the first relevant parent.
If all parent are past (or no relevant parent are found), the function will return 0.

Syntax

//   Visual Studio for Windows
public:
__int64 __declspec(dllexport) __stdcall GetParentsByIterator(
            __int64             owlClass,
            __int64             parentOwlClass
        );

//   Linux, OS-X and non-Visual Studio Windows solutions
public:
int64_t GetParentsByIterator(
            int64_t             owlClass,
            int64_t             parentOwlClass
        );    

Property owlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the class. The term owl is comming from W3C, the classes follow the expression power of Semantic Web concepts, therefore classes support multiple inheritance. Technically classes can also be distributed over different resources, however for this the parametric library is required as an extension on the basic Geometry Kernel API.

Property parentOwlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the parent class.

Example

Here you can find code snippits that show how the API call GetParentsByIterator can be used.

#include "engine/include/engine.h"

bool    ClassHasClassAsParent(int64_t childClass, int64_t parentClass)
{
    //
    //  This function checks recursively if a child class has a parent class as parent
    //
    
    if (childClass == parentClass) {
        return  true;
    }

    int64_t directParentClass = GetParentsByIterator(childClass, 0);
    while (directParentClass) {
        if (ClassHasClassAsParent(directParentClass, parentClass)) {
            return  true;
        }
        directParentClass = GetParentsByIterator(childClass, directParentClass);
    }

    return  false;
}

int _tmain(int argc, _TCHAR* argv[])
{
    int64_t model = CreateModel();

    if (model) {
        //
        //  Classes
        //
        int64_t classGeometricItem = GetClassByName(model, "GeometricItem"),
                classMaterial = GetClassByName(model, "Material"),
                classSurface = GetClassByName(model, "Surface"),
                classNURBSSurface = GetClassByName(model, "NURBSSurface");

        bool    NURBSSurface_is_A_Surface = ClassHasClassAsParent(classNURBSSurface, classSurface),
                NURBSSurface_is_A_Material = ClassHasClassAsParent(classNURBSSurface, classMaterial),
                Surface_is_A_GeometricItem = ClassHasClassAsParent(classSurface, classGeometricItem),
                NURBSSurface_is_A_GeometricItem = ClassHasClassAsParent(classNURBSSurface, classGeometricItem),
                Surface_is_A_NURBSSurface = ClassHasClassAsParent(classSurface, classNURBSSurface),
                GeometricItem_is_A_Surface = ClassHasClassAsParent(classGeometricItem, classSurface);

        assert(NURBSSurface_is_A_Surface == true);
        assert(NURBSSurface_is_A_Material == false);
        assert(Surface_is_A_GeometricItem == true);
        assert(NURBSSurface_is_A_GeometricItem == true);
        assert(Surface_is_A_NURBSSurface == false);
        assert(GeometricItem_is_A_Surface == false);

        int64_t myOwnClass = CreateClass(model, "MyOwnClass");

        assert(ClassHasClassAsParent(myOwnClass, classNURBSSurface) == false);
        assert(ClassHasClassAsParent(myOwnClass, classGeometricItem) == false);

        SetClassParent(myOwnClass, classSurface, 1);

        assert(ClassHasClassAsParent(myOwnClass, classNURBSSurface) == false);
        assert(ClassHasClassAsParent(myOwnClass, classGeometricItem) == true);

        CloseModel(model);
    }

    return  0;
}