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