HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GDT_Detail() override {}
37 
38  int64 getMemoryUsage(bool inclusive=false) const override;
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  void applyScaledPointDelta(GEO_Detail &gdp, GA_Offset pt,
51  float scale) const override;
52  void applyScaledVertexDelta(GEO_Detail &gdp,
53  GA_Offset vtxoff,
54  float scale) const override;
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  // Reset elements with deltas to the values from the source detail.
65  void resetElementsFromSource(GEO_Detail &gdp,
66  const GEO_Detail &src_gdp) const;
67 
68  // Apply stored deltas for elements also recordered in other to the
69  // given gdp.
70  void applyIntersectionDeltas(GEO_Detail &gdp,
71  const GDT_Detail &other) const;
72 
73  // Accessor for myPointList.
74  GDT_PointList *getPointList() { return &myPointList; }
75 
76  // IMPORTANT:
77  // The following methods are the main vehicles for optimization
78  // of the GDT classes. It is critical to properly determine
79  // which one should be called. They all have similar purposes
80  // with huge differences in the resulting performance.
81  // The calls to set*AttribDict set up the internal lists of
82  // deltas. It may or may not be necessary to destroy these
83  // lists.
84  //
85  // Set all deltas to zero, but don't delete any memory.
86  // This is the best option for interactive use where the
87  // number of modified elements is expected to stay constant.
88  // This method retains the internal lists of attributes.
89  void zeroDeltas();
90  //
91  // Destroy all deltas (delete any memory allocated for them).
92  // This is the best option for when the number of modified
93  // elements is expected to change, but the gdp you are working
94  // on has not changed.
95  // This method retains the internal lists of attributes.
96  void clearDeltas();
97  //
98  // Destroy all internal structures completely (including the
99  // internal lists of attributes). This should be used when
100  // the gdp you are working on has changed.
101  void destroy();
102 
103  // Returns whether we have any deltas at all
104  bool hasChange() const;
105 
106  ///////////////////////////////////
107  // Virtual methods //
108  // inherited from GEO_Delta, //
109  // for use by geometry functions //
110  ///////////////////////////////////
111 
112  void beginPointPositionChange(
113  const GA_Detail &gdp,
114  GA_Offset pt) override;
115  void beginPointPositionChange(
116  const GA_Detail &gdp,
117  const GA_Range &range) override;
118 
119  void beginPointAttributeChange(
120  const GEO_Detail &gdp,
121  GA_Offset pt) override;
122  void beginPointAttributeChange(
123  const GEO_Detail &gdp,
124  const GA_Range &range) override;
125 
126  void beginPointListAttributeChange(
127  const GEO_Detail &gdp) override;
128 
129  void beginPrimitiveTransformChange(
130  const GEO_Primitive &prim) override;
131 
132  void beginPrimitiveAttributeChange(
133  const GEO_Primitive &prim) override;
134 
135  void beginVertexAttributeChange(
136  const GEO_Detail &gdp,
137  GA_Offset vtx) override;
138  void beginVertexAttributeChange(
139  const GEO_Detail &gdp,
140  const GA_Range &range) override;
141 
142  // interface for changing point capture weights
143  void getOpPaths( UT_StringList &paths );
144  void getOpPathsCopy( UT_ValArray<char *> &paths );
145  void setOpPaths( const UT_ValArray<char *> &paths );
146  int changeOpPaths( const char *old_name,
147  const char *new_name );
148  bool changeCaptureRegionRoot( const char *old_root,
149  const char *new_root );
150  void refreshCaptureFrameInfo( const GEO_Detail &gdp,
151  GDT_CaptureRegionCB get_region,
152  void *user_data );
153  void initCaptureWeightChange(
154  const GEO_Detail &gdp) override;
155  void beginCaptureWeightChange(
156  const GEO_Detail &gdp,
157  GA_Offset pt) override;
158 
159  void endChange() override;
160 
161  // Computes the vertex offset array from the given geometry,
162  // so that vertex deltas can be computed correctly.
163  virtual void updateVertexOffsets(const GEO_Detail &gdp);
164 
165  // Sets point, primitive, or vertex attribute dictionaries,
166  // so that attribute deltas can be computed correctly.
167  // These methods will _add_ new attribute delta lists if necessary.
168  void setPointAttribDict(
169  const GA_AttributeDict &dict) override;
170  void setPrimAttribDict(
171  const GA_AttributeDict &dict) override;
172  void setVertexAttribDict(
173  const GA_AttributeDict &dict) override;
174 
175  // Refresh attributes added from set.*AttribDict() functions.
176  // These functions assume that your geometry has not changed but your
177  // attribute offsets might have changed because of added/deleted attributes.
178  // Note that any attributes added on the geometry will _not_ be added
179  // as new delta lists.
180  void refreshPointAttribDict(
181  const GA_AttributeDict &dict) override;
182  void refreshPrimAttribDict(
183  const GA_AttributeDict &dict) override;
184  void refreshVertexAttribDict(
185  const GA_AttributeDict &dict) override;
186 
187  /////////////////
188  // I/O Methods //
189  /////////////////
190  bool save(std::ostream &os, int binary=0) const;
191  bool load(UT_IStream &is);
192 
193  bool save(UT_JSONWriter &w) const;
194  bool load(UT_JSONParser &p);
195 
196  bool legacyLoad(UT_IStream &is);
197 
198  void setCoordinateFrames(const GDT_CoordinateFrames *coords);
199  const GDT_CoordinateFrames *getCoordinateFrames();
200 
201  void createSymmetryDeltas(const GDT_Detail &input, GDT_SymmetryTransform *transform);
202 
203 private:
204 
205  // Types of possible changes
206  enum GDT_CHANGE_TYPE
207  {
208  GDT_CHANGE_NONE,
209  GDT_CHANGE_FAKE,
210  GDT_CHANGE_POINT_POS,
211  GDT_CHANGE_POINT_CAPTUREWEIGHT,
212  GDT_CHANGE_POINT_ATTRIB,
213  GDT_CHANGE_POINTLIST_ATTRIB,
214  GDT_CHANGE_PRIM_TRANS,
215  GDT_CHANGE_PRIM_ATTRIB,
216  GDT_CHANGE_VERTEX_ATTRIB
217  };
218 
219  // Data cached for changing attributes or transforms
220  GDT_CHANGE_TYPE myChangeType;
221  const GEO_Detail *myChangeDetail;
222  const GEO_Primitive *myChangePrim;
223 
224  GDT_PointList myPointList; // point deltas
225  GDT_PrimitiveList myPrimList; // primitive deltas
226  GDT_VertexList myVertexList; // vertex deltas
227 };
228 
230 
231 #endif
#define GDT_API
Definition: GDT_API.h:10
GLenum GLint * range
Definition: glcorearb.h:1925
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
int64 getMemoryUsage(bool inclusive) const override
Compute memory usage (includes all shared memory)
~GDT_Detail() override
Definition: GDT_Detail.h:36
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
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:646
GA_API const UT_StringHolder scale
IOStatus load(const char *filename, const GA_LoadOptions *opts=0, UT_StringArray *errors=0)
Load a geometry file.
GLuint coords
Definition: glad.h:4091
long long int64
Definition: SYS_Types.h:116
IOStatus save(const char *filename, const GA_SaveOptions *options, UT_StringArray *errors=0) const
GA_API const UT_StringHolder transform
int(* GDT_CaptureRegionCB)(void *user_data, char *cregion, UT_Matrix4 &parent_xform, GU_DetailHandle &tube_gdp)
Container class for all geometry.
Definition: GA_Detail.h:96
GDT_PointList * getPointList()
Definition: GDT_Detail.h:74
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857