HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_Relax.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_Relax.h (GU Library, C++)
7  *
8  * COMMENTS: Declarations of functions for relaxing points away from each other
9  *
10  */
11 
12 #pragma once
13 
14 #ifndef __GU_Relax_h__
15 #define __GU_Relax_h__
16 
17 #include "GU_API.h"
18 #include <GA/GA_Handle.h>
19 #include <UT/UT_Array.h>
20 #include <UT/UT_VectorTypes.h>
21 #include <SYS/SYS_Types.h>
22 
23 class GA_Detail;
24 class GA_Range;
25 class GEO_Face;
27 class GU_RayIntersect;
28 class UT_KDTree;
29 
30 /// Computes new positions of points into newpositions, (which
31 /// is indexed by point offset, *not* index), such that the points
32 /// would be more spread out in the 2D space tangent to the
33 /// given normals. It returns true if at least one
34 /// point would be moved, and false if no points would be moved.
35 ///
36 /// NOTE: If you're relaxing points in volumes/tetrahedra/curves, you probably
37 /// want to use guRelaxPoints3D or guRelaxPoints1D instead. This is more
38 /// for surfaces.
39 ///
40 /// pttree must contain exactly the points that can influence the points
41 /// in relaxrange. It does not need to be all of the points in gdp,
42 /// but the points must be in gdp. If radiusattrib is invalid, pttree
43 /// shouldn't use radii.
44 ///
45 /// If normalattrib is invalid, normalvalue is used to get the tangent
46 /// plane for each point.
47 /// If radiusattrib is invalid, radiusvalue is used to indicate the
48 /// radius of each point either influencing or being relaxed.
49 ///
50 /// stepweight indicates the portion of the distance toward the target
51 /// position that the move represents. 1.0 moves directly to the target
52 /// on this iteration. 0.5 moves halfway there for extra stability.
53 /// 2.0 moves past the target, which may spread out points faster or may
54 /// not converge at all.
55 ///
56 /// NOTE: It is now the caller's responsibility to call buildIfNeeded()
57 /// on the tree before calling this! The point tree is
58 /// not modified by this function.
60  UT_Array<UT_Vector3> &newpositions,
61  const GA_Detail *gdp,
62  const GA_Range &relaxrange,
63  GEO_PointTreeGAOffset &pttree,
64  const GA_ROHandleV3 &normalattrib,
65  const UT_Vector3 &normalvalue,
66  const GA_ROHandleF &radiusattrib,
67  const fpreal radiusvalue,
68  const GA_ROHandleF &maxstepattrib = GA_ROHandleF(),
69  const fpreal stepweight=1.0,
70  const bool scaleattrib=false);
71 
72 /// Computes new positions of points into newpositions, (which
73 /// is indexed by point offset, *not* index), such that the points
74 /// would be more spread out in 3D space. It returns true if at least one
75 /// point would be moved, and false if no points would be moved.
76 ///
77 /// NOTE: If you're relaxing points on a surface/curve, you probably want
78 /// to use guRelaxPoints or guRelaxPoints1D instead. This is more for
79 /// volumes/tetrahedra.
80 ///
81 /// pttree must contain exactly the points that can influence the points
82 /// in relaxrange. It does not need to be all of the points in gdp,
83 /// but the points must be in gdp. If radiusattrib is invalid, pttree
84 /// shouldn't use radii.
85 ///
86 /// If radiusattrib is invalid, radiusvalue is used to indicate the
87 /// radius of each point either influencing or being relaxed.
88 ///
89 /// stepweight indicates the portion of the distance toward the target
90 /// position that the move represents. 1.0 moves directly to the target
91 /// on this iteration. 0.5 moves halfway there for extra stability.
92 /// 2.0 moves past the target, which may spread out points faster or may
93 /// not converge at all.
94 ///
95 /// NOTE: It is now the caller's responsibility to call buildIfNeeded()
96 /// on the tree before calling this! The point tree is
97 /// not modified by this function.
99  UT_Array<UT_Vector3> &newpositions,
100  const GA_Detail *gdp,
101  const GA_Range &relaxrange,
102  GEO_PointTreeGAOffset &pttree,
103  const GA_ROHandleF &radiusattrib,
104  const fpreal radiusvalue,
105  const GA_ROHandleF &maxstepattrib = GA_ROHandleF(),
106  const fpreal stepweight=1.0,
107  const bool scaleattrib=false);
108 
109 /// Computes new positions of points into newpositions, (which
110 /// is indexed by point offset, *not* index), such that the points would
111 /// be more spread out along the given curve. Distances are measured as
112 /// arc-lengths between the u values of the points. uvwattrib is updated
113 /// safely, (after all points have been moved, to avoid order-dependence).
114 /// It returns true if at least one point would be moved, and false if no
115 /// points would be moved.
116 ///
117 /// NOTE: If you're relaxing points on a surface/volume/tetrahedra, you
118 /// probably want to use guRelaxPoints or guRelaxPoints3D instead.
119 /// This is *only* for curves.
120 /// NOTE: u values must be in the range [0,1].
121 ///
122 /// If radiusattrib is invalid, radiusvalue is used to indicate the
123 /// radius (half-width) of each point either influencing or being relaxed.
124 ///
125 /// stepweight indicates the portion of the distance toward the target
126 /// position that the move represents. 1.0 moves directly to the target
127 /// on this iteration. 0.5 moves halfway there for extra stability.
128 /// 2.0 moves past the target, which may spread out points faster or may
129 /// not converge at all.
131  UT_Array<UT_Vector3> &newpositions,
132  const GA_Detail *gdp,
133  const GA_Range &relaxrange,
134  const GA_ROHandleF &radiusattrib,
135  fpreal radiusvalue,
136  const GA_RWHandleV3 &uvwattrib,
137  const GEO_Face &face,
138  const fpreal stepweight=1.0);
139 
140 /// Computes new (2D) positions of points into newpositions, such that the
141 /// points would be more spread out. It returns true if at least one
142 /// point would be moved, and false if no points would be moved.
143 ///
144 /// pttree must have dimension 2 and consist of *exactly all points in
145 /// oldpositions*, *in the same order as in pttree*. If radii is empty,
146 /// pttree shouldn't use radii.
147 ///
148 /// If radii is empty, radiusvalue is used to indicate the
149 /// radius of each point either influencing or being relaxed.
150 ///
151 /// If unitspacewrap is true, space will be treated as wrapping to
152 /// always stay within the unit square between 0 and 1 in both x and y,
153 /// e.g. points near x=0 may be adjacent to points near x=1. However,
154 /// input points themselves are then assumed to be between 0 and 1,
155 /// and output points will be between 0 and 1.
156 ///
157 /// stepweight indicates the portion of the distance toward the target
158 /// position that the move represents. 1.0 moves directly to the target
159 /// on this iteration. 0.5 moves halfway there for extra stability.
160 /// 2.0 moves past the target, which may spread out points faster or may
161 /// not converge at all.
162 ///
163 /// NOTE: It is now the caller's responsibility to call buildIfNeeded()
164 /// on the tree before calling this! GEO_2DTree handles this
165 /// automatically in its constructor. The point tree is
166 /// not modified by this function.
168  UT_Array<UT_Vector2> &newpositions,
169  const UT_Array<UT_Vector2> &oldpositions,
170  UT_KDTree &pttree,
171  const UT_Array<float> &radii,
172  const fpreal radiusvalue,
173  const bool wrapunitspace = true,
174  const fpreal stepweight=1.0);
175 
176 /// Projects the points in projectrange of gdp onto the closest points of the
177 /// surface specified by surfaceintersect.
178 /// (Uses minimum distance, *NOT* projecting along normal.)
179 ///
180 /// If normalattrib is valid, the normal on the surface at the new position
181 /// will be written to it. If surfacenormalattrib is specified, it will be
182 /// used to compute the surface normal, instead of using the surface
183 /// primitive's evaluateNormalVector().
184 ///
185 /// If primnumattrib or primuvwattrib are specified, the surface primitive
186 /// index or uvw of each points will be stored.
187 ///
188 /// If radiusattrib is specified, it will be used as an upper bound on the
189 /// distance to the surface to speed up querying the GU_RayIntersect. Points
190 /// more than this distance from the surface will not be moved. If
191 /// radiusattrib is invalid, radiusvalue will be used for all points.
193  GA_Detail *gdp,
194  const GA_Range &projectrange,
195  const GU_RayIntersect *surfaceintersect,
196  const GA_RWHandleV3 &normalattrib = GA_RWHandleV3(),
197  const GA_ROHandleV3 &surfacenormalattrib = GA_ROHandleV3(),
198  const GA_RWHandleT<int64> &primnumattrib = GA_RWHandleT<int64>(),
199  const GA_RWHandleV3 &primuvwattrib = GA_RWHandleV3(),
200  const GA_ROHandleF &radiusattrib = GA_ROHandleF(),
201  fpreal radiusvalue = FLT_MAX,
202  const bool scaleattrib=false);
203 
204 #endif
GU_API bool guRelaxPoints3D(UT_Array< UT_Vector3 > &newpositions, const GA_Detail *gdp, const GA_Range &relaxrange, GEO_PointTreeGAOffset &pttree, const GA_ROHandleF &radiusattrib, const fpreal radiusvalue, const GA_ROHandleF &maxstepattrib=GA_ROHandleF(), const fpreal stepweight=1.0, const bool scaleattrib=false)
3D Vector class.
GA_ROHandleT< UT_Vector3F > GA_ROHandleV3
Definition: GA_Handle.h:1319
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_RWHandleT< UT_Vector3F > GA_RWHandleV3
Definition: GA_Handle.h:1320
GU_API void guProjectPointsOntoSurface(GA_Detail *gdp, const GA_Range &projectrange, const GU_RayIntersect *surfaceintersect, const GA_RWHandleV3 &normalattrib=GA_RWHandleV3(), const GA_ROHandleV3 &surfacenormalattrib=GA_ROHandleV3(), const GA_RWHandleT< int64 > &primnumattrib=GA_RWHandleT< int64 >(), const GA_RWHandleV3 &primuvwattrib=GA_RWHandleV3(), const GA_ROHandleF &radiusattrib=GA_ROHandleF(), fpreal radiusvalue=FLT_MAX, const bool scaleattrib=false)
GA_ROHandleT< fpreal32 > GA_ROHandleF
Definition: GA_Handle.h:1295
GU_API bool guRelaxPoints(UT_Array< UT_Vector3 > &newpositions, const GA_Detail *gdp, const GA_Range &relaxrange, GEO_PointTreeGAOffset &pttree, const GA_ROHandleV3 &normalattrib, const UT_Vector3 &normalvalue, const GA_ROHandleF &radiusattrib, const fpreal radiusvalue, const GA_ROHandleF &maxstepattrib=GA_ROHandleF(), const fpreal stepweight=1.0, const bool scaleattrib=false)
GU_API bool guRelaxPoints1D(UT_Array< UT_Vector3 > &newpositions, const GA_Detail *gdp, const GA_Range &relaxrange, const GA_ROHandleF &radiusattrib, fpreal radiusvalue, const GA_RWHandleV3 &uvwattrib, const GEO_Face &face, const fpreal stepweight=1.0)
#define GU_API
Definition: GU_API.h:11
GU_API bool guRelaxPoints2D(UT_Array< UT_Vector2 > &newpositions, const UT_Array< UT_Vector2 > &oldpositions, UT_KDTree &pttree, const UT_Array< float > &radii, const fpreal radiusvalue, const bool wrapunitspace=true, const fpreal stepweight=1.0)
double fpreal
Definition: SYS_Types.h:269
Container class for all geometry.
Definition: GA_Detail.h:96