UnsetClassParentEx


Defines a parent class relation of a given class. Multiple-inheritance is supported and behavior
of parent classes is also inherited as well as cardinality restrictions on datatype properties and
object properties (relations).

It removes parentOwlClass as immediate parents of owlClass if result is consistent.

It will return 0 in case:
owlClass and/or parentOwlClass are 0
owlClass equals parentOwlClass
parentOwlClass was not a direct parent of owlClass (could be as another parent class of owlClass has parentOwlClass as parent)

It will return owlClass in case:
parentOwlClass was a direct parent of owlClass and is now removed

This call has the same behavior as SetClassParent, however needs to be used in case classes are exchanged as a successive series of integers.

Syntax

//
//   Strong typing definition
//
OwlClass        UnsetClassParentEx(
                        OwlModel                model,
                        OwlClass                owlClass,
                        OwlClass                parentOwlClass
                    );


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall UnsetClassParentEx(
                                                int64_t                 model,
                                                int64_t                 owlClass,
                                                int64_t                 parentOwlClass
                                            );
    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

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 UnsetClassParentEx can be used.

#include    "./include/engine.h"

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

    if (model) {
        int64_t classCnt = 0, propertyCnt = 0, instanceCnt = 0;
        OrderedHandles(model, &classCnt, &propertyCnt, &instanceCnt, 1 + 2 + 4, 1 + 2 + 4);
        assert(instanceCnt == 0);

        //
        //  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");
        assert(classMyOwnCylinderClass == classCnt + 1);    //  references are never 0, therefore classes, properties and instances start at 1

        //
        //  Classes
        //
        int64_t classCylinder = GetClassByName(model, "Cylinder");
        assert(classCylinder > 0 && classCylinder <= classCnt);

        //
        //  Datatype Properties (attributes)
        //
        int64_t propertyLength = GetPropertyByName(model, "length"),
                propertyRadius = GetPropertyByName(model, "radius"),
                propertySegmentationParts = GetPropertyByName(model, "segmentationParts");
        assert(propertyLength > 0 && propertyLength <= propertyCnt);
        assert(propertyRadius > 0 && propertyRadius <= propertyCnt);
        assert(propertySegmentationParts > 0 && propertySegmentationParts <= propertyCnt);

        //
        //  Instances
        //
        int64_t instanceMyOwnCylinderClass = CreateInstanceEx(model, classMyOwnCylinderClass, nullptr);
        assert(instanceMyOwnCylinderClass == 1);

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

        SetClassParentEx(model, classMyOwnCylinderClass, classCylinder, 1);

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

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

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