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
public const string enginedll = @"engine.dll"; [DllImport(enginedll, EntryPoint = "UnsetClassParentEx")] public static extern Int64 x86_UnsetClassParentEx(Int64 model, Int64 owlClass, Int64 parentOwlClass); [DllImport(enginedll, EntryPoint = "UnsetClassParentEx")] public static extern Int64 x64_UnsetClassParentEx(Int64 model, Int64 owlClass, Int64 parentOwlClass); public static Int64 UnsetClassParentEx(Int64 model, Int64 owlClass, Int64 parentOwlClass) { if (IntPtr.Size == 4) { var _result = x86_UnsetClassParentEx(model, owlClass, parentOwlClass); return _result; } else { return x64_UnsetClassParentEx(model, owlClass, parentOwlClass); } }
Property model
Size: 64 bit / 8 byte (value)Property owlClass
Size: 64 bit / 8 byte (value)Property parentOwlClass
Size: 64 bit / 8 byte (value)
Example (based on pure API calls)
Here you can find code snippits that show how the API call UnsetClassParentEx 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) { Int64 classCnt = 0, propertyCnt = 0, instanceCnt = 0; RDF.engine.OrderedHandles(model, out classCnt, out propertyCnt, out instanceCnt, 1 + 2 + 4, 1 + 2 + 4); System.Diagnostics.Debug.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 classMyOwnCylinderClass = RDF.engine.CreateClass(model, "MyOwnCylinderClass"); System.Diagnostics.Debug.Assert(classMyOwnCylinderClass == classCnt + 1); // references are never 0, therefore classes, properties and instances start at 1 // // Classes // Int64 classCylinder = RDF.engine.GetClassByName(model, "Cylinder"); System.Diagnostics.Debug.Assert(classCylinder > 0 && classCylinder <= classCnt); // // Datatype Properties (attributes) // Int64 propertyLength = RDF.engine.GetPropertyByName(model, "length"), propertyRadius = RDF.engine.GetPropertyByName(model, "radius"), propertySegmentationParts = RDF.engine.GetPropertyByName(model, "segmentationParts"); System.Diagnostics.Debug.Assert(propertyLength > 0 && propertyLength <= propertyCnt); System.Diagnostics.Debug.Assert(propertyRadius > 0 && propertyRadius <= propertyCnt); System.Diagnostics.Debug.Assert(propertySegmentationParts > 0 && propertySegmentationParts <= propertyCnt); // // Instances // Int64 instanceMyOwnCylinderClass = RDF.engine.CreateInstanceEx(model, classMyOwnCylinderClass, (string) null); System.Diagnostics.Debug.Assert(instanceMyOwnCylinderClass == 1); // // 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.GetGeometryClassEx(model, classMyOwnCylinderClass) == 0); RDF.engine.SetClassParentEx(model, classMyOwnCylinderClass, classCylinder, 1); // // Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder // System.Diagnostics.Debug.Assert(RDF.engine.GetGeometryClassEx(model, classMyOwnCylinderClass) == classCylinder); double length = 1.8, radius = 1.3; Int64 segmentationParts = 36; RDF.engine.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertyLength, ref length, 1); RDF.engine.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertyRadius, ref radius, 1); RDF.engine.SetDatatypePropertyEx(model, instanceMyOwnCylinderClass, propertySegmentationParts, ref segmentationParts, 1); // // The resulting model can be viewed in 3D-Editor.exe // RDF.engine.SaveModel(model, "c:\\created\\myFile.bin"); RDF.engine.CloseModel(model); } }