HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimRBezCurve.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: GU_PrimRBezCurve.h (C++)
7  *
8  * COMMENTS:
9  * Header file for GU_PrimRBezCurve.h class...
10  *
11  */
12 
13 #ifndef __GU_PrimRBezCurve_h__
14 #define __GU_PrimRBezCurve_h__
15 
16 #include "GU_API.h"
17 #include <GEO/GEO_PrimRBezCurve.h>
18 #include <GEO/GEO_PrimNURBCurve.h>
19 
20 class GA_Detail;
22 template<bool isconst> class GA_PwHandle;
24 class GEO_ConvertParms;
25 class GU_Detail;
26 class GU_PrimPoly;
27 class UT_MemoryCounter;
28 
29 /////////////////////////////////////////////////////////////
30 // //
31 // Class: GU_PrimRBezCurve //
32 // Descr: This class is responsible for operations //
33 // done on bezier primitives. As we need to access //
34 // the GU_Detail, the pointer is passed in the //
35 // constructor. The second constructor creates a //
36 // mesh with the given parameters. //
37 // //
38 /////////////////////////////////////////////////////////////
39 
41 {
42 protected:
43  /// NOTE: Primitives should not be deleted directly. They are managed
44  /// by the GA_PrimitiveList and the stash.
45  virtual ~GU_PrimRBezCurve() {}
46 
47 public:
48  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
51  {}
52 
53  virtual const GA_PrimitiveDefinition &getTypeDef() const
54  {
55  UT_ASSERT(theDefinition);
56  return *theDefinition;
57  }
58 
59  /// Report approximate memory usage.
60  virtual int64 getMemoryUsage() const;
61 
62  /// Count memory usage using a UT_MemoryCounter in order to count
63  /// shared memory correctly.
64  /// NOTE: This should always include sizeof(*this).
65  virtual void countMemory(UT_MemoryCounter &counter) const;
66 
67  GU_PrimPoly *makeGrevillePoly(GU_Detail *dest) const;
68 
69  // NOTE: For static member functions please call in the following
70  // manner. <ptrvalue> = GU_PrimRBezCurve::<functname>
71  // i.e. meshptr = GU_PrimRBezCurve::build(params...);
72 
73  // Optional Build Method. Returns 0 if it fails.
74 
75  static GU_PrimRBezCurve *build(GU_Detail *gudp,
76  int nelems, int order = 4, int closed=0,
77  int appendPoints = 1);
78 
79  virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
80  float tmax = 1E17F, float tol = 1E-12F,
81  float *distance = 0, UT_Vector3 *pos = 0,
82  UT_Vector3 *nml = 0, int accurate = 0,
83  float *u = 0, float *v = 0,
84  int ignoretrim = 1) const;
85 
86  virtual int intersect(const GEO_Primitive &prim,
87  UT_Array<GU_RayInfoHit> &hitList,
88  float tol = 0.01F, int ignoretrim=1) const;
89 
90  virtual GEO_Primitive *convert(GEO_ConvertParms &parms,
91  GA_PointGroup *usedpts = NULL);
92  virtual GEO_Primitive *convertNew(GEO_ConvertParms &parms);
93  GEO_PrimNURBCurve *convertToNURBNew(GA_ElementWranglerCache &wranglers);
94 
95  /// This is more powerful than convertNew. It always returns a NEW
96  /// object, so free it when you're done with it. It may return
97  /// a NURB curve or a Bezier curve depending on the type.
98  virtual GEO_Face *reconfigure(unsigned type,
99  int order, bool open, bool interpends,
100  bool nonrational) const;
101 
102  /// Cut a wedge of the primitive given a domain range
103  /// ind1 and ind2 are indices to the refined values
104  /// They are updated if negative on input, else used as is.
105  /// If keep is zero the curve is only refined and the indices
106  /// updated.
107  virtual GEO_Curve *cut(float u1, float u2,
108  int &ind1, int &ind2, int keep);
109 
110  /// Open the primitive at the given domain value
111  virtual void openAt(float u);
112 
113 
114  // Given a bit array representing the edges in the curve (1 meaning
115  // delete and 0 meaning keep) delete as many edges as possible
116  // if a particular edge cannot be deleted then negate the value
117  // in removededges[edgenum] DO NOT CHANGE THE MAGNITUDE!
118  // returns 0 if successful, -1 if the curve becomes degenerate, and
119  // -2 if the curve should be removed.
120  int removeEdges(const UT_BitArray &edgemap,
121  UT_IntArray &removededges);
122 
123  // Methods for fitting.
124  void interpLocal(const UT_Array<GA_Offset> &goData,
125  int order, int wrapped, int corner);
126  void interpLocal(const UT_Vector4Array &v4Data,
127  int order, int wrapped, int corner);
128 
129  // Get the bounding box for a specific range
130  virtual void getRangeBBox(const UT_Interval &u,
131  UT_BoundingBox &bbox,
132  const GA_PwHandleRO &h) const;
133 
134 private:
135 
136  // Fill the curve with data and build the basis. Return 0 if OK, and -1
137  // if error.
138  int create(int nelems, int order = 4, int closed = 0,
139  int appendPoints = 1);
140 
141  static GA_PrimitiveDefinition *theDefinition;
142  friend class GU_PrimitiveFactory;
143 };
144 
145 #endif
virtual ~GU_PrimRBezCurve()
const GLdouble * v
Definition: glcorearb.h:836
virtual const GA_PrimitiveDefinition & getTypeDef() const
virtual int intersect(const GEO_Primitive &prim, UT_Array< GU_RayInfoHit > &hitList, float tol=0.01F, int ignoretrim=1) const =0
virtual GEO_Curve * cut(float u1, float u2, int &ind1, int &ind2, int keep)=0
3D Vector class.
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:201
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:107
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
virtual void countMemory(UT_MemoryCounter &counter) const
GLintptr offset
Definition: glcorearb.h:664
#define GU_API
Definition: GU_API.h:12
virtual GEO_Face * reconfigure(unsigned type, int order, bool open, bool interpends, bool nonrational) const =0
virtual int open(float queuesize)
virtual void openAt(float u)=0
Open the primitive at the given domain value.
virtual void getRangeBBox(const UT_Interval &u, UT_BoundingBox &bbox, const GA_PwHandleRO &h) const =0
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1) const
GA_PwHandle< true > GA_PwHandleRO
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
Container class for all geometry.
Definition: GA_Detail.h:95
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:126
GU_PrimRBezCurve(GA_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
Definition of a geometric primitive.
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
int keep
Definition: png.h:2568