Interface FilterItemInterface

The FilterItemInterface interface is the base interface used to filter part instances.

NO FilterItemInterface are created per se. Instead, interfaces that inherit FilterItemInterface are created. The FilterItemInterface is a kind of "abstract interface".

The FilterItemInterface serves to elect a list of part instances based on a criterion (or a list of criteria), for example (others can be found in Filters examples):

  • Find all part instances whose size is lower than 3 cms
  • Find all part instances that overlaps a given 3D cube
  • Find all part instances that have a metadata "type" equal to "electrical" (electrical part instances)
  • Find all part instances that have a metadata "mounted" to true (mounted part instances).

Each example is made possible by the creation of a specific interface that inherits FilterItemInterface.

A FilterItemInterface is not usable as is, it must be included in a "solver" object : the FilterSolverInterface. The FilterSolverInterface interface allows the computation of the FilterItemInterfaces, and allows grouping them with set operators (intersection, union, exclusion). See FilterSolverInterface for more details, but keep in mind that FilterSolverInterfaces rely on filtering contexts to work : VisibilityContextInterface (see Filtering Context).

When a FilterItemInterface is modified, there is no automatic update of the content of a FilterSolverInterface : indeed, you may want to modify a lot of FilterItemInterface, ConfContextInterfaces, VisibilityContextInterfaces before getting the expected result. Moreover, VisibilityContextInterfaces may depend on FilterSolverInterfaces that could lead to massive dependency graphs. For this reason, VisibilityContextInterfaces, FilterSolverInterfaces and FilterItemInterfaces are not updated through a dedicated function on each interface but with the update function.
The dependency graph of ConfContextInterfaces, VisibilityContextInterfaces and FilterItemInterfaces is handled by the DataSessionInterface, this also prevent too many requests to be sent to the server for nothing.
To sum up : modify your FilterItemInterfaces, ConfContextInterfaces, VisibilityContextInterfaces and FilterSolverInterfaces without taking into account any dependency that may have between them, and when you want the server to compute the result, remember to call update.

DO NOT create interfaces that inherits FilterItemInterface before the DMU is loaded, such filters will be silently discarded.

Discard existing interfaces that inherits FilterItemInterface before loading a new DataSessionInterface (dispose).

The same FilterItemInterface cannot be used at the same time in multiple FilterSolverInterface, FilterSetInterface, FilterCompoundInterface : calling insertFilter, insertFilter or insertFilter on a FilterItemInterface that is already included will return false.
Warning : only FilterAttributeInterface, FilterRangeInterface, FilterHasFieldInterface and FilterBooleanInterface can be included in a FilterCompoundInterface.

Each FilterItemInterface is assigned a unique identifier upon creation.

The combination of the FilterItemInterfaces in a FilterSolverInterface, FilterSetInterface, FilterCompoundInterface may be a union, intersection, or exclusion (FilterOperator). Each FilterItemInterface stores a combination mode that tells its way to combine itself with the first enabled FORMER FilterItemInterface in the parent list.
The FilterItemInterface operator of the first enabled FilterItemInterface in a parent list (FilterSolverInterface, FilterSetInterface, FilterCompoundInterface) is always ignored, but a warning is outputted in the console when the FilterOperator is different that FO_UNION.
The FilterSetInterface allows to gather filters together and to create an operator precedence with FilterOperator. It is a sort of "parenthesis" FilterItemInterface.

A FilterItemInterface may be :

  • enabled/disabled : tells if this FilterItemInterface contributes to the filtering of the enclosing [FilterSolverInterface]], FilterSetInterface, FilterCompoundInterface. Warning, changing the enabled status of a FilterItemInterface without knowing its successor may result in unexpected results, since the successor FilterOperator will be used with the first enabled FilterItemInterface that precedes the disabled one.
  • normal/inverted : tells if the result of the FilterItemInterface may be "inverted". When "inverted", a FilterItemInterface "elects" all other part instances leaves minus the one in the "normal" FilterItemInterface (in a FilterCompoundInterface, the meaning of the "inverted" state is different).

The content of a FilterItemInterface is provided by getFilterData and can be restored by setFilterData.


Each filter has a depth contribution. For implementation reasons, the depth contribution of each FilterItemInterface included inside a FilterSolverInterface is limited. The depth contribution is available through getDepthContribution.

This depth contribution cannot be more than

Max Depth Contribution

Please see Available Filters for a list of available FilterItemInterfaces.

/** 
* Sample to illustrate the use of an intersection of
* FilterAABBInterface and FilterAttributeInterface.
*/
import {
AABB, AttributesDictionaryInterface, AttributeInfoInterface, AttributeType, DataSessionInterface,
ConfContextInterface, VisibilityContextInterface, FilterSolverInterface,
FilterAABBInterface, FilterAttributeInterface, FilterOperator,
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;

// MAKE SURE the attributes "CompletionStatus"
const lAttributeDictionary : AttributesDictionaryInterface = lDataSession.getAttributesDictionary();
const lAttributeInfo : AttributeInfoInterface | undefined = lAttributeDictionary.getAttributeInfo('CompletionStatus');
// make sure the attribute is a string one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_STRING));

// create the resolution chain :
// create a filtering context "unconfigured"
// first create ConfContextInterface "unconfigured"
const lConfCtx : ConfContextInterface = lDataSession.createConfContext();
// and create the filtering context and bind it to the unconfigured ConfContextInterface
const lConfVisibilityCtx: VisibilityContextInterface = lDataSession.createVisibilityContext();
lConfVisibilityCtx.setConfContext(lConfCtx);

// the AABB to use
const lABB : AABB = new AABB();
lABB.mCenter.x = 3.0;
lABB.mCenter.y = 3.0;
lABB.mCenter.z = 3.0;

lABB.mHalfExtent.x = 10.0;
lABB.mHalfExtent.y = 10.0;
lABB.mHalfExtent.z = 10.0;

// create a Filter Solver
const lFilterSolver : FilterSolverInterface = lDataSession.createFilterSolver();

// create a box filter
const lFilterAABB : FilterAABBInterface = lDataSession.createFilterAABB();
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter
// lFilterAABB.setFilterOperator(FilterOperator.FO_UNION);

lFilterAABB.setAABB(lABB);

// create an FilterAttributeInterface
const lFilterAttributes : FilterAttributeInterface = lDataSession.createFilterAttribute();
// completion status to done
lFilterAttributes.setAttributeName('CompletionStatus');
lFilterAttributes.setExactValues(['done']);
// no n/a
lFilterAttributes.setNaValueChecked(false);

// intersection is the way to go since intersection of box and instances that have the field "CompletionStatus"
// to "done"
// only change the operator of the filters except the first
lFilterAttributes.setFilterOperator(FilterOperator.FO_INTERSECTION);

// and add the filters
// push back (-1) the AABB filter
lFilterSolver.insertFilter(-1, lFilterAABB);
// push back (-1) the FilterAttributeInterface, as it is the second one, its operator is used and therefore
// intersection is used
lFilterSolver.insertFilter(-1, lFilterAttributes);

// set the conf context to use => unconfigured for this example
lFilterSolver.setVisibilityContext(lConfVisibilityCtx);
// and tell the DataSessionInterface to update the modified ConfContextInterface, VisibilityContextInterface and FilterSolverInterfaces
lDataSession.update();

Filters are created by the [DataSessionInterface](DataSessionInterface.html).
Metadata/Filters

See

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

  • Gets the depth contribution of the FilterItemInterface.

    This value is usually one.

    Returns

    The depth contribution of the FilterItemInterface.

    Returns number

  • Gets a deep copy of the internal data of the FilterItemInterface.

    Returns

    The internal FilterItemInterface data.

    Returns any

  • Gets the identifier of the FilterItemInterface.

    Returns

    The identifier of the FilterItemInterface.

    Returns string

  • Gets the identifier of the parent container that contains this FilterItemInterface (getFilterId()).

    Such a container may be a FilterSolverInterface, FilterSetInterface or a FilterCompoundInterface. Returns an empty string if the FilterItemInterface is not included in a parent container.

    Returns

    The identifier of the parent container.

    Returns string

  • 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 FilterItemInterface is enabled.

    If disabled, this FilterItemInterface is completely ignored during all the computations (the behavior is the same as if it had not been created).

    A FilterItemInterface is enabled by default.

    Returns

    true if the FilterItemInterface is enabled.

    Returns boolean

  • Tells if the FilterItemInterface is "inverted".

    When "inverted", a FilterItemInterface elects all the part instances that were not selected if it was not inverted.

    A FilterItemInterface is not "inverted" by default.

    Returns

    true if such a FilterItemInterface is "inverted".

    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](FilterItemInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Sets the FilterItemInterface enabled/disabled status.

    If disabled, this FilterItemInterface is completely ignored during all the computations (the behavior is the same as if it had not been created). Use addEventListener on the event FilterEnabledChanged to know when the FilterItemInterface has changed its enabled status.

    A FilterItemInterface is enabled by default.

    Parameters

    • pEnabled: boolean
      in
      If true, the given FilterItemInterface is enabled.

    Returns void

  • Sets the content of the FilterItemInterface from a former call to getFilterData.

    Use addEventListener on the event FilterDataChanged to know when the FilterItemInterface internal data changed.

    Returns

    true if the data is set.

    Parameters

    • pFilterData: any
      in
      Internal FilterItemInterface data to set.

    Returns boolean

  • Sets the identifier of the FilterItemInterface. Make sure the id is unique. A unique FilterItemInterface identifier is created if the identifier is not overridden.

    Parameters

    • pFilterId: string
      in
      The new identifier of the FilterItemInterface.

    Returns void

  • Sets the "inverted" status of the FilterItemInterface.

    When "inverted", a FilterItemInterface elects all the part instances that were not selected if it was not inverted. Use addEventListener on the event FilterInvertedChanged to know when the FilterItemInterface has changed its "inverted" status.

    A FilterItemInterface is not "inverted" by default.

    Parameters

    • pInverted: boolean
      in
      If true, such a FilterItemInterface will be "inverted".

    Returns void