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