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