HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEO_Delta.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 library (C++)
7  *
8  * COMMENTS: GEO_Delta is an abstract class for recording changes to
9  * point positions, as well as point, primitive, or vertex
10  * attributes.
11  *
12  * This class is a simple interface to the GDT library classes,
13  * specifically GDT_Detail, which inherits from GEO_Delta.
14  *
15  * Existing geometry-modifying functions which are called
16  * from the Edit SOP must be modified to take a GEO_Delta
17  * pointer as a parameter, and must record all changes
18  * to the geometry through this interface.
19  *
20  * Example of a point position change:
21  * void geo_foo(... , GEO_Delta *geodelta, ...)
22  * {
23  * .
24  * .
25  * .
26  * GA_Offset ptoff = gdp->pointOffset(i);
27  * geodelta->beginPointPositionChange(*gdp, ptoff);
28  * gdp->setPos4(ptoff, gdp->getPos4(ptoff).multiply3(xform));
29  * geodelta->endChange();
30  * .
31  * .
32  * .
33  * }
34  *
35  * IMPORTANT IMPLEMENTATION NOTES:
36  * The functions in this class are designed to
37  * be as fast as possible, while maintaining some
38  * degree of flexibility. The following rules are
39  * in place to ensure very fast operation:
40  *
41  * 1. Every begin*Change() call must be accompanied by
42  * a following endChange() call.
43  *
44  * 2. If a call to beginPointPositionChange() (for example)
45  * is made, then ONLY the position of the given point
46  * must change before the call to endChange. Any other
47  * changes will NOT be recorded. This applies to any
48  * begin*Change() call.
49  *
50  * 3. The attribute dictionary MUST be specifed with a
51  * call to set*AttribDict. Deltas will only be computed
52  * for the attributes found in this dictionary.
53  * A call to set*AttribDict should be found in the
54  * Edit SOP, and in any place where the dictionary is
55  * modified (which is why the set*AttribDict functions
56  * are included in this interface, just in case.
57  * Caution - this introduces a lot of additional cases
58  * to consider).
59  *
60  * 4. It is important that the given attribute dictionary
61  * stays constant for future begin/end calls, since the
62  * computation of deltas depends on its structure.
63  */
64 
65 #ifndef __GEO_Delta_h__
66 #define __GEO_Delta_h__
67 
68 #include "GEO_API.h"
69 #include "GEO_Primitive.h"
70 #include <GA/GA_Types.h>
71 class GEO_Detail;
72 class GEO_Primitive;
73 class GA_AttributeDict;
74 
76 {
77 public:
78  GEO_Delta() {}
79  virtual ~GEO_Delta() {}
80 
81  virtual int64 getMemoryUsage(bool inclusive=false) const = 0;
82 
83  /// Applies the delta to a point.
84  /// For orthogonality, additional methods should be created as needed.
85  virtual void applyScaledPointDelta(GEO_Detail &gdp, GA_Offset pt,
86  float scale) const = 0;
87  virtual void applyScaledVertexDelta(GEO_Detail &gdp,
88  GA_Offset vtxoff,
89  float scale) const = 0;
90 
91  // Begin changes to a point's position
92  virtual void beginPointPositionChange(
93  const GA_Detail &gdp,
94  GA_Offset pt) = 0;
95  virtual void beginPointPositionChange(
96  const GA_Detail &gdp,
97  const GA_Range &range) = 0;
98 
99  // Begin changes to a point's attributes
100  virtual void beginPointAttributeChange(
101  const GEO_Detail &gdp,
102  GA_Offset pt) = 0;
103  virtual void beginPointAttributeChange(
104  const GEO_Detail &gdp,
105  const GA_Range &range) = 0;
106 
107  // Begin changes to a point list's attributes
108  // NOTES:
109  // - This function will use MUCH more memory than
110  // beginPointAttributeChange.
111  // - It should only be used when you KNOW that ALL the point
112  // attributes on the gdp will change. beginPointAttributeChange is
113  // much faster when only some point attributes will change, since
114  // you can ignore the point attributes that don't matter.
115  virtual void beginPointListAttributeChange(
116  const GEO_Detail &gdp) = 0;
117 
118  // Begin changes to a primitive's transform
119  virtual void beginPrimitiveTransformChange(
120  const GEO_Primitive &prim) = 0;
121 
122  // Begin changes to a primitive's attributes
123  virtual void beginPrimitiveAttributeChange(
124  const GEO_Primitive &prim) = 0;
125 
126  // Begin changes to a vertex attribute;
127  // linear_index is the index which would be passed
128  // to GA_Primitive::getVertexOffset(GA_Size idx) to retrieve
129  // the desired vertex.
130  virtual void beginVertexAttributeChange(
131  const GEO_Detail &gdp,
132  GA_Offset vtx) = 0;
133  virtual void beginVertexAttributeChange(
134  const GEO_Detail &gdp,
135  const GA_Range &range) = 0;
136 
137  // interface for changing point capture weights
138  virtual void initCaptureWeightChange( const GEO_Detail &gdp ) = 0;
139  virtual void beginCaptureWeightChange(const GEO_Detail &gdp,
140  GA_Offset pt) = 0;
141 
142  // End any of the above changes
143  virtual void endChange() = 0;
144 
145  // Specify the attribute dictionary of the points to be modified
146  // in between subsequent calls to beginPointAttributeChange
147  // and endChange.
148  virtual void setPointAttribDict(
149  const GA_AttributeDict &dict) = 0;
150 
151  // Specify the attribute dictionary of the primitives to be modified
152  // in between subsequent calls to beginPointAttributeChange
153  // and endChange.
154  virtual void setPrimAttribDict(
155  const GA_AttributeDict &dict) = 0;
156 
157  // Specify the attribute dictionary of the vertices to be modified
158  // in between subsequent calls to beginPointAttributeChange
159  // and endChange.
160  virtual void setVertexAttribDict(
161  const GA_AttributeDict &dict) = 0;
162 
163  // Refresh attributes added from GDT_Detail::set.*AttribDict() functions.
164  // These functions assume that your geometry has not changed but your
165  // attribute offsets might have changed because of re-cooking.
166  // If a geometry function changes the attribute dictionary, then it should
167  // call these.
168  virtual void refreshPointAttribDict(
169  const GA_AttributeDict &dict) = 0;
170  virtual void refreshPrimAttribDict(
171  const GA_AttributeDict &dict) = 0;
172  virtual void refreshVertexAttribDict(
173  const GA_AttributeDict &dict) = 0;
174 
175 };
176 
177 #endif
GLenum GLint * range
Definition: glcorearb.h:1924
A range of elements in an index-map.
Definition: GA_Range.h:42
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual ~GEO_Delta()
Definition: GEO_Delta.h:79
long long int64
Definition: SYS_Types.h:100
GA_API const UT_StringHolder scale
#define GEO_API
Definition: GEO_API.h:10
Container class for all geometry.
Definition: GA_Detail.h:96
GEO_Delta()
Definition: GEO_Delta.h:78