HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Defines.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  * COMMENTS:
7  */
8 
9 #ifndef __HOM_Defines_h__
10 #define __HOM_Defines_h__
11 
12 #include <UT/UT_Assert.h>
13 
14 // Unfortunately, we can't compare against UT_ASSERT_LEVEL_PARANOID here,
15 // otherwise the comparison sometimes succeeds under swig when it shouldn't.
16 // So, we instead compare against the numeric value itself.
17 #if UT_ASSERT_LEVEL >= 2
18 #define HOM_DEBUG
19 #endif
20 
21 #ifdef SWIG
22 #define SWIGOUT(x) x
23 #else
24 #define SWIGOUT(x)
25 #endif
26 
27 #if defined(SWIG) && defined(SWIGPYTHON)
28 #define SWIGPYTHONOUT(x) x
29 #else
30 #define SWIGPYTHONOUT(x)
31 #endif
32 
33 // Define a synonym for hboost::any to customize a typemap for arguments that
34 // are to hold values to be inserted into a UT_Options object. SWIG allows
35 // typemaps to be defined for each typename independently.
36 #include <hboost/any.hpp>
37 typedef hboost::any HOM_UTOptionAny;
38 
39 // Define a synonym for hboost::any to customize a typemap for arguments that
40 // are to return drag-n-drop source data. SWIG allows typemaps to be defined
41 // for each typename independently.
42 typedef hboost::any HOM_DDSourceAny;
43 
44 // The following define should go in SYS_Math.h when we are ready to
45 // add equivalent defines for MAX_DOUBLE, MAX_INT, MIN_INT etc.
46 #define HOM_MIN_NEGATIVE_DOUBLE -1 * std::numeric_limits<double>::max()
47 
48 #ifdef SWIG
49 
50 //----------------------------------------------------------------------------
51 
52 // Since there's no way for a C++ function to have varying return types,
53 // we need to add special methods and functions that are only known
54 // to swig. For python, there's a typemap for PyObject* so that when
55 // swig encounters a function returning that type it won't try to wrap
56 // the return value, and will instead send it directly to the interpreter.
57 // We create a typemap for this type so our code can use it instead of
58 // PyObject* directly so it's easier to use more than just python in the
59 // future.
60 
61 // The swig code we output directly to the swig wrapper below (using %{%})
62 // uses InterpreterObject, so we need to say what it is.
63 %{
64 #ifdef SWIGPYTHON
65 typedef PyObject *InterpreterObject;
66 
67 PyObject *HOMincRef(PyObject *object)
68 {
69  if (!object)
70  object = Py_None;
71  Py_INCREF(object);
72  return object;
73 }
74 #endif
75 %}
76 
77 // We need to tell swig what InterpreterObject is so it applies the PyObject*
78 // typemap properly.
79 typedef PyObject *InterpreterObject;
80 
81 //----------------------------------------------------------------------------
82 
83 %{
84 
85 #include <UT/UT_StdUtil.h>
86 
87 // These helper functions convert from C++ objects to corresponding
88 // interpreter objects (PyObject*'s in python). They're roughly the same
89 // as swig::from(), but swig::from() does a slow lookup on the name of the
90 // type. These functions know the type at compile-time so they're faster.
91 // Unfortunately, we need to explicitly specialize all the types supported by
92 // the functions. Specifically, since HOM_IterableList calls these functions,
93 // objects that can be inside HOM_IterableList need to be specialized below.
94 
95 // The general case is left unimplemented so we get compiler errors if
96 // we call the function with an unspecialized type.
97 template <typename T> InterpreterObject
98 HOMconvertValueForInterpreter(const T &value, int own);
99 
100 // These functions specialize the native data types.
101 template <> InterpreterObject
102 HOMconvertValueForInterpreter<int>(const int& value, int /*own*/)
103 { return SWIG_From_int(value); }
104 
105 template <> InterpreterObject
106 HOMconvertValueForInterpreter<float>(const float& value, int /*own*/)
107 { return SWIG_From_float(value); }
108 
109 template <> InterpreterObject
110 HOMconvertValueForInterpreter<double>(const double& value, int /*own*/)
111 { return SWIG_From_double(value); }
112 
113 template <> InterpreterObject
114 HOMconvertValueForInterpreter<std::string>(
115  const std::string& value, int /*own*/)
116 { return SWIG_From_std_string(value); }
117 
118 // These functions specialize base classes to return interpreter instances
119 // of the proper subclass.
120 template <> InterpreterObject
121 HOMconvertValueForInterpreter<HOM_Node*>(HOM_Node *const &node, int own)
122 {
123  PY_InterpreterAutoLock py_lock;
124  OP_OpTypeId optypeid;
125 
126  if (!node)
127  return SWIG_NewPointerObj(node, SWIGTYPE_p_HOM_Node, own);
128 
129  optypeid = (OP_OpTypeId)node->opTypeIdAsInt();
130  switch (optypeid)
131  {
132  case OBJ_OPTYPE_ID:
133  // Because of multiple inheritance, it's extremely important that
134  // we explicitly cast the pointer to a HOM_ObjNode so we
135  // pass the right address to SWIG_NewPointerObject, since it takes
136  // a void*.
137  return SWIG_NewPointerObj(
138  (void*)dynamic_cast<const HOM_ObjNode* const>(node),
139  SWIGTYPE_p_HOM_ObjNode, own);
140 
141  case SOP_OPTYPE_ID:
142  // Because of multiple inheritance, it's extremely important that
143  // we explicitly cast the pointer to a HOM_SopNode so we
144  // pass the right address to SWIG_NewPointerObject, since it takes
145  // a void*.
146  return SWIG_NewPointerObj(
147  (void*)dynamic_cast<const HOM_SopNode* const>(node),
148  SWIGTYPE_p_HOM_SopNode, own);
149 
150  case CHOP_OPTYPE_ID:
151  // Because of multiple inheritance, it's extremely important that
152  // we explicitly cast the pointer to a HOM_ChopNode so we
153  // pass the right address to SWIG_NewPointerObject, since it takes
154  // a void*.
155  return SWIG_NewPointerObj(
156  (void*)dynamic_cast<const HOM_ChopNode* const>(node),
157  SWIGTYPE_p_HOM_ChopNode, own);
158 
159  case COP2_OPTYPE_ID:
160  // Because of multiple inheritance, it's extremely important that
161  // we explicitly cast the pointer to a HOM_CopNode so we
162  // pass the right address to SWIG_NewPointerObject, since it takes
163  // a void*.
164  return SWIG_NewPointerObj(
165  (void*)dynamic_cast<const HOM_CopNode* const>(node),
166  SWIGTYPE_p_HOM_CopNode, own);
167 
168  case DOP_OPTYPE_ID:
169  // Because of multiple inheritance, it's extremely important that
170  // we explicitly cast the pointer to a HOM_DopNode so we
171  // pass the right address to SWIG_NewPointerObject, since it takes
172  // a void*.
173  return SWIG_NewPointerObj(
174  (void*)dynamic_cast<const HOM_DopNode* const>(node),
175  SWIGTYPE_p_HOM_DopNode, own);
176 
177  case POP_OPTYPE_ID:
178  // Because of multiple inheritance, it's extremely important that
179  // we explicitly cast the pointer to a HOM_PopNode so we
180  // pass the right address to SWIG_NewPointerObject, since it takes
181  // a void*.
182  return SWIG_NewPointerObj(
183  (void*)dynamic_cast<const HOM_PopNode* const>(node),
184  SWIGTYPE_p_HOM_PopNode, own);
185 
186  case POPNET_OPTYPE_ID:
187  // Because of multiple inheritance, it's extremely important that
188  // we explicitly cast the pointer to a HOM_PopNetNode so we
189  // pass the right address to SWIG_NewPointerObject, since it takes
190  // a void*.
191  return SWIG_NewPointerObj(
192  (void*)dynamic_cast<const HOM_PopNetNode* const>(node),
193  SWIGTYPE_p_HOM_PopNetNode, own);
194 
195  case SHOP_OPTYPE_ID:
196  // Because of multiple inheritance, it's extremely important that
197  // we explicitly cast the pointer to a HOM_ShopNode so we
198  // pass the right address to SWIG_NewPointerObject, since it takes
199  // a void*.
200  return SWIG_NewPointerObj(
201  (void*)dynamic_cast<const HOM_ShopNode* const>(node),
202  SWIGTYPE_p_HOM_ShopNode, own);
203 
204  case VOPNET_OPTYPE_ID:
205  // Because of multiple inheritance, it's extremely important that
206  // we explicitly cast the pointer to a HOM_VopNetNode so we
207  // pass the right address to SWIG_NewPointerObject, since it takes
208  // a void*.
209  return SWIG_NewPointerObj(
210  (void*)dynamic_cast<const HOM_VopNetNode* const>(node),
211  SWIGTYPE_p_HOM_VopNetNode, own);
212 
213  case ROP_OPTYPE_ID:
214  // Because of multiple inheritance, it's extremely important that
215  // we explicitly cast the pointer to a HOM_RopNode so we
216  // pass the right address to SWIG_NewPointerObject, since it takes
217  // a void*.
218  return SWIG_NewPointerObj(
219  (void*)dynamic_cast<const HOM_RopNode* const>(node),
220  SWIGTYPE_p_HOM_RopNode, own);
221 
222  case VOP_OPTYPE_ID:
223  // Because of multiple inheritance, it's extremely important that
224  // we explicitly cast the pointer to a HOM_VopNode so we
225  // pass the right address to SWIG_NewPointerObject, since it takes
226  // a void*.
227  return SWIG_NewPointerObj(
228  (void*)dynamic_cast<const HOM_VopNode* const>(node),
229  SWIGTYPE_p_HOM_VopNode, own);
230 
231  case TOP_OPTYPE_ID:
232  // Because of multiple inheritance, it's extremely important that
233  // we explicitly cast the pointer to a HOM_TopNode so we
234  // pass the right address to SWIG_NewPointerObject, since it takes
235  // a void*.
236  return SWIG_NewPointerObj(
237  (void*)dynamic_cast<const HOM_TopNode* const>(node),
238  SWIGTYPE_p_HOM_TopNode, own);
239 
240  case LOP_OPTYPE_ID:
241  // Because of multiple inheritance, it's extremely important that
242  // we explicitly cast the pointer to a HOM_LopNode so we
243  // pass the right address to SWIG_NewPointerObject, since it takes
244  // a void*.
245  return SWIG_NewPointerObj(
246  (void*)dynamic_cast<const HOM_LopNode* const>(node),
247  SWIGTYPE_p_HOM_LopNode, own);
248 
249  case MGR_OPTYPE_ID:
250  // Special case for the /stage manager node, which is actually a
251  // LOP_Network, and therefore a LOP_Node.
252  if (HOM().lopNodeTypeCategory() == node->childTypeCategory())
253  return SWIG_NewPointerObj(
254  (void*)dynamic_cast<const HOM_LopNode* const>(node),
255  SWIGTYPE_p_HOM_LopNode, own);
256 
257  default:
258  break;
259  };
260 
261  return SWIG_NewPointerObj(node, SWIGTYPE_p_HOM_Node, own);
262 }
263 
264 template <> InterpreterObject
265 HOMconvertValueForInterpreter<HOM_NodeType*>(
266  HOM_NodeType *const &nodetype, int own)
267 {
268  PY_InterpreterAutoLock py_lock;
269  OP_OpTypeId optypeid;
270 
271  if (!nodetype)
272  return SWIG_NewPointerObj(nodetype, SWIGTYPE_p_HOM_NodeType, own);
273 
274  if( !nodetype->managerFlag() )
275  {
276  optypeid = (OP_OpTypeId)nodetype->opTypeIdAsInt();
277  switch (optypeid)
278  {
279  case SOP_OPTYPE_ID:
280  // Because of multiple inheritance, it's extremely important that
281  // we explicitly cast the pointer to a HOM_SopNodeType so we
282  // pass the right address to SWIG_NewPointerObject, since it takes
283  // a void*.
284  return SWIG_NewPointerObj(
285  (void*)dynamic_cast<const HOM_SopNodeType* const>(nodetype),
286  SWIGTYPE_p_HOM_SopNodeType, own);
287 
288  case SHOP_OPTYPE_ID:
289  // Because of multiple inheritance, it's extremely important that
290  // we explicitly cast the pointer to a HOM_ShopNodeType so we
291  // pass the right address to SWIG_NewPointerObject, since it takes
292  // a void*.
293  return SWIG_NewPointerObj(
294  (void*)dynamic_cast<const HOM_ShopNodeType* const>(nodetype),
295  SWIGTYPE_p_HOM_ShopNodeType, own);
296 
297  case VOP_OPTYPE_ID:
298  // Because of multiple inheritance, it's extremely important that
299  // we explicitly cast the pointer to a HOM_VopNodeType so we
300  // pass the right address to SWIG_NewPointerObject, since it takes
301  // a void*.
302  return SWIG_NewPointerObj(
303  (void*)dynamic_cast<const HOM_VopNodeType* const>(nodetype),
304  SWIGTYPE_p_HOM_VopNodeType, own);
305  default:
306  break;
307  }
308  }
309 
310  return SWIG_NewPointerObj(nodetype, SWIGTYPE_p_HOM_NodeType, own);
311 }
312 
313 template <> InterpreterObject
314 HOMconvertValueForInterpreter<HOM_BaseKeyframe*>(
315  HOM_BaseKeyframe *const &keyframe, int own)
316 {
317  PY_InterpreterAutoLock py_lock;
318 
319  if (!keyframe)
320  return SWIG_NewPointerObj(keyframe, SWIGTYPE_p_HOM_BaseKeyframe, own);
321 
322  if (keyframe->evaluatedType() == HOM_parmData::Float)
323  {
324  // Because of multiple inheritance, it's extremely important that
325  // we explicitly cast the pointer to a HOM_Keyframe so we
326  // pass the right address to SWIG_NewPointerObject, since it takes
327  // a void*.
328  return SWIG_NewPointerObj(
329  (void*)dynamic_cast<const HOM_Keyframe* const>(keyframe),
330  SWIGTYPE_p_HOM_Keyframe, own);
331  }
332  else if (keyframe->evaluatedType() == HOM_parmData::String)
333  {
334  // Because of multiple inheritance, it's extremely important that
335  // we explicitly cast the pointer to a HOM_Keyframe so we
336  // pass the right address to SWIG_NewPointerObject, since it takes
337  // a void*.
338  return SWIG_NewPointerObj(
339  (void*)dynamic_cast<const HOM_StringKeyframe* const>(keyframe),
340  SWIGTYPE_p_HOM_StringKeyframe, own);
341  }
342 
343  return SWIG_NewPointerObj(keyframe, SWIGTYPE_p_HOM_BaseKeyframe, own);
344 }
345 
346 template <> InterpreterObject
347 HOMconvertValueForInterpreter<HOM_PackedPrim*>(HOM_PackedPrim *const &prim, int own)
348 {
349  PY_InterpreterAutoLock py_lock;
350 
351  if (!prim)
352  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_PackedPrim, own);
353 
354  // Because of multiple inheritance, it's extremely important that
355  // we explicitly cast the pointer to the right HOM type so we
356  // pass the right address to SWIG_NewPointerObject, since it takes
357  // a void*.
358 
359  switch (prim->type().id())
360  {
361  case HOM_primType::Agent_Id:
362  return SWIG_NewPointerObj(
363  (void *)dynamic_cast<const HOM_Agent *const>(prim),
364  SWIGTYPE_p_HOM_Agent, own);
365 
366  case HOM_primType::PackedFragment_Id:
367  return SWIG_NewPointerObj(
368  (void *)dynamic_cast<const HOM_PackedFragment *const>(prim),
369  SWIGTYPE_p_HOM_PackedFragment, own);
370 
371  case HOM_primType::PackedGeometry_Id:
372  return SWIG_NewPointerObj(
373  (void *)dynamic_cast<const HOM_PackedGeometry *const>(prim),
374  SWIGTYPE_p_HOM_PackedGeometry, own);
375  }
376 
377  return SWIG_NewPointerObj(
378  (void *)dynamic_cast<const HOM_PackedPrim *const>(prim),
379  SWIGTYPE_p_HOM_PackedPrim, own);
380 }
381 
382 template <> InterpreterObject
383 HOMconvertValueForInterpreter<HOM_Prim*>(HOM_Prim *const &prim, int own)
384 {
385  PY_InterpreterAutoLock py_lock;
386 
387  if (!prim)
388  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_Prim, own);
389 
390  // Because of multiple inheritance, it's extremely important that
391  // we explicitly cast the pointer to the right HOM type so we
392  // pass the right address to SWIG_NewPointerObject, since it takes
393  // a void*.
394  HOM_PackedPrim * packed = dynamic_cast<HOM_PackedPrim *>(prim);
395  if(packed)
396  return HOMconvertValueForInterpreter(packed, own);
397 
398  switch (prim->type().id())
399  {
400  case HOM_primType::Polygon_Id:
401  return SWIG_NewPointerObj(
402  (void*)dynamic_cast<const HOM_Polygon* const>(prim),
403  SWIGTYPE_p_HOM_Polygon, own);
404 
405  case HOM_primType::NURBSCurve_Id:
406  case HOM_primType::BezierCurve_Id:
407  return SWIG_NewPointerObj(
408  (void*)dynamic_cast<const HOM_Face* const>(prim),
409  SWIGTYPE_p_HOM_Face, own);
410 
411  case HOM_primType::Mesh_Id:
412  case HOM_primType::NURBSSurface_Id:
413  case HOM_primType::BezierSurface_Id:
414  return SWIG_NewPointerObj(
415  (void*)dynamic_cast<const HOM_Surface* const>(prim),
416  SWIGTYPE_p_HOM_Surface, own);
417 
418  case HOM_primType::Circle_Id:
419  case HOM_primType::Sphere_Id:
420  case HOM_primType::Tube_Id:
421  return SWIG_NewPointerObj(
422  (void*)dynamic_cast<const HOM_Quadric* const>(prim),
423  SWIGTYPE_p_HOM_Quadric, own);
424 
425  case HOM_primType::Volume_Id:
426  return SWIG_NewPointerObj(
427  (void*)dynamic_cast<const HOM_Volume* const>(prim),
428  SWIGTYPE_p_HOM_Volume, own);
429 
430  case HOM_primType::VDB_Id:
431  return SWIG_NewPointerObj(
432  (void*)dynamic_cast<const HOM_VDB* const>(prim),
433  SWIGTYPE_p_HOM_VDB, own);
434 
435  // TODO: Support more primitive types.
436  }
437 
438  return SWIG_NewPointerObj(prim, SWIGTYPE_p_HOM_Prim, own);
439 }
440 
441 template <> InterpreterObject
442 HOMconvertValueForInterpreter<HOM_ParmTemplate*>(
443  HOM_ParmTemplate *const &parm_template, int own)
444 {
445  PY_InterpreterAutoLock py_lock;
446 
447  if (!parm_template)
448  return SWIG_NewPointerObj(
449  parm_template, SWIGTYPE_p_HOM_ParmTemplate, own);
450 
451  // Because of multiple inheritance, it's extremely important that we
452  // explicitly cast to a pointer to the subclass so we pass the right
453  // address to SWIG_NewPointerObject, since it takes a void*.
454  switch (parm_template->type().id())
455  {
456  case HOM_parmTemplateType::Int_Id:
457  return SWIG_NewPointerObj(
458  (void*)dynamic_cast<const HOM_IntParmTemplate* const>(
459  parm_template),
460  SWIGTYPE_p_HOM_IntParmTemplate, own);
461 
462  case HOM_parmTemplateType::Float_Id:
463  return SWIG_NewPointerObj(
464  (void*)dynamic_cast<const HOM_FloatParmTemplate* const>(
465  parm_template),
466  SWIGTYPE_p_HOM_FloatParmTemplate, own);
467 
468  case HOM_parmTemplateType::String_Id:
469  return SWIG_NewPointerObj(
470  (void*)dynamic_cast<const HOM_StringParmTemplate* const>(
471  parm_template),
472  SWIGTYPE_p_HOM_StringParmTemplate, own);
473 
474  case HOM_parmTemplateType::Data_Id:
475  return SWIG_NewPointerObj(
476  (void*)dynamic_cast<const HOM_DataParmTemplate* const>(
477  parm_template),
478  SWIGTYPE_p_HOM_DataParmTemplate, own);
479 
480  case HOM_parmTemplateType::Toggle_Id:
481  return SWIG_NewPointerObj(
482  (void*)dynamic_cast<const HOM_ToggleParmTemplate* const>(
483  parm_template),
484  SWIGTYPE_p_HOM_ToggleParmTemplate, own);
485 
486  case HOM_parmTemplateType::Menu_Id:
487  return SWIG_NewPointerObj(
488  (void*)dynamic_cast<const HOM_MenuParmTemplate* const>(
489  parm_template),
490  SWIGTYPE_p_HOM_MenuParmTemplate, own);
491 
492  case HOM_parmTemplateType::Button_Id:
493  return SWIG_NewPointerObj(
494  (void*)dynamic_cast<const HOM_ButtonParmTemplate* const>(
495  parm_template),
496  SWIGTYPE_p_HOM_ButtonParmTemplate, own);
497 
498  case HOM_parmTemplateType::Label_Id:
499  return SWIG_NewPointerObj(
500  (void*)dynamic_cast<const HOM_LabelParmTemplate* const>(
501  parm_template),
502  SWIGTYPE_p_HOM_LabelParmTemplate, own);
503 
504  case HOM_parmTemplateType::Separator_Id:
505  return SWIG_NewPointerObj(
506  (void*)dynamic_cast<const HOM_SeparatorParmTemplate* const>(
507  parm_template),
508  SWIGTYPE_p_HOM_SeparatorParmTemplate, own);
509 
510  case HOM_parmTemplateType::FolderSet_Id:
511  return SWIG_NewPointerObj(
512  (void*)dynamic_cast<const HOM_FolderSetParmTemplate* const>(
513  parm_template),
514  SWIGTYPE_p_HOM_FolderSetParmTemplate, own);
515 
516  case HOM_parmTemplateType::Folder_Id:
517  return SWIG_NewPointerObj(
518  (void*)dynamic_cast<const HOM_FolderParmTemplate* const>(
519  parm_template),
520  SWIGTYPE_p_HOM_FolderParmTemplate, own);
521 
522  case HOM_parmTemplateType::Ramp_Id:
523  return SWIG_NewPointerObj(
524  (void*)dynamic_cast<const HOM_RampParmTemplate* const>(
525  parm_template),
526  SWIGTYPE_p_HOM_RampParmTemplate, own);
527  };
528 
529  UT_ASSERT(!"Unknown parm template type");
530  return SWIG_NewPointerObj(parm_template, SWIGTYPE_p_HOM_ParmTemplate, own);
531 }
532 
533 template <> InterpreterObject
534 HOMconvertValueForInterpreter<HOM_PaneTab*>(
535  HOM_PaneTab *const &pane_tab, int own)
536 {
537  PY_InterpreterAutoLock py_lock;
538 
539  if (!pane_tab)
540  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
541 
542  // Because of multiple inheritance, it's extremely important that
543  // we explicitly cast the pointer to the HOM type so we pass the right
544  // address to SWIG_NewPointerObject, since it takes a void*.
545 
546  switch (pane_tab->type().id())
547  {
548  case HOM_paneTabType::ContextViewer_Id:
549  return SWIG_NewPointerObj(
550  (void*)dynamic_cast<const HOM_ContextViewer* const>(pane_tab),
551  SWIGTYPE_p_HOM_ContextViewer, own);
552 
553  case HOM_paneTabType::SceneViewer_Id:
554  return SWIG_NewPointerObj(
555  (void*)dynamic_cast<const HOM_SceneViewer* const>(pane_tab),
556  SWIGTYPE_p_HOM_SceneViewer, own);
557 
558  case HOM_paneTabType::CompositorViewer_Id:
559  return SWIG_NewPointerObj(
560  (void*)dynamic_cast<const HOM_CompositorViewer* const>(pane_tab),
561  SWIGTYPE_p_HOM_CompositorViewer, own);
562 
563  case HOM_paneTabType::NetworkEditor_Id:
564  return SWIG_NewPointerObj(
565  (void*)dynamic_cast<const HOM_NetworkEditor* const>(pane_tab),
566  SWIGTYPE_p_HOM_NetworkEditor, own);
567 
568  case HOM_paneTabType::HelpBrowser_Id:
569  return SWIG_NewPointerObj(
570  (void*)dynamic_cast<const HOM_HelpBrowser* const>(pane_tab),
571  SWIGTYPE_p_HOM_HelpBrowser, own);
572 
573  case HOM_paneTabType::PythonPanel_Id:
574  return SWIG_NewPointerObj(
575  (void*)dynamic_cast<const HOM_PythonPanel* const>(pane_tab),
576  SWIGTYPE_p_HOM_PythonPanel, own);
577 
578  case HOM_paneTabType::IPRViewer_Id:
579  return SWIG_NewPointerObj(
580  (void*)dynamic_cast<const HOM_IPRViewer* const>(pane_tab),
581  SWIGTYPE_p_HOM_IPRViewer, own);
582 
583  case HOM_paneTabType::AssetBrowser_Id:
584  return SWIG_NewPointerObj(
585  (void*)dynamic_cast<const HOM_AssetBrowser* const>(pane_tab),
586  SWIGTYPE_p_HOM_AssetBrowser, own);
587 
588  case HOM_paneTabType::PerformanceMonitor_Id:
589  return SWIG_NewPointerObj(
590  (void*)dynamic_cast<const HOM_PerformanceMonitor* const>(pane_tab),
591  SWIGTYPE_p_HOM_PerformanceMonitor, own);
592 
593  case HOM_paneTabType::ChannelEditor_Id:
594  return SWIG_NewPointerObj(
595  (void*)dynamic_cast<const HOM_ChannelEditorPane* const>(pane_tab),
596  SWIGTYPE_p_HOM_ChannelEditorPane, own);
597 
598  case HOM_paneTabType::DataTree_Id:
599  return SWIG_NewPointerObj(
600  (void*)dynamic_cast<const HOM_DataTree* const>(pane_tab),
601  SWIGTYPE_p_HOM_DataTree, own);
602 
603  case HOM_paneTabType::SceneGraphTree_Id:
604  return SWIG_NewPointerObj(
605  (void*)dynamic_cast<const HOM_SceneGraphTree* const>(pane_tab),
606  SWIGTYPE_p_HOM_SceneGraphTree, own);
607 
608  case HOM_paneTabType::ChannelViewer_Id:
609  case HOM_paneTabType::OutputViewer_Id:
610  case HOM_paneTabType::ShaderViewer_Id:
611  case HOM_paneTabType::Parm_Id:
612  case HOM_paneTabType::DetailsView_Id:
613  case HOM_paneTabType::TreeView_Id:
614  case HOM_paneTabType::TaskGraphTable_Id:
615  return SWIG_NewPointerObj(
616  (void*)dynamic_cast<const HOM_PathBasedPaneTab* const>(pane_tab),
617  SWIGTYPE_p_HOM_PathBasedPaneTab, own);
618 
619  case HOM_paneTabType::ChannelList_Id:
620  case HOM_paneTabType::Textport_Id:
621  case HOM_paneTabType::PythonShell_Id:
622  case HOM_paneTabType::HandleList_Id:
623  case HOM_paneTabType::BundleList_Id:
624  case HOM_paneTabType::TakeList_Id:
625  case HOM_paneTabType::ParmSpreadsheet_Id:
626  case HOM_paneTabType::LightLinker_Id:
627  case HOM_paneTabType::MaterialPalette_Id:
628  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
629  };
630 
631  UT_ASSERT(!"Unknown pane tab type");
632  return SWIG_NewPointerObj(pane_tab, SWIGTYPE_p_HOM_PaneTab, own);
633 }
634 
635 template <> InterpreterObject
636 HOMconvertValueForInterpreter<HOM_SopVerb*>(
637  HOM_SopVerb *const &verb, int own)
638 {
639  PY_InterpreterAutoLock py_lock;
640 
641  return SWIG_NewPointerObj(verb, SWIGTYPE_p_HOM_SopVerb, own);
642 }
643 
644 template <> InterpreterObject
645 HOMconvertValueForInterpreter<HOM_Geometry*>(
646  HOM_Geometry *const &geo, int own)
647 {
648  PY_InterpreterAutoLock py_lock;
649 
650  return SWIG_NewPointerObj(geo, SWIGTYPE_p_HOM_Geometry, own);
651 }
652 
653 template <> InterpreterObject
654 HOMconvertValueForInterpreter<HOM_NetworkItem*>(
655  HOM_NetworkItem *const &item, int own)
656 {
657  PY_InterpreterAutoLock py_lock;
658 
659  if (item)
660  {
661  switch (item->networkItemType().id())
662  {
663  case HOM_networkItemType::Node_Id:
664  // We know its a node, but we need to convert to the specific
665  // node type referred to by this item.
666  return HOMconvertValueForInterpreter(
667  dynamic_cast<HOM_Node* const>(item), own);
668 
669  case HOM_networkItemType::NetworkBox_Id:
670  return SWIG_NewPointerObj(
671  (void*)dynamic_cast<const HOM_NetworkBox* const>(item),
672  SWIGTYPE_p_HOM_NetworkBox, own);
673 
674  case HOM_networkItemType::StickyNote_Id:
675  return SWIG_NewPointerObj(
676  (void*)dynamic_cast<const HOM_StickyNote* const>(item),
677  SWIGTYPE_p_HOM_StickyNote, own);
678 
679  case HOM_networkItemType::SubnetIndirectInput_Id:
680  return SWIG_NewPointerObj(
681  (void*)dynamic_cast<const HOM_SubnetIndirectInput* const>(item),
682  SWIGTYPE_p_HOM_SubnetIndirectInput, own);
683 
684  case HOM_networkItemType::Connection_Id:
685  return SWIG_NewPointerObj(
686  (void*)dynamic_cast<const HOM_NodeConnection* const>(item),
687  SWIGTYPE_p_HOM_NodeConnection, own);
688 
689  case HOM_networkItemType::NetworkDot_Id:
690  return SWIG_NewPointerObj(
691  (void*)dynamic_cast<const HOM_NetworkDot* const>(item),
692  SWIGTYPE_p_HOM_NetworkDot, own);
693 
694  default:
695  break;
696  };
697  }
698 
699  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkItem, own);
700 }
701 
702 template <> InterpreterObject
703 HOMconvertValueForInterpreter<HOM_NetworkMovableItem*>(
704  HOM_NetworkMovableItem *const &item, int own)
705 {
706  PY_InterpreterAutoLock py_lock;
707 
708  if (!item)
709  return SWIG_NewPointerObj(item, SWIGTYPE_p_HOM_NetworkMovableItem, own);
710 
711  return HOMconvertValueForInterpreter<HOM_NetworkItem *>(item, own);
712 }
713 
714 template <> InterpreterObject
715 HOMconvertValueForInterpreter<
716  std::vector<HOM_ElemPtr<HOM_NodeConnection> >*>(
717  std::vector<HOM_ElemPtr<HOM_NodeConnection> > *const &list,
718  int own)
719 {
720  return swig::from(*list);
721 }
722 
723 template <> InterpreterObject
724 HOMconvertValueForInterpreter<HOM_DopData*>(HOM_DopData *const &data, int own)
725 {
726  PY_InterpreterAutoLock py_lock;
727 
728  const HOM_DopObject *const dop_object =
729  dynamic_cast<const HOM_DopObject *const>(data);
730  if (dop_object)
731  return SWIG_NewPointerObj(
732  (void *)dop_object, SWIGTYPE_p_HOM_DopObject, own);
733 
734  const HOM_DopRelationship *const dop_relationship =
735  dynamic_cast<const HOM_DopRelationship *const>(data);
736  if (dop_relationship)
737  return SWIG_NewPointerObj(
738  (void *)dop_relationship, SWIGTYPE_p_HOM_DopRelationship, own);
739 
740  return SWIG_NewPointerObj(data, SWIGTYPE_p_HOM_DopData, own);
741 }
742 
743 // These functions specialize pointers to other classes. If a class is
744 // used inside HOM_IterableList or HOM_ElemPtr, it must be listed here.
745 #define HOM_PROVIDE_SWIG_LOOKUP(type) \
746  template <> InterpreterObject HOMconvertValueForInterpreter<type*>( \
747  type* const& value, int own) \
748  { \
749  PY_InterpreterAutoLock py_lock; \
750  return SWIG_NewPointerObj(SWIG_as_voidptr(value), \
751  SWIGTYPE_p_ ## type, own); \
752  }
753 
754 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentClip)
755 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentDefinition)
756 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentLayer)
757 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShape)
758 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeBinding)
759 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentShapeDeformer)
760 HOM_PROVIDE_SWIG_LOOKUP(HOM_AgentTransformGroup)
761 HOM_PROVIDE_SWIG_LOOKUP(HOM_Attrib)
762 HOM_PROVIDE_SWIG_LOOKUP(HOM_Desktop)
763 HOM_PROVIDE_SWIG_LOOKUP(HOM_Dialog)
764 HOM_PROVIDE_SWIG_LOOKUP(HOM_DopRecord)
765 HOM_PROVIDE_SWIG_LOOKUP(HOM_Drawable)
766 HOM_PROVIDE_SWIG_LOOKUP(HOM_FloatingPanel)
767 HOM_PROVIDE_SWIG_LOOKUP(HOM_Gallery)
768 HOM_PROVIDE_SWIG_LOOKUP(HOM_GalleryEntry)
769 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometrySelection)
770 HOM_PROVIDE_SWIG_LOOKUP(HOM_GeometryViewport)
771 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDADefinition)
772 HOM_PROVIDE_SWIG_LOOKUP(HOM_HDASection)
773 HOM_PROVIDE_SWIG_LOOKUP(HOM_IndexPairPropertyTable)
774 HOM_PROVIDE_SWIG_LOOKUP(HOM_LopSelectionRule)
775 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix2)
776 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix3)
777 HOM_PROVIDE_SWIG_LOOKUP(HOM_Matrix4)
778 HOM_PROVIDE_SWIG_LOOKUP(HOM_NetworkBox)
779 HOM_PROVIDE_SWIG_LOOKUP(HOM_NetworkDot)
780 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeBundle)
781 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeConnection)
782 HOM_PROVIDE_SWIG_LOOKUP(HOM_NodeGroup)
783 HOM_PROVIDE_SWIG_LOOKUP(HOM_Pane)
784 HOM_PROVIDE_SWIG_LOOKUP(HOM_Parm)
785 HOM_PROVIDE_SWIG_LOOKUP(HOM_ParmTuple)
786 HOM_PROVIDE_SWIG_LOOKUP(HOM_Point)
787 HOM_PROVIDE_SWIG_LOOKUP(HOM_Polygon)
788 HOM_PROVIDE_SWIG_LOOKUP(HOM_PythonPanelInterface)
789 HOM_PROVIDE_SWIG_LOOKUP(HOM_Edge)
790 HOM_PROVIDE_SWIG_LOOKUP(HOM_PointGroup)
791 HOM_PROVIDE_SWIG_LOOKUP(HOM_PrimGroup)
792 HOM_PROVIDE_SWIG_LOOKUP(HOM_EdgeGroup)
793 HOM_PROVIDE_SWIG_LOOKUP(HOM_Quaternion)
794 HOM_PROVIDE_SWIG_LOOKUP(HOM_RadialItem)
795 HOM_PROVIDE_SWIG_LOOKUP(HOM_RadialSubmenu)
796 HOM_PROVIDE_SWIG_LOOKUP(HOM_RadialMenu)
797 HOM_PROVIDE_SWIG_LOOKUP(HOM_Ramp)
798 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selection)
799 HOM_PROVIDE_SWIG_LOOKUP(HOM_Selector)
800 HOM_PROVIDE_SWIG_LOOKUP(HOM_Shelf)
801 HOM_PROVIDE_SWIG_LOOKUP(HOM_ShelfSet)
802 HOM_PROVIDE_SWIG_LOOKUP(HOM_StickyNote)
803 HOM_PROVIDE_SWIG_LOOKUP(HOM_SubnetIndirectInput)
804 HOM_PROVIDE_SWIG_LOOKUP(HOM_Take)
805 HOM_PROVIDE_SWIG_LOOKUP(HOM_Tool)
806 HOM_PROVIDE_SWIG_LOOKUP(HOM_Track)
807 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEvent)
808 HOM_PROVIDE_SWIG_LOOKUP(HOM_UIEventDevice)
809 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector2)
810 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector3)
811 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vector4)
812 HOM_PROVIDE_SWIG_LOOKUP(HOM_Vertex)
813 HOM_PROVIDE_SWIG_LOOKUP(HOM_VexContext)
814 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerState)
815 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateMenu)
816 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewerStateTemplate)
817 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizer)
818 HOM_PROVIDE_SWIG_LOOKUP(HOM_ViewportVisualizerType)
819 
820 %}
821 
822 //----------------------------------------------------------------------------
823 
824 // We create typemaps for base classes that appear as return types to make
825 // sure swig instances the proper subclasses in the interpreter.
826 %typemap(out) HOM_Prim* {
827  $result = HOMconvertValueForInterpreter($1, $owner);
828 }
829 
830 %typemap(out) HOM_PackedPrim* {
831  $result = HOMconvertValueForInterpreter($1, $owner);
832 }
833 
834 %typemap(out) HOM_Node* {
835  $result = HOMconvertValueForInterpreter($1, $owner);
836 }
837 
838 %typemap(out) HOM_NodeType* {
839  $result = HOMconvertValueForInterpreter($1, $owner);
840 }
841 
842 %typemap(out) HOM_BaseKeyframe* {
843  $result = HOMconvertValueForInterpreter($1, $owner);
844 }
845 
846 %typemap(out) HOM_ParmTemplate* {
847  $result = HOMconvertValueForInterpreter($1, $owner);
848 }
849 
850 %typemap(out) HOM_Pane* {
851  $result = HOMconvertValueForInterpreter($1, $owner);
852 }
853 
854 %typemap(out) HOM_PaneTab* {
855  $result = HOMconvertValueForInterpreter($1, $owner);
856 }
857 
858 %typemap(out) HOM_DopData* {
859  $result = HOMconvertValueForInterpreter($1, $owner);
860 }
861 
862 %typemap(out) HOM_NetworkMovableItem* {
863  $result = HOMconvertValueForInterpreter($1, $owner);
864 }
865 
866 %typemap(out) HOM_NetworkItem* {
867  $result = HOMconvertValueForInterpreter($1, $owner);
868 }
869 
870 %typemap(out) std::vector<HOM_ElemPtr<HOM_NodeConnection> > * {
871  $result = HOMconvertValueForInterpreter($1, $owner);
872 }
873 
874 //----------------------------------------------------------------------------
875 
876 // These typemaps convert HOM exceptions into corresponding python standard
877 // exceptions.
878 %typemap(throws) HOM_TypeError %{
879  SWIG_exception_fail(SWIG_TypeError, $1.instanceMessage().c_str());
880 %}
881 
882 %typemap(throws) HOM_ValueError %{
883  SWIG_exception_fail(SWIG_ValueError, $1.instanceMessage().c_str());
884 %}
885 
886 #ifdef SWIGPYTHON
887 %typemap(throws) HOM_SystemExit %{
888  PyErr_SetObject(PyExc_SystemExit, SWIG_From_int($1.code()));
889  SWIG_fail;
890 %}
891 #endif
892 
893 //----------------------------------------------------------------------------
894 
895 // This typemap lets you declare a hboost::any parameter and swig will convert
896 // the interpreter (Python) object to a hboost::any that wraps the C++ data
897 // type.
898 %typemap(in) hboost::any {
899  // Note that if we can't convert to a hboost::any, we leave the hboost::any
900  // as empty (i.e. its empty() method returns true).
901  HOMinterpreterObjectToBoostAny($input, $1);
902 }
903 
904 // This typemap lets you declare a HOM_UTOptionAny (hboost::any) parameter and
905 // swig will convert the interpreter (Python) object into the C++ data type
906 // for interpreter objects that correspond to a UT_OptionType.
907 %typemap(in) HOM_UTOptionAny {
908  // Note that if we can't convert to a hboost::any, we leave the hboost::any
909  // as empty (i.e. its empty() method returns true).
910  HOMinterpreterObjectToUTOptionAny($input, $1);
911 }
912 
913 // This typemap lets you return hboost::any objects.
914 %typemap(out) hboost::any {
915  $result = HOMboostAnyToInterpreterObject($1);
916 }
917 
918 %typemap(out) HOM_DDSourceAny {
919  $result = HOMDDSourceAnyToInterpreterObject($1);
920 }
921 
922 //----------------------------------------------------------------------------
923 
924 #ifdef SWIGPYTHON
925 %typemap(out) PY_OpaqueObject {
926  $result = HOMincRef((InterpreterObject)$1.opaqueObject());
927 }
928 #endif
929 
930 // For whatever reason, adding the typemap does not customize swig::from(),
931 // so we do that manually.
932 %{
933 #ifdef SWIGPYTHON
934 namespace swig {
935  template <>
936  struct traits_from<PY_OpaqueObject>
937  {
938  static PyObject *from(const PY_OpaqueObject &val)
939  {
940  return HOMincRef((InterpreterObject)val.opaqueObject());
941  }
942  };
943 }
944 #endif
945 
946 //----------------------------------------------------------------------------
947 
948 // This helper function takes an interpreter (Python) object and converts it
949 // into a hboost::any object. It returns whether or not the conversion was
950 // possible, and leaves the hboost::any unchanged if a conversion wasn't
951 // possible.
952 bool
953 HOMinterpreterObjectToBoostAny(InterpreterObject input, hboost::any &result)
954 {
955 #ifdef SWIGPYTHON
956  if (input == Py_None)
957  {
958  result = (void *)NULL;
959  return true;
960  }
961 
962  // SWIG_AsVal_bool is too permissive, and treats thinks that an integer
963  // is a bool. So, we explicitly check against True and False.
964  if (input == Py_True)
965  {
966  result = true;
967  return true;
968  }
969 
970  if (input == Py_False)
971  {
972  result = false;
973  return true;
974  }
975 #endif
976 
977  int int_result;
978  if (SWIG_IsOK(SWIG_AsVal_int(input, &int_result)))
979  {
980  result = int_result;
981  return true;
982  }
983 
984  double double_result;
985  if (SWIG_IsOK(SWIG_AsVal_double(input, &double_result)))
986  {
987  result = double_result;
988  return true;
989  }
990 
991  std::string string_result;
992  if (SWIG_IsOK(SWIG_AsVal_std_string(input, &string_result)))
993  {
994  result = string_result;
995  return true;
996  }
997 
998  void *geometry_result = NULL;
999  if (SWIG_IsOK(SWIG_ConvertPtr(input, &geometry_result,
1000  SWIGTYPE_p_HOM_Geometry, 0)) && geometry_result)
1001  {
1002  result = reinterpret_cast<HOM_Geometry *>(geometry_result);
1003  return true;
1004  }
1005 
1006  void *ramp_result = NULL;
1007  if (SWIG_IsOK(SWIG_ConvertPtr(input, &ramp_result,
1008  SWIGTYPE_p_HOM_Ramp, 0)) && ramp_result)
1009  {
1010  result = reinterpret_cast<HOM_Ramp *>(ramp_result);
1011  return true;
1012  }
1013 
1014  std::vector<int> *int_vector_ptr = NULL;
1015  if (SWIG_IsOK(swig::asptr(input, (std::vector<int> **)NULL)) &&
1016  SWIG_IsOK(swig::asptr(input, &int_vector_ptr)))
1017  {
1018  result = *int_vector_ptr;
1019  delete int_vector_ptr;
1020  return true;
1021  }
1022 
1023  std::vector<double> *double_vector_ptr = NULL;
1024  if (SWIG_IsOK(swig::asptr(input, (std::vector<double> **)NULL)) &&
1025  SWIG_IsOK(swig::asptr(input, &double_vector_ptr)))
1026  {
1027  result = *double_vector_ptr;
1028  delete double_vector_ptr;
1029  return true;
1030  }
1031 
1032  std::vector<std::string> *string_vector_ptr = NULL;
1033  if (SWIG_IsOK(swig::asptr(input, (std::vector<std::string> **)NULL)) &&
1034  SWIG_IsOK(swig::asptr(input, &string_vector_ptr)))
1035  {
1036  result = *string_vector_ptr;
1037  delete string_vector_ptr;
1038  return true;
1039  }
1040 
1041  std::vector<HOM_Vector2> *vector2_vector_ptr = NULL;
1042  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector2> **)NULL)) &&
1043  SWIG_IsOK(swig::asptr(input, &vector2_vector_ptr)))
1044  {
1045  result = *vector2_vector_ptr;
1046  delete vector2_vector_ptr;
1047  return true;
1048  }
1049 
1050  std::vector<HOM_Vector3> *vector3_vector_ptr = NULL;
1051  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector3> **)NULL)) &&
1052  SWIG_IsOK(swig::asptr(input, &vector3_vector_ptr)))
1053  {
1054  result = *vector3_vector_ptr;
1055  delete vector3_vector_ptr;
1056  return true;
1057  }
1058 
1059  std::vector<HOM_Vector4> *vector4_vector_ptr = NULL;
1060  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector4> **)NULL)) &&
1061  SWIG_IsOK(swig::asptr(input, &vector4_vector_ptr)))
1062  {
1063  result = *vector4_vector_ptr;
1064  delete vector4_vector_ptr;
1065  return true;
1066  }
1067 
1068  std::vector<HOM_Matrix2> *matrix2_vector_ptr = NULL;
1069  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix2> **)NULL)) &&
1070  SWIG_IsOK(swig::asptr(input, &matrix2_vector_ptr)))
1071  {
1072  result = *matrix2_vector_ptr;
1073  delete matrix2_vector_ptr;
1074  return true;
1075  }
1076 
1077  std::vector<HOM_Matrix3> *matrix3_vector_ptr = NULL;
1078  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix3> **)NULL)) &&
1079  SWIG_IsOK(swig::asptr(input, &matrix3_vector_ptr)))
1080  {
1081  result = *matrix3_vector_ptr;
1082  delete matrix3_vector_ptr;
1083  return true;
1084  }
1085 
1086  std::vector<HOM_Matrix4> *matrix4_vector_ptr = NULL;
1087  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix4> **)NULL)) &&
1088  SWIG_IsOK(swig::asptr(input, &matrix4_vector_ptr)))
1089  {
1090  result = *matrix4_vector_ptr;
1091  delete matrix4_vector_ptr;
1092  return true;
1093  }
1094 
1095  UT_ASSERT(result.empty());
1096  return false;
1097 }
1098 
1099 // This helper function takes an interpreter (Python) object and converts it
1100 // into a HOM_UTOptionAny (hboost::any) object. It returns whether or not the
1101 // conversion was possible, and leaves the HOM_UTOptionAny unchanged if a
1102 // conversion wasn't possible.
1103 bool
1104 HOMinterpreterObjectToUTOptionAny(InterpreterObject input,
1105  HOM_UTOptionAny &result)
1106 {
1107 #ifdef SWIGPYTHON
1108  if (input == Py_None)
1109  {
1110  result = (void *)NULL;
1111  return true;
1112  }
1113 
1114  // SWIG_AsVal_bool is too permissive, and treats thinks that an integer
1115  // is a bool. So, we explicitly check against True and False.
1116  if (input == Py_True)
1117  {
1118  result = true;
1119  return true;
1120  }
1121 
1122  if (input == Py_False)
1123  {
1124  result = false;
1125  return true;
1126  }
1127 #endif
1128 
1129  int int_result;
1130  if (SWIG_IsOK(SWIG_AsVal_int(input, &int_result)))
1131  {
1132  result = int_result;
1133  return true;
1134  }
1135 
1136  double double_result;
1137  if (SWIG_IsOK(SWIG_AsVal_double(input, &double_result)))
1138  {
1139  result = double_result;
1140  return true;
1141  }
1142 
1143  std::string string_result;
1144  if (SWIG_IsOK(SWIG_AsVal_std_string(input, &string_result)))
1145  {
1146  result = string_result;
1147  return true;
1148  }
1149 
1150  void *vector2_result = NULL;
1151  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector2_result,
1152  SWIGTYPE_p_HOM_Vector2, 0)) && vector2_result)
1153  {
1154  result = reinterpret_cast<HOM_Vector2 *>(vector2_result);
1155  return true;
1156  }
1157 
1158  void *vector3_result = NULL;
1159  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector3_result,
1160  SWIGTYPE_p_HOM_Vector3, 0)) && vector3_result)
1161  {
1162  result = reinterpret_cast<HOM_Vector3 *>(vector3_result);
1163  return true;
1164  }
1165 
1166  void *vector4_result = NULL;
1167  if (SWIG_IsOK(SWIG_ConvertPtr(input, &vector4_result,
1168  SWIGTYPE_p_HOM_Vector4, 0)) && vector4_result)
1169  {
1170  result = reinterpret_cast<HOM_Vector4 *>(vector4_result);
1171  return true;
1172  }
1173 
1174  void *quat_result = NULL;
1175  if (SWIG_IsOK(SWIG_ConvertPtr(input, &quat_result,
1176  SWIGTYPE_p_HOM_Quaternion, 0)) && quat_result)
1177  {
1178  result = reinterpret_cast<HOM_Quaternion *>(quat_result);
1179  return true;
1180  }
1181 
1182  void *matrix2_result = NULL;
1183  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix2_result,
1184  SWIGTYPE_p_HOM_Matrix2, 0)) && matrix2_result)
1185  {
1186  result = reinterpret_cast<HOM_Matrix2 *>(matrix2_result);
1187  return true;
1188  }
1189 
1190  void *matrix3_result = NULL;
1191  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix3_result,
1192  SWIGTYPE_p_HOM_Matrix3, 0)) && matrix3_result)
1193  {
1194  result = reinterpret_cast<HOM_Matrix3 *>(matrix3_result);
1195  return true;
1196  }
1197 
1198  void *matrix4_result = NULL;
1199  if (SWIG_IsOK(SWIG_ConvertPtr(input, &matrix4_result,
1200  SWIGTYPE_p_HOM_Matrix4, 0)) && matrix4_result)
1201  {
1202  result = reinterpret_cast<HOM_Matrix4 *>(matrix4_result);
1203  return true;
1204  }
1205 
1206  void *geometry_result = NULL;
1207  if (SWIG_IsOK(SWIG_ConvertPtr(input, &geometry_result,
1208  SWIGTYPE_p_HOM_Geometry, 0)) && geometry_result)
1209  {
1210  result = reinterpret_cast<HOM_Geometry *>(geometry_result);
1211  return true;
1212  }
1213 
1214  void *ramp_result = NULL;
1215  if (SWIG_IsOK(SWIG_ConvertPtr(input, &ramp_result,
1216  SWIGTYPE_p_HOM_Ramp, 0)) && ramp_result)
1217  {
1218  result = reinterpret_cast<HOM_Ramp *>(ramp_result);
1219  return true;
1220  }
1221 
1222  std::vector<int> *int_vector_ptr = NULL;
1223  if (SWIG_IsOK(swig::asptr(input, (std::vector<int> **)NULL)) &&
1224  SWIG_IsOK(swig::asptr(input, &int_vector_ptr)))
1225  {
1226  result = *int_vector_ptr;
1227  delete int_vector_ptr;
1228  return true;
1229  }
1230 
1231  std::vector<double> *double_vector_ptr = NULL;
1232  if (SWIG_IsOK(swig::asptr(input, (std::vector<double> **)NULL)) &&
1233  SWIG_IsOK(swig::asptr(input, &double_vector_ptr)))
1234  {
1235  result = *double_vector_ptr;
1236  delete double_vector_ptr;
1237  return true;
1238  }
1239 
1240  std::vector<std::string> *string_vector_ptr = NULL;
1241  if (SWIG_IsOK(swig::asptr(input, (std::vector<std::string> **)NULL)) &&
1242  SWIG_IsOK(swig::asptr(input, &string_vector_ptr)))
1243  {
1244  result = *string_vector_ptr;
1245  delete string_vector_ptr;
1246  return true;
1247  }
1248 
1249  std::vector<HOM_Vector2> *vector2_vector_ptr = NULL;
1250  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector2> **)NULL)) &&
1251  SWIG_IsOK(swig::asptr(input, &vector2_vector_ptr)))
1252  {
1253  result = *vector2_vector_ptr;
1254  delete vector2_vector_ptr;
1255  return true;
1256  }
1257 
1258  std::vector<HOM_Vector3> *vector3_vector_ptr = NULL;
1259  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector3> **)NULL)) &&
1260  SWIG_IsOK(swig::asptr(input, &vector3_vector_ptr)))
1261  {
1262  result = *vector3_vector_ptr;
1263  delete vector3_vector_ptr;
1264  return true;
1265  }
1266 
1267  std::vector<HOM_Vector4> *vector4_vector_ptr = NULL;
1268  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Vector4> **)NULL)) &&
1269  SWIG_IsOK(swig::asptr(input, &vector4_vector_ptr)))
1270  {
1271  result = *vector4_vector_ptr;
1272  delete vector4_vector_ptr;
1273  return true;
1274  }
1275 
1276  std::vector<HOM_Matrix2> *matrix2_vector_ptr = NULL;
1277  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix2> **)NULL)) &&
1278  SWIG_IsOK(swig::asptr(input, &matrix2_vector_ptr)))
1279  {
1280  result = *matrix2_vector_ptr;
1281  delete matrix2_vector_ptr;
1282  return true;
1283  }
1284 
1285  std::vector<HOM_Matrix3> *matrix3_vector_ptr = NULL;
1286  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix3> **)NULL)) &&
1287  SWIG_IsOK(swig::asptr(input, &matrix3_vector_ptr)))
1288  {
1289  result = *matrix3_vector_ptr;
1290  delete matrix3_vector_ptr;
1291  return true;
1292  }
1293 
1294  std::vector<HOM_Matrix4> *matrix4_vector_ptr = NULL;
1295  if (SWIG_IsOK(swig::asptr(input, (std::vector<HOM_Matrix4> **)NULL)) &&
1296  SWIG_IsOK(swig::asptr(input, &matrix4_vector_ptr)))
1297  {
1298  result = *matrix4_vector_ptr;
1299  delete matrix4_vector_ptr;
1300  return true;
1301  }
1302 
1303  UT_ASSERT(result.empty());
1304  return false;
1305 }
1306 
1307 // Creating an input typemap isn't sufficient to handle input parameters with
1308 // std::vector's or std::map's of hboost::any's, so we need to specialize
1309 // swig::traits_asptr<hboost::any>.
1310 namespace swig {
1311  template <>
1312  struct traits_asptr<hboost::any>
1313  {
1314  static int asptr(InterpreterObject obj, hboost::any **val)
1315  {
1316  // TODO: Will the hboost::any be properly deleted?
1317  hboost::any *p = new hboost::any();
1318  HOMinterpreterObjectToBoostAny(obj, *p);
1319  if (val)
1320  *val = p;
1321  return SWIG_NEWOBJ;
1322  }
1323  };
1324 }
1325 
1326 // This function is not instantiated until the first use of HOM_BinaryString,
1327 // but we need to use it in HOMboostAnyToInterpreterObject. So just forward
1328 // declare it here.
1329 static PyObject * SWIG_From_HOM_BinaryString(const HOM_BinaryString& s);
1330 
1331 // This helper function takes a variable wrapped inside a hboost::any object
1332 // and creates a new instance of the corresponding InterpreterObject.
1333 static InterpreterObject
1334 HOMboostAnyToInterpreterObject(const hboost::any &result)
1335 {
1336  if (result.empty())
1337  return SWIG_Py_Void();
1338 
1339  if (result.type() == typeid(int))
1340  return SWIG_From_int(hboost::any_cast<int>(result));
1341 
1342  if (result.type() == typeid(long))
1343  return SWIG_From_long(hboost::any_cast<long>(result));
1344 
1345  if (result.type() == typeid(int64))
1346  return swig::from(hboost::any_cast<int64>(result));
1347 
1348  if (result.type() == typeid(float))
1349  return SWIG_From_float(hboost::any_cast<float>(result));
1350 
1351  if (result.type() == typeid(double))
1352  return SWIG_From_double(hboost::any_cast<double>(result));
1353 
1354  if (result.type() == typeid(std::string))
1355  return SWIG_From_std_string(hboost::any_cast<std::string>(result));
1356 
1357  if (result.type() == typeid(HOM_BinaryString))
1358  return SWIG_From_HOM_BinaryString(hboost::any_cast<HOM_BinaryString>(result));
1359 
1360  if (result.type() == typeid(std::vector<int>))
1361  return swig::from(hboost::any_cast<std::vector<int> >(result));
1362 
1363  if (result.type() == typeid(std::vector<int64>))
1364  return swig::from(hboost::any_cast<std::vector<int64> >(result));
1365 
1366  if (result.type() == typeid(std::vector<float>))
1367  return swig::from(hboost::any_cast<std::vector<float> >(result));
1368 
1369  if (result.type() == typeid(std::vector<std::string>))
1370  return swig::from(hboost::any_cast<std::vector<std::string> >(result));
1371 
1372  if (result.type() == typeid(std::vector<double>))
1373  return swig::from(hboost::any_cast<std::vector<double> >(result));
1374 
1375  if (result.type() == typeid(std::vector<std::vector<float> >))
1376  return swig::from(
1377  hboost::any_cast<std::vector<std::vector<float> > >(result));
1378 
1379  if (result.type() == typeid(std::vector<std::vector<double> >))
1380  return swig::from(
1381  hboost::any_cast<std::vector<std::vector<double> > >(result));
1382 
1383  // If a HOM function returns a pointer to a HOM_Vector*/HOM_Matrix*, it
1384  // will transfer the ownership of that object to swig.
1385  if (result.type() == typeid(HOM_Vector2 *))
1386  return HOMconvertValueForInterpreter(
1387  hboost::any_cast<HOM_Vector2 *>(result), SWIG_POINTER_OWN);
1388 
1389  if (result.type() == typeid(HOM_Vector3 *))
1390  return HOMconvertValueForInterpreter(
1391  hboost::any_cast<HOM_Vector3 *>(result), SWIG_POINTER_OWN);
1392 
1393  if (result.type() == typeid(HOM_Vector4 *))
1394  return HOMconvertValueForInterpreter(
1395  hboost::any_cast<HOM_Vector4 *>(result), SWIG_POINTER_OWN);
1396 
1397  if (result.type() == typeid(HOM_Matrix2 *))
1398  return HOMconvertValueForInterpreter(
1399  hboost::any_cast<HOM_Matrix2 *>(result), SWIG_POINTER_OWN);
1400 
1401  if (result.type() == typeid(HOM_Matrix3 *))
1402  return HOMconvertValueForInterpreter(
1403  hboost::any_cast<HOM_Matrix3 *>(result), SWIG_POINTER_OWN);
1404 
1405  if (result.type() == typeid(HOM_Matrix4 *))
1406  return HOMconvertValueForInterpreter(
1407  hboost::any_cast<HOM_Matrix4 *>(result), SWIG_POINTER_OWN);
1408 
1409  if (result.type() == typeid(HOM_NodeType *))
1410  return HOMconvertValueForInterpreter(
1411  hboost::any_cast<HOM_NodeType *>(result), SWIG_POINTER_OWN);
1412 
1413  if (result.type() == typeid(HOM_Ramp *))
1414  return HOMconvertValueForInterpreter(
1415  hboost::any_cast<HOM_Ramp *>(result), SWIG_POINTER_OWN);
1416 
1417  if (result.type() == typeid(HOM_Geometry *))
1418  return HOMconvertValueForInterpreter(
1419  hboost::any_cast<HOM_Geometry *>(result), SWIG_POINTER_OWN);
1420 
1421  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector2> >))
1422  return swig::from(
1423  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector2> > >(result));
1424 
1425  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector3> >))
1426  return swig::from(
1427  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector3> > >(result));
1428 
1429  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Vector4> >))
1430  return swig::from(
1431  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Vector4> > >(result));
1432 
1433  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix2> >))
1434  return swig::from(
1435  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix2> > >(result));
1436 
1437  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix3> >))
1438  return swig::from(
1439  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix3> > >(result));
1440 
1441  if (result.type() == typeid(std::vector<HOM_ElemPtr<HOM_Matrix4> >))
1442  return swig::from(
1443  hboost::any_cast<std::vector<HOM_ElemPtr<HOM_Matrix4> > >(result));
1444 
1445 #if UT_ASSERT_LEVEL > 0
1446  std::cout << "Unknown data type: "
1447  << UTunmangleClassNameFromTypeIdName(result.type().name()) << "\n";
1448 #endif
1449  UT_ASSERT(!"Unknown data type");
1450  return SWIG_Py_Void();
1451 }
1452 
1453 // This helper function takes a variable wrapped inside a hboost::any object
1454 // and creates a new instance of the corresponding InterpreterObject.
1455 static InterpreterObject
1456 HOMDDSourceAnyToInterpreterObject(const HOM_DDSourceAny &result)
1457 {
1458  if (result.type() == typeid(HOM_Node *))
1459  {
1460  return HOMconvertValueForInterpreter(
1461  hboost::any_cast<HOM_Node *>(result), SWIG_POINTER_OWN);
1462  }
1463  if (result.type() == typeid(HOM_Parm *))
1464  {
1465  return HOMconvertValueForInterpreter(
1466  hboost::any_cast<HOM_Parm *>(result), SWIG_POINTER_OWN);
1467  }
1468  if (result.type() == typeid(HOM_GalleryEntry *))
1469  {
1470  return HOMconvertValueForInterpreter(
1471  hboost::any_cast<HOM_GalleryEntry *>(result), SWIG_POINTER_OWN);
1472  }
1473 
1474  return HOMboostAnyToInterpreterObject(result);
1475 }
1476 
1477 namespace swig {
1478  // Adding the typemap does not customize swig::from() so we do that
1479  // manually.
1480  template <>
1481  struct traits_from<hboost::any>
1482  {
1483  static PyObject *from(const hboost::any &val)
1484  { return HOMboostAnyToInterpreterObject(val); }
1485  };
1486 }
1487 
1488 static InterpreterObject
1489 HOMoptionEntryToInterpreterObject(const UT_OptionEntry &option_entry)
1490 {
1491  InterpreterObject result = NULL;
1492 
1493  switch (option_entry.getType())
1494  {
1495  case UT_OPTION_INT:
1496  return SWIG_From_int(
1497  ((const UT_OptionInt &)option_entry).getValue());
1498 
1499  case UT_OPTION_BOOL:
1500  return SWIG_From_bool(
1501  ((const UT_OptionBool &)option_entry).getValue());
1502 
1503  case UT_OPTION_FPREAL:
1504  return SWIG_From_double(
1505  ((const UT_OptionFpreal &)option_entry).getValue());
1506 
1507  case UT_OPTION_STRING:
1508  case UT_OPTION_STRINGRAW:
1509  {
1510  return SWIG_From_std_string(
1511  ((const UT_OptionString &)option_entry).getValue().toStdString());
1512  }
1513 
1514  case UT_OPTION_VECTOR2:
1515  return HOMconvertValueForInterpreter(
1516  new HOM_Vector2(
1517  ((const UT_OptionVector2 &)option_entry).getValue()),
1518  SWIG_POINTER_OWN);
1519 
1520  case UT_OPTION_VECTOR3:
1521  return HOMconvertValueForInterpreter(
1522  new HOM_Vector3(
1523  ((const UT_OptionVector3 &)option_entry).getValue()),
1524  SWIG_POINTER_OWN);
1525 
1526  case UT_OPTION_VECTOR4:
1527  return HOMconvertValueForInterpreter(
1528  new HOM_Vector4(
1529  ((const UT_OptionVector4 &)option_entry).getValue()),
1530  SWIG_POINTER_OWN);
1531 
1532  case UT_OPTION_QUATERNION:
1533  return HOMconvertValueForInterpreter(
1534  new HOM_Quaternion(
1535  ((const UT_OptionQuaternion &)option_entry).getValue()),
1536  SWIG_POINTER_OWN);
1537 
1538  case UT_OPTION_MATRIX2:
1539  return HOMconvertValueForInterpreter(
1541  ((const UT_OptionMatrix2 &)option_entry).getValue())),
1542  SWIG_POINTER_OWN);
1543 
1544  case UT_OPTION_MATRIX3:
1545  return HOMconvertValueForInterpreter(
1547  ((const UT_OptionMatrix3 &)option_entry).getValue())),
1548  SWIG_POINTER_OWN);
1549 
1550  case UT_OPTION_MATRIX4:
1551  return HOMconvertValueForInterpreter(
1553  ((const UT_OptionMatrix4 &)option_entry).getValue())),
1554  SWIG_POINTER_OWN);
1555 
1556  case UT_OPTION_UV:
1557  return HOMconvertValueForInterpreter(
1558  new HOM_Vector2(
1559  ((const UT_OptionUV &)option_entry).getValue()),
1560  SWIG_POINTER_OWN);
1561 
1562  case UT_OPTION_UVW:
1563  return HOMconvertValueForInterpreter(
1564  new HOM_Vector3(
1565  ((const UT_OptionUVW &)option_entry).getValue()),
1566  SWIG_POINTER_OWN);
1567 
1568  case UT_OPTION_INTARRAY:
1569  {
1570  std::vector<int64> int_vector;
1571  UTarrayToStdVector(
1572  static_cast<const UT_OptionInt64Array &>(option_entry)
1573  .getValue(), int_vector);
1574  return swig::from(int_vector);
1575  }
1576 
1577  case UT_OPTION_FPREALARRAY:
1578  {
1579  std::vector<double> double_vector;
1580  UTarrayToStdVector(
1581  static_cast<const UT_OptionFpreal64Array &>(option_entry)
1582  .getValue(), double_vector);
1583  return swig::from(double_vector);
1584  }
1585 
1586  case UT_OPTION_STRINGARRAY:
1587  {
1588  std::vector<std::string> str_vector;
1589  UTarrayToStdVectorOfStrings(
1590  static_cast<const UT_OptionStringArray &>(option_entry)
1591  .getValue(), str_vector);
1592  return swig::from(str_vector);
1593  }
1594 
1595  case UT_OPTION_INVALID:
1596  case UT_OPTION_NUM_TYPES:
1597  // Just exit the switch with no result.
1598  break;
1599  }
1600 
1601  return result ? result : SWIG_Py_Void();
1602 }
1603 
1604 #ifdef SWIGPYTHON
1605 static InterpreterObject
1606 HOMoptionsToInterpreterObject(const UT_Options &options)
1607 {
1608  InterpreterObject result = PyDict_New();
1609 
1610  for (UT_Options::iterator it = options.begin(); !it.atEnd(); ++it)
1611  {
1612  // The Python dictionary object will increment the reference count
1613  // on the value, so we decrement it since we just allocated it.
1614  InterpreterObject value=HOMoptionEntryToInterpreterObject(*it.entry());
1615  PyDict_SetItemString(result, it.name(), value);
1616  Py_DECREF(value);
1617  }
1618 
1619  return result;
1620 }
1621 #endif
1622 
1623 //----------------------------------------------------------------------------
1624 
1625 #ifdef SWIGPYTHON
1626 // This helper class takes a Python buffer object and provides access to
1627 // the underlying C buffer. Note that the class is only used inside the
1628 // swig file, so it doesn't need to be exported from the current library.
1629 class HOM_PyBuffer
1630 {
1631 public:
1632  HOM_PyBuffer(InterpreterObject py_object)
1633  {
1634  myData = NULL;
1635  myLength = 0;
1636 
1637  // Python added a new buffer interface starting with Python 2.6.
1638 #if PY_VERSION_HEX >= 0x02060000
1639  myUseNewAPI = false;
1640  if (PyObject_CheckBuffer(py_object))
1641  {
1642  if (PyObject_GetBuffer(py_object, &myPyBuffer, PyBUF_SIMPLE) < 0)
1643  throw HOM_TypeError("failed to get readable buffer");
1644 
1645  myUseNewAPI = true;
1646  myData = myPyBuffer.buf;
1647  myLength = myPyBuffer.len;
1648  return;
1649  }
1650 #endif
1651  // Either the new API isn't supported in this Python version or the
1652  // Python object doesn't support it. Try the old API.
1653  if (!PyObject_CheckReadBuffer(py_object))
1654  throw HOM_TypeError("expected a readable buffer");
1655 
1656  if (PyObject_AsReadBuffer(py_object, &myData, &myLength) < 0)
1657  throw HOM_TypeError("failed to get readable buffer");
1658  }
1659 
1660  ~HOM_PyBuffer()
1661  {
1662 #if PY_VERSION_HEX >= 0x02060000
1663  if (myUseNewAPI)
1664  PyBuffer_Release(&myPyBuffer);
1665 #endif
1666  }
1667 
1668 #if PY_VERSION_HEX >= 0x02060000
1669  bool myUseNewAPI;
1670  Py_buffer myPyBuffer;
1671 #endif
1672  const void *myData;
1673  Py_ssize_t myLength;
1674 };
1675 #endif
1676 
1677 //----------------------------------------------------------------------------
1678 
1679 // These helper functions are used to implement the attrib() methods of
1680 // Points, Prims, and Vertices. We need to do extra work for these methods
1681 // because the return type can vary.
1682 template <typename T>
1683 InterpreterObject
1684 HOMattribValue(T &geo_element, HOM_Attrib &hom_attrib)
1685 {
1686  InterpreterObject result = NULL;
1687  switch (hom_attrib.dataType().id())
1688  {
1689  case HOM_attribData::Int_Id:
1690  if (hom_attrib.size() == 1)
1691  result = swig::from(
1692  hboost::any_cast<int64>(geo_element.intAttribValue(hom_attrib)));
1693  else
1694  result = swig::from(
1695  hboost::any_cast<std::vector<int64> >(
1696  geo_element.intListAttribValue(hom_attrib)));
1697  break;
1698 
1699  case HOM_attribData::Float_Id:
1700  if (hom_attrib.size() == 1)
1701  result = SWIG_From_double(geo_element.floatAttribValue(hom_attrib));
1702  else
1703  result = swig::from(geo_element.floatListAttribValue(hom_attrib));
1704  break;
1705 
1706  case HOM_attribData::String_Id:
1707  if (hom_attrib.size() == 1)
1708  result = SWIG_From_std_string(
1709  geo_element.stringAttribValue(hom_attrib));
1710  else
1711  result = swig::from(geo_element.stringListAttribValue(hom_attrib));
1712  break;
1713  }
1714  UT_ASSERT(result);
1715  return result;
1716 }
1717 
1718 
1719 // Note that the caller is responsible for deleting the HOM_Attrib object
1720 // that's returned.
1721 template <typename T> HOM_Attrib*
1722 HOMlookUpAttrib(T &geo_element, const char *name);
1723 
1724 template <> HOM_Attrib*
1725 HOMlookUpAttrib(HOM_Point &point, const char *name)
1726 { return HOMdel(point.geometry())->findPointAttrib(name); }
1727 
1728 template <> HOM_Attrib*
1729 HOMlookUpAttrib(HOM_Prim &prim, const char *name)
1730 { return HOMdel(prim.geometry())->findPrimAttrib(name); }
1731 
1732 template <> HOM_Attrib*
1733 HOMlookUpAttrib(HOM_Vertex &vertex, const char *name)
1734 { return HOMdel(vertex.geometry())->findVertexAttrib(name); }
1735 
1736 template <> HOM_Attrib*
1737 HOMlookUpAttrib(HOM_Geometry &geometry, const char *name)
1738 { return geometry.findGlobalAttrib(name); }
1739 
1740 template <typename T>
1741 InterpreterObject
1742 HOMattribValue(T &geo_element, const char *name)
1743 {
1744  HOM_Attrib *hom_attrib = HOMlookUpAttrib(geo_element, name);
1745  if (!hom_attrib)
1746  throw HOM_OperationFailed();
1747 
1748  InterpreterObject result = HOMattribValue(geo_element, *hom_attrib);
1749  delete hom_attrib;
1750  return result;
1751 }
1752 %}
1753 
1754 //----------------------------------------------------------------------------
1755 
1756 %{
1757 // These helper functions are used to implement parm evaluation.
1758 static InterpreterObject
1759 HOMevalParm(HOM_Parm &parm)
1760 {
1761  PY_InterpreterAutoLock py_lock;
1762 
1763  switch (parm.parmDataTypeEnumId())
1764  {
1765  case HOM_parmData::Int_Id:
1766  return SWIG_From_int(parm.evalAsInt());
1767  case HOM_parmData::Float_Id:
1768  return SWIG_From_double(parm.evalAsFloat());
1769  case HOM_parmData::String_Id:
1770  return SWIG_From_std_string(parm.evalAsString());
1771  case HOM_parmData::Ramp_Id:
1772  return SWIG_NewPointerObj(
1773  (void*)parm.evalAsRamp(), SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
1774  case HOM_parmData::Data_Id:
1775  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
1776  return swig::from(parm.evalAsJSONMap());
1777 
1778  return SWIG_NewPointerObj(
1779  (void*)parm.evalAsGeometry(), SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
1780  }
1781 
1782  UT_ASSERT(!"Unknown parm data type");
1783  return SWIG_Py_Void();
1784 }
1785 
1786 static InterpreterObject
1787 HOMevalParmAtFrame(HOM_Parm &parm, double frame)
1788 {
1789  PY_InterpreterAutoLock py_lock;
1790 
1791  switch (parm.parmDataTypeEnumId())
1792  {
1793  case HOM_parmData::Int_Id:
1794  return SWIG_From_int(parm.evalAsIntAtFrame(frame));
1795  case HOM_parmData::Float_Id:
1796  return SWIG_From_double(parm.evalAsFloatAtFrame(frame));
1797  case HOM_parmData::String_Id:
1798  return SWIG_From_std_string(parm.evalAsStringAtFrame(frame));
1799  case HOM_parmData::Ramp_Id:
1800  return SWIG_NewPointerObj(
1801  (void*)parm.evalAsRampAtFrame(frame),
1802  SWIGTYPE_p_HOM_Ramp, SWIG_POINTER_OWN);
1803  case HOM_parmData::Data_Id:
1804  if (parm.dataParmTypeEnumId() == HOM_dataParmType::KeyValueDictionary_Id)
1805  return swig::from(parm.evalAsJSONMapAtFrame(frame));
1806 
1807  return SWIG_NewPointerObj(
1808  (void*)parm.evalAsGeometryAtFrame(frame),
1809  SWIGTYPE_p_HOM_Geometry, SWIG_POINTER_OWN);
1810  }
1811 
1812  UT_ASSERT(!"Unknown parm data type");
1813  return SWIG_Py_Void();
1814 }
1815 
1816 static InterpreterObject
1817 HOMevalParmTuple(HOM_ParmTuple &parm_tuple)
1818 {
1819  switch (parm_tuple.parmDataTypeEnumId())
1820  {
1821  case HOM_parmData::Int_Id:
1822  return swig::from(parm_tuple.evalAsInts());
1823  case HOM_parmData::Float_Id:
1824  return swig::from(parm_tuple.evalAsFloats());
1825  case HOM_parmData::String_Id:
1826  return swig::from(parm_tuple.evalAsStrings());
1827  case HOM_parmData::Ramp_Id:
1828  return swig::from(parm_tuple.evalAsRamps());
1829  case HOM_parmData::Data_Id:
1830  return swig::from(parm_tuple.evalAsGeometries());
1831  }
1832 
1833  UT_ASSERT(!"Unknown parm data type");
1834  return SWIG_Py_Void();
1835 }
1836 
1837 static InterpreterObject
1838 HOMevalParmTupleAtFrame(HOM_ParmTuple &parm_tuple, double frame)
1839 {
1840  switch (parm_tuple.parmDataTypeEnumId())
1841  {
1842  case HOM_parmData::Int_Id:
1843  return swig::from(parm_tuple.evalAsIntsAtFrame(frame));
1844  case HOM_parmData::Float_Id:
1845  return swig::from(parm_tuple.evalAsFloatsAtFrame(frame));
1846  case HOM_parmData::String_Id:
1847  return swig::from(parm_tuple.evalAsStringsAtFrame(frame));
1848  case HOM_parmData::Ramp_Id:
1849  return swig::from(parm_tuple.evalAsRampsAtFrame(frame));
1850  case HOM_parmData::Data_Id:
1851  return swig::from(parm_tuple.evalAsGeometriesAtFrame(frame));
1852  }
1853 
1854  UT_ASSERT(!"Unknown parm data type");
1855  return SWIG_Py_Void();
1856 }
1857 
1858 static InterpreterObject
1859 HOMevalViewportVisualizerParm(HOM_ViewportVisualizer &visualizer, const char *parm_name)
1860 {
1861  PY_InterpreterAutoLock py_lock;
1862 
1863  switch (visualizer.parmDataTypeEnumId(parm_name))
1864  {
1865  case HOM_parmData::Int_Id:
1866  return SWIG_From_int(visualizer.evalParmAsInt(parm_name));
1867  case HOM_parmData::Float_Id:
1868  return SWIG_From_double(visualizer.evalParmAsFloat(parm_name));
1869  case HOM_parmData::String_Id:
1870  return SWIG_From_std_string(visualizer.evalParmAsString(parm_name));
1871  case HOM_parmData::Ramp_Id:
1872  return SWIG_NewPointerObj(
1873  (void*)visualizer.evalParmAsRamp(parm_name), SWIGTYPE_p_HOM_Ramp,
1874  SWIG_POINTER_OWN);
1875  }
1876 
1877  UT_ASSERT(!"Unknown parm data type");
1878  return SWIG_Py_Void();
1879 }
1880 
1881 
1882 //----------------------------------------------------------------------------
1883 
1884 %}
1885 #endif
1886 
1887 #endif
UT_Matrix4T< double > UT_DMatrix4
virtual std::vector< HOM_ElemPtr< HOM_Geometry > > evalAsGeometries()=0
UT_Matrix3T< double > UT_DMatrix3
virtual std::vector< int > evalAsIntsAtFrame(double frame)=0
virtual int size()=0
virtual std::string evalParmAsString(const char *parm_name)=0
virtual HOM_Prim * prim(int index)=0
virtual std::vector< HOM_ElemPtr< HOM_Ramp > > evalAsRampsAtFrame(double frame)=0
virtual HOM_Attrib * findGlobalAttrib(const char *name)=0
hboost::any HOM_UTOptionAny
Definition: HOM_Defines.h:37
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
virtual int parmDataTypeEnumId()=0
virtual double evalAsFloat()=0
virtual std::vector< int > evalAsInts()=0
UT_UniquePtr< T > HOMdel(T *hom_object)
Definition: HOM_Module.h:946
bool atEnd() const
Definition: UT_Options.h:241
virtual HOM_Ramp * evalParmAsRamp(const char *parm_name)=0
virtual HOM_Ramp * evalAsRampAtFrame(double frame)=0
long long int64
Definition: SYS_Types.h:107
virtual std::vector< std::string > evalAsStrings()=0
UT_API std::string UTunmangleClassNameFromTypeIdName(const std::string &name)
virtual HOM_Geometry * geometry()=0
virtual double evalAsFloatAtFrame(double frame)=0
virtual int evalAsIntAtFrame(double frame)=0
virtual int dataParmTypeEnumId()=0
virtual std::map< std::string, std::string > evalAsJSONMapAtFrame(double frame)=0
virtual HOM_Geometry * geometry()=0
virtual HOM_Geometry * evalAsGeometryAtFrame(double frame)=0
virtual UT_OptionType getType() const
UT_Matrix2T< double > UT_DMatrix2
virtual std::map< std::string, std::string > evalAsJSONMap()=0
OP_OpTypeId
Definition: OP_OpTypeId.h:15
void * opaqueObject() const
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual int parmDataTypeEnumId()=0
virtual std::string evalAsStringAtFrame(double frame)=0
virtual std::vector< HOM_ElemPtr< HOM_Geometry > > evalAsGeometriesAtFrame(double frame)=0
virtual std::vector< double > evalAsFloatsAtFrame(double frame)=0
virtual HOM_Ramp * evalAsRamp()=0
hboost::any HOM_DDSourceAny
Definition: HOM_Defines.h:42
virtual int evalAsInt()=0
iterator begin() const
Definition: UT_Options.h:354
virtual std::vector< double > evalAsFloats()=0
GLsizei const GLfloat * value
Definition: glcorearb.h:823
A map of string to various well defined value types.
Definition: UT_Options.h:42
virtual double evalParmAsFloat(const char *parm_name)=0
virtual int parmDataTypeEnumId(const char *parm_name)=0
typedef int
Definition: png.h:1175
GLuint GLfloat * val
Definition: glcorearb.h:1607
virtual HOM_EnumValue & dataType()=0
int id() const
Definition: HOM_EnumValue.h:82
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:126
virtual std::vector< HOM_ElemPtr< HOM_Ramp > > evalAsRamps()=0
#define const
Definition: zconf.h:214
virtual int evalParmAsInt(const char *parm_name)=0
HOM_API HOM_Module & HOM()
virtual std::vector< std::string > evalAsStringsAtFrame(double frame)=0
virtual std::string evalAsString()=0
virtual HOM_Geometry * evalAsGeometry()=0
virtual HOM_Geometry * geometry()=0