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