CreateClassW

Returns a handle to an on the fly created class, however when
a class with this name already exists the handle of existing class will be returned.

The following reasons will cause a return value of 0:
    - when the name is already used for an instance or property;
    - if the model input is zero or not a model handle.

Giving the class a name is optional, if a name is not given it will receive an automatically generated name,
it's automatically generated name can change between sessions.

Syntax

//
//   Strong typing definition
//
OwlClass        CreateClassW(
                        OwlModel                model,
                        const wchar_t           * name
                    );

static  inline  OwlClass    CreateClassW(
                                    OwlModel                model,
                                    wchar_t                 * name
                                )
{
    return  CreateClassW(
                    model,
                    (const wchar_t*) name
                );
}

static  inline  OwlClass    CreateClassW(
                                    OwlModel                model
                                )
{
    return  CreateClassW(
                    model,
                    (const wchar_t*) nullptr            //    name
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall CreateClassW(
                                                int64_t                 model,
                                                const wchar_t           * name
                                            );

static  inline  int64_t CreateClassW(
                                int64_t                 model,
                                wchar_t                 * name
                            )
{
    return  CreateClassW(
                    model,
                    (const wchar_t*) name
                );
}

static  inline  int64_t CreateClassW(
                                int64_t                 model
                            )
{
    return  CreateClassW(
                    model,
                    (const wchar_t*) nullptr            //    name
                );
}
    

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 name

Size: 32 bit / 4 byte (reference)
This attribute represents the name of the class (given as wchar_t array / Unicode). The name is given by the host and the attribute is not changed.

Example (based on pure API calls)

Here you can find code snippits that show how the API call CreateClassW 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 = CreateClassW(model, L"MyOwnCylinderClass");

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

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

        //
        //  Instances
        //
        int64_t instanceMyOwnCylinderClass = CreateInstanceW(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
        //
        SaveModelW(model, L"c:\\created\\myFile.bin");
        CloseModel(model);
    }
}