GetClassParentsByIterator

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

public const string enginedll = @"engine.dll";

[DllImport(enginedll, EntryPoint = "GetClassParentsByIterator")]
public static extern Int64 GetClassParentsByIterator(Int64 owlClass, Int64 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 (based on pure API calls)

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

using RDF;      //  include at least engine.cs within your solution

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

    Int64   directParentClass = RDF.engine.GetParentsByIterator(childClass, 0);
    while (directParentClass != 0)
    {
        if (ClassHasClassAsParent(directParentClass, parentClass))
        {
            return  true;
        }
        directParentClass = RDF.engine.GetClassParentsByIterator(childClass, directParentClass);
    }

    return  false;
}

public void Example()
{
    Int64 model = RDF.engine.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classGeometricItem = RDF.engine.GetClassByName(model, "GeometricItem"),
                classMaterial = RDF.engine.GetClassByName(model, "Material"),
                classSurface = RDF.engine.GetClassByName(model, "Surface"),
                classNURBSSurface = RDF.engine.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);

        System.Diagnostics.Debug.Assert(NURBSSurface_is_A_Surface == true);
        System.Diagnostics.Debug.Assert(NURBSSurface_is_A_Material == false);
        System.Diagnostics.Debug.Assert(Surface_is_A_GeometricItem == true);
        System.Diagnostics.Debug.Assert(NURBSSurface_is_A_GeometricItem == true);
        System.Diagnostics.Debug.Assert(Surface_is_A_NURBSSurface == false);
        System.Diagnostics.Debug.Assert(GeometricItem_is_A_Surface == false);

        Int64   myOwnClass = RDF.engine.CreateClass(model, "MyOwnClass");

        System.Diagnostics.Debug.Assert(ClassHasClassAsParent(myOwnClass, classNURBSSurface) == false);
        System.Diagnostics.Debug.Assert(ClassHasClassAsParent(myOwnClass, classGeometricItem) == false);

        RDF.engine.SetClassParent(myOwnClass, classSurface, 1);

        System.Diagnostics.Debug.Assert(ClassHasClassAsParent(myOwnClass, classNURBSSurface) == false);
        System.Diagnostics.Debug.Assert(ClassHasClassAsParent(myOwnClass, classGeometricItem) == true);

        RDF.engine.CloseModel(model);
    }
}