HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_TPSurf.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_TPSurf.h (C++)
7  *
8  * COMMENTS:
9  * Header file for GU_TPSurf.h class...
10  *
11  */
12 
13 #ifndef __GU_TPSurf_h__
14 #define __GU_TPSurf_h__
15 
16 #include "GU_API.h"
17 #include <GEO/GEO_SurfaceType.h>
18 #include <UT/UT_Axis.h>
19 #include <UT/UT_Vector3.h>
20 #include <UT/UT_Vector3Array.h>
21 #include <UT/UT_Vector4Array.h>
22 
23 class GA_PointGroup;
24 class GA_PrimitiveGroup;
25 class GD_Primitive;
26 class GEO_ConvertMethod;
27 class GEO_ConvertParms;
28 class GEO_Curve;
29 class GEO_Face;
30 class GEO_Primitive;
31 class GEO_TPSurf;
32 class GU_PrimPoly;
33 class GU_RayInfo;
34 class GU_Detail;
35 class GU_IsectCurveSet;
36 class GU_RayIntersect;
37 
39 {
40 public:
42 
43  int type; // by vector (0) or by parametric (1) mapping
44 
45  UT_Vector3 axis; // projection axis if projecting along vector
46  int fnorm; // use face normal for projection axis
47  int side; // closest (0), farthest (1) , or all sides (2)
48  int sdivs; // number of divisions per 3D curve span
49  float rtol; // ray intersection tolerance
50  float ftol; // 2D tolerance for fitting
51  float uvgap; // max % uv distance for joining profiles
52  int sharp; // maintain sharpness when fitting
53  int order; // 2D spline order for the fit
54  int ignoretrim; // If true, ignores trimming info
55  int algebraic; // If true, uses Algebraic Pruning.
56 
57  UT_Axis3::axis uaxis; // u axis for parametric mapping
58  UT_Axis3::axis vaxis; // v axis for parametric mapping
59  int range; // use the range below to map the curve into
60  float umin; // 0 <= umin <= 1
61  float umax; // 0 <= umax <= 1
62  float vmin; // 0 <= vmin <= 1
63  float vmax; // 0 <= vmax <= 1
64  int unif; // uniform (1) or arc length (0) mapping
65 };
66 
67 /////////////////////////////////////////////////////////////
68 // //
69 // Class: GU_TPSurf //
70 // Descr: This class is responsible for general type //
71 // of operations on nurbs and the surf classes. //
72 // //
73 /////////////////////////////////////////////////////////////
74 
76 {
77 public:
78  static int intersectRay(const GEO_TPSurf &surf,
79  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);
85  static int intersectSurf(GEO_TPSurf &surf1, GEO_TPSurf &surf2,
86  GU_IsectCurveSet &curveset,
87  float worldtol = 1e-4F,
88  float domaintol = 1e-2F,
89  int steps = 100,
90  bool docompact = true);
91  static int doesIntersect(const GEO_TPSurf &surf,const GEO_Primitive &prim,
92  float worldtol = 1e-4F, int nontrivial = 0);
93 
94  // Send a ray to see if it intersects the surface. The hitinfo should
95  // contain all the needed info, such as tolerance and find farthest.
96  // The hit info is updated if a hit is found, and 1 is returned. The
97  // (u,v) intersection point is also set in hitinfo.
98  static int rayHit(const GEO_TPSurf &surf,
99  const UT_Vector3 &o, const UT_Vector3 &dir,
101 
102  /// Extract one or more (if not fully inside the domain) 3D curve(s) out of
103  /// a profile's image onto the surface. Return the first 3D curve if
104  /// successful and 0 otherwise. Only one (the first visible piece of the
105  /// curve) will be extracted if only_first_visible_part is set.
106  /// The second extract doeas a parametric extract, so the whole profile will
107  /// be extracted regardless of its visibility. The resulting 3D curve will
108  /// be a planar XY curve at the given z elevation.
109  static GEO_Curve *extract(const GEO_TPSurf &surf,
110  GU_Detail *gdp,
111  const GD_Primitive &profile, int smooth = 1,
112  int sdivs = 20, float tol = 0.001F,
113  int sharp = 1, int order = 4,
114  int only_first_visible_part = 0);
115  static GEO_Face *extract(const GEO_TPSurf &surf,
116  GU_Detail *gdp,
117  const GD_Primitive &profile, float z=0);
118 
119  // Project the face or the group of faces onto the surface to create a
120  // curve on surface. Return 0 if OK and -1 otherwise.
121  // If the projection type is set to parametric mapping, the group method
122  // maps the faces in sequence rather than one on top of each other. Also,
123  // if the gdp pointer is zero, we assume the faces live in our gdp.
124  static int project(GEO_TPSurf &surf,
125  const GEO_Face &f, const GU_ProjectParms &p,
126  GU_RayIntersect *intersect = NULL);
127  static int project(GEO_TPSurf &surf,
128  const GA_PrimitiveGroup &faces,
129  const GU_ProjectParms &p, const GU_Detail *gdp = 0);
130 
131  // Finds the points on the surface that is minimums to the points on the
132  // face. We will find the points so that the face is divided into
133  // "numdivs" segments. Returns via the UT_Array. Returns the actual
134  // number of points in the domain.
135  static int findMins(const GEO_TPSurf &surf,
136  const GEO_Face &face, int numdivs,
137  UT_Vector3Array &domain,
138  const GEO_Face *dface = 0,
139  UT_Vector4Array *displaces = 0);
140  // Projects points from the face to the surface in the direction of
141  // projdir. We will find the points so that the face is divided into
142  // "numdivs" segments. Returns the (u,v) pairs of the domain via the
143  // UT_Array. Returns the actual number of points added.
144  static int findProjects(const GEO_TPSurf &surf,
145  GEO_Face& face, int numdivs,
146  const UT_Vector3 &projdir,
147  UT_Vector3Array &domain,
148  const GEO_Face *dface = 0,
149  UT_Vector4Array *displaces = 0);
150 
151  // Fill the hull with row and column data. Return 0 if OK, and -1 if error.
152  static int create(GEO_TPSurf *surf, int rows, int cols,
153  GEO_SurfaceType type, bool wrapu, bool wrapv,
154  bool appendPoints = true);
155 
156  // Return the start and and knots for a full uniform evaluation of the
157  // mesh.
158  static void evaluationInterval(const GEO_TPSurf &surf,
159  float lodu, float lodv,
160  float &ustart, float &ustop, int &nu,
161  float &vstart, float &vstop, int &nv);
162 
163  // Fill with values within the valid uv interval. Return 0 if OK and -1
164  // otherwise.
165  static int evaluateSurface(const GEO_TPSurf &surf,
166  GEO_ConvertMethod &method,
167  UT_Vector4Array &pos,
168  int &nu, int &nv,
169  UT_FloatArray *uval = 0,
170  UT_FloatArray *vval = 0);
171 
172  static GEO_Primitive *convert(GEO_TPSurf *surf, GEO_ConvertParms &parms, GA_PointGroup *usedpts);
173  static GEO_Primitive *convertNew(GEO_TPSurf *surf, GEO_ConvertParms &parms);
174  static GEO_Primitive *convertToPoly(GEO_TPSurf *surf, GEO_ConvertParms &parms);
175 
176 private:
177  // We don't want anybody to instantiate a GU_TPSurf.
178  GU_TPSurf() {}
179 
180  // Helpers for curve-on-surface projections:
181  static GU_PrimPoly *projectOnePoint(const GEO_TPSurf &surf,
182  const UT_Vector3 &orig,
183  const UT_Vector3 &dir, float uvgap,
184  GU_RayInfo &hitinfo, GU_Detail &polygdp,
185  float &pdot, int &pclose, int &projcount,
186  GU_PrimPoly *&poly,
187  GU_PrimPoly *&pfirst, GU_PrimPoly *&nfirst,
188  const GEO_Face &face, int cridx, int lod,
189  int numdiv, GU_RayIntersect *intersect);
190  static int projectOnSide(const GEO_TPSurf &surf,
191  const UT_Vector4Array &pos,
192  const UT_Vector3 &dir, const UT_Vector3 &ndir,
193  int myfar, float rtol, float uvgap, int cls,
194  GU_Detail &pgdp, const GEO_Face &face, int lod,
195  int algebraic, int ignoretrim,
196  GU_RayIntersect *intersect);
197  static int projectOnAllSides(const GEO_TPSurf &surf,
198  const UT_Vector4Array &pos,
199  const UT_Vector3 &dir, const UT_Vector3 &ndir,
200  float rtol, float uvgap, int cls,
201  GU_Detail &pgdp, const GEO_Face &face, int lod,
202  int algebraic, int ignoretrim,
203  GU_RayIntersect *intersect);
204  static int projectAlongMinimum(const GEO_TPSurf &surf,
205  const UT_Vector4Array &pos,
206  int closed, float uvgap,
207  GU_Detail &polygdp);
208  static void processSideHit(const GEO_TPSurf &surf,
209  GU_PrimPoly *pinpoly,
210  GU_PrimPoly *&poutpoly, GU_PrimPoly *&pfirst,
211  GU_PrimPoly *ninpoly, GU_PrimPoly *&noutpoly,
212  GU_PrimPoly *&nfirst, float uvgap,
213  GU_Detail &polygdp, int &pstartidx,
214  int &nstartidx, int cridx);
215  static void processEndHit(const GEO_TPSurf &surf,
216  GU_Detail &polygdp, GU_PrimPoly &poly,
217  GU_PrimPoly *first, float uvgap, int close);
218  static void joinHits(const GEO_TPSurf &surf,
219  GU_PrimPoly &apoly, GU_PrimPoly &bpoly,
220  GU_PrimPoly *&pfirst, GU_PrimPoly *&nfirst);
221  /// Warning: Makes point index map non-monontonic
222  static int connectToEdge(const GEO_TPSurf &surf,
223  GU_PrimPoly *poly, GU_Detail &polygdp,
224  float uvgap, int isfirst);
225  /// Warning: Makes point index map non-monontonic
226  static int projectAddBisectPoints(const GEO_TPSurf &surf,
227  GU_PrimPoly *poly,
228  GU_Detail &polygdp, const GEO_Face &face,
229  int lod, int index, int isfirst,
230  const UT_Vector3 &dir, GU_RayInfo &hitinfo,
231  float uvgap, float pdot, int numdiv,
232  GU_RayIntersect *intersect);
233 
234  // Project Function Pointers
235  typedef int (*GU_PFP)(const GEO_TPSurf &,
236  UT_Vector3 &, float&, float&, const UT_Vector3 &);
237 
238  // Functions as input for findMinOrProj
239  static int minimumFunction(const GEO_TPSurf &surf,
240  UT_Vector3 &from, float &u, float &v,
241  const UT_Vector3 &);
242  static int projectFunction(const GEO_TPSurf &surf,
243  UT_Vector3 &from, float &u, float &v,
244  const UT_Vector3 &projdir);
245  // Finds the points on the surface that is minimums to the points on the
246  // face. We will find the points so that the face is divided into
247  // "numdivs" segments. Returns via the UT_Array. Returns the actual
248  // number of points in the domain.
249  static int findMinsOrProj(const GEO_TPSurf &surf,
250  GU_PFP fp, const GEO_Face &face,
251  int numdivs, const UT_Vector3 &projdir,
252  UT_Vector3Array &domain,
253  const GEO_Face *dface = 0,
254  UT_Vector4Array *displaces = 0);
255 };
256 
257 #endif
GLint first
Definition: glcorearb.h:405
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
const GLdouble * v
Definition: glcorearb.h:837
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
Tto convert(const Tfrom &source)
void close() override
UT_Axis3::axis vaxis
Definition: GU_TPSurf.h:58
OIIO_FORCEINLINE bool extract(const vbool4 &a)
Definition: simd.h:3426
GLfloat f
Definition: glcorearb.h:1926
UT_Vector2T< T > project(const UT_Vector2T< T > &u, const UT_Vector2T< T > &v)
The orthogonal projection of a vector u onto a vector v.
Definition: UT_Vector2.h:700
UT_Vector3 axis
Definition: GU_TPSurf.h:45
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
#define GU_API
Definition: GU_API.h:14
UT_Axis3::axis uaxis
Definition: GU_TPSurf.h:57
virtual bool smooth(GA_AttributeOperand &d, GA_AttributeOperand &min, GA_AttributeOperand &max, GA_AttributeOperand &t) const
d = SYSsmooth(min, max, t);
GLuint index
Definition: glcorearb.h:786
IMATH_CONSTEXPR14 bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front) IMATH_NOEXCEPT
Definition: ImathLineAlgo.h:80
GEO_SurfaceType
SIM_API const UT_StringHolder distance
type
Definition: core.h:1059
GLint lod
Definition: glcorearb.h:2765