HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_RefineParms.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: GT_RefineParms.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_RefineParms__
12 #define __GT_RefineParms__
13 
14 #include "GT_API.h"
15 #include <GEO/GEO_Normal.h>
16 #include <GEO/GEO_PackedTypes.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_Options.h>
20 #include "GT_Handles.h"
21 #include "GT_DataArray.h"
22 
24 
26 public:
28  ~GT_RefineParms();
29 
30  /// Hash function
31  unsigned hash() const;
32 
33  /// Comparison test
34  bool isEqual(const GT_RefineParms &src) const;
35 
36  /// @{
37  /// Equivalence operators
38  bool operator==(const GT_RefineParms &src) const
39  { return isEqual(src); }
40  bool operator!=(const GT_RefineParms &src) const
41  { return !isEqual(src); }
42  /// @}
43 
44  /// @{
45  /// Import parameters/options.
46  void set(const char *name, bool v)
47  { myOptions.setOptionB(name, v); }
48  void set(const char *name, exint v)
49  { myOptions.setOptionI(name, v); }
50  void set(const char *name, fpreal v)
51  { myOptions.setOptionF(name, v); }
52  void set(const char *name, const char *v)
53  { myOptions.setOptionS(name, v); }
54  void set(const char *name, UT_Int64Array &v)
55  { myOptions.setOptionIArray(name, v); }
56  void set(const char *name, UT_Fpreal64Array &v)
57  { myOptions.setOptionFArray(name, v); }
58  /// @}
59 
60 
61  /// @{
62  /// Import parameters/options.
63  bool import(const char *name, bool &v) const
64  { return importOption(name, v); }
65  bool import(const char *name, int32 &v) const
66  { return importOption(name, v); }
67  bool import(const char *name, int64 &v) const
68  { return importOption(name, v); }
69  bool import(const char *name, fpreal32 &v) const
70  { return importOption(name, v); }
71  bool import(const char *name, fpreal64 &v) const
72  { return importOption(name, v); }
73  bool import(const char *name, UT_String &v) const
74  { return importOption(name, v); }
75  bool import(const UT_StringRef &name, UT_StringHolder &v) const
76  { return importOption(name, v); }
77  bool import(const char *name, UT_Int64Array &v) const
78  { return importOption(name, v); }
79  bool import(const char *name, UT_Fpreal64Array &v) const
80  { return importOption(name, v); }
81  /// @}
82 
83  /// @{
84  /// Get a defaulted value
85  bool get(const char *name, bool def) const
86  {
87  bool val;
88  return import(name, val) ? val : def;
89  }
90  exint get(const char *name, exint def) const
91  {
92  exint val;
93  return import(name, val) ? val : def;
94  }
95  fpreal get(const char *name, fpreal def) const
96  {
97  fpreal val;
98  return import(name, val) ? val : def;
99  }
100  const char *get(const char *name, const char *def,
101  UT_String &storage) const
102  {
103  return import(name, storage) ? (const char *)storage : def;
104  }
105  /// @}
106 
107  /// @{
108  /// Static methods to get a defaulted parameter, with possibly a NULL
109  /// parameter pointer.
110  static bool getBool(const GT_RefineParms *parms,
111  const char *name, bool def)
112  {
113  return parms ? parms->get(name, def) : def;
114  }
115  static exint getInt(const GT_RefineParms *parms,
116  const char *name, exint def)
117  {
118  return parms ? parms->get(name, def) : def;
119  }
120  static fpreal getFloat(const GT_RefineParms *parms,
121  const char *name, fpreal def)
122  {
123  return parms ? parms->get(name, def) : def;
124  }
125  static const char *getString(const GT_RefineParms *parms,
126  const char *name, const char *def,
128  {
129  return parms
130  ? parms->get(name, def, storage)
131  : def;
132  }
133  /// @}
134 
135  /// @{
136  /// Common parameters
137 
138  /// @def Define get/set method for bool, int, float types
139 #define GT_GETSET(METHOD, NAME, TYPE, DEF) \
140  void set##METHOD(TYPE v) { set(NAME, v); } \
141  TYPE get##METHOD() const { return get(NAME, (TYPE)DEF); } \
142  static TYPE get##METHOD(const GT_RefineParms *parms) \
143  { return parms ? parms->get(NAME,(TYPE)DEF) : (TYPE)DEF; }
144 
145  /// @def Define get/set method for string types
146 #define GT_GETSET_STR(METHOD, NAME, DEF) \
147  void set##METHOD(const char *v) { set(NAME, v); } \
148  const char *get##METHOD(UT_String &storage) const \
149  { return get(NAME, DEF, storage); } \
150  static const char *get##METHOD(const GT_RefineParms *parms, \
151  UT_String &storage) \
152  { return parms ? parms->get(NAME,DEF,storage) : DEF; }
153 
154 #define GT_GETSET_BIT(METHOD, MEMBER, DEF) \
155  void set##METHOD(bool v) { MEMBER = v; } \
156  bool get##METHOD() const { return MEMBER; } \
157  static bool get##METHOD(const GT_RefineParms *parms) \
158  { return parms ? parms->get##METHOD() : DEF; }
159 
160 #define GT_GETSET_INT(METHOD, MEMBER, DEF) \
161  void set##METHOD(exint v) { MEMBER = v; } \
162  exint get##METHOD() const { return MEMBER; } \
163  static exint get##METHOD(const GT_RefineParms *parms) \
164  { return parms ? parms->get##METHOD() : DEF; }
165 
166  /// Render a geometry as a point mesh
167  GT_GETSET (GeoPointMesh, "geo:pointmesh", bool, false)
168 
169  /// Render dangling (unreferenced) points as a point mesh
170  GT_GETSET (ShowUnusedPoints, "geo:unusedpoints", bool, true)
171  /// Render all points, even if not dangled. Requires unusedpoints
172  /// already be set!
173  GT_GETSET (ShowAllPoints, "geo:allpoints", bool, false)
174 
175  /// Use polygon mesh primitives
176  GT_GETSET (GeoPolygonMesh, "geo:polygonmesh", bool, true)
177 
178  /// Refine only a specific group of primitives
179  GT_GETSET_STR(GeoRefineGroup, "geo:refinegroup", NULL)
180 
181  /// Global level of detail
182  GT_GETSET (LOD, "lod", fpreal, 1.0)
183 
184  /// Parametric u level of detail
185  GT_GETSET (ULOD, "ulod", fpreal, 1.0)
186  GT_GETSET (VLOD, "vlod", fpreal, 1.0)
187 
188  /// Quadric parameters
189  GT_GETSET (QuadricDivs, "quadricdivs", fpreal, 20.0)
190 
191  /// Metaball parameters
192  GT_GETSET (MetaMaxDivs, "metamaxdivs", exint, 4096)
193  GT_GETSET (MetaDensity, "metadensity", fpreal, 30.0)
194 
195  /// Parametric u/v range
196  GT_GETSET (URange0, "urange_min", fpreal, 0.0)
197  GT_GETSET (URange1, "urange_max", fpreal, 1.0)
198  GT_GETSET (VRange0, "vrange_min", fpreal, 0.0)
199  GT_GETSET (VRange1, "vrange_max", fpreal, 1.0)
200 
201  /// Whether to respect the packed primitive viewport LOD. This is set for
202  /// viewport rendering, but not for mantra.
203  GT_GETSET_BIT(PackedViewportLOD, myPackedViewLOD, false)
204 
205  /// Override the viewport LOD for packed primitives. The value should be
206  /// set to one of the enum values in $GEO/GEO_PackedTypes.h
207  GT_GETSET_INT(OverridePackedViewportLOD, myOverridePackedLOD, -1);
208 
209  /// The maximum number of LOD levels for agents.
210  GT_GETSET (ViewportAgentMaxLOD, "agent:maxlod", exint, 4)
211 
212  /// The minimum number of polygons for an LOD level; will halt the LOD.
213  GT_GETSET (ViewportAgentPointLimit, "agent:pointlimit", exint, 1000)
214 
215  /// Whether to enable the viewport specific code when refining agents.
216  GT_GETSET (RefineAgentsForViewport, "agent:refineviewport", bool, false)
217 
218  /// Whether to refine the collision layer (if available) for agents instead
219  /// of their current layer.
220  GT_GETSET (UseAgentCollisionLayer, "agent:collisionlayer", bool, false)
221 
222  /// @{
223  /// When loading Alembic for the viewport, (i.e. when PackedViewportLOD is
224  /// true), we check the following settings to determine whether to load
225  /// face sets and arbitrary attributes.
226  GT_GETSET_BIT(ViewportAlembicFaceSets, myAlembicFaceSets, false)
227  GT_GETSET_BIT(ViewportAlembicArbGeometry, myAlembicArbGeo, true)
228  /// @}
229  GT_GETSET_BIT(AlembicHoudiniAttribs, myAlembicHoudiniAttribs, true)
230  GT_GETSET_BIT(AlembicInstancing, myAlembicInstancing, false)
231  GT_GETSET_BIT(AlembicGLOptimize, myAlembicGLOptimize, false)
232  GT_GETSET_BIT(PointInstanceEnable, myPointInstanceEnable, false)
233 
234 
235  /// When unpacking Alembic, prune geometry that isn't visible. If this is
236  /// false, empty geometry will be created.
237  GT_GETSET_BIT(AlembicSkipInvisible, myAlembicSkipInvisible, true)
238 
239  /// Whether to include primitive/vertex id's when converting to geo
240  GT_GETSET (ConvertIncludeIds, "gconvert:include_ids", bool, false)
241  /// Convert point clouds into a particle primitive (instead of unconnected
242  /// points).
243  GT_GETSET (ConvertParticlePrim, "gconvert:particleprim", bool, false)
244  /// When converting from GT to GU, create packed geometry containing the
245  /// converted GU details.
246  GT_GETSET (ConvertPack, "gconvert:pack", bool, false)
247  /// Convert to Polygon Soup primitives if possible
248  GT_GETSET (AllowPolySoup, "gconvert:allow_polysoup", bool, true)
249  /// When converting from GU_Detail to GT primitives, create a subdivivision
250  /// surface for polygons (instead of a GT_PrimPolygonMesh).
251  GT_GETSET_BIT(PolysAsSubdivision, mySubdivPolys, false)
252  /// Allow display of GT_PrimSubdivisionMeshes as subd surfaces. This won't
253  /// create subd surfaces for regular polygons meshes like the above option.
254  GT_GETSET_BIT(AllowSubdivision, myAllowSubdivPolys, false)
255 
256  /// Whether to coalesce fragments into a single mesh. In most cases, the
257  /// fragment geometry is constant over time, while only the transform
258  /// changes. Some applications prefer getting a large chunk of geometry
259  /// rather than lots of little pieces. Others prefer to use the fact that
260  /// only the transform is animated.
261  GT_GETSET (CoalesceFragments, "coalescefragments", bool, true);
262 
263  /// Whether to coalesce volumes into a single GT_Primitive. Mantra and
264  /// probably most uses of GT require this to be true but at least HAPI
265  /// likes to have volumes be kept as separate GT_Primitives.
266  GT_GETSET (CoalesceVolumes, "coalescevolumes", bool, true);
267 
268  enum
269  {
270  FACESET_NONE = 0, // Don't create facesets
271  FACESET_NON_EMPTY, // Create face sets for non-empty groups
272  FACESET_ALL_GROUPS, // Create face sets for all groups
273  };
274  /// When building polygon/curve meshes from geometry, optionally build a
275  /// "face set" to store group information in the meshes.
276  GT_GETSET (FaceSetMode, "facesetmode", exint, FACESET_NONE)
277 
278  /// When collecting polygons, there are some simple/fast heuristics to
279  /// check whether point attributes need to be compacted. However, this
280  /// doesn't always catch cases if there are stray points (unconnected
281  /// points) in the geometry. If you want precise polygonal meshes, you can
282  /// disable fast detection.
283  GT_GETSET (FastPolyCompacting, "fastpolycompacting", bool, true);
284 
285  /// When collecting polygons, if there are no point or vertex normals
286  /// on the incoming geometry, this indicates whether to compute and add
287  /// vertex normals to the GT_PrimPolygonMesh.
288  GT_GETSET (AddVertexNormals, "addvertexnormals", bool, false);
289 
290  /// When adding vertex normals, this is the cusp angle to use.
291  /// If the dihedral angle of an edge is larger than this, it will be cusped.
292  GT_GETSET (CuspAngle, "cuspangle", float,GEO_DEFAULT_ADJUSTED_CUSP_ANGLE);
293 
294  /// Maximum number of points in a point mesh. This is used when refining a
295  /// GEO_Detail.
296  GT_GETSET (MaxPointMeshSize, "maxpointmeshsize", exint, -1)
297 
298  /// Maximum number of points in a point mesh. This is used when refining a
299  /// GEO_Detail.
300  GT_GETSET (MaxPolyMeshSize, "maxpolymeshsize", exint, -1)
301 
302  /// Number of sub-frame timesteps used when unpacking sequence packed
303  /// primitives. Each sub-step requires a blended detail. A value of -1
304  /// indicated no quantization, 0 will use only keyframe values, 1 will have
305  /// one sub-frame (i.e. 0.5), etc.
306  GT_GETSET (SequenceSubsteps, "sequencesubsteps", exint, -1)
307 
308  /// When creating instances during refining, rather than creating an
309  /// instance with multiple transforms for the geometry, create separate
310  /// instances, but still with a single shared GT_Primitive. This helps
311  /// create aligned instances when trying to match segments for motion blur.
312  GT_GETSET (SeparateInstances, "separateinstance", bool, false)
313 
314  /// When refining Houdini curves (NURBs/Bezier), generate Bezier curve
315  /// meshes along with NURBS curve meshes where appropriate. Otherwise,
316  /// only NURBS curves will be generated.
317  GT_GETSET (FullBezierSupport, "fullBezierSupport", bool, true);
318  /// If full Beziers aren't supported, still refine cubic Bezier curves to a
319  /// pure Bezier curve mesh.
320  GT_GETSET (CubicBezierSupport, "cubicBezierSupport", bool, true);
321 
322  /// Whether to refine capture regions to curves (e.g. as required by the
323  /// viewport) or to polygons.
324  GT_GETSET (RefineCRegionsToCurves, "refinecregionstocurves", bool, false)
325 
326  /// Prune geometry that is hidden.
327  GT_GETSET_BIT(SkipHidden, mySkipHidden, true)
328 
329  /// After height field volumes are coalesced, refine them into
330  /// GT_PrimPolygonMesh (or GT_PrimSubdivisionMesh if PolysAsSubdivision
331  /// option is enabled) instead of GT_PrimVolume(s).
332  GT_GETSET (HeightFieldConvert, "heightfieldconvert", bool, false);
333 
334 #undef GT_IMPLEMENT_GETSET
335 #undef GT_IMPLEMENT_GETSET_STR
336 
338  { return myViewportMaterialAttrib; }
340  { return myViewportMaterialRemapAttrib; }
342  const GT_DataArrayHandle &rh)
343  { myViewportMaterialAttrib = mh;
344  myViewportMaterialRemapAttrib = rh; }
345 
347  { myAttribFilter = af; }
349  { return myAttribFilter; }
350 
351  /// Load from UT_Options
352  bool load(const UT_Options &opts);
353 
354  /// @{
355  /// Debugging methods to dump the non-default parameters. Dump to either
356  /// stdout or a string buffer.
357  void dump() const;
358  bool dump(UT_WorkBuffer &buf) const;
359  /// @}
360 
361 public:
362  /// @{
363  /// For memory tracking, we override the new/delete operators
364  static void *operator new(size_t size);
365  static void *operator new(size_t size, void *p);
366  static void operator delete(void *p, size_t size);
367  /// @}
368 
369 protected:
370  template <typename T> bool
371  importOption(const char *name, T &value) const
372  {
373  return myOptions.importOption(name, value);
374  }
375 private:
376  UT_Options myOptions;
377  int myAlembicArbGeo : 1,
378  myAlembicFaceSets : 1,
379  myAlembicHoudiniAttribs : 1,
380  myAlembicInstancing : 1,
381  myAlembicGLOptimize : 1,
382  myAlembicSkipInvisible : 1,
383  myPackedViewLOD : 1,
384  mySubdivPolys : 1,
385  myAllowSubdivPolys : 1,
386  myPointInstanceEnable : 1,
387  myOverridePackedLOD : 5,
388  mySkipHidden : 1;
389  GT_DataArrayHandle myViewportMaterialAttrib;
390  GT_DataArrayHandle myViewportMaterialRemapAttrib;
391  const GT_GEOAttributeFilter *myAttribFilter;
392 };
393 
394 #endif
void set(const char *name, bool v)
void set(const char *name, fpreal v)
void setViewportMaterialAttrib(const GT_DataArrayHandle &mh, const GT_DataArrayHandle &rh)
static exint getInt(const GT_RefineParms *parms, const char *name, exint def)
#define GT_GETSET_BIT(METHOD, MEMBER, DEF)
static const char * getString(const GT_RefineParms *parms, const char *name, const char *def, UT_String &storage)
GT_DataArrayHandle getViewportMaterialRemapAttrib() const
int int32
Definition: SYS_Types.h:39
#define GT_GETSET_INT(METHOD, MEMBER, DEF)
Class to filter attributes when building GT_AttributeLists.
#define GT_API
Definition: GT_API.h:11
int64 exint
Definition: SYS_Types.h:125
#define GT_GETSET(METHOD, NAME, TYPE, DEF)
GLuint const GLchar * name
Definition: glcorearb.h:785
void set(const char *name, UT_Int64Array &v)
GLenum src
Definition: glcorearb.h:1792
float fpreal32
Definition: SYS_Types.h:200
GLsizeiptr size
Definition: glcorearb.h:663
double fpreal64
Definition: SYS_Types.h:201
static fpreal getFloat(const GT_RefineParms *parms, const char *name, fpreal def)
#define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
Definition: GEO_Normal.h:28
bool operator!=(const GT_RefineParms &src) const
GT_DataArrayHandle getViewportMaterialAttrib() const
void set(const char *name, exint v)
const GLdouble * v
Definition: glcorearb.h:836
void set(const char *name, const char *v)
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
#define GT_GETSET_STR(METHOD, NAME, DEF)
bool get(const char *name, bool def) const
void setAttributeFilter(const GT_GEOAttributeFilter *af)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
const GT_GEOAttributeFilter * getAttributeFilter() const
GLuint GLfloat * val
Definition: glcorearb.h:1607
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
void set(const char *name, UT_Fpreal64Array &v)
static bool getBool(const GT_RefineParms *parms, const char *name, bool def)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
bool importOption(const char *name, T &value) const
GLint lod
Definition: glcorearb.h:2764
bool operator==(const GT_RefineParms &src) const