HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GD_PrimPoly.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  * COMMENTS: polygon definition
9  *
10  */
11 
12 #ifndef __GD_PrimPoly_H__
13 #define __GD_PrimPoly_H__
14 
15 #include "GD_API.h"
16 #include "GD_Face.h"
17 #include "GD_PrimType.h"
18 #include <iosfwd>
19 
20 class GD_Detail;
21 class UT_MemoryCounter;
22 
23 class GD_API GD_PrimPoly : public GD_Face
24 {
25 public:
27  : GD_Face(d, offset)
28  { }
29  ~GD_PrimPoly() override {}
30 
31  /// Report memory usage
32  int64 getMemoryUsage() const override;
33 
34  /// Count memory usage using a UT_MemoryCounter in order to count
35  /// shared memory correctly.
36  /// NOTE: This should always include sizeof(*this).
37  void countMemory(UT_MemoryCounter &counter) const override;
38 
39  const GA_PrimitiveJSON *getJSON() const override;
40 
41  const GA_PrimitiveDefinition &getTypeDef() const override;
42 
43  // Build a new polygon and insert it into the given detail.
44  static GD_PrimPoly *build(GD_Detail *d, int npts, int closed = 0,
45  int appendPts = 1);
46 
47  unsigned getOrder() const override;
48 
49  // Evaluate one point (when du=0), or the du-th derivative.
50  // Return 0 if successful, and -1 otherwise.
51  int evaluate(float u, UT_Vector3 &pos,
52  unsigned du=0, int uOffset=-1) const override;
54  fpreal u, uint du=0,
55  int uoffset=-1) const override;
56 
57  // Build a trim loop (which will be open unless the face is closed). The
58  // loop is build every time you call this method, so it's expensive. You
59  // must free the loop yourself when you are done with it. The trim pieces
60  // are generated in the [ustart,ustop] or [ustop,ustart] interval, where
61  // ustart and ustop are parametric values.
62  GD_TrimLoop *trimLoop(float ustart, float ustop) const override;
63  int breakCount() const override;
64 
65 protected:
66  /// All subclasses should call this method to register the poly intrinsics.
67  /// @see GA_AttributeIntrinsic
70  { return GD_Face::registerIntrinsics(definition); }
71 
72  // We don't need to save anything other than what's in a face
73  bool savePrivateH9(std::ostream &,
74  bool binary) const override;
75  bool loadPrivateH9(UT_IStream &) override;
76 
77 private:
78  int create(int npts, int closed = 0, int appendPts = 1);
79 
80  friend std::ostream &operator<<(std::ostream &os, const GD_PrimPoly &d)
81  {
82  d.saveH9(os, 0,
85  return os;
86  }
87 
88  friend class GD_PrimitiveFactory;
89 
90  static GA_PrimitiveDefinition *theDefinition;
91 };
92 #endif
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
virtual int evaluate(float u, UT_Vector3 &pos, unsigned du=0, int uOffset=-1) const =0
virtual bool loadPrivateH9(UT_IStream &is)=0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
virtual bool savePrivateH9(std::ostream &os, bool binary) const =0
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &definition)
Definition: GD_PrimPoly.h:69
virtual GD_TrimLoop * trimLoop(float ustart, float ustop) const =0
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
~GD_PrimPoly() override
Definition: GD_PrimPoly.h:29
GD_PrimPoly(GD_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
Definition: GD_PrimPoly.h:26
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
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
friend std::ostream & operator<<(std::ostream &os, const GD_PrimPoly &d)
Definition: GD_PrimPoly.h:80
virtual void countMemory(UT_MemoryCounter &counter) const
virtual const GA_PrimitiveJSON * getJSON() const =0
Provide a JSON interface to a primitive.
long long int64
Definition: SYS_Types.h:116
A handle to simplify manipulation of multiple attributes.
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
virtual int breakCount() const =0
#define GD_API
Definition: GD_API.h:10
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual unsigned getOrder() const =0
Definition of a geometric primitive.
virtual const GA_PrimitiveDefinition & getTypeDef() const =0
unsigned int uint
Definition: SYS_Types.h:45
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &definition)
Definition: GD_Face.h:251