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