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

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

[DllImport(enginedll, EntryPoint = "IsDuplicate")]
public static extern byte IsDuplicate(Int64 originalOwlInstance, Int64 duplicateOwlInstance, out double duplicateMatrix, double absoluteEpsilon, double relativeEpsilon, byte checkMaterial);

[DllImport(enginedll, EntryPoint = "IsDuplicate")]
public static extern byte IsDuplicate(Int64 originalOwlInstance, Int64 duplicateOwlInstance, double[] duplicateMatrix, double absoluteEpsilon, double relativeEpsilon, byte 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.

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

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

    double  epsilon = 0.000001;

    //  Box     (https://rdf.bg/gkdoc/Box/CP64.html)e
    Int64   owlInstanceBox = RDF.engine.CreateInstance(RDF.engine.GetClassByName(model, "Box"));
    RDF.engine.SetDatatypeProperty(owlInstanceBox, RDF.engine.GetPropertyByName(model, "height"), 4.0 - epsilon / 3.0);
    RDF.engine.SetDatatypeProperty(owlInstanceBox, RDF.engine.GetPropertyByName(model, "length"), 4.0);
    RDF.engine.SetDatatypeProperty(owlInstanceBox, RDF.engine.GetPropertyByName(model, "width"), 4.0 + epsilon / 3.0);

    //  Cube    (https://rdf.bg/gkdoc/Cube/CP64.html)
    Int64   owlInstanceCube = RDF.engine.CreateInstance(RDF.engine.GetClassByName(model, "Cube"));
    RDF.engine.SetDatatypeProperty(owlInstanceCube, RDF.engine.GetPropertyByName(model, "length"), 4.0);

    //  Matrix  (https://rdf.bg/gkdoc/Matrix/CP64.html)
    Int64   owlInstanceMatrix = RDF.engine.CreateInstance(RDF.engine.GetClassByName(model, "Matrix"));
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_11"),   0.0);
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_12"),   1.0);
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_21"), - 1.0);
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_22"),   0.0);
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_41"),  12.0);
    RDF.engine.SetDatatypeProperty(owlInstanceMatrix, RDF.engine.GetPropertyByName(model, "_43"),  33.0);

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

    double  matrix[12];

    Debug.Assert(RDF.engine.IsDuplicate(owlInstanceTransformation, owlInstanceBox, matrix, 0.0, false) == false);
    bool    isDuplicate = RDF.engine.IsDuplicate(owlInstanceTransformation, owlInstanceBox, matrix, epsilon, false);
    assert(isDuplicate &&
            matrix[0] ==   0.0 && matrix[3] == 1.0 && matrix[6] == 0.0 && matrix[9]  ==    0.0 &&
            matrix[1] == - 1.0 && matrix[4] == 0.0 && matrix[7] == 0.0 && matrix[10] ==   12.0 &&
            matrix[2] ==   0.0 && matrix[5] == 0.0 && matrix[8] == 1.0 && matrix[11] == - 33.0);

    CloseModel(model);