HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Cusp.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_Csup.h (GU Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 
13 #ifndef __GU_Cusp_h__
14 #define __GU_Cusp_h__
15 
16 #include "GU_API.h"
17 #include <GA/GA_Handle.h>
18 #include <SYS/SYS_Types.h>
19 
20 class GU_Detail;
22 class GA_Attribute;
23 class GA_AttributeRefMap;
24 class GA_EdgeGroup;
25 class GA_PointGroup;
26 class GA_PrimitiveGroup;
27 class GA_VertexGroup;
28 class UT_Classifier;
29 class GEO_Hedge;
30 
31 // Cusping operations are defined over a set of "cut-edges", which can be
32 // specified in various ways, and a primitive group. When no primitive group
33 // is specified, the primitive group is taken to be all primitives. In this
34 // more straight-forward case, a cusp operations computes a classification
35 // of vertices wired into each point into equivalence classes. The
36 // classes are formed by initially putting each vertex in its own class and
37 // then merging classes of vertices separated by non-cut-edges.
38 // Note that both cut-edge and non-cut-edges can be incident to 1, 2,
39 // or more faces but the classification defined this way is unique.
40 //
41 // If a primitive group is also specified, then classes of two
42 // vertices separated by non-cut-edge are merged as before but only if in
43 // addition both vertices belong to primitives in the specified group. If a
44 // non-cut-edge separates a vertex of a primitive in the group and
45 // another from a non-group primitive, then class of the former vertex
46 // will be called a "run-over" class, meaning that the class would have been
47 // larger if the operation were not limited to the given primitive group.
48 //
49 // Once vertex classes are determined, cusp operations equalize/uniques the the
50 // specified attribute(s) of vertices in each equivalence class:
51 //
52 // Point cusping makes the points wired to each class unique,
53 // Attribute cusping averages out the specified attributes in each class
54 // and overwrites those attributes with the average value of the
55 // class for all vertices in the class.
56 
57 // Cusp the edges in the given edge group. If cut_boundaries is false,
58 // classes running over unshared edges that are not in the given edge group,
59 // or those running over outside the primitive group, are not wired to their
60 // unique copy of the point.
61 
62 GU_API void GUcusp(GU_Detail *gdp, const GA_EdgeGroup &edges,
63  bool cut_boundaries = false,
64  const GA_PrimitiveGroup *prims = 0);
65 
66 
67 // Simlar to the above cusp but uses an array of half-edges instead of an
68 // edge group as input. The optional hedge interface is used to avoid rebuilding
69 // a const hedge interface. Note that cusping edges would render an existing
70 // const hedge interface invalid.
71 
72 GU_API void GUcusp(GU_Detail *gdp, const UT_Array<GEO_Hedge> &hedges,
73  bool cut_boundaries = false,
74  const GA_PrimitiveGroup *prims = 0,
75  const GEO_DetachedHedgeInterface *hip = 0);
76 
77 // Simlar to the above cusp but uses an vertex group instead. Any edge matching
78 // a half-edge determined by vertex group is a cut edge.
79 
80 GU_API void GUcusp(GU_Detail *gdp, const GA_VertexGroup *vtxs,
81  bool cut_boundaries = false,
82  const GA_PrimitiveGroup *prims = 0,
83  const GEO_DetachedHedgeInterface *hip = 0);
84 
85 
86 // Cusp vertex normal attributes based on cut-edges defined as manifold edges
87 // whose two incident primitives have normals deviating by more than
88 // "cusp_angle" degrees. vnh is the handle for the attribute to be written
89 // into. pnh is the primitive normal attribute handle which will be computed
90 // if not supplied.
91 //
92 // * If prims is given, only vertices of the primitives in prims are used in
93 // doing the calculations.
94 //
95 // * If vtxs are given, only values for classes whose root is contained
96 // in vtxs is overwritten and the others are left unchanged.
97 //
98 // * If always_cusp is given, edges in always_cusp are cusped regardless of
99 // their diehedral angle.
100 //
101 // * If never_cups is given, edges in never_cusp are not cusped unless they
102 // are nonmanifold edges.
103 //
104 // * If cattrib_cusp is false,
105 // then it does point cusp instead of attribute cusp.
106 
108  GA_RWHandleV3 vnh,
109  fpreal cusp_angle,
110  GA_ROHandleV3 pnh = GA_ROHandleV3(nullptr),
111  bool attrib_cusp = true,
112  const GA_PrimitiveGroup *prims = nullptr,
113  GA_VertexGroup *vtxs = nullptr,
114  GA_EdgeGroup *always_cusp = nullptr,
115  GA_EdgeGroup *never_cusp = nullptr,
116  GEO_DetachedHedgeInterface *hip = nullptr,
117  bool use_angle_weights = false);
118 
119 
120 // Generic function for creating equivalence classes which can be used
121 // for point or attribute cusping. The template class T must have a method
122 //
123 // inline bool isHedgeSelected(GEO_Hedge e)
124 //
125 // which decides whether the edge described by half-edge e is a cut edge
126 // or not. If not null, nontrivial_ptgrp will include points which are
127 // incident to at least one cut-edge. If runover_vtxgrp is not null, then
128 // it will include roots of run-over equivalence classes.
129 
130 template <class T>
131 GU_API
134  const GU_Detail *gdp,
135  const GEO_DetachedHedgeInterface *dhip,
136  const GA_PointGroup *pts,
137  T &hedge_selector,
138  const GA_PrimitiveGroup *prims,
139  GA_PointGroup *nontrivial_ptgrp,
140  GA_VertexGroup *runover_vtxgrp);
141 
142 
143 // Cusp points or attributes according to the given vertex classifier:
144 // GUpointCusp() splits the points (there will be a unique point for each
145 // class of vertices). GUattributeCusp() unifies the attributes values over
146 // each vertex class based on cusp_fn by either
147 // - taking an arbitrary member's value (GU_CUSP_ANY),
148 // - taking the value of the member with smallest weight (GU_CUSP_MIN), or
149 // - taking the value of the member with largest weight (GU_CUSP_MAX), or
150 // - taking the weighted average of all members.
151 // wth is the handle for the weight attribute to be used in weighted
152 // average computation. If wth is invalid, all eights are taken to be 1.
153 //
154 // vtx_classes must have (at least) the same number of elements as the
155 // number of vertex offsets.
156 //
157 // If ignore_classes is specified, classes whose root elements are contained
158 // in the ignore_classes group are left unchanged.
159 //
160 // There are two version of GUattributeCusp, one taking a single attribute
161 // and the other taking an GA_AttributeRefMap which allows simultaneous cusping
162 // of multiple attributes.
163 
165 {
170 };
171 
173 {
176 };
177 
178 GU_API void GUpointCusp(GU_Detail *gdp,
179  const UT_Classifier *vtx_classes,
180  const GA_PointGroup *pts = 0,
181  const GA_PrimitiveGroup *prims = 0,
182  const GA_VertexGroup *mask_classes = 0,
183  GU_CuspMaskType mask_type = GU_CUSP_INCLUDE);
184 
186  const UT_Classifier *vtx_classes,
187  GA_Attribute *attrib,
188  GA_ROHandleF &wth,
189  GU_CuspFunction cusp_fn = GU_CUSP_ANY,
190  const GA_PrimitiveGroup *prims = 0,
191  const GA_VertexGroup *mask_classes = 0,
192  GU_CuspMaskType mask_type = GU_CUSP_INCLUDE);
193 
195  const UT_Classifier *vtx_classes,
196  GA_AttributeRefMap &refmap,
197  GA_ROHandleF &wth,
198  GU_CuspFunction cusp_fn = GU_CUSP_ANY,
199  const GA_PrimitiveGroup *prims = 0,
200  const GA_VertexGroup *mask_classes = 0,
201  GU_CuspMaskType mask_type = GU_CUSP_INCLUDE);
202 
203 #endif
GU_API void GUcusp(GU_Detail *gdp, const GA_EdgeGroup &edges, bool cut_boundaries=false, const GA_PrimitiveGroup *prims=0)
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
GA_ROHandleT< UT_Vector3F > GA_ROHandleV3
Definition: GA_Handle.h:1381
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
GU_API void GUattributeCusp(GU_Detail *gdp, const UT_Classifier *vtx_classes, GA_Attribute *attrib, GA_ROHandleF &wth, GU_CuspFunction cusp_fn=GU_CUSP_ANY, const GA_PrimitiveGroup *prims=0, const GA_VertexGroup *mask_classes=0, GU_CuspMaskType mask_type=GU_CUSP_INCLUDE)
GU_API UT_UniquePtr< UT_Classifier > GUclassifyVertices(const GU_Detail *gdp, const GEO_DetachedHedgeInterface *dhip, const GA_PointGroup *pts, T &hedge_selector, const GA_PrimitiveGroup *prims, GA_PointGroup *nontrivial_ptgrp, GA_VertexGroup *runover_vtxgrp)
A handle to simplify manipulation of multiple attributes.
#define GU_API
Definition: GU_API.h:14
GU_API void GUpointCusp(GU_Detail *gdp, const UT_Classifier *vtx_classes, const GA_PointGroup *pts=0, const GA_PrimitiveGroup *prims=0, const GA_VertexGroup *mask_classes=0, GU_CuspMaskType mask_type=GU_CUSP_INCLUDE)
GU_CuspFunction
Definition: GU_Cusp.h:164
fpreal64 fpreal
Definition: SYS_Types.h:277
GU_CuspMaskType
Definition: GU_Cusp.h:172
UT_StringArray JOINTS hip
GU_API void GUcomputeVertexNormals(GU_Detail *gdp, GA_RWHandleV3 vnh, fpreal cusp_angle, GA_ROHandleV3 pnh=GA_ROHandleV3(nullptr), bool attrib_cusp=true, const GA_PrimitiveGroup *prims=nullptr, GA_VertexGroup *vtxs=nullptr, GA_EdgeGroup *always_cusp=nullptr, GA_EdgeGroup *never_cusp=nullptr, GEO_DetachedHedgeInterface *hip=nullptr, bool use_angle_weights=false)