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  ~GU_PrimRBezSurf() override {}
46 
47 public:
48  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
50  : GEO_PrimRBezSurf(gdp, offset)
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  // 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 
83  GA_PointGroup *usedpts = NULL) override;
84  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
85 
86  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 override;
92 
93  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) override;
99  int doesIntersect(const GEO_Primitive &prim,
100  float worldtol = 1e-4F,
101  int nontrivial = 0) const override;
102 
103  // This is more powerful than convertNew. It always returns a NEW
104  // object, so free it when you're done with it. It may return
105  // a NURB surface or a Bezier surface depending on the type.
106  GEO_Hull *reconfigure(unsigned type, int orderu, int orderv,
107  bool openu, bool openv,
108  bool, bool) const override;
109 
110  // Cut a wedge of the primitive given a domain range
111  // ind1 and ind2 are indices to the refined values
112  // They are updated if negative on input, else used as is.
113  // If keep is zero the curve is only refined and the indices
114  // updated.
115 
116  GEO_TPSurf *cutU(float u1, float u2,
117  int &ind1, int &ind2, int keep) override;
118  GEO_TPSurf *cutV(float v1, float v2,
119  int &ind1, int &ind2, int keep) override;
120 
121  // Open the primitive at the given domain value
122  void openAtU(float u) override;
123  void openAtV(float v) override;
124 
125  // Divide a surface into its components patches. Do not
126  // modify 'this'.
127  // every_patch - Split even if this is already a minimal patch
128  // appendPoints - Add new points for split patches
129  // outprims - Group to add created primitives to
130  // Return: npatches added or -1 on error
131  int split(int every_patch = 0,
132  int append_points = 0,
133  GA_PrimitiveGroup *out_prims = 0);
134 
135  /// Construct a curve that has our characteristics in u or v. The
136  /// CVs of the new curve are not set.
137  /// @{
138  GEO_Curve *buildRowCurve(bool appendPoints,
139  GEO_Detail *parent) const override;
140  GEO_Curve *buildColCurve(bool appendPoints,
141  GEO_Detail *parent) const override;
142  /// @}
143 
144  static GU_PrimRBezSurf *build(GEO_Detail *gudp,
145  int rows, int cols,
146  int orderu = 4, int orderv = 4,
147  int wrapu = 0, int wrapv = 0,
149  int appendPoints = 1);
150 
151  // Remove as many of the given edges of possible from this poly.
152  // If edge #a is removed, bit a in the bit array is set to a & 1.
153  // returns 0 if successful, -1 if the poly becomes degenerate, and
154  // -2 if the poly should be removed.
155  int removeEdges(const GA_EdgeGroup &edges,
156  UT_BitArray *remove_edges=0);
157 
158  // Get the bounding box for a specific range of u and v
159  void getRangeBBox(const UT_Interval &u,
160  const UT_Interval &v,
161  UT_BoundingBox &bbox,
162  const GA_PwHandleRO &h) const override;
163 
164 protected:
165  GEO_Hull *getSubHull(int top, int left, int bottom, int right,
166  GEO_SubHullFlags break_flags) override;
167 
168 private:
169  static GA_PrimitiveDefinition *theDefinition;
170  friend class GU_PrimitiveFactory;
171 };
172 
173 #endif
virtual GEO_Hull * reconfigure(unsigned type, int orderu, int orderv, bool openu, bool openv, bool endsu, bool endsv) const =0
GLuint GLdouble u1
Definition: glew.h:3446
GLint left
Definition: glew.h:8008
virtual void openAtU(float u)=0
Open the primitive at the given domain value.
const GLdouble * v
Definition: glew.h:1391
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
~GU_PrimRBezSurf() override
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:676
GA_Size GA_Offset
Definition: GA_Types.h:639
GLint GLint bottom
Definition: glew.h:8008
GLfloat GLfloat GLfloat v2
Definition: glew.h:1856
void OIIO_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
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.
virtual void countMemory(UT_MemoryCounter &counter) const
GLfloat GLfloat GLfloat top
Definition: glew.h:15186
virtual GEO_Curve * buildRowCurve(bool appendPoints, GEO_Detail *parent) const =0
GLsizei GLsizei GLfloat distance
Definition: glew.h:13640
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
GLfloat right
Definition: glew.h:15186
virtual GEO_TPSurf * cutV(float v1, float v2, int &ind1, int &ind2, int keep)=0
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
const GA_PrimitiveDefinition & getTypeDef() const override
virtual GEO_TPSurf * cutU(float u1, float u2, int &ind1, int &ind2, int keep)=0
GLuint counter
Definition: glew.h:2740
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
virtual GEO_Hull * getSubHull(int top, int left, int bottom, int right, GEO_SubHullFlags break_flags)=0
GEO_SurfaceType
GLuint GLdouble GLdouble u2
Definition: glew.h:3446
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:135
Definition of a geometric primitive.
virtual GEO_Curve * buildColCurve(bool appendPoints, GEO_Detail *parent) const =0
GLfloat GLfloat v1
Definition: glew.h:1852
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
GLintptr offset
Definition: glew.h:1682