HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GDT_PointList.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: GDT_PointList contains tokens for point attributes and
9  * a position token. All these tokens are not sparse.
10  *
11  */
12 #ifndef __GDT_PointList_h__
13 #define __GDT_PointList_h__
14 
15 #include "GDT_API.h"
16 #include "GDT_TokenList.h"
17 
18 #include <GA/GA_Types.h>
19 #include <GEO/GEO_Detail.h>
20 #include "GDT_CaptureWeight.h"
21 #include "GDT_Position.h"
22 #include "GDT_CoordinateFrames.h"
23 
24 class GA_PointGroup;
25 
27 {
28 public:
29  GDT_PointList() : myPosition(0), myCaptureWeight(0), myCoordinateFrames(0) {}
30  GDT_PointList(const GDT_PointList &other);
31  ~GDT_PointList() override;
32 
33  // Implement the pure virtual applyDeltas() from GDT_TokenList.
34  void applyDeltas(GEO_Detail &gdp,
35  bool inverse = false) const override;
36 
37  virtual void applyScaledDelta(GEO_Detail &gdp,
38  GA_Offset pt, float scale) const;
39  virtual void applyScaledPosDeltas(GEO_Detail &gdp,
40  float scale,
41  const GA_PointGroup *ptgroup = 0) const;
42 
43  // Merge the point deltas from another GDT_PointList into this one
44  void mergePointDeltas(const GDT_PointList &other,
45  bool inverse = false);
46 
47  // Reset elements with deltas to the values from the source detail.
48  void resetElementsFromSource(GEO_Detail &gdp,
49  const GEO_Detail &src_gdp) const;
50 
51  // Apply stored deltas for elements also recordered in other to the
52  // given gdp.
53  void applyIntersectionDeltas(GEO_Detail &gdp,
54  const GDT_PointList &other) const;
55 
56  // Overload hiding base class method which requires a GA_AIFEditDeltaMap.
57  void endAttributeChange(const GEO_Detail &gdp);
58 
59  // Begin/end a change to a point position
60  void beginPointPositionChange(const GA_Attribute *P,
61  GA_Offset element);
62  void beginPointPositionChange(const GA_Attribute *P,
63  const GA_Range &range);
64  void endPointPositionChange(const GEO_Detail &gdp);
65 
66  void getOpPaths( UT_StringList &paths );
67  void getOpPathsCopy( UT_ValArray<char *> &paths );
68  void setOpPaths( const UT_ValArray<char *> &paths );
69  int changeOpPaths( const char *old_name,
70  const char *new_name );
71  bool changeCaptureRegionRoot( const char *old_root,
72  const char *new_root );
73  void refreshCaptureFrameInfo(
74  const GEO_Detail &gdp,
75  GDT_CaptureRegionCB get_region,
76  void *user_data );
77  void initCaptureWeightChange( const GEO_Detail &gdp );
78  void beginCaptureWeightChange(
79  GA_Offset element );
80  void endCaptureWeightChange(const GEO_Detail &gdp);
81 
83  const GEO_Detail &gdp) const override
84  { return gdp.pointAttribs(); }
85 
86  bool hasChange() const override;
87  virtual bool haveAttributesChanged() const
88  { return GDT_TokenList::hasChange(); }
89  // Returns true if point position data is present, return false otherwise
90  bool hasPositionChanged() const
91  {
92  return (myPosition &&
93  myPosition->changed() > 0);
94  }
96  {
97  return (myCaptureWeight &&
98  myCaptureWeight->changed() > 0);
99  }
100 
101  // If myPosition has been blanked out, then loadPos will pre-allocate
102  // numtotal slots in the position array. If myPosition exists, then this
103  // number is ignored and the data is loaded and merged with what already
104  // exists.
105  bool legacyLoadPos(UT_IStream &is, uint numtotal);
106 
107  bool savePos(UT_JSONWriter &w,
108  const GDT_JSON &json) const;
109  bool loadPos(UT_JSONParser &p,
110  const GDT_JSON &json);
111 
112  bool legacyLoadCaptureWeight(UT_IStream &is,
113  unsigned int numtotal);
114 
115  bool saveCaptureWeight(UT_JSONWriter &w,
116  const GDT_JSON &json) const;
117  bool loadCaptureWeight(UT_JSONParser &p,
118  const GDT_JSON &json);
119 
120  // Zero the point deltas
121  void zeroDeltas() override;
122  // Destroy the point deltas, but not the attribute lists
123  void clearDeltas() override;
124  // Destroy the point deltas
125  void destroy() override;
126 
127  void setCoordinateFrames(const GDT_CoordinateFrames *coords);
128  const GDT_CoordinateFrames *getCoordinateFrames();
129 
130  void createSymmetryDeltas(const GDT_PointList &input, GDT_SymmetryTransform *transform);
131 
132 protected:
133  GDT_Position *newPosition(const GDT_Position &p);
134  GDT_Position *newPosition();
135 
136 private:
137  // The position token is kept apart from the token list, so that
138  // we can make the token list general and not have to check extra cases.
139  GDT_Position *myPosition;
140 
141  GDT_CaptureWeight *myCaptureWeight;
142 
143  const GDT_CoordinateFrames *myCoordinateFrames;
144 };
145 #endif
const GA_AttributeDict & getAttributeDict(const GEO_Detail &gdp) const override
Definition: GDT_PointList.h:82
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
#define GDT_API
Definition: GDT_API.h:10
GLenum GLint * range
Definition: glcorearb.h:1925
SYS_FORCE_INLINE const GA_AttributeDict & pointAttribs() const
Definition: GEO_Detail.h:1939
virtual void zeroDeltas()
bool hasCaptureWeightChanged() const
Definition: GDT_PointList.h:95
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:641
GA_API const UT_StringHolder scale
GLuint coords
Definition: glad.h:4091
GA_API const UT_StringHolder transform
int(* GDT_CaptureRegionCB)(void *user_data, char *cregion, UT_Matrix4 &parent_xform, GU_DetailHandle &tube_gdp)
virtual void applyDeltas(GEO_Detail &gdp, bool inverse=0) const =0
virtual bool haveAttributesChanged() const
Definition: GDT_PointList.h:87
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
void endAttributeChange(const GA_AIFEditDeltaMap &map)
virtual bool hasChange() const
unsigned int uint
Definition: SYS_Types.h:45
virtual void clearDeltas()
virtual void destroy()
bool hasPositionChanged() const
Definition: GDT_PointList.h:90