HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GD_Primitive.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: Geometry Library (C++)
7  *
8  */
9 
10 #ifndef __GD_Primitive_H__
11 #define __GD_Primitive_H__
12 
13 #include "GD_API.h"
14 #include <iosfwd>
15 #include <UT/UT_BoundingRect.h>
16 #include <UT/UT_Matrix4.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <GA/GA_Primitive.h>
19 #include <GA/GA_ElementGroup.h>
20 
21 class UT_BoundingSphere;
22 class GD_Detail;
23 
25 {
26 public:
28 
29  virtual GD_Primitive *copy(int preserve_shared_pts = 0) const;
30  virtual int copy(const GD_Primitive &src, int ptoffset) = 0;
31 
32  // Evaluate the position or the derivatives at (u,v), where u and v MUST
33  // be in [0,1]. Return 0 if OK and -1 otherwise.
34  virtual int evaluatePoint(UT_Vector3 &pos, float u,
35  unsigned du = 0) const;
36 
37  GA_PrimCompat::TypeMask getPrimitiveId() const override;
38 
39  GD_Detail *getParent() const;
40 
41  // Return the barycenter of the part that visible (inside the surf domain).
42  // 1 if found, 0 otherwise.
43  virtual int visibleBaryCenter(float &uctr, float &vctr) const;
44 
45  // Transform the primitive according to the given matrix:
46  virtual void transform(const UT_Matrix3 &);
47 
48  // Base class virtuals:
49  bool isDegenerate() const override;
50  virtual int getBBox(UT_BoundingBox *bbox) const;
51  virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
52  virtual void getBRect(UT_BoundingRect *brect) const;
53  virtual UT_Vector3 baryCenter() const;
54  virtual UT_Vector3 computeNormal() const;
55  void reverse() override;
56 #if !GA_PRIMITIVE_VERTEXLIST
57  virtual void addPointRefToGroup(GA_PointGroup &grp) const;
58 #endif
59  virtual int detachPoints(GA_PointGroup &grp);
60 #if !GA_PRIMITIVE_VERTEXLIST
61  virtual GA_Size getVertexCount() const;
62  virtual bool vertexApply(bool (*apply)(GA_Offset vtx, void *),
63  void *data = 0) const = 0;
64 #endif
65 
66  /// Convience objects to pass as arguments to saveH9()/loadH9().
68 
69 protected:
70  /// All subclasses should call this method to register the primitive
71  /// intrinsics.
72  /// @see GA_AttributeIntrinsic
75  { return GA_Primitive::registerIntrinsics(definition); }
76 
77 private:
78  friend std::ostream &operator<<(std::ostream &os, const GD_Primitive &d)
79  {
80  // TODO: Use d.jsonSave(os);?
81  d.saveH9(os, 0,
84  return os;
85  }
86  void jsonSave(std::ostream &os) const;
87 };
88 #endif
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &definition)
Definition: GD_Primitive.h:74
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:232
friend std::ostream & operator<<(std::ostream &os, const GD_Primitive &d)
Definition: GD_Primitive.h:78
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
GU_API GA_Offset getParent(const GU_Detail *gdp, const GA_Offset &node)
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:646
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
Definition: GD_Primitive.h:67
GLintptr offset
Definition: glcorearb.h:665
virtual GA_PrimCompat::TypeMask getPrimitiveId() const
Definition: GA_Primitive.h:204
void addPointRefToGroup(GA_PointGroup &grp) const
GA_API const UT_StringHolder transform
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=nullptr) const
Definition: GA_Primitive.h:788
#define GD_API
Definition: GD_API.h:10
Definition of a geometric primitive.
Definition: format.h:895
virtual void reverse()=0
GLenum src
Definition: glcorearb.h:1793