HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GDT_Detail.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: GDT Library. (Geo Delta)
7  *
8  * COMMENTS: Stores a GEO_Detail delta, for point/primitive/vertex
9  * attributes and point positions.
10  *
11  */
12 
13 #ifndef __GDT_Detail_h__
14 #define __GDT_Detail_h__
15 
16 #include "GDT_API.h"
17 #include "GDT_PointList.h"
18 #include "GDT_PrimitiveList.h"
19 #include "GDT_VertexList.h"
20 #include "GDT_CoordinateFrames.h"
21 #include <GEO/GEO_Delta.h>
22 #include <SYS/SYS_Types.h>
23 #include <iosfwd>
24 
25 class UT_IStream;
26 class GEO_Detail;
27 
29 
31 {
32 public:
33 
34  GDT_Detail() : myChangeType(GDT_CHANGE_NONE) {}
35  GDT_Detail(const GDT_Detail &other);
36  virtual ~GDT_Detail() {}
37 
38  virtual int64 getMemoryUsage(bool inclusive=false) const;
39 
40  /////////////////////////////
41  // Methods for use by SOPs //
42  /////////////////////////////
43 
44  // Apply stored deltas to the given gdp (optionally inverted)
45  void applyDeltas(GEO_Detail &gdp) const;
46  void applyInverseDeltas(GEO_Detail &gdp) const;
47 
48  // Operates on a single element. For orthoganality, functions
49  // should be made for GEO_Primitive, etc, as required.
50  virtual void applyScaledPointDelta(GEO_Detail &gdp, GA_Offset pt,
51  float scale) const;
52  virtual void applyScaledVertexDelta(GEO_Detail &gdp,
53  GA_Offset vtxoff,
54  float scale) const;
55  // Currently, this only supports point positions
56  void applyScaledPointPosDeltas(GEO_Detail &gdp,
57  float scale,
58  const GA_PointGroup *ptgroup = NULL) const;
59 
60  // Apply given deltas to the stored deltas
61  void mergeDeltas(const GDT_Detail &other);
62  void mergeInverseDeltas(const GDT_Detail &other);
63 
64  // Accessor for myPointList.
65  GDT_PointList *getPointList() { return &myPointList; }
66 
67  // IMPORTANT:
68  // The following methods are the main vehicles for optimization
69  // of the GDT classes. It is critical to properly determine
70  // which one should be called. They all have similar purposes
71  // with huge differences in the resulting performance.
72  // The calls to set*AttribDict set up the internal lists of
73  // deltas. It may or may not be necessary to destroy these
74  // lists.
75  //
76  // Set all deltas to zero, but don't delete any memory.
77  // This is the best option for interactive use where the
78  // number of modified elements is expected to stay constant.
79  // This method retains the internal lists of attributes.
80  void zeroDeltas();
81  //
82  // Destroy all deltas (delete any memory allocated for them).
83  // This is the best option for when the number of modified
84  // elements is expected to change, but the gdp you are working
85  // on has not changed.
86  // This method retains the internal lists of attributes.
87  void clearDeltas();
88  //
89  // Destroy all internal structures completely (including the
90  // internal lists of attributes). This should be used when
91  // the gdp you are working on has changed.
92  void destroy();
93 
94  // Returns whether we have any deltas at all
95  bool hasChange() const;
96 
97  ///////////////////////////////////
98  // Virtual methods //
99  // inherited from GEO_Delta, //
100  // for use by geometry functions //
101  ///////////////////////////////////
102 
103  virtual void beginPointPositionChange(
104  const GA_Detail &gdp,
105  GA_Offset pt);
106  virtual void beginPointPositionChange(
107  const GA_Detail &gdp,
108  const GA_Range &range);
109 
110  virtual void beginPointAttributeChange(
111  const GEO_Detail &gdp,
112  GA_Offset pt);
113  virtual void beginPointAttributeChange(
114  const GEO_Detail &gdp,
115  const GA_Range &range);
116 
117  virtual void beginPointListAttributeChange(
118  const GEO_Detail &gdp);
119 
120  virtual void beginPrimitiveTransformChange(
121  const GEO_Primitive &prim);
122 
123  virtual void beginPrimitiveAttributeChange(
124  const GEO_Primitive &prim);
125 
126  virtual void beginVertexAttributeChange(
127  const GEO_Detail &gdp,
128  GA_Offset vtx);
129  virtual void beginVertexAttributeChange(
130  const GEO_Detail &gdp,
131  const GA_Range &range);
132 
133  // interface for changing point capture weights
134  void getOpPaths( UT_StringList &paths );
135  void getOpPathsCopy( UT_ValArray<char *> &paths );
136  void setOpPaths( const UT_ValArray<char *> &paths );
137  int changeOpPaths( const char *old_name,
138  const char *new_name );
139  bool changeCaptureRegionRoot( const char *old_root,
140  const char *new_root );
141  void refreshCaptureFrameInfo( const GEO_Detail &gdp,
142  GDT_CaptureRegionCB get_region,
143  void *user_data );
144  virtual void initCaptureWeightChange( const GEO_Detail &gdp );
145  virtual void beginCaptureWeightChange(const GEO_Detail &gdp, GA_Offset pt);
146 
147  virtual void endChange();
148 
149  // Computes the vertex offset array from the given geometry,
150  // so that vertex deltas can be computed correctly.
151  virtual void updateVertexOffsets(const GEO_Detail &gdp);
152 
153  // Sets point, primitive, or vertex attribute dictionaries,
154  // so that attribute deltas can be computed correctly.
155  // These methods will _add_ new attribute delta lists if necessary.
156  virtual void setPointAttribDict(const GA_AttributeDict &dict);
157  virtual void setPrimAttribDict(const GA_AttributeDict &dict);
158  virtual void setVertexAttribDict(const GA_AttributeDict &dict);
159 
160  // Refresh attributes added from set.*AttribDict() functions.
161  // These functions assume that your geometry has not changed but your
162  // attribute offsets might have changed because of added/deleted attributes.
163  // Note that any attributes added on the geometry will _not_ be added
164  // as new delta lists.
165  virtual void refreshPointAttribDict(const GA_AttributeDict &dict);
166  virtual void refreshPrimAttribDict(const GA_AttributeDict &dict);
167  virtual void refreshVertexAttribDict(const GA_AttributeDict &dict);
168 
169  /////////////////
170  // I/O Methods //
171  /////////////////
172  bool save(std::ostream &os, int binary=0) const;
173  bool load(UT_IStream &is);
174 
175  bool save(UT_JSONWriter &w) const;
176  bool load(UT_JSONParser &p);
177 
178  bool legacyLoad(UT_IStream &is);
179 
180  void setCoordinateFrames(const GDT_CoordinateFrames *coords);
181  const GDT_CoordinateFrames *getCoordinateFrames();
182 
183  void createSymmetryDeltas(const GDT_Detail &input, GDT_SymmetryTransform *transform);
184 
185 private:
186 
187  // Types of possible changes
188  enum GDT_CHANGE_TYPE
189  {
190  GDT_CHANGE_NONE,
191  GDT_CHANGE_FAKE,
192  GDT_CHANGE_POINT_POS,
193  GDT_CHANGE_POINT_CAPTUREWEIGHT,
194  GDT_CHANGE_POINT_ATTRIB,
195  GDT_CHANGE_POINTLIST_ATTRIB,
196  GDT_CHANGE_PRIM_TRANS,
197  GDT_CHANGE_PRIM_ATTRIB,
198  GDT_CHANGE_VERTEX_ATTRIB
199  };
200 
201  // Data cached for changing attributes or transforms
202  GDT_CHANGE_TYPE myChangeType;
203  const GEO_Detail *myChangeDetail;
204  const GEO_Primitive *myChangePrim;
205 
206  GDT_PointList myPointList; // point deltas
207  GDT_PrimitiveList myPrimList; // primitive deltas
208  GDT_VertexList myVertexList; // vertex deltas
209 };
210 
212 
213 #endif
#define GDT_API
Definition: GDT_API.h:10
GLenum GLint * range
Definition: glcorearb.h:1924
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
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
long long int64
Definition: SYS_Types.h:100
GA_API const UT_StringHolder scale
IOStatus load(const char *filename, const GA_LoadOptions *opts=0, UT_StringArray *errors=0)
Load a geometry file.
IOStatus save(const char *filename, const GA_SaveOptions *options, UT_StringArray *errors=0) const
GA_API const UT_StringHolder transform
virtual ~GDT_Detail()
Definition: GDT_Detail.h:36
int(* GDT_CaptureRegionCB)(void *user_data, char *cregion, UT_Matrix4 &parent_xform, GU_DetailHandle &tube_gdp)
virtual int64 getMemoryUsage(bool inclusive) const
Compute memory usage (includes all shared memory)
Container class for all geometry.
Definition: GA_Detail.h:96
GDT_PointList * getPointList()
Definition: GDT_Detail.h:65
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856