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  ~GU_PrimRBezCurve() override {}
46 
47 public:
48  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
51  {}
52 
53  const GA_PrimitiveDefinition &getTypeDef() const override
54  {
55  UT_ASSERT(theDefinition);
56  return *theDefinition;
57  }
58 
59  /// Report approximate memory usage.
60  int64 getMemoryUsage() const override;
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  void countMemory(UT_MemoryCounter &counter) const override;
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  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 override;
85 
86  int intersect(const GEO_Primitive &prim,
87  UT_Array<GU_RayInfoHit> &hitList,
88  float tol = 0.01F,
89  int ignoretrim=1) const override;
90 
92  GA_PointGroup *usedpts = NULL) override;
93  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
94  GEO_PrimNURBCurve *convertToNURBNew(GA_ElementWranglerCache &wranglers);
95 
96  /// This is more powerful than convertNew. It always returns a NEW
97  /// object, so free it when you're done with it. It may return
98  /// a NURB curve or a Bezier curve depending on the type.
99  GEO_Face *reconfigure(unsigned type,
100  int order, bool open, bool interpends,
101  bool nonrational) const override;
102 
103  /// Cut a wedge of the primitive given a domain range
104  /// ind1 and ind2 are indices to the refined values
105  /// They are updated if negative on input, else used as is.
106  /// If keep is zero the curve is only refined and the indices
107  /// updated.
108  GEO_Curve *cut(float u1, float u2,
109  int &ind1, int &ind2, int keep) override;
110 
111  /// Open the primitive at the given domain value
112  void openAt(float u) override;
113 
114 
115  // Given a bit array representing the edges in the curve (1 meaning
116  // delete and 0 meaning keep) delete as many edges as possible
117  // if a particular edge cannot be deleted then negate the value
118  // in removededges[edgenum] DO NOT CHANGE THE MAGNITUDE!
119  // returns 0 if successful, -1 if the curve becomes degenerate, and
120  // -2 if the curve should be removed.
121  int removeEdges(const UT_BitArray &edgemap,
122  UT_IntArray &removededges);
123 
124  // Methods for fitting.
125  void interpLocal(const UT_Array<GA_Offset> &goData,
126  int order, int wrapped, int corner);
127  void interpLocal(const UT_Vector4Array &v4Data,
128  int order, int wrapped, int corner);
129 
130  // Get the bounding box for a specific range
131  void getRangeBBox(const UT_Interval &u,
132  UT_BoundingBox &bbox,
133  const GA_PwHandleRO &h) const override;
134 
135 private:
136 
137  // Fill the curve with data and build the basis. Return 0 if OK, and -1
138  // if error.
139  int create(int nelems, int order = 4, int closed = 0,
140  int appendPoints = 1);
141 
142  static GA_PrimitiveDefinition *theDefinition;
143  friend class GU_PrimitiveFactory;
144 };
145 
146 #endif
const GLdouble * v
Definition: glcorearb.h:837
virtual GEO_Curve * cut(float u1, float u2, int &ind1, int &ind2, int keep)=0
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
GLdouble u1
Definition: glad.h:2676
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size GA_Offset
Definition: GA_Types.h:646
GLintptr offset
Definition: glcorearb.h:665
int open(float queuesize) override
virtual void countMemory(UT_MemoryCounter &counter) const
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
GLdouble GLdouble u2
Definition: glad.h:2676
virtual GEO_Face * reconfigure(unsigned type, int order, bool open, bool interpends, bool nonrational) const =0
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:2002
~GU_PrimRBezCurve() override
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
const GA_PrimitiveDefinition & getTypeDef() const override
Container class for all geometry.
Definition: GA_Detail.h:96
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
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.
SIM_API const UT_StringHolder distance
type
Definition: core.h:1059
virtual int intersect(const GEO_Primitive &prim, UT_Array< GU_RayInfoHit > &hit_list, float tol=0.01F, int ignoretrim=1) const =0
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0