HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimRBezSurf.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_PrimRBezSurf.h (C++)
7  *
8  * COMMENTS:
9  * Header file for GU_PrimRBezSurf.h class...
10  *
11  */
12 
13 #ifndef __GU_PrimRBezSurf_h__
14 #define __GU_PrimRBezSurf_h__
15 
16 #include "GU_API.h"
17 #include <GEO/GEO_PrimRBezSurf.h>
18 #include <GEO/GEO_PrimNURBSurf.h>
19 
20 class GA_Detail;
21 class GA_EdgeGroup;
23 template<bool isconst> class GA_PwHandle;
25 class GEO_ConvertParms;
26 class GEO_Detail;
27 class UT_MemoryCounter;
28 
29 /////////////////////////////////////////////////////////////
30 // //
31 // Class: GU_PrimRBezSurf //
32 // Descr: This class is responsible for operations //
33 // done on bezier primitives. As we need to access //
34 // the GEO_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_PrimRBezSurf() {}
46 
47 public:
48  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
50  : GEO_PrimRBezSurf(gdp, offset)
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  // Fill the surface with data and build the bases. Return 0 if OK, and -1
68  // if error.
69  int create(int rows, int cols, int orderu=4, int orderv=4,
70  int wrapu = 0, int wrapv = 0,
72  int appendPoints = 1);
73 
74  // Conversion Method
75  // uses 'this' for surfacetype, primattribs, orderu and orderv.
76  GEO_PrimNURBSurf *convertToNURBNew(GA_ElementWranglerCache &wranglers);
77 
78  // This only works with unit patches. And only well for order 4
79  // and less.
80  GEO_Primitive *convertToTriBezNew(GEO_ConvertParms &parms);
81 
82  virtual GEO_Primitive *convert(GEO_ConvertParms &parms,
83  GA_PointGroup *usedpts = NULL);
84  virtual GEO_Primitive *convertNew(GEO_ConvertParms &parms);
85 
86  virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
87  float tmax = 1E17F, float tol = 1E-12F,
88  float *distance = 0, UT_Vector3 *pos = 0,
89  UT_Vector3 *nml = 0, int accurate = 0,
90  float *u = 0, float *v = 0,
91  int ignoretrim = 1) const;
92 
93  virtual int intersectSurf(GEO_TPSurf &surf2,
94  GU_IsectCurveSet &curveset,
95  float worldtol = 1e-4F,
96  float domaintol = 1e-2F,
97  int steps = 100,
98  bool docompact = true);
99  virtual int doesIntersect(const GEO_Primitive &prim,
100  float worldtol = 1e-4F, int nontrivial = 0) const;
101 
102  // This is more powerful than convertNew. It always returns a NEW
103  // object, so free it when you're done with it. It may return
104  // a NURB surface or a Bezier surface depending on the type.
105  virtual GEO_Hull *reconfigure(unsigned type, int orderu, int orderv,
106  bool openu, bool openv, bool, bool) const;
107 
108  // Cut a wedge of the primitive given a domain range
109  // ind1 and ind2 are indices to the refined values
110  // They are updated if negative on input, else used as is.
111  // If keep is zero the curve is only refined and the indices
112  // updated.
113 
114  virtual GEO_TPSurf *cutU(float u1, float u2,
115  int &ind1, int &ind2, int keep);
116  virtual GEO_TPSurf *cutV(float v1, float v2,
117  int &ind1, int &ind2, int keep);
118 
119  // Open the primitive at the given domain value
120  virtual void openAtU(float u);
121  virtual void openAtV(float v);
122 
123  // Divide a surface into its components patches. Do not
124  // modify 'this'.
125  // every_patch - Split even if this is already a minimal patch
126  // appendPoints - Add new points for split patches
127  // outprims - Group to add created primitives to
128  // Return: npatches added or -1 on error
129  int split(int every_patch = 0,
130  int append_points = 0,
131  GA_PrimitiveGroup *out_prims = 0);
132 
133  /// Construct a curve that has our characteristics in u or v. The
134  /// CVs of the new curve are not set.
135  /// @{
136  virtual GEO_Curve *buildRowCurve(bool appendPoints,
137  GEO_Detail *parent) const;
138  virtual GEO_Curve *buildColCurve(bool appendPoints,
139  GEO_Detail *parent) const;
140  /// @}
141 
142  static GU_PrimRBezSurf *build(GEO_Detail *gudp,
143  int rows, int cols,
144  int orderu = 4, int orderv = 4,
145  int wrapu = 0, int wrapv = 0,
147  int appendPoints = 1);
148 
149  // Remove as many of the given edges of possible from this poly.
150  // If edge #a is removed, bit a in the bit array is set to a & 1.
151  // returns 0 if successful, -1 if the poly becomes degenerate, and
152  // -2 if the poly should be removed.
153  int removeEdges(const GA_EdgeGroup &edges,
154  UT_BitArray *remove_edges=0);
155 
156  // Get the bounding box for a specific range of u and v
157  virtual void getRangeBBox(const UT_Interval &u,
158  const UT_Interval &v,
159  UT_BoundingBox &bbox,
160  const GA_PwHandleRO &h) const;
161 
162 protected:
163  virtual GEO_Hull *getSubHull(int top, int left, int bottom, int right,
164  GEO_SubHullFlags break_flags);
165 
166 private:
167  static GA_PrimitiveDefinition *theDefinition;
168  friend class GU_PrimitiveFactory;
169 };
170 
171 #endif
virtual GEO_Hull * reconfigure(unsigned type, int orderu, int orderv, bool openu, bool openv, bool endsu, bool endsv) const =0
GLint left
Definition: glcorearb.h:2004
const GLdouble * v
Definition: glcorearb.h:836
virtual const GA_PrimitiveDefinition & getTypeDef() const
virtual void openAtU(float u)=0
Open the primitive at the given domain value.
virtual ~GU_PrimRBezSurf()
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
3D Vector class.
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:201
virtual int intersectSurf(GEO_TPSurf &surf2, GU_IsectCurveSet &curveset, float worldtol=1e-4F, float domaintol=1e-2F, int steps=100, bool docompact=true)=0
virtual int doesIntersect(const GEO_Primitive &prim, float worldtol=1e-4F, int nontrivial=0) const =0
virtual void openAtV(float v)=0
#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
virtual void getRangeBBox(const UT_Interval &u, const UT_Interval &v, UT_BoundingBox &bbox, const GA_PwHandleRO &h) const =0
GA_PwHandle< true > GA_PwHandleRO
GU_PrimRBezSurf(GA_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
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
virtual GEO_Curve * buildRowCurve(bool appendPoints, GEO_Detail *parent) const =0
#define GU_API
Definition: GU_API.h:12
virtual GEO_TPSurf * cutV(float v1, float v2, int &ind1, int &ind2, int keep)=0
GLint GLint bottom
Definition: glcorearb.h:2004
virtual GEO_TPSurf * cutU(float u1, float u2, int &ind1, int &ind2, int keep)=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
GLfloat GLfloat v1
Definition: glcorearb.h:816
virtual GEO_Hull * getSubHull(int top, int left, int bottom, int right, GEO_SubHullFlags break_flags)=0
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GEO_SurfaceType
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
Definition of a geometric primitive.
virtual GEO_Curve * buildColCurve(bool appendPoints, GEO_Detail *parent) const =0
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
int keep
Definition: png.h:2568