Public Member Functions

Interval Class Reference

This reference page is linked to from the following overview topics: Lesson 3: the reference system, Lesson 4: Animation Controllers, Lesson 6: Parameter Blocks, Getting and Setting Parameter Block Values.


Search for all occurrences

Detailed Description

See also:
Advanced Topics sections on Intervals and Time.

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)

#include <interval.h>

Inheritance diagram for Interval:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  Interval (TimeValue s, TimeValue e)
  Interval ()
int  operator== (const Interval &i)
CoreExport int  InInterval (const TimeValue t) const
int  InInterval (const Interval interval) const
int  Empty ()
void  Set (TimeValue s, TimeValue e)
void  SetStart (TimeValue s)
void  SetEnd (TimeValue e)
void  SetEmpty ()
void  SetInfinite ()
void  SetInstant (const TimeValue t)
TimeValue  Start () const
TimeValue  End () const
TimeValue  Duration () const
CoreExport Interval  operator& (const Interval i) const
Interval operator&= (const Interval i)
Interval operator+= (const TimeValue t)

Constructor & Destructor Documentation

CoreExport 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.
Interval ( ) [inline]
Remarks:
Constructor that returns an EMPTY interval, i.e. having a start and end time equal to TIME_NegInfinity
{ SetEmpty(); } 

Member Function Documentation

int operator== ( const Interval i ) [inline]
Remarks:
Checks for equality between two Intervals.
Returns:
Nonzero if the intervals are equal; otherwise 0.
{ return( i.start==start && i.end==end ); }
CoreExport int InInterval ( const TimeValue  t ) const
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
Returns:
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.
int InInterval ( const Interval  interval ) const [inline]
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.
Returns:
Returns nonzero if the interval passed is contained within the interval; otherwise 0.
{ return InInterval( interval.Start() ) && InInterval( interval.End() ); }
int Empty ( ) [inline]
Remarks:
Returns 1 if the interval is EMPTY, i.e. has a start and end time equal to TIME_NegInfinity. Returns 0 otherwise.
{ return (start == TIME_NegInfinity) && (end == TIME_NegInfinity); }
void Set ( TimeValue  s,
TimeValue  e 
) [inline]
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.
{ start = s; end = e; }
void SetStart ( TimeValue  s ) [inline]
Remarks:
Sets the start value only.
Parameters:
TimeValue s

Start time for the interval.
{ start = s;          }
void SetEnd ( TimeValue  e ) [inline]
Remarks:
Sets the end value only.
Parameters:
TimeValue e

End time for the interval.
{ end = e;            }
void SetEmpty ( ) [inline]
Remarks:
Sets the interval to be EMPTY, i.e. having a start and end time equal to TIME_NegInfinity.
{ start = TIME_NegInfinity; end = TIME_NegInfinity; }
void SetInfinite ( ) [inline]
Remarks:
Sets the interval to be FOREVER, i.e. have a start time equal TIME_NegInfinity and end time equal to TIME_PosInfinity.
{ start = TIME_NegInfinity; end = TIME_PosInfinity; }
void SetInstant ( const TimeValue  t ) [inline]
Remarks:
Sets both the start and end times to the time passed.
{ start = end = t; }
TimeValue Start ( ) const [inline]
Remarks:
Returns the start time of the interval.
{ return start; }
TimeValue End ( ) const [inline]
Remarks:
Returns the end time of the interval.
{ return end; }
TimeValue Duration ( ) const [inline]
Remarks:
Implemented by the System.

Returns the duration of the interval (end points included).
Operators:
{ return end-start+TimeValue(1); } // end points included
CoreExport 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.
Returns:
An Interval that is the intersection of the intervals.
Interval& operator&= ( const Interval  i ) [inline]
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));
{ return (*this = (*this&i)); }
Interval& operator+= ( const TimeValue  t ) [inline]
Remarks:
Expands the Interval to include the TimeValue.

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

Interval Interval Interval Interval Interval Interval Interval Interval Interval Interval
Interval Interval Interval Interval Interval Interval Interval Interval Interval Interval