Interface FilterDiagonalInterface

The FilterDiagonalInterface interface is a FilterItemInterface to elect part instances leaves that have an oriented bounding box diagonal SQUARED length contained in one of the range specified in the filter.

This interface allows to create range items FilterRangeItemInterface to allow the creation of an union of ranges, to be tested against the diagonal SQUARED length of the part instances leaves.

Suppose the user wants to get all part instances leaves which have a diagonal SQUARED length contained within 2 and 3 mm.

/** 
* Sample to illustrate how to use a FilterDiagonalInterface and the unit conversion system.
*/
import {
FilterSolverInterface,
Unit, FilterRangeItemInterface,
ConfContextInterface, VisibilityContextInterface, FilterSolverInterfaceSignal, tListenerCallback, FilterDiagonalInterface, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

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

// what to do when result has been computed ?
let onResultReady : tListenerCallback;

/* FILTERING CONTEXT / CONF CONTEXT */
// 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);

/* SOLVER */
// create the solver to retrieve the result
const lGlobalSolver : FilterSolverInterface = lDataSession.createFilterSolver();
lGlobalSolver.setVisibilityContext(lConfVisibilityCtx);
// we want to retrieve `geometric instance ids` and `part instance ids` on the solver
lGlobalSolver.setRetrievePartInstanceIds(true);
// bind the solver to custom implementation when the result is ready
lGlobalSolver.addEventListener(FilterSolverInterfaceSignal.SolverReady, onResultReady);

/* DIAGONAL FILTER */
// get the DMU build unit
const lDMUUnit : Unit = lDataSession.getDmuBuildUnit();
// we want to get values in DMU units
const lConvertFactor : number = lDataSession.convertUnitFactor(Unit.U_Millimeter, lDMUUnit);

// all leaves whose diagonal is contained within 2 and 3 millimeters
let lMinValue : number = 2 * lConvertFactor;
let lMaxValue : number = 3 * lConvertFactor;

// diagonal SQUARED
lMinValue *= lMinValue;
lMaxValue *= lMaxValue;

// create a diagonal filter
const lDiagonalFilter : FilterDiagonalInterface = lDataSession.createDiagonalFilter();
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter
// lDiagonalFilter.setFilterOperator(FilterOperator.FO_UNION);

// and add a range to test ([2mm, 3mm] included)
const lDiagonalFilterContent : FilterRangeItemInterface = lDiagonalFilter.createFilterRangeItem();
// include lower bound
lDiagonalFilterContent.setIncludedLower(true);
// include upper bound
lDiagonalFilterContent.setIncludedUpper(true);
// set the lower bound as 2 mm in DMU units SQUARED
lDiagonalFilterContent.setLowerBound(lMinValue);
// set the upper bound as 3 mm in DMU units SQUARED
lDiagonalFilterContent.setUpperBound(lMaxValue);

// add the filter to the solver
lGlobalSolver.insertFilter(0, lDiagonalFilter);
// and go => make the DataSessionInterface compute the result
lDataSession.update();

This interface MUST be used in a [FilterSolverInterface](FilterSolverInterface.html), which in turn should refer to a valid [VisibilityContextInterface](VisibilityContextInterface.html) (see Filtering Context).
Metadata/Filters

See

FilterRangeItemInterface

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 range item at index pRangeIndex.

    If pRangeIndex is negative or superior or equal to the number of range items, this function does nothing and returns undefined.

    Returns

    The given FilterRangeItemInterface (this is the actual data held by the FilterDiagonalInterface, and not a copy) if pRangeIndex is valid else return undefined.

    Parameters

    • pRangeIndex: number
      in
      Index of the range item to get.

    Returns undefined | FilterRangeItemInterface

  • Gets the list of all range items.

    This function should not be used to add or remove range items, the FilterDiagonalInterface will not see the modifications if the array is modified.

    However, modifying items inside the array is allowed.

    Returns

    warning
    All range items inside the FilterDiagonalInterface.

    Returns FilterRangeItemInterface[]

  • 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 this object has been gotten rid off.

    Returns

    true if dispose has been called on this object.

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

    Returns boolean

  • Removes the range item at the position pRangeIndex.

    If pRangeIndex is negative or superior or equal to the number of range items, this function does nothing and returns false. Returns true if the item is effectively removed.

    Returns

    true if the item was removed else return false.

    Parameters

    • pRangeIndex: number
      in
      Index of the range item 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