Class Interval

3DS Max Plug-In SDK

Class Interval

See Also: Advanced Topics sections on Intervals and Time.

class Interval

Description:

An Interval is a class that represents a length of time. It has two private data members, start and end that are each TimeValues. A TimeValue is a single instant in time. For more explanation see the Advanced Topics section on Intervals. All the methods of this class are implemented by the system.

Definitions:

#define FOREVER Interval(TIME_NegInfinity, TIME_PosInfinity)

#define NEVER Interval(TIME_NegInfinity, TIME_NegInfinity)

Methods:

Prototype:

Interval(TimeValue s, TimeValue e )

Remarks:

Constructor that assigns both the start and end times of the interval. If TimeValue e is less than

TimeValue s the values are swapped before they are assigned.

Parameters:

TimeValue s

Specifies the start time.

TimeValue e

Specifies the end time.

Prototype:

Interval()

Remarks:

Constructor that returns an EMPTY interval, i.e. having a start and end time equal to TIME_NegInfinity

Prototype:

int InInterval(const TimeValue t);

Remarks:

Return Nonzero if the TimeValue passed is greater than or equal to the start value and less than or equal to the end value and not equal to TIME_NegInfinity. Returns 0 otherwise.

Parameters:

const TimeValue t

Return Value:

Nonzero if the TimeValue passed is greater than or equal to the start value and less than or equal to the end value and not equal to TIME_NegInfinity; otherwise 0.

Prototype:

int InInterval(const Interval interval)

Remarks:

Returns nonzero if the interval passed is contained within the interval; otherwise 0.

return InInterval( interval.Start() ) && InInterval( interval.End() );

Parameters:

const Interval interval

The interval to check.

Return Value:

Returns nonzero if the interval passed is contained within the interval; otherwise 0.

Prototype:

int Empty()

Remarks:

Returns 1 if the interval is EMPTY, i.e. has a start and end time equal to TIME_NegInfinity. Returns 0 otherwise.

Prototype:

void Set(TimeValue s, TimeValue e)

Remarks:

Sets the start and end times for the interval.

Parameters:

TimeValue s

Start time for the interval.

TimeValue e

End time for the interval.

Prototype:

void SetStart(TimeValue s)

Remarks:

Sets the start value only.

Parameters:

TimeValue s

Start time for the interval.

Prototype:

void SetEnd(TimeValue e)

Remarks:

Sets the end value only.

Parameters:

TimeValue e

End time for the interval.

Prototype:

void SetEmpty()

Remarks:

Sets the interval to be EMPTY, i.e. having a start and end time equal to TIME_NegInfinity.

Prototype:

void SetInfinite()

Remarks:

Sets the interval to be FOREVER, i.e. have a start time equal TIME_NegInfinity and end time equal to TIME_PosInfinity.

Prototype:

void SetInstant(const TimeValue t)

Remarks:

Sets both the start and end times to the time passed.

Prototype:

TimeValue Start()

Remarks:

Returns the start time of the interval.

Prototype:

TimeValue End()

Remarks:

Returns the end time of the interval.

Prototype:

TimeValue Duration()

Remarks:

Implemented by the System.

Returns the duration of the interval (end points included).

Operators:

Prototype:

int operator==(const Interval& i)

Remarks:

Checks for equality between two Intervals.

Return Value:

Nonzero if the intervals are equal; otherwise 0.

Prototype:

Interval operator&(const Interval i) const;

Remarks:

Intersects Interval and i. The interval will have a start time of the greater of the two interval start times, and an end value which is the lesser of the two end values. If the end time is less than the start time, both the start and end times are set to TIME_NegInfinity.

Return Value:

An Interval that is the intersection of the intervals.

Prototype:

Interval& operator&=(const Interval i)

Remarks:

This updates the invoking interval so it will have a start time of the greater of the two interval start times, and an end value which is the lesser of the two end values.

return (*this = (*this&i));

Prototype:

Interval& operator+=(const TimeValue t)

Remarks:

Expands the Interval to include the TimeValue.

if (t<start) start=t; if (t>end) end=t; return *this;