IsDuplicate

Checks if two geometry representations are (almost) similar except for a transformation matrix and a given epsilon. The parameter duplicateMatrix is optional and can be left to zero.

Syntax

//
//   Strong typing definition
//
bool            IsDuplicate(
                        OwlInstance             originalOwlInstance,
                        OwlInstance             duplicateOwlInstance,
                        double                  * duplicateMatrix,
                        double                  absoluteEpsilon,
                        double                  relativeEpsilon,
                        bool                    checkMaterial
                    );

static  inline  bool    IsDuplicate(
                                OwlInstance             originalOwlInstance,
                                OwlInstance             duplicateOwlInstance,
                                double                  * duplicateMatrix,
                                double                  epsilon,
                                bool                    checkMaterial
                            )
{
    return  IsDuplicate(
                    originalOwlInstance,
                    duplicateOwlInstance,
                    duplicateMatrix,
                    epsilon,
                    0.,                                 //    relativeEpsilon
                    checkMaterial
                );
}

static  inline  bool    IsDuplicate(
                                OwlInstance             originalOwlInstance,
                                OwlInstance             duplicateOwlInstance
                            )
{
    return  IsDuplicate(
                    originalOwlInstance,
                    duplicateOwlInstance,
                    nullptr,                            //    duplicateMatrix
                    0.,                                 //    absoluteEpsilon
                    0.,                                 //    relativeEpsilon
                    false                               //    checkMaterial
                );
}


//
//   Weak typing definition
//
bool    __declspec(dllexport) __stdcall IsDuplicate(
                                                int64_t                 originalOwlInstance,
                                                int64_t                 duplicateOwlInstance,
                                                double                  * duplicateMatrix,
                                                double                  absoluteEpsilon,
                                                double                  relativeEpsilon,
                                                bool                    checkMaterial
                                            );

static  inline  bool    IsDuplicate(
                                int64_t                 originalOwlInstance,
                                int64_t                 duplicateOwlInstance,
                                double                  * duplicateMatrix,
                                double                  epsilon,
                                bool                    checkMaterial
                            )
{
    return  IsDuplicate(
                    originalOwlInstance,
                    duplicateOwlInstance,
                    duplicateMatrix,
                    epsilon,
                    0.,                                 //    relativeEpsilon
                    checkMaterial
                );
}

static  inline  bool    IsDuplicate(
                                int64_t                 originalOwlInstance,
                                int64_t                 duplicateOwlInstance
                            )
{
    return  IsDuplicate(
                    originalOwlInstance,
                    duplicateOwlInstance,
                    nullptr,                            //    duplicateMatrix
                    0.,                                 //    absoluteEpsilon
                    0.,                                 //    relativeEpsilon
                    false                               //    checkMaterial
                );
}
    

Property originalOwlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property duplicateOwlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property duplicateMatrix

Size: 32 bit / 4 byte (reference)
The matrix defining the position of the duplicate instances compared to the original instance if this function returns true.

Property absoluteEpsilon

Size: 64 bit / 8 byte (value)
???.

Property relativeEpsilon

Size: 64 bit / 8 byte (value)
???.

Property checkMaterial

Size: 8 bit / 1 byte (value)
If true the material definition of both instances are checked to be exactly equal also, i.e. material definitions can be different but resulting colors have to be the same.

Example (based on pure API calls)

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

#include    "./include/engine.h"

int64_t model = CreateModel();

double  epsilon = 0.000001;

//  Box     (https://rdf.bg/gkdoc/Box/CP64.html)e
int64_t owlInstanceBox = CreateInstance(GetClassByName(model, "Box"));
SetDatatypeProperty(owlInstanceBox, GetPropertyByName(model, "height"), 4. - epsilon / 3.);
SetDatatypeProperty(owlInstanceBox, GetPropertyByName(model, "length"), 4.);
SetDatatypeProperty(owlInstanceBox, GetPropertyByName(model, "width"), 4. + epsilon / 3.);

//  Cube    (https://rdf.bg/gkdoc/Cube/CP64.html)
int64_t owlInstanceCube = CreateInstance(GetClassByName(model, "Cube"));
SetDatatypeProperty(owlInstanceCube, GetPropertyByName(model, "length"), 4.);

//  Matrix  (https://rdf.bg/gkdoc/Matrix/CP64.html)
int64_t owlInstanceMatrix = CreateInstance(GetClassByName(model, "Matrix"));
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_11"),   0.);
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_12"),   1.);
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_21"), - 1.);
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_22"),   0.);
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_41"),  12.);
SetDatatypeProperty(owlInstanceMatrix, GetPropertyByName(model, "_43"),  33.);

//  Transformation  (https://rdf.bg/gkdoc/Transformation/CP64.html)
int64_t owlInstanceTransformation = CreateInstance(GetClassByName(model, "Transformation"));
SetObjectProperty(owlInstanceTransformation, GetPropertyByName(model, "object"), owlInstanceCube);
SetObjectProperty(owlInstanceTransformation, GetPropertyByName(model, "matrix"), owlInstanceMatrix);

double  matrix[12];

assert(IsDuplicate(owlInstanceTransformation, owlInstanceBox, matrix, 0., false) == false);
bool    isDuplicate = IsDuplicate(owlInstanceTransformation, owlInstanceBox, matrix, epsilon, false);
assert(isDuplicate &&
        matrix[0] ==   0. && matrix[3] == 1. && matrix[6] == 0. && matrix[9]  ==    0. &&
        matrix[1] == - 1. && matrix[4] == 0. && matrix[7] == 0. && matrix[10] ==   12. &&
        matrix[2] ==   0. && matrix[5] == 0. && matrix[8] == 1. && matrix[11] == - 33.);

CloseModel(model);