SetClassParent

Defines (set/unset) the parent class of a given class. Multiple-inheritence is supported and behavior of parent classes is also inherited as well as cardinality restrictions on datatype properties and object properties (relations). When set: it adds parentOwlClass as immediate parent of owlClass if and only if parentOwlClass is not ancestor of owlClass and owlClass is not ancestor of parentOwlClass. Returns the same value as IsClassAncestor after the call. When unset: it removes parentOwlClass from immediate parents and returns 1, or retunrs 0 if parentOwlClass is not immediate parent

Syntax

//
//   Strong typing definition
//
int64_t         SetClassParent(
                        OwlClass                owlClass,
                        OwlClass                parentOwlClass,
                        int64_t                 setting
                    );


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall SetClassParent(
                                                int64_t                 owlClass,
                                                int64_t                 parentOwlClass,
                                                int64_t                 setting
                                            );
    

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.

Property setting

Size: 64 bit / 8 byte (value)
The setting is the data that is defined for bitwise operations, only bits set in the mask will be relevant.

Example (based on pure API calls)

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

#include    "./include/engine.h"

void    main()
{
    int64_t model = CreateModel();

    if (model) {
        //
        //  The following class will be created on-the-fly if the name is not used already
        //  for a class or property (attribute / relation).
        //
        //  note: calling GetClassByName with a name not yet existing will do the same trick)
        //
        int64_t classMyOwnCylinderClass = CreateClass(model, "MyOwnCylinderClass");

        //
        //  Classes
        //
        int64_t classCylinder = GetClassByName(model, "Cylinder");

        //
        //  Datatype Properties (attributes)
        //
        int64_t propertyLength = GetPropertyByName(model, "length"),
                propertyRadius = GetPropertyByName(model, "radius"),
                propertySegmentationParts = GetPropertyByName(model, "segmentationParts");

        //
        //  Instances
        //
        int64_t instanceMyOwnCylinderClass = CreateInstance(classMyOwnCylinderClass, nullptr);

        //
        //  At this moment our new class is unrelated to other classes and instances of it not generating any geometry
        //
        assert(GetGeometryClass(classMyOwnCylinderClass) == 0);

        SetClassParent(classMyOwnCylinderClass, classCylinder, 1);

        //
        //  Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder
        //
        assert(GetGeometryClass(classMyOwnCylinderClass) == classCylinder);

        double  length = 1.8,
                radius = 1.3;
        int64_t segmentationParts = 36;
        
        SetDatatypeProperty(instanceMyOwnCylinderClass, propertyLength, &length, 1);
        SetDatatypeProperty(instanceMyOwnCylinderClass, propertyRadius, &radius, 1);
        SetDatatypeProperty(instanceMyOwnCylinderClass, propertySegmentationParts, &segmentationParts, 1);

        double  volume = GetVolume(instanceMyOwnCylinderClass, nullptr, nullptr);

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        SaveModel(model, "c:\\created\\myFile.bin");
        CloseModel(model);
    }
}