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