Katana Plug-in APIs 0.1

FnAttributeUtils.h

00001 #ifndef FoundryKatanaAttributeUtils_H
00002 #define FoundryKatanaAttributeUtils_H
00003 
00004 #include <vector>
00005 #include <set>
00006 #include <map>
00007 #include <ostream>
00008 
00009 #include <FnAttribute/FnAttribute.h>
00010 #include <FnAttribute/FnAttributeAPI.h>
00011 #include <FnAttribute/FnGroupBuilder.h>
00012 
00013 FNATTRIBUTE_NAMESPACE_ENTER
00014 {
00016     //
00017     // WARNING - these are likely to be moved to an alternate library / header
00018     //
00019 
00020     // To compute a global attribute, start at leaf, and walk up, querying
00021     // the specified attribute.
00022     //
00023     // If, at any point, a non-group attr is encountered, return that.
00024     // If, at any point, an enclosing group attr is non-inheriting, stop walking up.
00025     //
00026     // Finally, collapse the accumulated GroupAttrs into a single return value.
00027     //
00028     // NOTE: localAttributes vector is ordered from LEAF to ROOT
00029     // index[0] = LEAF
00030     // index[n-1] = ROOT
00031 
00032     FNATTRIBUTE_API
00033     Attribute GetGlobalAttribute(
00034         const std::vector<GroupAttribute> & localAttributes);
00035 
00036     // return a1.extend(a2)
00037     // Similar to python's "extend" array function, though this does type
00038     // checking. If types a1 and a2 do not match, an invalid attr is
00039     // returned.
00040 
00041     FNATTRIBUTE_API
00042     Attribute ExtendDataAttr(const Attribute & a1,
00043                              const Attribute & a2);
00044 
00045     // Given an attribute, add all the available time samples to the
00046     // incoming set. GroupAttributes are deeply recursed, with all DataAttribute
00047     // leaves added.
00048 
00049     FNATTRIBUTE_API
00050     void GetAttributeTimeSamples(std::set<float> * samples, const Attribute & attr);
00051 
00052     // Given an attribute, if it is multi-sampled and the values are the same,
00053     // return a new attribute with only the initial time-sample. If the values
00054     // are varying, the original attribute will be returned unmodified.
00055     // GroupAttributes will be traversed, with this applied to all leaves
00056     FNATTRIBUTE_API
00057     Attribute RemoveTimeSamplesIfAllSame(const Attribute & attr);
00058 
00059     // Given a shutter range, this will remove all unnecessary time samples.
00060     // Note that to maintain interpolation accuraccy, if a timesample doesnt
00061     // fall exactly on shutterOpen, shutterClose, one extra sample outside the
00062     // specified range will be kept. (But samples further outside will be
00063     // removed).
00064 
00065     FNATTRIBUTE_API
00066     Attribute RemoveTimeSamplesUnneededForShutter(const Attribute & attr,
00067         float shutterOpen, float shutterClose);
00068 
00069     // Resample the specified value to match the time samples present
00070     // in the timeReference. New values will be created using fillInterpSample
00071     // for FloatAttribute and DoubleAttributes, and getNearestSample
00072     // for IntAttributes, StringAttribute.
00073     // NullAttributes are returned 'as is'
00074     // GroupAttributes are recursed, and converted at all appropriate leaves.
00075     //
00076     // Note: the attr values for timeReference are ignored.
00077 
00078     FNATTRIBUTE_API
00079     FnAttribute::Attribute ResampleAttrWithInterp(
00080         const FnAttribute::Attribute & value,
00081         const FnAttribute::DataAttribute & timeReference);
00082 
00083     // Useful for pretty printing of FnAttributes
00084     FNATTRIBUTE_API
00085     void GetAttrValueAsPrettyText(std::ostream & os,
00086         const Attribute & attr,
00087         int maxArrayValues=-1);
00088 
00089     FNATTRIBUTE_API
00090     void GetAttrTypeAsPrettyText(std::ostream& os, const Attribute& attr);
00091 }
00092 FNATTRIBUTE_NAMESPACE_EXIT
00093 
00094 #endif // FoundryKatanaAttributeUtils_H
 All Classes Functions Variables Typedefs Enumerations Enumerator