3ds Max C++ API Reference
Loading...
Searching...
No Matches
Interval Class Reference

#include <interval.h>

+ Inheritance diagram for Interval:

Public Member Functions

CoreExport Interval (TimeValue s, TimeValue e)
 
 Interval ()
 
int operator== (const Interval &i) const
 
bool operator!= (const Interval &i) const
 
CoreExport int InInterval (const TimeValue t) const
 
int InInterval (const Interval interval) const
 
bool IsSubset (const Interval &subset) const
 Returns whether an interval is a subset of this interval.
 
bool Intersects (const Interval &other) const
 Returns whether an interval intersects with another interval.
 
int Empty () const
 
bool IsInfinite () const
 
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
 
Intervaloperator&= (const Interval i)
 
Intervaloperator+= (const TimeValue t)
 
CoreExport void ApplyOffset (const TimeValue offset)
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown.
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned.
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen.
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

Detailed Description

See also
Advanced Topics sections on Intervals and Time Functions.

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)

Constructor & Destructor Documentation

◆ Interval() [1/2]

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() [2/2]

Interval ( )
inline
Remarks
Constructor that returns an EMPTY interval, i.e. having a start and end time equal to TIME_NegInfinity
58{ SetEmpty(); }
void SetEmpty()
Definition: interval.h:126

Member Function Documentation

◆ operator==()

int operator== ( const Interval i) const
inline
Remarks
Checks for equality between two Intervals.
Returns
Nonzero if the intervals are equal; otherwise 0.
62{ return( i.start==start && i.end==end ); }

◆ operator!=()

bool operator!= ( const Interval i) const
inline
Remarks
Checks for inequality between two Intervals.
Returns
false if and only if the intervals are not equal.
65{ return ((operator==(i)) == 0); }

◆ InInterval() [1/2]

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.

◆ InInterval() [2/2]

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.
85{ return InInterval( interval.Start() ) && InInterval( interval.End() ); }
TimeValue Start() const
Definition: interval.h:134
TimeValue End() const
Definition: interval.h:136
CoreExport int InInterval(const TimeValue t) const

◆ IsSubset()

bool IsSubset ( const Interval subset) const
inline

Returns whether an interval is a subset of this interval.

This method is different from InInterval() in the way that it deals with infinite and empty sets. Infinite sets are supersets of everything. Empty sets are subsets or everything.

89{ return (IsInfinite() || subset.Empty() || InInterval(subset)); }
bool IsInfinite() const
Definition: interval.h:104
int Empty() const
Definition: interval.h:102

◆ Intersects()

bool Intersects ( const Interval other) const
inline

Returns whether an interval intersects with another interval.

93 {
94 if (Empty() || other.Empty())
95 return false;
96 return InInterval(other.Start()) || InInterval(other.End()) || other.InInterval(Start()) || other.InInterval(End());
97 }

◆ Empty()

int Empty ( ) const
inline
Remarks
Returns 1 if the interval is EMPTY, i.e. has a start and end time equal to TIME_NegInfinity. Returns 0 otherwise.
102{ return (start == TIME_NegInfinity) && (end == TIME_NegInfinity); }
#define TIME_NegInfinity
Returns a time value that represents negative infinity.
Definition: maxtypes.h:49

◆ IsInfinite()

bool IsInfinite ( ) const
inline
Remarks
Returns true if and only if the interval covers all possible time values, i.e. equals the result of calling SetInfinite().
104{ return (start == TIME_NegInfinity) && (end == TIME_PosInfinity); }
#define TIME_PosInfinity
Returns a time value that represents positive infinity.
Definition: maxtypes.h:47

◆ Set()

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.
112{ start = s; end = e; }

◆ SetStart()

void SetStart ( TimeValue  s)
inline
Remarks
Sets the start value only.
Parameters:
TimeValue s

Start time for the interval.
117{ start = s; }

◆ SetEnd()

void SetEnd ( TimeValue  e)
inline
Remarks
Sets the end value only.
Parameters:
TimeValue e

End time for the interval.
122{ end = e; }

◆ SetEmpty()

void SetEmpty ( )
inline
Remarks
Sets the interval to be EMPTY, i.e. having a start and end time equal to TIME_NegInfinity.
126{ start = TIME_NegInfinity; end = TIME_NegInfinity; }

◆ SetInfinite()

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.
130{ start = TIME_NegInfinity; end = TIME_PosInfinity; }

◆ SetInstant()

void SetInstant ( const TimeValue  t)
inline
Remarks
Sets both the start and end times to the time passed.
132{ start = end = t; }

◆ Start()

TimeValue Start ( ) const
inline
Remarks
Returns the start time of the interval.
134{ return start; }

◆ End()

TimeValue End ( ) const
inline
Remarks
Returns the end time of the interval.
136{ return end; }

◆ Duration()

TimeValue Duration ( ) const
inline
Remarks
Implemented by the System.

Returns the duration of the interval (end points included).
Operators:
141{ return end-start+TimeValue(1); } // end points included
int TimeValue
Definition: maxtypes.h:31

◆ operator&()

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.

◆ operator&=()

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));
155{ return (*this = (*this&i)); }

◆ operator+=()

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;
158{ if (t<start) start=t; if (t>end) end=t; return *this; }

◆ ApplyOffset()

CoreExport void ApplyOffset ( const TimeValue  offset)
Remarks
Offsets the entire interval; shifts the beginning and end by the provided time value. Only effective if the interval is neither empty nor infinite. The offset may be positive or negative. Upon returning, the duration of the interval will be identical to what it was before the call, unless this is made impossible by clamping at either end of the valid numerical range.