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  ~GEO_PrimPacked() override;
35 
36  /// @{
37  /// Required interface methods for GEO primitive
38  bool isDegenerate() const override = 0;
39  bool getBBox(UT_BoundingBox *bbox) const override;
40  void enlargePointBounds(UT_BoundingBox &box) const override;
41  void reverse() override {}
42  UT_Vector3D computeNormalD() const override;
43  UT_Vector3 computeNormal() const override;
44  void copyPrimitive(const GEO_Primitive *src) override;
45  void copySubclassData(const GA_Primitive *source) override;
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  int detachPoints(GA_PointGroup &grp) override;
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  GA_DereferenceStatus dereferencePoint(GA_Offset point,
58  bool dry_run=false) override;
59  GA_DereferenceStatus dereferencePoints(
60  const GA_RangeMemberQuery &pt_q,
61  bool dry_run=false) override;
62 
63  const GA_PrimitiveJSON *getJSON() const override;
64 
65  /// Evalaute a point given a u,v coordinate (with derivatives)
67  GA_Offset result_vtx,
68  GA_AttributeRefMap &hlist,
69  fpreal u, fpreal v,
70  uint du, uint dv) const override;
71  /// Evalaute position given a u,v coordinate (with derivatives)
73  UT_Vector4 &pos,
74  float u, float v = 0,
75  unsigned du=0, unsigned dv=0) const override
76  {
77  return GEO_Primitive::evaluatePointV4(pos, u, v,
78  du, dv);
79  }
80  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
81  void stashed(bool beingstashed,
83  void transform(const UT_Matrix4 &xform) override = 0;
84  UT_Vector3 baryCenter() const override;
85  fpreal calcVolume(const UT_Vector3 &refpt) const override = 0;
86  fpreal calcArea() const override = 0;
87  fpreal calcPerimeter() const override = 0;
88  void getLocalTransform(UT_Matrix3D &matrix) const override;
89  void setLocalTransform(const UT_Matrix3D &matrix) override;
90  virtual void getPivot(UT_Vector3 &pos) const;
91  virtual void setPivot(const UT_Vector3 &pos);
92  /// @}
93 
94  /// Return the full transform matrix for the primitive. This includes the
95  /// local transform combined with any additional transforms which might be
96  /// implicit to the primitive.
97  /// The default behaviour is to simply call @c getLocalTransform4();
98  virtual void getFullTransform4(UT_Matrix4D &matrix) const = 0;
99 
100  /// @{
101  /// Get the un-transformed bounding box
102  virtual bool getUntransformedBounds(UT_BoundingBox &box) const = 0;
103  virtual bool getUntransformedRenderingBounds(UT_BoundingBox &box) const = 0;
104  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax) const = 0;
105  /// @}
106 
107  /// Method to assist with rendering. To get accurate bounding boxes for
108  /// rendering, the "width" of points and curve objects needs to be taken
109  /// into account. These bounds will include the transform on the primitive.
110  ///
111  /// Returns false if the bounds are invalid.
112  bool getRenderingBounds(UT_BoundingBox &box) const;
113 
114  /// Method to assist with rendering. When rendering velocity based motion
115  /// blur, the renderer needs to know the bounds on the velocity to
116  /// accurately compute a bounding box.
117  ///
118  /// These velocities will *not* include any scales applied by the transform
119 
120  /// Set vertex to reference the given point. This will ensure the vertex
121  /// is allocated.
124  {
125  if (getVertexCount() == 0)
126  myVertexList.append(allocateVertex());
127 
128  setPointOffset(0, point);
129  }
130  /// Called when loading to set the vertex
131  void assignVertex(GA_Offset vtx, bool update_topology);
132 
133  /// @{
134  /// Accessors for viewport LOD
135  GEO_ViewportLOD viewportLOD() const { return myViewportLOD; }
136  void setViewportLOD(GEO_ViewportLOD vlod);
137  /// @}
138 
139  /// Fast access to local transform
140  const UT_Matrix3D &localTransform() const { return myLocalTransform; }
141 
142  /// Fast access to pivot transform
143  const UT_Vector3 &pivot() const { return myPivot; }
144  UT_Vector3 &pivot() { return myPivot; }
145 
146  /// @{
147  /// Sub-classes should make sure to call the base class dirty methods
148  virtual void transformDirty();
149  virtual void attributeDirty();
150  virtual void topologyDirty();
151  /// @}
152 
153  virtual bool saveOptions(UT_Options &options,
154  const GA_SaveMap &map) const = 0;
155  virtual bool loadOptions(const UT_Options &options,
156  const GA_LoadMap &map) = 0;
157  virtual bool supportsJSONLoad() const = 0;
158  virtual bool loadOptionsJSON(UT_JSONParser &p,
159  const GA_LoadMap &map) = 0;
160  virtual bool loadOptionsJSONMap(UT_JSONValueMap &options,
161  const GA_LoadMap &map) = 0;
162  virtual bool loadUnknownToken(const char *token,
163  UT_JSONParser &p,
164  const GA_LoadMap &map) = 0;
165 
166  /// @{
167  /// Any sub-classes *must* call the GEO method for shared load data since
168  /// name maps are saved as shared data.
169  ///
170  /// The sub-classes cannot use GEO_SHARED_DATA_NAMEMAP as a key.
171  /// However, GU_PrimPacked handles it in registerSharedLoadData,
172  /// since it needs access to the GU_PackedImpl anyway.
173  bool saveSharedLoadData(
174  UT_JSONWriter &w,
175  GA_SaveMap &map,
176  GA_GeometryIndex *geo_index) const override;
178  int load_data_type,
179  GA_SharedDataHandlePtr item) override = 0;
180  /// @}
181 
182  /// Copies the member data of the source packed primitive into this.
183  /// This does not modify the vertex list or any attributes.
184  void copyMemberDataFrom(const GEO_PrimPacked &src);
185 
186  /// @{
187  /// Attribute name mappings (Alembic only)
188  virtual void setAttributeNameMap(const GEO_PackedNameMapPtr &m) = 0;
189  virtual const GEO_PackedNameMapPtr &attributeNameMap() const = 0;
190  /// @}
191 
192  /// @{
193  /// Faceset name attribute (Alembic only)
194  virtual void setFacesetAttribute(const UT_StringHolder &s) = 0;
195  virtual const UT_StringHolder &facesetAttribute() const = 0;
197  /// @}
198 
199 protected:
201  UT_Vector4 &pos, fpreal u, fpreal v, fpreal w = 0) const override;
202 
206 };
207 
208 #endif
fpreal calcPerimeter() const override
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:232
virtual UT_Vector3D computeNormalD() const =0
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:499
fpreal calcVolume(const UT_Vector3 &) const override
virtual bool saveSharedLoadData(UT_JSONWriter &w, GA_SaveMap &save, GA_GeometryIndex *geo_index) const
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:260
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:88
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
Abstract base class for a range membership query object.
GLenum src
Definition: glcorearb.h:1793
SYS_FORCE_INLINE void setVertexPoint(GA_Offset point)
fpreal calcArea() const override
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:677
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GEO_ViewportLOD myViewportLOD
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:640
static const UT_StringHolder theDefaultFacesetAttribute
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
const GLdouble * v
Definition: glcorearb.h:837
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
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:14
int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const override
Evalaute position given a u,v coordinate (with derivatives)
const UT_Vector3 & pivot() const
Fast access to pivot transform.
A handle to simplify manipulation of multiple attributes.
GLfloat GLfloat p
Definition: glew.h:16656
UT_Vector3 & pivot()
Options during loading.
Definition: GA_LoadMap.h:42
UT_Vector3 myPivot
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
void reverse() override
GLuint GLenum matrix
Definition: glew.h:15055
GEO_ViewportLOD viewportLOD() const
virtual void transform(const UT_Matrix4 &)
virtual void enlargePointBounds(UT_BoundingBox &box) const
virtual void getLocalTransform(UT_Matrix3D &matrix) const
A map of string to various well defined value types.
Definition: UT_Options.h:84
GLsizei const GLint box[]
Definition: glew.h:11654
virtual int detachPoints(GA_PointGroup &grp)=0
GEO_ViewportLOD
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual bool getBBox(UT_BoundingBox *bbox) const =0
const GLdouble * m
Definition: glew.h:9166
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.
GLintptr offset
Definition: glcorearb.h:665
virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item)
GLdouble s
Definition: glew.h:1395
unsigned int uint
Definition: SYS_Types.h:45
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)