Interface GeometricInstanceConverterInterface

The GeometricInstanceConverterInterface interface is used to get, from a list of geometric instance ids, the corresponding part instance ids.

Such a conversion is dependant on a filtering context. Indeed, the list of current part instances is dependant on the chosen configuration (at least) and may be dependant on the list of visible part instances for example. For this reason, converting geometric instance ids (from a picking request for example) needs a filtering context (see VisibilityContextInterface).

This conversion is particularly useful to make idcard requests, since metadata documents are retrieved from part instances and not geometric instances.

The GeometricInstanceConverterInterface interfaces are created through the createGeometricInstanceConverter method.

The list of signals the GeometricInstanceConverterInterface may trigger is available in the GeometricInstanceConverterInterfaceSignal enumeration.

The conversion mechanism is triggered through the convert method. The result is not available right away, but the event GeometricInstanceConverterReady is triggered when the result of the GeometricInstanceConverterInterfaceSignal is available. The result is available through the getPartInstanceIds function.

Warning : there may be cases when the getPartInstanceIds is not available such as when the GeometricInstanceConverterInterface is fetching data, i.e. when isRunning returns true, or when the GeometricInstanceConverterInterface has been cancelled, i.e. when isCancelled returns true.

A GeometricInstanceConverterInterface may be interrupted (cancelled) when the GeometricInstanceConverterInterface is fetching data and cancel is called. In such cases, the GeometricInstanceConverterCancelled signal is fired, and shortly after, GeometricInstanceConverterReady signal is fired, but getPartInstanceIds will return undefined. Just call convert with another (or the same) geometric instance ids to trigger a new retrieval.

If you call multiple times convert before receiving the GeometricInstanceConverterReady, only one GeometricInstanceConverterReady will be sent with the content of the last call to convert.

This interface performs the opposite operation of the PartInstanceConverterInterface interface.

/** 
* Sample to illustrate the use of a GeometricInstanceConverterInterface from a `geometric instance id`.
*/
import {
VisibilityContextInterface, GeometricInstanceConverterInterface, GeometricInstanceConverterInterfaceSignal,
DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

// the `geometric instances` are retrieved by a picking for example

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the `geometric instance id` to get information from
let lGeometricInstanceId : number;
// create a `geometric instance id` converter
const lGeometricConverter : GeometricInstanceConverterInterface = lDataSession.createGeometricInstanceConverter();
// the current filtering context has been created previously
let lVisibilityContext : VisibilityContextInterface;

// the `geometric instance` to get
const lGeometricInstanceIds: Uint32Array = new Uint32Array(1);
lGeometricInstanceIds[0] = lGeometricInstanceId;

const onPartInstanceReady = (_pEvent, _pCallbackData) : void =>
{
// triggered when we have all the `part instances` of the given geometry
const lPartInstanceIds : Uint32Array| undefined = lGeometricConverter.getPartInstanceIds();
if (lPartInstanceIds && (lPartInstanceIds.length > 0))
{
// only work if result is valid
console.log('result found');
console.log(lPartInstanceIds.join(','));
}
}

// connect the GeometricInstanceConverterReady signal to the id card retrieval
lGeometricConverter.addEventListener(GeometricInstanceConverterInterfaceSignal.GeometricInstanceConverterReady, onPartInstanceReady);

// trigger the conversion
lGeometricConverter.convert(lGeometricInstanceIds, lVisibilityContext);

Or with async calls :
/** 
* Sample to illustrate the asynchronous use of a GeometricInstanceConverterInterface from a `geometric instance id`.
*/
import {
VisibilityContextInterface, GeometricInstanceConverterInterface, AsyncUInt32ArrayResult, AsyncResultReason,
DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

// the `geometric instances` are retrieved by a picking for example

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the `geometric instance id` to get information from
let lGeometricInstanceId : number;
// create a `geometric instance id` converter
const lGeometricConverter : GeometricInstanceConverterInterface = lDataSession.createGeometricInstanceConverter();
// the current filtering context has been created previously
let lVisibilityContext : VisibilityContextInterface;

// the `geometric instance` to get
const lGeometricInstanceIds: Uint32Array = new Uint32Array(1);
lGeometricInstanceIds[0] = lGeometricInstanceId;

const convertInstance = async () : Promise<any> =>
{
// trigger the conversion
const lResult : AsyncUInt32ArrayResult = await lGeometricConverter.asyncConvert(lGeometricInstanceIds, lVisibilityContext);

// triggered when we have all the `part instances` of the given geometry
const lPartInstanceIds : Uint32Array| undefined = lGeometricConverter.getPartInstanceIds();
console.assert(lResult.value === lPartInstanceIds);
if (lPartInstanceIds && (lPartInstanceIds.length > 0))
{
console.assert(lResult.reason === AsyncResultReason.ARR_Success);
// only work if result is valid
console.log('result found');
console.log(lPartInstanceIds.join(','));
}
}

convertInstance();

An example with an idcard request :
/** 
* Sample to illustrate the use of an IdCardGetterInterface from a `geometric instance id`.
*/
import {
VisibilityContextInterface, IdCardGetterInterface, GeometricInstanceConverterInterface,
IdCardGetterInterfaceSignal, GeometricInstanceConverterInterfaceSignal, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';
// the `part instances` are retrieved by a picking for example

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the `geometric instance id` to get information from
let lGeometricInstanceId : number;
// create a `geometric instance id` converter
const lGeometricConverter : GeometricInstanceConverterInterface = lDataSession.createGeometricInstanceConverter();
// the current filtering context has been created previously
let lVisibilityContext : VisibilityContextInterface;
// what to do when the conversion from picking is ready
let onPartInstanceReady : (pEvent, _pCallbackData) => void;
// what to do when the id card retrieval is over
let onIdCardReady : (pEvent, _pCallbackData) => void;

// id card getter interface creation
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();
// connect the IDCardReady signal to the handling of the metadata of the `part instance` and its genealogy
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);

// the `geometric instance` to get
const lGeometricInstanceIds: Uint32Array = new Uint32Array(1);
lGeometricInstanceIds[0] = lGeometricInstanceId;
// connect the GeometricInstanceConverterReady signal to the id card retrieval
lGeometricConverter.addEventListener(GeometricInstanceConverterInterfaceSignal.GeometricInstanceConverterReady, onPartInstanceReady);

onPartInstanceReady = (_pEvent, _pCallbackData) : void =>
{
// triggered when we have all the `part instances` of the given geometry
const lPartInstanceIds : Uint32Array| undefined = lGeometricConverter.getPartInstanceIds();
if (lPartInstanceIds && (lPartInstanceIds.length > 0))
{
// only get the idcard of the first `part instance` (we may do other things if multiple idcards to retrieve)
// onIdCardReady will be called shortly after
lIdCardGetterInterface.retrieveIdCard(lPartInstanceIds[0], lVisibilityContext);
}
}

// trigger the conversion
lGeometricConverter.convert(lGeometricInstanceIds, lVisibilityContext);

Please refer to [IdCardGetterInterface](IdCardGetterInterface.html) for more information about idcard requests.
Converters

See

GeometricInstanceConverterInterfaceSignal

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Asynchronously triggers a request to "translate" the given geometric instance ids to the corresponding part instance ids.

    The server will try to find all part instances that are linked to the given geometric instance ids in the given filtering context.

    Returns a promise.

    Please note that in case of multiple promises running at the same time on the same GeometricInstanceConverterInterface, the first promises will be signalled as cancelled, the last as ok, but all calls to getPartInstanceIds after awaiting will return the same value.

    If pVisibilityContext is modified during the execution, then the call is cancelled (see cancel).

    Returns

    A promise. The promise is resolved with the reason (success, cancelled, disposed, bad input). In case of success, the promise contains the requested Uint32Array.

    Parameters

    • pGeometricInstanceIds: number[] | Uint32Array
      in
      The geometric instance ids to perform the conversion with.
    • pVisibilityContext: VisibilityContextInterface
      in
      The filtering context to use when "converting" to a list of part instance ids.

    Returns Promise<AsyncUInt32ArrayResult>

  • Triggers a request to "translate" the given geometric instance ids to the corresponding part instance ids.

    The server will try to find all part instances that are linked to the given geometric instance ids in the given filtering context. An event GeometricInstanceConverterReady is fired when the translation is finished, use getLastError() to check if it was correctly performed.

    Returns true if the "conversion" is started. If not, just call getLastError to get the reason why the procedure failed.

    If pVisibilityContext is modified during the execution, then the call is cancelled (see cancel).

    Returns

    true if the conversion process has started, just wait for GeometricInstanceConverterReady.

    Parameters

    • pGeometricInstanceIds: number[] | Uint32Array
      in
      The geometric instance ids to perform the conversion with.
    • pVisibilityContext: VisibilityContextInterface
      in
      The filtering context to use when "converting" to a list of part instance ids.

    Returns boolean

  • Gets the last error returned by the convert call of the GeometricInstanceConverterInterface.

    Returns

    The last error message (if any, or an empty string if no error occurred).

    Returns string

  • Each call to convert is assigned a request id.

    This call tels the id of the last call to convert.

    Returns

    The id of the last call to convert.

    Returns string

  • Gets the result of the last convert call of the geometric instance ids conversion.

    An Uint32Array representing the part instance ids is returned if the GeometricInstanceConverterInterface has finished computing. Use addEventListener on the event GeometricInstanceConverterReady to know when the GeometricInstanceConverterInterface is ready.

    DO NOT modify this data in place, this results in undefined behavior.

    Returns

    const
    The list of part instance ids, result of the conversion, or undefined if the converter had an error, or is still computing.

    See

    Returns undefined | Uint32Array

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if the GeometricInstanceConverterInterface has been cancelled.

    This is generally the case after calling cancel when the GeometricInstanceConverterInterface is retrieving data.

    Returns

    true if the GeometricInstanceConverterInterface is cancelled.

    Returns boolean

  • Tells if the GeometricInstanceConverterInterface is converting data.

    This is the case after calling convert.

    Returns

    true if the GeometricInstanceConverterInterface is converting.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](GeometricInstanceConverterInterface.html#addEventListener) that you want to remove.

    Returns boolean