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  bool getVisibleBBox(UT_BoundingBox *bbox) const override;
41  void enlargePointBounds(UT_BoundingBox &box) const override;
42  void reverse() override {}
43  UT_Vector3D computeNormalD() const override;
44  UT_Vector3 computeNormal() const override;
45  void copyPrimitive(const GEO_Primitive *src) override;
46  void copySubclassData(const GA_Primitive *source) override;
47  virtual void copyImplementation(const GEO_PrimPacked &src) = 0;
48 
49  // Take the whole set of points into consideration when applying the
50  // point removal operation to this primitive. The method returns 0 if
51  // successful, -1 if it failed because it would have become degenerate,
52  // and -2 if it failed because it would have had to remove the primitive
53  // altogether.
54  int detachPoints(GA_PointGroup &grp) override;
55  /// Before a point is deleted, all primitives using the point will be
56  /// notified. The method should return "false" if it's impossible to
57  /// delete the point. Otherwise, the vertices should be removed.
58  GA_DereferenceStatus dereferencePoint(GA_Offset point,
59  bool dry_run=false) override;
60  GA_DereferenceStatus dereferencePoints(
61  const GA_RangeMemberQuery &pt_q,
62  bool dry_run=false) override;
63 
64  const GA_PrimitiveJSON *getJSON() const override;
65 
66  /// Evalaute a point given a u,v coordinate (with derivatives)
68  GA_Offset result_vtx,
69  GA_AttributeRefMap &hlist,
70  fpreal u, fpreal v,
71  uint du, uint dv) const override;
72  /// Evalaute position given a u,v coordinate (with derivatives)
74  UT_Vector4 &pos,
75  float u, float v = 0,
76  unsigned du=0, unsigned dv=0) const override
77  {
78  return GEO_Primitive::evaluatePointV4(pos, u, v,
79  du, dv);
80  }
81  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
82  void stashed(bool beingstashed,
84  void transform(const UT_Matrix4 &xform) override = 0;
85  UT_Vector3 baryCenter() const override;
86  fpreal calcVolume(const UT_Vector3 &refpt) const override = 0;
87  fpreal calcArea() const override = 0;
88  fpreal calcPerimeter() const override = 0;
89  void getLocalTransform(UT_Matrix3D &matrix) const override;
90  void setLocalTransform(const UT_Matrix3D &matrix) override;
91  virtual void getPivot(UT_Vector3 &pos) const;
92  virtual void setPivot(const UT_Vector3 &pos);
93  /// @}
94 
95  /// Return the full transform matrix for the primitive. This includes the
96  /// local transform combined with any additional transforms which might be
97  /// implicit to the primitive.
98  /// The default behaviour is to simply call @c getLocalTransform4();
99  virtual void getFullTransform4(UT_Matrix4D &matrix) const = 0;
100 
101  /// @{
102  /// Get the un-transformed bounding box
103  virtual bool getUntransformedBounds(UT_BoundingBox &box) const = 0;
104  virtual bool getUntransformedVisibleBounds(UT_BoundingBox &box) const = 0;
105  virtual bool getUntransformedRenderingBounds(UT_BoundingBox &box) const = 0;
106  virtual void getVelocityRange(UT_Vector3 &vmin, UT_Vector3 &vmax) const = 0;
107  /// @}
108 
109  /// Method to assist with rendering. To get accurate bounding boxes for
110  /// rendering, the "width" of points and curve objects needs to be taken
111  /// into account. These bounds will include the transform on the primitive.
112  ///
113  /// Returns false if the bounds are invalid.
114  bool getRenderingBounds(UT_BoundingBox &box) const;
115 
116  /// Method to assist with rendering. When rendering velocity based motion
117  /// blur, the renderer needs to know the bounds on the velocity to
118  /// accurately compute a bounding box.
119  ///
120  /// These velocities will *not* include any scales applied by the transform
121 
122  /// Set vertex to reference the given point. This will ensure the vertex
123  /// is allocated.
126  {
127  if (getVertexCount() == 0)
128  myVertexList.append(allocateVertex());
129 
130  setPointOffset(0, point);
131  }
132  /// Called when loading to set the vertex
133  void assignVertex(GA_Offset vtx, bool update_topology);
134 
135  /// @{
136  /// Accessors for viewport LOD
137  GEO_ViewportLOD viewportLOD() const { return myViewportLOD; }
138  void setViewportLOD(GEO_ViewportLOD vlod);
139  /// @}
140 
141  /// Fast access to local transform
142  const UT_Matrix3D &localTransform() const { return myLocalTransform; }
143 
144  /// Fast access to pivot transform
145  const UT_Vector3 &pivot() const { return myPivot; }
146  UT_Vector3 &pivot() { return myPivot; }
147 
148  /// @{
149  /// Sub-classes should make sure to call the base class dirty methods
150  virtual void transformDirty();
151  virtual void attributeDirty();
152  virtual void topologyDirty();
153  /// @}
154 
155  virtual bool saveOptions(UT_Options &options,
156  const GA_SaveMap &map) const = 0;
157  virtual bool loadOptions(const UT_Options &options,
158  const GA_LoadMap &map) = 0;
159  virtual bool supportsJSONLoad() const = 0;
160  virtual bool loadOptionsJSON(UT_JSONParser &p,
161  const GA_LoadMap &map) = 0;
162  virtual bool loadOptionsJSONMap(UT_JSONValueMap &options,
163  const GA_LoadMap &map) = 0;
164  virtual bool loadUnknownToken(const char *token,
165  UT_JSONParser &p,
166  const GA_LoadMap &map) = 0;
167 
168  /// @{
169  /// Any sub-classes *must* call the GEO method for shared load data since
170  /// name maps are saved as shared data.
171  ///
172  /// The sub-classes cannot use GEO_SHARED_DATA_NAMEMAP as a key.
173  /// However, GU_PrimPacked handles it in registerSharedLoadData,
174  /// since it needs access to the GU_PackedImpl anyway.
175  bool saveSharedLoadData(
176  UT_JSONWriter &w,
177  GA_SaveMap &map,
178  GA_GeometryIndex *geo_index) const override;
180  int load_data_type,
181  GA_SharedDataHandlePtr item) override = 0;
182  /// @}
183 
184  /// Copies the member data of the source packed primitive into this.
185  /// This does not modify the vertex list or any attributes.
186  void copyMemberDataFrom(const GEO_PrimPacked &src);
187 
188  /// @{
189  /// Attribute name mappings (Alembic only)
190  virtual void setAttributeNameMap(const GEO_PackedNameMapPtr &m) = 0;
191  virtual const GEO_PackedNameMapPtr &attributeNameMap() const = 0;
192  /// @}
193 
194  /// @{
195  /// Faceset name attribute (Alembic only)
196  virtual void setFacesetAttribute(const UT_StringHolder &s) = 0;
197  virtual const UT_StringHolder &facesetAttribute() const = 0;
199  /// @}
200 
201 protected:
203  UT_Vector4 &pos, fpreal u, fpreal v, fpreal w = 0) const override;
204 
208 };
209 
210 #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
const GLdouble * v
Definition: glcorearb.h:837
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:508
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
GLdouble s
Definition: glad.h:3009
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:87
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
Abstract base class for a range membership query object.
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:678
GEO_ViewportLOD myViewportLOD
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:641
static const UT_StringHolder theDefaultFacesetAttribute
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
GLintptr offset
Definition: glcorearb.h:665
Map to translate from Alembic attribute names to Houdini names.
virtual int evaluateInteriorPointV4(UT_Vector4 &pos, fpreal u, fpreal v, fpreal w=0) const
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
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.
UT_Vector3 & pivot()
Options during loading.
Definition: GA_LoadMap.h:42
UT_Vector3 myPivot
virtual bool getVisibleBBox(UT_BoundingBox *bbox) const
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
void reverse() override
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
virtual int detachPoints(GA_PointGroup &grp)=0
GEO_ViewportLOD
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual bool getBBox(UT_BoundingBox *bbox) const =0
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:857
virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item)
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)
GLenum src
Definition: glcorearb.h:1793