HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimPacked.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_PrimPacked.h (GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GEO_PrimPacked__
12 #define __GEO_PrimPacked__
13 
14 #include "GEO_API.h"
15 #include "GEO_PackedTypes.h"
16 #include "GEO_Primitive.h"
17 #include <UT/UT_IntrusivePtr.h>
18 
19 class GEO_PackedNameMap;
21 
22 /// This is the key associated with the name map hash. It should not be used
23 /// by sub-classes for loadSharedLoadData()
24 #define GEO_SHARED_DATA_NAMEMAP (('A'<<24)|('m'<<16)|('a'<<8)|('p'))
25 
27 {
28 public:
29  /// The primitive takes ownership if the @c procedural passed in
32 
33  /// This needs to be outlined in order to avoid including GEO_PackedNameMap.h
34  virtual ~GEO_PrimPacked();
35 
36  /// @{
37  /// Required interface methods for GEO primitive
38  virtual bool isDegenerate() const = 0;
39  virtual int getBBox(UT_BoundingBox *bbox) const;
40  virtual void enlargePointBounds(UT_BoundingBox &box) const;
41  virtual void reverse() {}
42  virtual UT_Vector3 computeNormal() const;
43  virtual void copyPrimitive(const GEO_Primitive *src);
44  virtual void copyUnwiredForMerge(const GA_Primitive *src,
45  const GA_MergeMap &map);
46  virtual void copyImplementation(const GEO_PrimPacked &src) = 0;
47 
48  // Take the whole set of points into consideration when applying the
49  // point removal operation to this primitive. The method returns 0 if
50  // successful, -1 if it failed because it would have become degenerate,
51  // and -2 if it failed because it would have had to remove the primitive
52  // altogether.
53  virtual int detachPoints(GA_PointGroup &grp);
54  /// Before a point is deleted, all primitives using the point will be
55  /// notified. The method should return "false" if it's impossible to
56  /// delete the point. Otherwise, the vertices should be removed.
57  virtual GA_DereferenceStatus dereferencePoint(GA_Offset point,
58  bool dry_run=false);
59  virtual GA_DereferenceStatus dereferencePoints(
60  const GA_RangeMemberQuery &pt_q,
61  bool dry_run=false);
62  virtual const GA_PrimitiveJSON *getJSON() const;
63 
64  /// Evalaute a point given a u,v coordinate (with derivatives)
65  virtual bool evaluatePointRefMap(GA_Offset result_vtx,
66  GA_AttributeRefMap &hlist,
67  fpreal u, fpreal v, uint du, uint dv) const;
68  /// Evalaute position given a u,v coordinate (with derivatives)
69  virtual int evaluatePointV4( UT_Vector4 &pos, float u, float v = 0,
70  unsigned du=0, unsigned dv=0) const
71  {
72  return GEO_Primitive::evaluatePointV4(pos, u, v,
73  du, dv);
74  }
75  virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
76  virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET);
77  virtual void transform(const UT_Matrix4 &xform) = 0;
78  virtual UT_Vector3 baryCenter() const;
79  virtual fpreal calcVolume(const UT_Vector3 &refpt) const = 0;
80  virtual fpreal calcArea() const = 0;
81  virtual fpreal calcPerimeter() const = 0;
82  virtual void getLocalTransform(UT_Matrix3D &matrix) const;
83  virtual void setLocalTransform(const UT_Matrix3D &matrix);
84  virtual void getPivot(UT_Vector3 &pos) const;
85  virtual void setPivot(const UT_Vector3 &pos);
86  /// @}
87 
88  /// Return the full transform matrix for the primitive. This includes the
89  /// local transform combined with any additional transforms which might be
90  /// implicit to the primitive.
91  /// The default behaviour is to simply call @c getLocalTransform4();
92  virtual void getFullTransform4(UT_Matrix4D &matrix) const = 0;
93 
94  /// @{
95  /// Get the un-transformed bounding box
96  virtual bool getUntransformedBounds(UT_BoundingBox &box) const = 0;
97  virtual bool getUntransformedRenderingBounds(UT_BoundingBox &box) const = 0;
98  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax) const = 0;
99  /// @}
100 
101  /// Method to assist with rendering. To get accurate bounding boxes for
102  /// rendering, the "width" of points and curve objects needs to be taken
103  /// into account. These bounds will include the transform on the primitive.
104  ///
105  /// Returns false if the bounds are invalid.
106  bool getRenderingBounds(UT_BoundingBox &box) const;
107 
108  /// Method to assist with rendering. When rendering velocity based motion
109  /// blur, the renderer needs to know the bounds on the velocity to
110  /// accurately compute a bounding box.
111  ///
112  /// These velocities will *not* include any scales applied by the transform
113 
114  /// Set vertex to reference the given point. This will ensure the vertex
115  /// is allocated.
118  {
119  if (getVertexCount() == 0)
120  myVertexList.append(allocateVertex());
121 
122  setPointOffset(0, point);
123  }
124  /// Called when loading to set the vertex
125  void assignVertex(GA_Offset vtx, bool update_topology);
126 
127  /// @{
128  /// Accessors for viewport LOD
129  GEO_ViewportLOD viewportLOD() const { return myViewportLOD; }
130  void setViewportLOD(GEO_ViewportLOD vlod);
131  /// @}
132 
133  /// @{
134  /// Attribute name mappings
135  void setAttributeNameMap(const GEO_PackedNameMapPtr &m);
137  {
138  if (mySharedNameMapData)
139  {
140  setupNameMap();
141  }
142  return myAttributeNameMap;
143  }
144  /// @}
145 
146  /// @{
147  /// Faceset name attribute
148  void setFacesetAttribute(const char *s)
149  { myFacesetAttribute.harden(s); }
151  { return myFacesetAttribute; }
152  /// @}
153 
154  /// Fast access to local transform
155  const UT_Matrix3D &localTransform() const { return myLocalTransform; }
156 
157  /// Fast access to pivot transform
158  const UT_Vector3 &pivot() const { return myPivot; }
159  UT_Vector3 &pivot() { return myPivot; }
160 
161  /// @{
162  /// Sub-classes should make sure to call the base class dirty methods
163  virtual void transformDirty();
164  virtual void attributeDirty();
165  virtual void topologyDirty();
166  /// @}
167 
168  virtual bool saveOptions(UT_Options &options,
169  const GA_SaveMap &map) const = 0;
170  virtual bool loadOptions(const UT_Options &options,
171  const GA_LoadMap &map) = 0;
172  virtual bool supportsJSONLoad() const = 0;
173  virtual bool loadOptionsJSON(UT_JSONParser &p,
174  const GA_LoadMap &map) = 0;
175  virtual bool loadOptionsJSONMap(UT_JSONValueMap &options,
176  const GA_LoadMap &map) = 0;
177  virtual bool loadUnknownToken(const char *token,
178  UT_JSONParser &p,
179  const GA_LoadMap &map) = 0;
180 
181  /// @{
182  /// Any sub-classes *must* call the GEO method for shared load data since
183  /// name maps are saved as shared data.
184  ///
185  /// The sub-classes cannot use GEO_SHARED_DATA_NAMEMAP as a key.
186  virtual bool saveSharedLoadData(UT_JSONWriter &w, GA_SaveMap &map, GA_GeometryIndex* geometryIndex) const;
187  virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item);
188  /// @}
189 
190  /// Copies the member data of the source packed primitive into this.
191  /// This does not modify the vertex list or any attributes.
192  void copyMemberDataFrom(const GEO_PrimPacked &src);
193 
194 private:
195  void setupNameMap() const;
196 protected:
197  virtual int evaluateInteriorPointV4(UT_Vector4 &pos,
198  fpreal u, fpreal v, fpreal w = 0) const;
199 
206 };
207 
208 #endif
virtual void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
virtual UT_Vector3 baryCenter() const
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
virtual void copyPrimitive(const GEO_Primitive *src)=0
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:224
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
Evalaute position given a u,v coordinate (with derivatives)
const GLdouble * v
Definition: glcorearb.h:836
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:252
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
void setFacesetAttribute(const char *s)
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
Abstract base class for a range membership query object.
virtual void reverse()
3D Vector class.
SYS_FORCE_INLINE void setVertexPoint(GA_Offset point)
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
virtual bool saveSharedLoadData(UT_JSONWriter &w, GA_SaveMap &save, GA_GeometryIndex *geometryIndex) const
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GEO_ViewportLOD myViewportLOD
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:617
GEO_PackedNameMapPtr myAttributeNameMap
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
Map to translate from Alembic attribute names to Houdini names.
virtual int evaluateInteriorPointV4(UT_Vector4 &pos, fpreal u, fpreal v, fpreal w=0) const
virtual fpreal calcArea() const
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
GLintptr offset
Definition: glcorearb.h:664
Provide a JSON interface to a primitive.
GA_Offset allocateVertex(GA_Offset point=GA_INVALID_OFFSET)
allocateVertex() will call wireVertex() if the point given is not -1
#define GEO_API
Definition: GEO_API.h:10
const UT_Vector3 & pivot() const
Fast access to pivot transform.
A handle to simplify manipulation of multiple attributes.
UT_Vector3 & pivot()
Options during loading.
Definition: GA_LoadMap.h:42
virtual int getBBox(UT_BoundingBox *bbox) const =0
UT_Vector3 myPivot
virtual fpreal calcPerimeter() const
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
unsigned int uint
Definition: SYS_Types.h:40
GEO_ViewportLOD viewportLOD() const
virtual void transform(const UT_Matrix4 &)
virtual void enlargePointBounds(UT_BoundingBox &box) const
virtual void getLocalTransform(UT_Matrix3D &matrix) const
double fpreal
Definition: SYS_Types.h:270
A map of string to various well defined value types.
Definition: UT_Options.h:42
virtual int detachPoints(GA_PointGroup &grp)=0
GEO_ViewportLOD
GA_SharedDataHandlePtr mySharedNameMapData
virtual fpreal calcVolume(const UT_Vector3 &) const
UT_String myFacesetAttribute
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
const UT_Matrix3D & localTransform() const
Fast access to local transform.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
const UT_String & facesetAttribute() const
virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item)
const GEO_PackedNameMapPtr & attributeNameMap() const
UT_Matrix3D myLocalTransform
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
GLenum src
Definition: glcorearb.h:1792