SetClassParent


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 adds parentOwlClass as immediate parent of owlClass if and only if parentOwlClass is not an
ancestor of owlClass and owlClass is not an ancestor of parentOwlClass.

Returns owlClass if this call made any change to the parent class relation of owlClass.

It will return 0 in case:
owlClass and/or parentOwlClass are 0
owlClass equals parentOwlClass
parentOwlClass is already (indirectly) a parent of owlClass
owlClass is (indirectly) a parent of parentOwlClass

It will return owlClass in case:
parentOwlClass became a direct parent of owlClass and they were not related this manner before

Syntax

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

[DllImport(enginedll, EntryPoint = "SetClassParent")]
public static extern Int64 x86_SetClassParent(Int64 owlClass, Int64 parentOwlClass);

[DllImport(enginedll, EntryPoint = "SetClassParent")]
public static extern Int64 x64_SetClassParent(Int64 owlClass, Int64 parentOwlClass);

public static Int64 SetClassParent(Int64 owlClass, Int64 parentOwlClass)
		{
			if (IntPtr.Size == 4)
			{
				var _result = x86_SetClassParent(owlClass, parentOwlClass);
				return _result;
			}
			else
			{
				return x64_SetClassParent(owlClass, 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 SetClassParent can be used.

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

static void Main(string[] args)
{
    Int64 model = RDF.engine.CreateModel();

    if (model != 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   classMyOwnCylinderClass = RDF.engine.CreateClass(model, "MyOwnCylinderClass");

        //
        //  Specific for C#, note that the following call is also allowed,
        //  they should give the same result as we expect to use only ASCII characters in the context of this call
        //
        Int64   classMyOwnSecondClass = RDF.engine.CreateClass(model, System.Text.Encoding.ASCII.GetBytes("MyOwnSecondClass"));
    

        //
        //  Classes
        //
        Int64   classCylinder = RDF.engine.GetClassByName(model, "Cylinder");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = RDF.engine.GetPropertyByName(model, "length"),
                propertyRadius = RDF.engine.GetPropertyByName(model, "radius"),
                propertySegmentationParts = RDF.engine.GetPropertyByName(model, "segmentationParts");

        //
        //  Instances
        //
        Int64   instanceMyOwnCylinderClass = RDF.engine.CreateInstance(classMyOwnCylinderClass, (string) null);

        //
        //  At this moment our new class is unrelated to other classes and instances of it not generating any geometry
        //
        System.Diagnostics.Debug.Assert(RDF.engine.GetGeometryClass(classMyOwnCylinderClass) == 0);

        RDF.engine.SetClassParent(classMyOwnCylinderClass, classCylinder, 1);

        //
        //  Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder
        //
        System.Diagnostics.Debug.Assert(RDF.engine.GetGeometryClass(classMyOwnCylinderClass) == classCylinder);

        double  length = 1.8,
                radius = 1.3;
        Int64   segmentationParts = 36;
        
        RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyLength, ref length, 1);
        RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyRadius, ref radius, 1);
        RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertySegmentationParts, ref segmentationParts, 1);

        double  volume = RDF.engine.GetVolume(instanceMyOwnCylinderClass, (IntPtr) 0, (IntPtr) 0);

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