HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PolyFill.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_PolyFill.h (GU Librayr, C++)
7  *
8  * COMMENTS: Caps polygons
9  *
10  */
11 
12 #ifndef __GU_PolyFill_h__
13 #define __GU_PolyFill_h__
14 
15 #include "GU_API.h"
16 
17 #include <GA/GA_Types.h>
18 class GU_Detail;
19 class GA_PrimitiveGroup;
20 class GA_PointGroup;
21 
22 namespace GU_PolyFill
23 {
24 
25 // The following are some bitmasks for a couple of the methods which can fail.
26 // fan can return ODD_SIZED_HOLE
27 // quadFan can return ODD_SIZED_HOLE and CONFLICTING_CORNERS
28 // quads can return ODD_SIZED_HOLE and NO_PLANE_NORMAL
29 // perfectGrid can return ODD_SIZED_HOLE, ONLY_ONE_CORNER, CONFLICTING_CORNERS
31  {
36  };
37 
38 /*
39  * README
40  * The holes that will be patched are determined by rings. Each GA_OffsetArray
41  * will be treated as a list of point offsets that describe a closed polygon
42  * (the hole) which is the surface of the patch. Attributes will be
43  * interpolated based on the geometry surrounding the hole. Note that each pair
44  * of consecutive points don't need to correspond to a real edge. For example,
45  * when auto-complete boundaries is off, one of the edges won't exist.
46  * Theoretically the code might be able to handle a polygone consisting
47  * entirely of free floating points, but this has never been tested in any way
48  * at all, and there are some snags which are noted in the code. Use with
49  * caution. Everything should work if all edges exist though.
50  * The distinction between rings and ringOrigs is that the generated polygons
51  * will be attached to the points in rings, but tangents for surface matching
52  * and attributes for interpolating will be taken from the geometry surrounding
53  * ringOrigs. This is useful for when you want to have the PolyFill be attached
54  * to unique points.
55  * If you want to reverse the orientation of the generated polygons, simply
56  * reverse each GA_OffsetArray in rings and ringOrigs.
57  *
58  * For functions that accept both a patch group and a loopgroup, the diagram
59  * below shows which polygons will be put into each group
60  * p - patch group
61  * l - loop group
62  * e - pre-existing geometry (not in any group)
63  *
64  * : : :
65  * e : e : e : e
66  * _ _ _ __|_____|____|__ _ _ _
67  * |\__l_|_l_/|
68  * e |l| p | p|l| e
69  * _ _ _ __|_|___|__|_|__ _ _ _
70  * | | p | p| |
71  * e |l|___|__|l| e
72  * _ _ _ __|/__l_|_l_\|__ _ _ _
73  * | | |
74  * e : e : e : e
75  * : : :
76  *
77  * For functions with cornerOffset, the topology that's generated will be
78  * rotated by the given amount around the ring.
79  *
80  * For functions with customCorners, this allows for defining the corners of
81  * quads explicitly instead of letting the function choose what it wants. If a
82  * hole does not have any boundary points in the group, automatic choosing will
83  * still be used. If conflicting corners are input (for example three points in
84  * a row on a perfect grid of boundary size ten), the return value will set
85  * CONFLICTING_CORNERS high.
86  *
87  * For functions with an edgeloop, the bool is for whether or not to add one.
88  * If this is false, the loopgroup will always be empty.
89  * Otherwise a point is inserted at percentage along each edge for points on
90  * the hole boundary with an even number of adjacent polygons in the patch. For
91  * boundary points with an odd number of adjacent polygons, the middle polygon
92  * is evaluated at percentage into it's surface. Note that since this is only
93  * currently possible with quad-generating fill modes, so if you add a fill
94  * mode that breaks this assumption, you will need to visit sop_makeedgeloop in
95  * GU_PolyFill.C
96  * The percentage must be in the range [0,1].
97  *
98  * For functions with a smooth parameter, the bool determines whether or not to
99  * pass the patch group to the smooth sop with default parameters except for
100  * the given strength. The smoothing occurs before edge loop generation so that
101  * the edge loop appears to be on the surface of the patch.
102  *
103  * For functions with a ctrTranslation parameter, deform patch determines
104  * whether or not the center points should translated along the hole's normals
105  * by the given amount. perfectGrid does something a bit more complex, see the
106  * GU_NSidedSubdivPatch it uses for more information.
107  */
108  GU_API void singlePolys(
109  GU_Detail* gdp,
111  UT_Array<GA_OffsetArray>& ringOrigs,
112  GA_PrimitiveGroup* patchGroup);
113 
114  // builds a fan out of polygons with degree edges each. Returns
115  // ODD_SIZED_HOLE if any of the holes could not be filled because they were
116  // not the correct size (for example a ten sided hole with hexagons). In
117  // this case any holes that were the correct size will still be filled.
118  GU_API exint fan(
119  GU_Detail* gdp,
121  UT_Array<GA_OffsetArray>& ringOrigs,
122  GA_PrimitiveGroup* patchgroup = nullptr,
123  GA_PrimitiveGroup* loopgroup = nullptr,
124  exint degree = 3,
125  bool deformpatch = false,
126  fpreal ctrTranslation = 0.0,
127  bool edgeloop = false,
128  fpreal edgelooppercentage = 0.5);
129 
130  // handles the customcorner checking by rotating the rings, and then passes
131  // it off to fan() to finish the job
132  // can return ODD_SIZED_HOLE and CONFLICTING_CORNERS
134  GU_Detail* gdp,
136  UT_Array<GA_OffsetArray>& originalRings,
137  GA_PrimitiveGroup* patchgroup = nullptr,
138  GA_PrimitiveGroup* loopgroup = nullptr,
139  GA_PointGroup* customcorners = nullptr,
140  exint cornerOffset = 0,
141  bool deformPatch = false,
142  fpreal ctrTranslation = 0.0,
143  bool edgeloop = false,
144  fpreal edgeloopPercentage = 0.5);
145 
146  // uses a greedy algorithm to fill holes as a human might
147  // can return ODD_SIZED_HOLE and NO_PLANE_NORMAL
149  GU_Detail* gdp,
151  UT_Array<GA_OffsetArray>& originalRings,
152  GA_PrimitiveGroup* patchgroup,
153  GA_PrimitiveGroup* loopgroup,
154  bool smooth,
155  fpreal smoothstrength,
156  bool edgeloop,
157  fpreal edgeloopPercentage);
158 
159  // creates a topologically perfect grid patch by interpolating rows and
160  // columns across the hole. When deformpatch is true, it creates a
161  // GU_NSidedSubdivPatch which guarantees a smooth patch. tanstrength can be
162  // tuned to make it smooth with the surrounding geometry as well. Note that
163  // there can be unfortunate stretching of the outer ring of polygons when
164  // tanstrength is too high. This could be made to scale somehow with the
165  // surrounding geometry size, but when I tried I couldn't find any
166  // reasonable, easy to understand methods.
167  // can return ODD_SIZED_HOLE, ONLY_ONE_CORNER, CONFLICTING_CORNERS
169  GU_Detail* gdp,
171  UT_Array<GA_OffsetArray>& originalRings,
172  GA_PrimitiveGroup* patchgroup,
173  GA_PrimitiveGroup* loopgroup,
174  GA_PointGroup* customcorners,
175  exint corneroffset,
176  bool smooth,
177  fpreal smoothstrength,
178  bool edgeloop,
179  fpreal edgeloopPercentage,
180  bool deformPatch,
181  fpreal ctrTranslation,
182  fpreal tanstrength);
183 } // namespace GU_PolyFill
184 #endif
GU_API exint quads(GU_Detail *gdp, UT_Array< GA_OffsetArray > &rings, UT_Array< GA_OffsetArray > &originalRings, GA_PrimitiveGroup *patchgroup, GA_PrimitiveGroup *loopgroup, bool smooth, fpreal smoothstrength, bool edgeloop, fpreal edgeloopPercentage)
GU_API void singlePolys(GU_Detail *gdp, UT_Array< GA_OffsetArray > &rings, UT_Array< GA_OffsetArray > &ringOrigs, GA_PrimitiveGroup *patchGroup)
GU_API exint perfectGrid(GU_Detail *gdp, UT_Array< GA_OffsetArray > &rings, UT_Array< GA_OffsetArray > &originalRings, GA_PrimitiveGroup *patchgroup, GA_PrimitiveGroup *loopgroup, GA_PointGroup *customcorners, exint corneroffset, bool smooth, fpreal smoothstrength, bool edgeloop, fpreal edgeloopPercentage, bool deformPatch, fpreal ctrTranslation, fpreal tanstrength)
int64 exint
Definition: SYS_Types.h:125
#define GU_API
Definition: GU_API.h:14
GU_API exint fan(GU_Detail *gdp, UT_Array< GA_OffsetArray > &rings, UT_Array< GA_OffsetArray > &ringOrigs, GA_PrimitiveGroup *patchgroup=nullptr, GA_PrimitiveGroup *loopgroup=nullptr, exint degree=3, bool deformpatch=false, fpreal ctrTranslation=0.0, bool edgeloop=false, fpreal edgelooppercentage=0.5)
virtual bool smooth(GA_AttributeOperand &d, GA_AttributeOperand &min, GA_AttributeOperand &max, GA_AttributeOperand &t) const
d = SYSsmooth(min, max, t);
fpreal64 fpreal
Definition: SYS_Types.h:277
GU_API exint quadFan(GU_Detail *gdp, UT_Array< GA_OffsetArray > &rings, UT_Array< GA_OffsetArray > &originalRings, GA_PrimitiveGroup *patchgroup=nullptr, GA_PrimitiveGroup *loopgroup=nullptr, GA_PointGroup *customcorners=nullptr, exint cornerOffset=0, bool deformPatch=false, fpreal ctrTranslation=0.0, bool edgeloop=false, fpreal edgeloopPercentage=0.5)