HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_SubDivCurve.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_SubDivCurve.h (GU Library, C++)
7  *
8  * COMMENTS: Functions for evaluating subdivision curves, similar to
9  * subdivision surfaces.
10  */
11 
12 #pragma once
13 
14 #ifndef __GU_SubDivCurve__
15 #define __GU_SubDivCurve__
16 
17 #include "GU_API.h"
18 #include <GA/GA_Handle.h>
19 #include <GA/GA_Types.h>
20 #include <GEO/GEO_Face.h>
21 #include <UT/UT_VectorTypes.h>
22 #include <UT/UT_Span.h>
23 #include <UT/UT_Spline.h>
24 #include "UT/UT_Tuple.h"
25 #include <stddef.h>
26 
27 class GA_Detail;
28 class GA_PrimitiveGroup;
29 
30 /// Returns the number of open polygons in the given detail.
32  const GA_Detail &detail,
33  const GA_PrimitiveGroup *group=nullptr);
34 
35 /// Creates new polygon curves in dest from any curves in src (srcgroup if
36 /// specified), that are subdivided levels times.
37 /// If dest==src and treatasindependent is false, it will reuse any points that
38 /// are used by primitives that are not being subdivided, to maintain
39 /// equivalent connectivity. Curves with zero vertices or one vertex
40 /// will be left untouched. Other points, vertices, and primitives will
41 /// usually be new.
42 /// Returns the number of polygon curves that were generated in dest.
43 /// NOTE: The number of vertices generated is exponential in levels, not linear!
45  GA_Detail &dest,
46  const GA_Detail &src,
47  int segmentsperedge,
48  bool treatasindependent=false,
49  const GA_PrimitiveGroup *srcgroup=nullptr);
50 
51 /// Evaluates this curve (or face boundary if closed) as the specified
52 /// cubic spline at u (in [0,1]).
53 ///
54 /// If midbasis and startbasis are not specified, the bases for
55 /// subdivision curves will be used.
56 /// Column 0 of midbasis is the unit coefficients for p[-1],p[0],p[1],p[2].
57 /// Column 1 is the t coefficients; column 2 is the t^2 coefficients, and
58 /// column 3 is the t^3 coefficients. firstbasis is only used if the
59 /// face is open and has rows in the order p[0],p[1],p[2],p[3] for the
60 /// first edge, and is used in reverse for the last edge.
61 ///
62 /// attrib can have any owner, including primitive and detail,
63 /// in which case the value is constant. Otherwise, if this face has no
64 /// vertices, the output will be zeroed. If it has one vertex, the value
65 /// will be copied. If it has two vertices, the values will be lerped.
66 /// If it has 3 vertices and firstbasis has a non-zero row 3,
67 /// the quadratic interpolating basis will be used (this may change).
68 ///
69 /// This is instantiated for fpreal16, fpreal32, fpreal64, and the
70 /// corresponding UT_Vector2T, UT_Vector3T, UT_Vector4T, UT_Matrix2T,
71 /// UT_Matrix3T, and UT_Matrix4T types.
72 ///
73 /// If T is a scalar type and component=-1, all components of the attribute
74 /// will be evaluated into vals, instead of just one, so make sure
75 /// it's large enough. In the version that takes a T&val, only the
76 /// specified component is evaluated into val.
77 /// @{
78 template<typename T>
80  const GEO_Face &face,
81  float u, T &val, const GA_ROHandleT<T> &attrib,
82  const UT_Matrix4 *midbasis=nullptr,
83  const UT_Matrix4 *firstbasis=nullptr,
84  int component=0);
85 
86 template<typename T>
88  const GEO_Face &face,
89  float startu, float endu, exint nus,
90  T *vals, const GA_ROHandleT<T> &attrib,
91  const UT_Matrix4 *midbasis=nullptr,
92  const UT_Matrix4 *firstbasis=nullptr,
93  int component=-1);
94 
95 template<typename T>
97  const GEO_Face &face,
98  const UT_Span<const float> &uvals,
99  T *vals, const GA_ROHandleT<T> &attrib,
100  const UT_Matrix4 *midbasis=nullptr,
101  const UT_Matrix4 *firstbasis=nullptr,
102  int component=-1);
103 /// @}
104 
105 /// This computes point indices and coefficients at u for a curve with n
106 /// vertices. This allows one to evaluate subdivision curve values outside of
107 /// the GEO framework. This function is used by GUevaluateCubicCurve, so matches
108 /// its behavior. This doesn't handle the n==0 case though. Any unused/invalid
109 /// indices are set to -1. Evaluate the subdivision curve by adding the products
110 /// of all coefficients & values at index where index >=0.
112  float u,
113  exint n,
114  bool closed,
115  const UT_Matrix4 *firstbasis,
116  const UT_Matrix4 *midbasis);
117 
119  float u,
120  exint n,
121  bool closed);
122 
123 /// This moves the values of the given attribute such that
124 /// if this polygon were subdivided as a subdivision curve,
125 /// the limit curve would interpolate the starting values.
126 /// In a sense, this "undoes" the subdivision so that it
127 /// can be done later to produce the same result.
128 ///
129 /// If T is a scalar type and component=-1, all components of the attribute
130 /// will be evaluated into vals, instead of just one, so make sure
131 /// it's large enough.
132 /// ARRAY is specialized for GA_OffsetList, UT_Array<GA_Offset>,
133 /// UT_Span<const GA_Offset>
134 /// @{
135 template<typename T>
137  const GEO_Face &face,
138  const GA_RWHandleT<T> &attrib,
139  int component=-1);
140 template<typename ARRAY,typename T>
141 
143  const ARRAY &offsets,
144  GA_AttributeOwner offsetowner,
145  const GA_RWHandleT<T> &attrib,
146  int component=-1,
147  bool closed=false);
148 /// @}
149 
150 #endif
int64 exint
Definition: SYS_Types.h:125
GA_Size GU_API GUcountOpenPolys(const GA_Detail &detail, const GA_PrimitiveGroup *group=nullptr)
Returns the number of open polygons in the given detail.
std::tuple< Types...> UT_Tuple
Definition: UT_Tuple.h:53
void GUinterpolateCurveAsSubD(const GEO_Face &face, const GA_RWHandleT< T > &attrib, int component=-1)
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
GLdouble n
Definition: glcorearb.h:2008
GA_Size GU_API GUsubdivideCurves(GA_Detail &dest, const GA_Detail &src, int segmentsperedge, bool treatasindependent=false, const GA_PrimitiveGroup *srcgroup=nullptr)
#define GU_API
Definition: GU_API.h:14
UT_Tuple< UT_Vector4, UT_Vector4i > GU_API GUcomputeCubicCurveCoeffsAndIndices(float u, exint n, bool closed, const UT_Matrix4 *firstbasis, const UT_Matrix4 *midbasis)
GA_AttributeOwner
Definition: GA_Types.h:35
GLuint GLfloat * val
Definition: glcorearb.h:1608
Container class for all geometry.
Definition: GA_Detail.h:96
void GUevaluateCubicCurve(const GEO_Face &face, float u, T &val, const GA_ROHandleT< T > &attrib, const UT_Matrix4 *midbasis=nullptr, const UT_Matrix4 *firstbasis=nullptr, int component=0)
GLenum src
Definition: glcorearb.h:1793