HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_CaptureOverrideData.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GEO_CaptureOverrideData.h (GEO Library, C++)
7  *
8  * COMMENTS: Class to store overrides for point capture weight attributes.
9  */
10 
11 #ifndef __GEO_CaptureOverrideData_h__
12 #define __GEO_CaptureOverrideData_h__
13 
14 #include "GEO_API.h"
15 
16 #include <GA/GA_AIFIndexPair.h>
17 #include <GA/GA_AIFStringTuple.h>
18 #include <GA/GA_AttributeRef.h>
19 #include <GA/GA_Types.h>
20 
21 #include <UT/UT_Array.h>
22 #include <UT/UT_IntArray.h>
23 #include <UT/UT_Matrix4.h>
24 #include <UT/UT_VectorTypes.h>
25 
26 
27 class UT_IStream;
28 class GA_PointGroup;
29 class GEO_Detail;
32 
33 class geo_CaptureOverridePointData;
34 
35 typedef int (*GEO_CaptureRegionDataCB)( void *user_data,
36  char *full_cregion_path,
37  char *relative_cregion_path,
38  GEO_CaptureBoneStorage &tube_data );
39 
41 {
42 public:
44  virtual ~GEO_CaptureOverrideData();
45 
46  void destroy();
47 
48  void getOpPaths( UT_Array<const char *> &paths );
49  void getOpPathsCopy( UT_Array<char *> &paths );
50  void setOpPaths( const UT_Array<char *> &paths );
51  int changeOpPaths( const char *old_name,
52  const char *new_name );
53  void changeCaptureRegionRoot( const char *old_root,
54  const char *new_root );
55  void refreshCaptureFrameInfo( const GEO_Detail &gdp,
56  GEO_CaptureRegionDataCB get_region,
57  void *user_data );
58 
59  // Apply the stored overrides to the given detail.
60  void applyOverrides(GEO_Detail &gdp);
61 
62  // The following pair of methods is for either merging in the
63  // specified changes, or undoing the previous merge of those
64  // changes.
65  void mergeCaptureWeightOverridesDelta(
66  GEO_CaptureOverrideDelta &delta );
67  void undoCaptureWeightOverridesDelta(
68  const GEO_CaptureOverrideDelta &delta );
69 
70  bool overrideExists( int point_num ) const;
71 
72  // Compute the memory usage of this object (in bytes).
73  int64 getMemoryUsage() const;
74 
75  int save( std::ostream &os, int binary ) const;
76  bool load( UT_IStream &is );
77 
78 private: // methods
79 
80  // The following method converts the specified override to indices
81  // in our local table and applies the override, possibly overriding
82  // an existing one. It only adds paths to our region paths if the
83  // added_delta_paths array is specified to record those added. If
84  // not allowed to add paths and it needs to, it is an error, and so
85  // an assert is triggered. In that case it does not add the override,
86  // still potentially removing an old one.
87  void setOverride(int point_num, const float *weights, int size,
88  UT_IntArray &map_from_delta,
89  const UT_Array<char *> &delta_paths,
90  const UT_Array<GEO_CaptureBoneStorage *> &delta_tubes,
91  UT_IntArray *added_delta_paths,
92  bool &max_size_invalid);
93 
94  void updateIndexBounds( int point_num, bool exists,
95  bool &min_invalid, bool &max_invalid );
96 
97  int findPathIndex( const char *path ) const;
98 
99 private: // data
100  UT_Array<char *> myRegionPaths;
101  UT_Array<GEO_CaptureBoneStorage *> myCaptureTubes;
102 
103  // We store our weight overrides as <index, weight> pairs, with
104  // <-1, -1> signalling the end. The indices are indices into
105  // the our array of capture regions (paths).
107 
108  int myMinPointIndex;
109  int myMaxPointIndex;
110 
111  int myNumOverrides;
112  int myMaxWeightDataSize;
113 };
114 
115 enum
116 {
121 };
122 
123 class geo_CaptureOverrideDeltaData;
124 
125 // This class is used for the undo mechanism and generally doesn't
126 // contain too many changes (as opposed to the GEO_CaptureOverrideData
127 // class), and so is stored in a very sparse form. Observe that it
128 // has no method to apply the changes to the gdp as this is unnecessary
129 // since it is always built directly from the changes to the gdp. Note
130 // the it is only intended to undo changes directly from the gdp if the
131 // input has not changed at all (ie. within the cook mechanism). When it
132 // is part of an actual undo, the undo should only be applied to the
133 // permanent overrides object, and a full cook redone.
134 
136 {
137 public:
139  virtual ~GEO_CaptureOverrideDelta();
140 
141  void copyForUndo( const GEO_CaptureOverrideDelta &other );
142 
143  // Destroy all internal structures completely.
144  void destroy();
145 
146  // Methods to query the state of the changes for particular points.
147  bool removesOverride( int point_num ) const;
148  bool addsOverride( int point_num ) const;
149 
150  // Capture regions MUST be added before any points are changed, and
151  // initCaptureWeightChange is called.
152  void addedCaptureRegion( const GEO_Detail &gdp, const char *path,
153  int cindex );
154 
155  // We must be re-initialized if the attributes have grown, been
156  // added, or removed as we cache offsets and sizes. Make sure
157  // that this is not called between a beginCaptureWeightChange
158  // and the corresponding endCaptureWeightChange.
159  void initCaptureWeightChange( const GEO_Detail &gdp );
160 
161  // It is important that only one change per point is stored in this
162  // class. We cannot, in all cases, combine multiple changes to the
163  // same point and so disallow this.
164  void beginCaptureWeightChange( GA_Offset point );
165  void endCaptureWeightChange( GA_Offset point,
166  unsigned int point_index,
167  int operation );
168 
169  const UT_Array<char *> &getPaths() const
170  { return myRegionPaths; }
173  { return myCaptureTubes; }
175  { return myAddedRegionsToOverrides; }
177  { return myAddedRegionsToOverrides; }
178 
179  int getNumChanges() const { return myChanges.entries(); }
180  const geo_CaptureOverrideDeltaData *getChange(int i) const
181  { return myChanges(i); }
182 
183  // Undo the stored overrides to the given detail.
184  void undoOverrideDeltas( GEO_Detail &gdp );
185 
186  // Compute the memory usage of this object (in bytes).
187  int64 getMemoryUsage() const;
188 
189 private: // methods
190  void convertAndStorePtData( const float *gdp_data,
191  int num_point_regions,
192  float *&store_data, int &store_size );
193 
194  void prepareCaptureRegionChange( int path_index );
195  void convertAndRestorePtData( GA_Attribute *attrib,
196  const GA_AIFIndexPair *indexpair,
197  GA_Offset point,
198  int num_point_regions,
199  const float *store_data,
200  int store_size,
201  const UT_IntArray &map_to_gdp,
202  float *tmp_data );
203 
204 
205 private: // data
206  UT_Array<char *> myRegionPaths;
207  UT_Array<GEO_CaptureBoneStorage *> myCaptureTubes;
208 
209  // We need to keep track of regions we added to the gdp or region
210  // paths we added to the permanent overrides class to allow us to
211  // properly undo the changes.
212  UT_IntArray myAddedRegionsToGdp;
213  UT_IntArray myAddedRegionsToOverrides;
214 
216 
217  // the following data is used for init/begin/end changes
218  GA_ROAttributeRef mySavedTubeRef;
219  float *mySavedData;
220  const GA_Attribute *mySavedDataAttrib;
221  const GA_AIFIndexPair *mySavedDataAIF;
222  unsigned int mySavedDataSize;
223  UT_IntArray myMapFromGdp;
224 };
225 
226 #endif // __GEO_CaptureOverrideData_h__
227 
const UT_Array< char * > & getPaths() const
const UT_IntArray & getRegionsAddedToOverrides() const
Definition of a geometry attribute.
Definition: GA_Attribute.h:190
Generic Attribute Interface class to get/set data as index pairs.
int(* GEO_CaptureRegionDataCB)(void *user_data, char *full_cregion_path, char *relative_cregion_path, GEO_CaptureBoneStorage &tube_data)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
Convenience class to store a bone capture region.
png_uint_32 i
Definition: png.h:2877
GLsizeiptr size
Definition: glcorearb.h:663
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:107
This class provides a way to manage a reference to an attribute permitting Read-Only access...
#define GEO_API
Definition: GEO_API.h:10
UT_IntArray & getRegionsAddedToOverrides()
const UT_Array< GEO_CaptureBoneStorage * > & getCaptureTubes() const
typedef int
Definition: png.h:1175
const geo_CaptureOverrideDeltaData * getChange(int i) const