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  virtual ~GD_PrimPoly() {}
30 
31  /// Report memory usage
32  virtual int64 getMemoryUsage() const;
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  virtual void countMemory(UT_MemoryCounter &counter) const;
38 
39  virtual const GA_PrimitiveJSON *getJSON() const;
40 
41  virtual const GA_PrimitiveDefinition &getTypeDef() const;
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  virtual unsigned getOrder() const;
48 
49  // Evaluate one point (when du=0), or the du-th derivative.
50  // Return 0 if successful, and -1 otherwise.
51  virtual int evaluate(float u, UT_Vector3 &pos,
52  unsigned du=0, int uOffset=-1) const;
53  virtual bool evaluate(GA_Offset vtx, GA_AttributeRefMap &h,
54  fpreal u, uint du=0, int uoffset=-1) const;
55 
56  // Build a trim loop (which will be open unless the face is closed). The
57  // loop is build every time you call this method, so it's expensive. You
58  // must free the loop yourself when you are done with it. The trim pieces
59  // are generated in the [ustart,ustop] or [ustop,ustart] interval, where
60  // ustart and ustop are parametric values.
61  virtual GD_TrimLoop *trimLoop(float ustart, float ustop) const;
62  virtual int breakCount() const;
63 
64 protected:
65  /// All subclasses should call this method to register the poly intrinsics.
66  /// @see GA_AttributeIntrinsic
69  { return GD_Face::registerIntrinsics(definition); }
70 
71  // We don't need to save anything other than what's in a face
72  virtual bool savePrivateH9(std::ostream &, bool binary) const;
73  virtual bool loadPrivateH9(UT_IStream &);
74 
75 private:
76  int create(int npts, int closed = 0, int appendPts = 1);
77 
78  friend std::ostream &operator<<(std::ostream &os, const GD_PrimPoly &d)
79  {
80  d.saveH9(os, 0,
83  return os;
84  }
85 
86  friend class GD_PrimitiveFactory;
87 
88  static GA_PrimitiveDefinition *theDefinition;
89 };
90 #endif
virtual int evaluate(float u, UT_Vector3 &pos, unsigned du=0, int uOffset=-1) const =0
virtual ~GD_PrimPoly()
Definition: GD_PrimPoly.h:29
virtual bool loadPrivateH9(UT_IStream &is)=0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
virtual bool savePrivateH9(std::ostream &os, bool binary) const =0
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &definition)
Definition: GD_PrimPoly.h:68
virtual GD_TrimLoop * trimLoop(float ustart, float ustop) const =0
3D Vector class.
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:201
GD_PrimPoly(GD_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
Definition: GD_PrimPoly.h:26
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
Definition: GD_Primitive.h:67
long long int64
Definition: SYS_Types.h:107
friend std::ostream & operator<<(std::ostream &os, const GD_PrimPoly &d)
Definition: GD_PrimPoly.h:78
virtual void countMemory(UT_MemoryCounter &counter) const
virtual const GA_PrimitiveJSON * getJSON() const =0
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
GLintptr offset
Definition: glcorearb.h:664
Provide a JSON interface to a primitive.
A handle to simplify manipulation of multiple attributes.
unsigned int uint
Definition: SYS_Types.h:40
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:270
virtual int breakCount() const =0
#define GD_API
Definition: GD_API.h:10
virtual unsigned getOrder(void) const =0
Definition of a geometric primitive.
virtual const GA_PrimitiveDefinition & getTypeDef() const =0
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &definition)
Definition: GD_Face.h:266