HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Module.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  * This class is not directly wrapped by swig. However, when creating
8  * the swig wrapper modules we wrap each of the methods of this class
9  * in functions. This way, the methods of this class appear as the
10  * top-level parts of the hou module.
11  */
12 
13 #ifndef __HOM_Module_h__
14 #define __HOM_Module_h__
15 
16 #include "HOM_API.h"
17 #include "HOM_BinaryString.h"
18 #include "HOM_Defines.h"
19 #include "HOM_Errors.h"
20 #include "HOM_ElemPtr.h"
21 #include "HOM_EnumModules.h"
23 #include <UT/UT_Lock.h>
24 #include <UT/UT_NonCopyable.h>
25 #include <UT/UT_Notifier.h>
26 #include <UT/UT_TaskLock.h>
27 #include <UT/UT_Thread.h>
28 #include <UT/UT_UniquePtr.h>
29 #include <UT/UT_OptionEntry.h>
30 #include <SYS/SYS_Types.h>
31 #include <typeinfo>
32 #include <string>
33 #include <vector>
34 #include <map>
35 #include <hboost/any.hpp>
36 
37 class OP_Node;
38 class STORUI_OrboltURLHandler;
39 
41 class HOM_AgentClip;
43 class HOM_AgentLayer;
44 class HOM_AgentMetadata;
45 class HOM_AgentRig;
46 class HOM_AgentShape;
51 class HOM_AttribDataId;
52 class HOM_anonstats;
53 class HOM_audio;
55 class HOM_ChopNode;
56 class HOM_Clip;
57 class HOM_Color;
58 class HOM_crowds;
60 class HOM_SimpleDrawable;
61 class HOM_dop;
62 class HOM_DopData;
63 class HOM_DopSimulation;
64 class HOM_Edge;
65 class HOM_EnumValue;
69 class HOM_GadgetContext;
70 class HOM_GadgetDrawable;
71 class HOM_galleries;
72 class HOM_Geometry;
75 class HOM_Handle;
76 class HOM_hda;
77 class HOM_HDADefinition;
78 class HOM_HDAModule;
79 class HOM_HDAOptions;
80 class HOM_hipFile;
81 class HOM_hmath;
82 class HOM_ik;
85 class HOM_Keyframe;
87 class HOM_lop;
91 class HOM_Matrix4;
93 class HOM_NetworkBox;
94 class HOM_NetworkDot;
96 class HOM_Node;
97 class HOM_NodeBundle;
98 class HOM_NodeConnection;
99 class HOM_NodeType;
102 class HOM_Parm;
103 class HOM_ParmTemplate;
105 class HOM_ParmTuple;
106 class HOM_perfMon;
108 class HOM_pypanel;
109 class HOM_playbar;
110 class HOM_Point;
111 class HOM_Prim;
112 class HOM_properties;
113 class HOM_qt;
115 class HOM_RedrawBlock;
116 #ifndef SWIG
118 #endif
119 class HOM_SceneViewer;
121 class HOM_Selection;
123 class HOM_shelves;
124 class HOM_StickyNote;
125 class HOM_StringKeyframe;
127 class HOM_styles;
128 class HOM_StyleSheet;
130 class HOM_takes;
131 class HOM_text;
132 class HOM_TextDrawable;
134 class HOM_ui;
135 class HOM_hotkeys;
136 class HOM_UIEvent;
137 class HOM_UIEventDevice;
138 class HOM_undos;
139 class HOM_Vertex;
140 class HOM_VexContext;
141 class HOM_ViewerEvent;
143 class HOM_ViewerDragger;
149 class HOM_ViewerStateMenu;
153 class HOM_webServer;
154 
155 #define HOM_SESSION_MODULE_NAME "hou.session"
156 #define HOM_SESSION_MODULE_CPIO_NAME "." HOM_SESSION_MODULE_NAME
157 
158 // Use this function to access the HOM module from C++ in Houdini. This
159 // is equivalent to writing "hou" in python. It will only throw an exception
160 // if the python module could not be imported, which should not happen.
161 class HOM_Module;
163 
165 {
166 public:
167  static void setHOMCreator(void (*homCreator)());
168 
169  virtual ~HOM_Module() {}
170 
171  virtual std::vector<std::string> _getArgumentAutoComplete(
172  const char *method_name, const char *arguments,
173  bool meta_info_only = false) = 0;
174 
175  // This method is called by the expression editor to force autocompletion
176  // to be relative to the node containing the expression. It is not
177  // wrapped by swig.
178  virtual void setRelativeNodeForAutoComplete(OP_Node *node) = 0;
179 
180  virtual HOM_ui& ui() = 0;
181  virtual HOM_qt& qt() = 0;
182  virtual HOM_hotkeys& hotkeys() = 0;
183  virtual HOM_audio& audio() = 0;
184  virtual bool isUIAvailable() = 0;
185  virtual bool _isCurrentThreadHoldingHOMLock() = 0;
186 
187  virtual HOM_galleries& galleries() = 0;
188  virtual HOM_hda& hda() = 0;
189  virtual HOM_hipFile& hipFile() = 0;
190  virtual HOM_perfMon& perfMon() = 0;
191  virtual HOM_playbar& playbar() = 0;
192  virtual HOM_pypanel& pypanel() = 0;
193  virtual HOM_hmath& hmath() = 0;
194  virtual HOM_dop& dop() = 0;
195  virtual HOM_properties& properties() = 0;
196  virtual HOM_shelves& shelves() = 0;
197  virtual HOM_styles& styles() = 0;
198  virtual HOM_takes& takes() = 0;
199  virtual HOM_undos& undos() = 0;
200  virtual HOM_viewportVisualizers& viewportVisualizers() = 0;
201  virtual HOM_anonstats& anonstats() = 0;
202  virtual HOM_crowds& crowds() = 0;
203  virtual HOM_ik& ik() = 0;
204  virtual HOM_lop& lop() = 0;
205  virtual HOM_text& text() = 0;
206  virtual HOM_webServer& webServer() = 0;
207 
208  virtual bool _assertWrapper(
209  const char *file, int linenum, const char *function,
210  const char *condition, const char *reason) = 0;
211 
212  virtual void exit(int exit_code=0, bool suppress_save_prompt=false) = 0;
213 
214  // isExiting() will return true if the program is actually Houdini (not
215  // mplay) and the UI queue is closed. This method is wrapped by swig, but
216  // only so houdiniInterpreter can call it.
217  virtual bool isExiting() = 0;
218 
219  virtual void addPreloadIcon(const char *name, int w, int h) = 0;
220  virtual void rasterizePreloadIcons() = 0;
221 
222  virtual std::string applicationName() = 0;
223  virtual std::vector<int> applicationVersion(bool include_patch=false) = 0;
224  virtual std::string applicationVersionString() = 0;
225  virtual std::string applicationCompilationDate() = 0;
226  virtual std::string applicationPlatformInfo() = 0;
227  virtual HOM_EnumValue &licenseCategory() = 0;
228  virtual bool isApprentice() = 0;
229  virtual void releaseLicense() = 0;
230 
231  // Threading controls
232  virtual int maxThreads() = 0;
233  virtual void setMaxThreads(int max_threads) = 0;
234 
235  // These methods return a new HOM_Node object.
236  virtual HOM_Node* root() = 0;
237  virtual HOM_Node* pwd() = 0;
238  virtual HOM_Node* parent() = 0;
239 
240  virtual void setPwd(HOM_Node &newpwd) = 0;
241  virtual void cd(const char *path) = 0;
242 
243  // Calling phm() is a shortcut for calling pwd().hdaModule().
244  virtual HOM_HDAModule* phm() = 0;
245 
246  // This method returns a new HOM_DopNetNode object or None.
247  virtual HOM_Node* currentDopNet() = 0;
248  virtual void setCurrentDopNet(HOM_Node &dopnet) = 0;
249 
250  // Gets or sets the simulation enabled state.
251  virtual bool simulationEnabled() = 0;
252  virtual void setSimulationEnabled(bool enabled) = 0;
253 
254  // These methods return a new HOM_Node object or null if the node couldn't
255  // be found.
256  virtual HOM_Node *node(const char *path) = 0;
257  virtual HOM_NetworkMovableItem* item(const char *path) = 0;
258 
259  virtual std::vector<HOM_ElemPtr<HOM_Node> > nodes(const std::vector<std::string> &paths) = 0;
260  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > items(const std::vector<std::string> &paths) = 0;
261 
262  virtual HOM_Node *nodeBySessionId(int session_id) = 0;
263  virtual HOM_NetworkBox *networkBoxBySessionId(int session_id) = 0;
264  virtual HOM_StickyNote *stickyNoteBySessionId(int session_id) = 0;
265  virtual HOM_SubnetIndirectInput *subnetIndirectInputBySessionId(
266  int64 session_id) = 0;
267  virtual HOM_NetworkDot *networkDotBySessionId(int session_id) = 0;
268  virtual HOM_NetworkMovableItem *itemBySessionId(
269  HOM_EnumValue &item_type, int64 session_id) = 0;
270  virtual HOM_NodeConnection *nodeConnectionBySessionId(
271  int node_session_id, int input_index) = 0;
272 
273  // Functions for configuring default colors on network elements.
274  virtual HOM_Color defaultColor(HOM_EnumValue &color_item) = 0;
275  virtual void setDefaultColor(HOM_EnumValue &color_item, HOM_Color *color) = 0;
276 
277  // Return HOM_Nodes for all selected nodes in the session.
278  virtual std::vector<HOM_ElemPtr<HOM_Node> > selectedNodes(
279  bool include_hidden = false) = 0;
280  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > selectedItems(
281  bool include_hidden = false) = 0;
282  virtual std::vector<HOM_ElemPtr<HOM_NodeConnection> > selectedConnections() = 0;
283  virtual void clearAllSelected() = 0;
284 
285  // Copy nodes to and paste from clipboard.
286  virtual void copyNodesToClipboard(const std::vector<HOM_Node *> &nodes) = 0;
287  virtual void pasteNodesFromClipboard(HOM_Node &destination_node) = 0;
288 
289  // These methods return new HOM_Parm/HOM_ParmTuple objects or null if the
290  // parm couldn't be found.
291  virtual HOM_Parm* parm(const char *path) = 0;
292  SWIGOUT(%ignore newParm;)
293  virtual HOM_Parm* newParm(OP_Node &node, int parm_index, int vector_index) = 0;
294  virtual HOM_ParmTuple* parmTuple(const char *path) = 0;
295  virtual HOM_Parm *evaluatingParm() = 0;
296 
297  virtual HOM_ScriptEvalContext * newScriptEvalContext(HOM_Node &node) = 0;
298  virtual HOM_ScriptEvalContext * newScriptEvalContext(HOM_Parm &parm) = 0;
299 
300  // Access to the contents of the parm clipboard
301  virtual std::vector< std::map<std::string, std::string> >
302  parmClipboardContents() = 0;
303 
304  // These methods return a new HOM_NodeType object or null if it couldn't
305  // be found.
306  virtual HOM_NodeType *nodeType(
307  HOM_NodeTypeCategory &category, const char *name) = 0;
308  virtual HOM_NodeType *nodeType(const char *name) = 0;
309 
310  virtual HOM_NodeType *preferredNodeType(
311  const char *name, HOM_Node *parentNode = NULL) = 0;
312 
313  virtual HOM_NodeTypeCategory &objNodeTypeCategory() = 0;
314  virtual HOM_NodeTypeCategory &sopNodeTypeCategory() = 0;
315 #if 0
316  virtual HOM_NodeTypeCategory &popNodeTypeCategory() = 0;
317 #endif
318  virtual HOM_NodeTypeCategory &dopNodeTypeCategory() = 0;
319  virtual HOM_NodeTypeCategory &cop2NodeTypeCategory() = 0;
320  virtual HOM_NodeTypeCategory &shopNodeTypeCategory() = 0;
321  virtual HOM_NodeTypeCategory &vopNodeTypeCategory() = 0;
322  virtual HOM_NodeTypeCategory &ropNodeTypeCategory() = 0;
323  virtual HOM_NodeTypeCategory &chopNodeTypeCategory() = 0;
324  virtual HOM_NodeTypeCategory &topNodeTypeCategory() = 0;
325  virtual HOM_NodeTypeCategory &lopNodeTypeCategory() = 0;
326 #if 0
327  virtual HOM_NodeTypeCategory &popNetNodeTypeCategory() = 0;
328 #endif
329  virtual HOM_NodeTypeCategory &cop2NetNodeTypeCategory() = 0;
330  virtual HOM_NodeTypeCategory &vopNetNodeTypeCategory() = 0;
331  virtual HOM_NodeTypeCategory &chopNetNodeTypeCategory() = 0;
332  virtual HOM_NodeTypeCategory &topNetNodeTypeCategory() = 0;
333  virtual HOM_NodeTypeCategory &managerNodeTypeCategory() = 0;
334  virtual HOM_NodeTypeCategory &rootNodeTypeCategory() = 0;
335  virtual std::map<std::string, HOM_NodeTypeCategory *>
336  nodeTypeCategories() = 0;
337 
338  virtual std::vector<HOM_ElemPtr<HOM_Node> > copyNodesTo(
339  const std::vector<HOM_Node *> &nodes,
340  HOM_Node &destination_node) = 0;
341  virtual std::vector<HOM_ElemPtr<HOM_Node> > moveNodesTo(
342  const std::vector<HOM_Node *> &nodes,
343  HOM_Node &destination_node) = 0;
344 
345  virtual HOM_NodeBundle *addNodeBundle(const char *name = NULL) = 0;
346  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > nodeBundles() = 0;
347  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > selectedNodeBundles() = 0;
348  virtual HOM_NodeBundle *nodeBundle(const char *name) = 0;
349 
350  virtual HOM_HDADefinition *hdaDefinition(
351  HOM_NodeTypeCategory &category, const char *name,
352  const char *file_path) = 0;
353 
354  // Note that getTimeWithoutAddingDependency is not wrapped by swig.
355  virtual fpreal getTimeWithoutAddingDependency() = 0;
356  virtual double time() = 0;
357  virtual void setTime(double time) = 0;
358  virtual double frame() = 0;
359  virtual int intFrame() = 0;
360  virtual void setFrame(double frame) = 0;
361  virtual double fps() = 0;
362  virtual void setFps(double fps) = 0;
363  virtual double timeToFrame(double time) = 0;
364  virtual double frameToTime(double frame) = 0;
365 
366  /// Private methods for ensuring that the current eval context
367  /// (including global time) is in-sync with the main thread's eval
368  /// context.
369  virtual void _syncFromMainContext() = 0;
370  virtual void _syncToMainContext() = 0;
371 
372  // Computes a scale factor given units
373  virtual fpreal scaleFromMKS(const char *units) = 0;
374  virtual fpreal scaleToMKS(const char *units) = 0;
375 
376  virtual double bezier() = 0;
377  virtual double constant() = 0;
378  virtual double cubic() = 0;
379  virtual double cycle(double start_frame, double end_frame) = 0;
380  virtual double cyclet(double start_time, double end_time) = 0;
381  virtual double cycleoffset(double start_frame, double end_frame) = 0;
382  virtual double cycleoffsett(double start_time, double end_time) = 0;
383  virtual double ease() = 0;
384  virtual double easein() = 0;
385  virtual double easeinp(double ease_speed) = 0;
386  virtual double easeout() = 0;
387  virtual double easeoutp(double ease_speed) = 0;
388  virtual double easep(double ease_bias) = 0;
389  virtual double linear() = 0;
390  virtual double match() = 0;
391  virtual double matchin() = 0;
392  virtual double matchout() = 0;
393  virtual double qlinear() = 0;
394  virtual double quintic() = 0;
395  virtual double repeat(double start_frame, double end_frame) = 0;
396  virtual double repeatt(double start_time, double end_time) = 0;
397  virtual double spline() = 0;
398  virtual double vmatch() = 0;
399  virtual double vmatchin() = 0;
400  virtual double vmatchout() = 0;
401 
402  virtual std::string chopExportConflictResolutionPattern() = 0;
403  virtual void setChopExportConflictResolutionPattern( const char *pattern) = 0;
404 
405  virtual std::vector<HOM_ElemPtr<HOM_VexContext> >
406  vexContexts() = 0;
407 
408  virtual HOM_VexContext* vexContextForShaderType(HOM_EnumValue &shader_type) = 0;
409 
410  virtual HOM_VexContext* vexContextForNodeTypeCategory(
411  HOM_NodeTypeCategory &node_type_category) = 0;
412 
413  virtual std::string helpServerUrl() = 0;
414 
415  virtual std::string hscriptCommandHelp(const char *command_name) = 0;
416 
417  // This method returns a pair of strings: one for stdout and one for
418  // stderr.
419  virtual std::vector<std::string> hscript(const char *command) = 0;
420 
421  // Compare if two numbers are almost equal.
422  virtual bool almostEqual(double x, double y) = 0;
423 
424  virtual std::vector<std::pair<HOM_ElemPtr<HOM_Parm>, std::string> >
425  fileReferences(
426  const char *project_dir_variable="HIP", bool include_all_refs=true) = 0;
427 
428  // Find files in $HOUDINI_PATH.
429  virtual std::string findFile(const char *file_name) = 0;
430  virtual std::vector<std::string> findFiles(
431  const char *file_name) = 0;
432  virtual std::vector<std::string> findFilesWithExtension(
433  const char *file_extension, const char *subdirectory = NULL) = 0;
434 
435  // Find directories in $HOUDINI_PATH.
436  virtual std::string findDirectory(const char *directory_name) = 0;
437  virtual std::vector<std::string> findDirectories(
438  const char *directory_name) = 0;
439 
440  virtual std::vector<std::string> houdiniPath(const char *pathvar = nullptr) = 0;
441 
442  virtual std::string homeHoudiniDirectory() = 0;
443 
444 #if defined(USE_PYTHON3)
445  virtual std::string readFile(const char *file_path) = 0;
446  virtual HOM_BinaryString readBinaryFile(const char *file_path) = 0;
447 #else
448  virtual HOM_BinaryString readFile(const char *file_path) = 0;
449 #endif
450 
451  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromString(
452  const char *data, int length) = 0;
453 
454  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromFile(
455  const char *file_path) = 0;
456 
457 #if PY_VERSION_HEX >= 0x03000000
458  virtual HOM_BinaryString saveIndexDataToString(
459  const std::map<std::string, HOM_BinaryString> &index_data) = 0;
460 
461  virtual void saveIndexDataToFile(
462  const char *file_path,
463  const std::map<std::string, HOM_BinaryString> &index_data) = 0;
464 #else
465  virtual HOM_BinaryString saveIndexDataToString(
466  const std::map<std::string, std::string> &index_data) = 0;
467 
468  virtual void saveIndexDataToFile(
469  const char *file_path,
470  const std::map<std::string, std::string> &index_data) = 0;
471 #endif
472 
473  // Note that, when wrapped by swig, this function takes a single string
474  // parameter.
475  virtual std::vector<std::pair<std::string, HOM_BinaryString> >
476  loadCPIODataFromString(const char *data, int length) = 0;
477 
478 #if PY_VERSION_HEX >= 0x03000000
479  virtual HOM_BinaryString saveCPIODataToString(
480  const std::vector<std::pair<std::string, HOM_BinaryString> >
481  &data) = 0;
482 #else
483  virtual HOM_BinaryString saveCPIODataToString(
484  const std::vector<std::pair<std::string, std::string> > &data) = 0;
485 #endif
486 
487  // These 3 methods are not wrapped by swig. They are used to notify
488  // interested parties that a change to the module source code was made and
489  // that they should forcefully update to match the change. The third
490  // is used to load the session module source from a hip file, even though
491  // that source might generate an exception.
492  virtual UT_NotifierImpl<int> &getSessionModuleSourceForceUpdateNotifier()=0;
493  virtual void forceUpdateFromSessionModuleSource() = 0;
494  virtual void forceSetSessionModuleSource(const char *source) = 0;
495 
496  virtual void setSessionModuleSource(const char *source) = 0;
497  virtual void appendSessionModuleSource(const char *source) = 0;
498  virtual std::string sessionModuleSource() = 0;
499  // This method is not wrapped by swig:
500  virtual int sessionModuleSourceChangeCount() = 0;
501 
502  // This static method lets you know if the HOM implementation is set,
503  // so you can check if it's safe to call the HOM() function. This method
504  // should only be called in rare cases.
505  static bool isImplementationSet()
506  { return theImplementation != NULL; }
507 
508  // Evaluates a parameter as if it was an OPpath parameter
509  virtual std::string chsop(const char *path) = 0;
510 
511  // Evaluates a parameter as if it was an OPlist parameter
512  virtual std::string chsoplist(const char *path) = 0;
513 
514  // Sorts a list of node paths using topological order from the graph.
515  virtual std::vector<std::string>
516  sortedNodePaths(const std::vector<std::string> &paths) = 0;
517 
518  // Sorts a list of HOM_Node using topological order from the graph.
519  virtual std::vector<HOM_ElemPtr<HOM_Node> >
520  sortedNodes(const std::vector<HOM_Node*> &nodes) = 0;
521 
522  virtual int patternMatch(
523  const char *pattern, const char *str,
524  bool ignore_case = false,
525  bool path_match = false) = 0;
526 
527  // hscriptExpression() will return different types, according to
528  // the return value of the expression.
529  virtual hboost::any hscriptExpression(const char *expression) = 0;
530  virtual double hscriptFloatExpression(const char *expression) = 0;
531  virtual std::string hscriptStringExpression(const char *expression) = 0;
532  virtual std::vector<double>hscriptVectorExpression(
533  const char *expression) = 0;
534  virtual std::vector<std::vector<double> > hscriptMatrixExpression(
535  const char *expression) = 0;
536 
537  virtual hboost::any lvar(const char *name) = 0;
538 
539  virtual char *getenv(const char *name, const char *default_value=NULL) = 0;
540 
541  virtual void putenv(const char *name, const char *value) = 0;
542 
543  virtual void unsetenv(const char *name) = 0;
544 
545  virtual void allowEnvironmentToOverwriteVariable(
546  const char *name, bool onoff) = 0;
547 
548  virtual void *expressionGlobals() = 0;
549 
550  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
551 
552  // This method is used to interact with the global interrupt object.
553  virtual bool updateProgressAndCheckForInterrupt(int percentage=-1) = 0;
554 
555  virtual std::map<std::string, hboost::any> runVex(
556  const char *vex_file,
557  const std::map<std::string, hboost::any> &inputs,
558  const char *precision = "32") = 0;
559 
560  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
561 
562  virtual void saveImageDataToFile(
563  const std::vector<float> &color_and_alpha_data,
564  int width, int height,
565  const char *file_name) = 0;
566 
567  virtual void saveImageDataToFile(
568  const std::string &color_and_alpha_data,
569  int width, int height,
570  const char *file_name) = 0;
571 
572  virtual HOM_BinaryString loadImageDataFromFile(
573  const char *image_file_name,
574  HOM_EnumValue &image_depth = HOM_imageDepth::Int8) = 0;
575 
576  virtual std::vector<int> imageResolution(const char *image_file_name) = 0;
577 
578  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
579 
580  virtual HOM_EnumValue &updateModeSetting() = 0;
581  virtual void setUpdateMode(HOM_EnumValue &mode) = 0;
582 
583  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
584 
585  virtual HOM_OrboltURLHandler *orboltURLHandler() = 0;
586 
587  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
588 
589  virtual void *opaqueRunCallbackAndCatchCrashes(void *opaque_callback) = 0;
590 
591  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
592 
593  // These methods are used to grant functions defined in an asset's
594  // PythonModule enhanced privileges. They are not wrapped by swig.
595  virtual void pushAccessPrivilege(const char *key) = 0;
596  virtual void popAccessPrivilege(const char *key) = 0;
597 
598  virtual std::string currentPythonModuleKey() = 0;
599 
600  virtual void registerAccessPrivilegePyClient(void *opaque_python_object) = 0;
601 
602  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
603 
604  // These methods are used to instantiate HOMF objects from the HOM
605  // library level. They are not wrapped by swig.
606  virtual HOM_FloatParmTemplate *newFloatParmTemplate(
607  const char *name,
608  const char *label,
609  int num_components,
610  const std::vector<double> &default_value,
611  double min, double max,
612  bool min_is_strict, bool max_is_strict,
613  HOM_EnumValue &look,
614  HOM_EnumValue &naming_scheme,
615  const char *disable_when,
616  bool is_hidden,
617  bool is_label_hidden,
618  bool join_with_next,
619  const char *help,
620  const char *script_callback,
621  HOM_EnumValue &script_callback_language,
622  const std::map<std::string, std::string> &tags,
623  const std::map<HOM_EnumValue *, std::string> &conditionals,
624  const std::vector<std::string> &default_expression,
625  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
626 
627  virtual HOM_IntParmTemplate *newIntParmTemplate(
628  const char *name,
629  const char *label,
630  int num_components,
631  const std::vector<int> &default_value,
632  int min, int max,
633  bool min_is_strict, bool max_is_strict,
634  HOM_EnumValue &naming_scheme,
635  const std::vector<std::string> &menu_items,
636  const std::vector<std::string> &menu_labels,
637  const std::vector<std::string> &icon_names,
638  const std::string &item_generator_script,
639  HOM_EnumValue *item_generator_script_language,
640  HOM_EnumValue &menu_type,
641  bool menu_use_token,
642  const char *disable_when,
643  bool is_hidden,
644  bool is_label_hidden,
645  bool join_with_next,
646  const char *help,
647  const char *script_callback,
648  HOM_EnumValue &script_callback_language,
649  const std::map<std::string, std::string> &tags,
650  const std::map<HOM_EnumValue *, std::string> &conditionals,
651  const std::vector<std::string> &default_expression,
652  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
653 
654  virtual HOM_StringParmTemplate *newStringParmTemplate(
655  const char *name,
656  const char *label,
657  int num_components,
658  const std::vector<std::string> &default_value,
659  HOM_EnumValue &naming_scheme,
661  HOM_EnumValue &file_type,
662  const std::vector<std::string> &menu_items,
663  const std::vector<std::string> &menu_labels,
664  const std::vector<std::string> &icon_names,
665  const std::string &item_generator_script,
666  HOM_EnumValue *item_generator_script_language,
667  HOM_EnumValue &menu_type,
668  const char *disable_when,
669  bool is_hidden,
670  bool is_label_hidden,
671  bool join_with_next,
672  const char *help,
673  const char *script_callback,
674  HOM_EnumValue &script_callback_language,
675  const std::map<std::string, std::string> &tags,
676  const std::map<HOM_EnumValue *, std::string> &conditionals,
677  const std::vector<std::string> &default_expression,
678  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
679 
680  virtual HOM_DataParmTemplate *newDataParmTemplate(
681  const char *name,
682  const char *label,
683  int num_components,
684  HOM_EnumValue &look,
685  HOM_EnumValue &naming_scheme,
686  HOM_EnumValue &data_parm_type,
687  const char *disable_when,
688  bool is_hidden,
689  bool is_label_hidden,
690  bool join_with_next,
691  const char *help,
692  const char *script_callback,
693  HOM_EnumValue &script_callback_language,
694  const std::map<std::string, std::string> &tags,
695  const std::map<HOM_EnumValue *, std::string> &conditionals,
696  const std::vector<std::string> &default_expression,
697  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
698 
699  virtual HOM_ToggleParmTemplate *newToggleParmTemplate(
700  const char *name,
701  const char *label,
702  bool default_value,
703  const char *disable_when,
704  bool is_hidden,
705  bool is_label_hidden,
706  bool join_with_next,
707  const char *help,
708  const char *script_callback,
709  HOM_EnumValue &script_callback_language,
710  const std::map<std::string, std::string> &tags,
711  const std::map<HOM_EnumValue *, std::string> &conditionals,
712  const std::string &default_expression,
713  const HOM_EnumValue &default_expression_language) = 0;
714 
715  virtual HOM_MenuParmTemplate *newMenuParmTemplate(
716  const char *name,
717  const char *label,
718  const std::vector<std::string> &menu_items,
719  const std::vector<std::string> &menu_labels,
720  int default_value,
721  const std::vector<std::string> &icon_names,
722  const std::string &item_generator_script,
723  HOM_EnumValue *item_generator_script_language,
724  HOM_EnumValue &menu_type,
725  bool menu_use_token,
726  const char *disable_when,
727  bool is_hidden,
728  bool is_label_hidden,
729  bool join_with_next,
730  const char *help,
731  const char *script_callback,
732  HOM_EnumValue &script_callback_language,
733  const std::map<std::string, std::string> &tags,
734  const std::map<HOM_EnumValue *, std::string> &conditionals,
735  const std::string &default_expression,
736  const HOM_EnumValue &default_expression_language,
737  bool store_default_value_as_string,
738  bool is_button_strip,
739  bool strip_uses_icons
740  ) = 0;
741 
742  virtual HOM_ButtonParmTemplate *newButtonParmTemplate(
743  const char *name,
744  const char *label,
745  const char *disable_when,
746  bool is_hidden,
747  bool is_label_hidden,
748  bool join_with_next,
749  const char *help,
750  const char *script_callback,
751  HOM_EnumValue &script_callback_language,
752  const std::map<std::string, std::string> &tags,
753  const std::map<HOM_EnumValue *, std::string> &conditionals ) = 0;
754 
755  virtual HOM_LabelParmTemplate *newLabelParmTemplate(
756  const char *name,
757  const char *label,
758  const std::vector<std::string> &column_labels,
759  bool is_hidden,
760  bool is_label_hidden,
761  bool join_with_next,
762  const char *help,
763  const std::map<std::string, std::string> &tags,
764  const std::map<HOM_EnumValue *, std::string> &conditionals) = 0;
765 
766  virtual HOM_SeparatorParmTemplate *newSeparatorParmTemplate(
767  const char *name,
768  bool is_hidden,
769  const std::map<std::string, std::string> &tags,
770  const std::map<HOM_EnumValue *, std::string> &conditionals) = 0;
771 
772  virtual HOM_FolderSetParmTemplate *newFolderSetParmTemplate(
773  const char *name,
774  const std::vector<std::string> &folder_names,
775  HOM_EnumValue &folder_type,
776  const std::map<std::string, std::string> &tags) = 0;
777 
778  virtual HOM_FolderParmTemplate *newFolderParmTemplate(
779  const char *name,
780  const char *label,
781  const std::vector<HOM_ParmTemplate *> &parm_templates,
782  HOM_EnumValue &folder_type,
783  int default_value,
784  bool is_hidden,
785  bool ends_tab_group,
786  const char *script_callback,
787  HOM_EnumValue &script_callback_language,
788  const std::map<std::string, std::string> &tags,
789  const std::map<HOM_EnumValue *, std::string> &conditionals,
790  const std::map<HOM_EnumValue *, std::string> &tab_conditionals) = 0;
791 
792  virtual HOM_RampParmTemplate *newRampParmTemplate(
793  const char *name,
794  const char *label,
795  HOM_EnumValue &ramp_parm_type,
796  int default_value,
797  HOM_EnumValue *default_basis,
798  bool show_controls,
799  HOM_EnumValue *color_type,
800  const char *disable_when,
801  bool is_hidden,
802  const char *help,
803  const char *script_callback,
804  HOM_EnumValue &script_callback_language,
805  const std::map<std::string, std::string> &tags,
806  const std::map<HOM_EnumValue *, std::string> &conditionals,
807  const std::string &default_expression,
808  const HOM_EnumValue &default_expression_language) = 0;
809 
810  virtual HOM_ParmTemplateGroup *newParmTemplateGroup(
811  const std::vector<HOM_ParmTemplate *> &parm_templates) = 0;
812 
813  virtual HOM_PerfMonRecordOptions *newPerfMonRecordOptions(
814  bool cook_stats, bool pdg_cook_stats, bool solve_stats,
815  bool draw_stats, bool gpu_draw_stats, bool viewport_stats,
816  bool script_stats, bool render_stats, bool thread_stats,
817  bool frame_stats, bool memory_stats, bool errors,
818  bool pane_stats) = 0;
819 
820  virtual HOM_Keyframe *newKeyframe() = 0;
821  virtual HOM_Keyframe *newKeyframe(double value) = 0;
822  virtual HOM_Keyframe *newKeyframe(double value, double time) = 0;
823  virtual HOM_Keyframe *newKeyframe(const HOM_Keyframe &keyframe) = 0;
824 
825  virtual HOM_StringKeyframe *newStringKeyframe() = 0;
826  virtual HOM_StringKeyframe *newStringKeyframe(
827  const std::string &value, HOM_EnumValue &language) = 0;
828  virtual HOM_StringKeyframe *newStringKeyframe(
829  const std::string &value, double time, HOM_EnumValue &language) = 0;
830  virtual HOM_StringKeyframe *newStringKeyframe(
831  const HOM_StringKeyframe &string_keyframe) = 0;
832 
833  virtual HOM_HDAOptions *newHDAOptions() = 0;
834  virtual HOM_LopViewportLoadMasks *newLopViewportLoadMasks() = 0;
835  virtual HOM_LopInstanceIdRule *newLopInstanceIdRule() = 0;
836  virtual HOM_LopSelectionRule *newLopSelectionRule() = 0;
837 
838  virtual HOM_InterruptableOperation *newInterruptableOperation(
839  const char *operation_name, const char *long_operation_name,
840  bool open_interrupt_dialog) = 0;
841 
842  virtual HOM_RedrawBlock *newRedrawBlock() = 0;
843 #ifndef SWIG
844  virtual HOM_RedrawResumeBlock *newRedrawResumeBlock() = 0;
845 #endif
846 
847  virtual HOM_StyleSheet *newStyleSheet() = 0;
848  virtual HOM_StyleSheet *newStyleSheet(const char *json_text) = 0;
849 
850  virtual HOM_Selection *newSelection(HOM_EnumValue &selection_type,
851  HOM_Geometry *geo, const char *selection_string) = 0;
852  virtual HOM_Selection *newSelection(
853  const std::vector<HOM_EnumValue *> &selection_types,
854  HOM_Geometry *geo, const char *selection_string) = 0;
855  virtual HOM_Selection *newSelection(
856  const std::vector<HOM_Prim *> &prims) = 0;
857  virtual HOM_Selection *newSelection(
858  const std::vector<HOM_Point *> &points) = 0;
859  virtual HOM_Selection *newSelection(
860  const std::vector<HOM_Vertex *> &vertices) = 0;
861  virtual HOM_Selection *newSelection(
862  const std::vector<HOM_Edge *> &edges) = 0;
863 
864  // This method returns a new HOM_Geometry object.
865  virtual HOM_Geometry *newGeometry(HOM_Geometry *geo = nullptr,
866  bool clone_data_ids = false) = 0;
867 
868  virtual HOM_GeometryRayCache *newGeometryRayCache() = 0;
869 
870  virtual HOM_DopSimulation *newDopSimulation() = 0;
871 
872  virtual HOM_Clip *newClip() = 0;
873 
874  virtual HOM_AgentDefinition *newAgentDefinition(
875  const HOM_AgentRig &rig, const HOM_AgentShapeLibrary &shapelib) = 0;
876 
877  virtual HOM_AgentClip *newAgentClip(
878  const char *name, const char *path, const HOM_AgentRig &rig,
879  bool keep_external_ref, bool delay_load) = 0;
880 
881  virtual HOM_AgentClip *newAgentClip(
882  const char *name, HOM_ChopNode &chop, const HOM_AgentRig &rig,
883  double frame) = 0;
884 
885  virtual HOM_AgentClip *newAgentClip(
886  const char *name, const HOM_AgentRig &rig, int sample_count) = 0;
887 
888  virtual HOM_AgentClip *newAgentClip(
889  const HOM_AgentClip &clip, const HOM_AgentRig &rig,
890  const char *name) = 0;
891 
892  virtual HOM_AgentRig *newAgentRig(const char *path, bool keep_external_ref) = 0;
893 
894  virtual HOM_AgentRig *newAgentRig(
895  const char *name, const std::vector<std::string> &transform_names,
896  const std::vector<std::vector<int>> &hierarchy) = 0;
897 
898  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
899  const char *path, const HOM_AgentRig &rig,
900  bool keep_external_ref = true) = 0;
901 
902  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
903  const char *name, const std::vector<int> &transforms,
904  const HOM_AgentRig &rig, const std::vector<double> &weights,
905  const std::vector<int> &channels) = 0;
906 
907  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary() = 0;
908  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary(
909  HOM_Geometry &geometry, const char *name) = 0;
910  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary(
911  const char *path, bool keep_external_ref) = 0;
912 
913  virtual HOM_AgentShapeBinding *
914  newAgentShapeBinding(int transform, const HOM_AgentShape &shape,
915  bool deforming, double bounds_scale) = 0;
916 
917  virtual HOM_AgentShapeBinding *
918  newAgentShapeBinding(int transform, const HOM_AgentShape &shape,
919  const HOM_AgentShapeDeformer *deformer,
920  double bounds_scale) = 0;
921 
922  virtual HOM_AgentShapeDeformer *
923  newAgentShapeDeformer(const char *name) = 0;
924 
925  virtual HOM_AgentShapeDeformer *
926  newAgentShapeDeformer(const HOM_EnumValue &deformer_type) = 0;
927 
928  virtual HOM_AgentLayer *newAgentLayer(
929  const char *name, const HOM_AgentRig &rig,
930  const HOM_AgentShapeLibrary &shapelib,
931  const std::vector<HOM_AgentShapeBinding *> &shape_bindings,
932  const HOM_AgentLayer *source_layer = 0) = 0;
933 
934  virtual HOM_AgentLayer *
935  newAgentLayer(const char *path, const HOM_AgentRig &rig,
936  const HOM_AgentShapeLibrary &shapelib,
937  bool keep_external_ref = true) = 0;
938 
939  virtual HOM_AgentMetadata *newAgentMetadata(
940  const char *path,
941  bool keep_external_ref = true) = 0;
942  virtual HOM_AgentMetadata *newAgentMetadata(
943  const std::map<std::string, hboost::any> &data) = 0;
944 
945  virtual bool compareNode(const char *path, const char *dest = NULL) = 0;
946  virtual bool compareNodeBackup(const char *path, int index,
947  const char *dest = NULL) = 0;
948  virtual bool compareHDA(const char *path_left, const char *path_right,
949  const char *dest = NULL) = 0;
950  virtual bool compareHDABackup(const char *path, int index,
951  const char *dest = NULL) = 0;
952  virtual bool compareHip(const char *dest = NULL) = 0;
953  virtual bool compareHipBackup(int index, const char *dest = NULL) = 0;
954 
955  virtual bool hasContextOption(const char *opt) = 0;
956  virtual UT_OptionEntryPtr contextOption(const char *opt) = 0;
957  virtual std::vector<std::string> contextOptionNames() = 0;
958  virtual void setContextOption(const char *opt, const char *value) =0;
959  virtual void setContextOption(const char *opt, double value) = 0;
960  virtual void removeContextOption(const char *opt) = 0;
961  virtual std::string contextOptionConfig(const char *opt) = 0;
962  virtual void setContextOptionConfig(const char *opt,
963  const char *config) = 0;
964 
965  SWIGOUT(%ignore addOpaqueContextOptionChangeCallback;)
966  virtual void addOpaqueContextOptionChangeCallback(void *callback) = 0;
967  SWIGOUT(%ignore removeOpaqueContextOptionChangeCallback;)
968  virtual void removeOpaqueContextOptionChangeCallback(void *callback) = 0;
969 
970  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
971 
972  // This method is called when orbolt_url runs. It is not wrapped by swig.
973  virtual void setOrboltURLHandler(
974  STORUI_OrboltURLHandler &orbolt_url_handler) = 0;
975 
976  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
977 
978  // These methods are used to help debug HOM to make sure no objects
979  // get allocated that don't get deallocated.
980  virtual void constructObject(void *pointer, const std::type_info &type) = 0;
981  virtual void destructObject(void *pointer, const std::type_info &type) = 0;
982  virtual std::map<std::string, int> objectCounts() = 0;
983 
984  // Preferences
985  virtual std::vector<std::string> getPreferenceNames() = 0;
986  virtual std::string getPreference(const char *name) = 0;
987  virtual bool setPreference(const char *name, const char* value) = 0;
988  virtual bool addPreference(const char *name, const char* value) = 0;
989  virtual bool removePreference(const char *name) = 0;
990 
991  virtual HOM_ViewerStateTemplate * newViewerStateTemplate(
992  std::string const & type_name,
993  std::string const & label,
994  HOM_NodeTypeCategory const & category,
995  std::vector<HOM_NodeTypeCategory*> const & contexts) = 0;
996 
997  virtual HOM_ViewerHandleTemplate * newViewerHandleTemplate(
998  std::string const & type_name,
999  std::string const & label,
1000  std::vector<HOM_NodeTypeCategory*> const & categories) = 0;
1001 
1002  virtual HOM_ViewerStateMenu * newViewerStateMenu(std::string const & handle, std::string const & label) = 0;
1003 
1004  virtual HOM_SimpleDrawable * newSimpleDrawable( HOM_SceneViewer& scene_viewer, HOM_EnumValue const &prim_type, std::string const &name) = 0;
1005  virtual HOM_SimpleDrawable * newSimpleDrawable( HOM_SceneViewer& scene_viewer, HOM_Geometry const &geometry, std::string const &name) = 0;
1006 
1007  virtual HOM_ViewerHandleDragger * newViewerHandleDragger(std::string const & name) = 0;
1008  virtual HOM_ViewerStateDragger * newViewerStateDragger(std::string const & name, HOM_Matrix4 const & xform, HOM_Matrix4 const & inv_xform) = 0;
1009 
1010  virtual HOM_UIEvent * newUIEvent( int64 val ) = 0;
1011  virtual HOM_ViewerEvent * newViewerEvent( HOM_SceneViewer& sceneViewer, int64 val ) = 0;
1012  virtual HOM_UIEventDevice * newUIEventDevice(int64 val, int64 val2) = 0;
1013 
1014  virtual HOM_Handle * newHandle(HOM_SceneViewer& scene_viewer, std::string const &name ) = 0;
1015  virtual HOM_ViewerHandleContext * newViewerHandleContext(int64 val) = 0;
1016 
1017  virtual HOM_ViewerStateContext * newViewerStateContext(int64 val) = 0;
1018 
1019  virtual HOM_TextDrawable * newTextDrawable(
1020  HOM_SceneViewer& scene_viewer,
1021  std::string const & name,
1022  std::map<std::string, hboost::any> const & params,
1023  std::string const & label) = 0;
1024 
1025  virtual HOM_GeometryDrawable * newGeometryDrawable(
1026  HOM_SceneViewer& scene_viewer,
1027  HOM_EnumValue const & geo_type,
1028  std::string const & name,
1029  HOM_Geometry * geometry,
1030  std::map<std::string, hboost::any> const & params,
1031  std::string const & label) = 0;
1032 
1033  virtual HOM_GeometryDrawableGroup* newGeometryDrawableGroup(std::string const & name, std::string const & label) = 0;
1034 
1035  virtual HOM_GadgetDrawable * newGadgetDrawable(int64 widget, int64 gadget_context) = 0;
1036 
1037  virtual void startHoudiniEngineDebugger(unsigned short port) = 0;
1038  virtual void startHoudiniEngineDebugger(const char *pipe_name) = 0;
1039 
1040  virtual HOM_GeometrySelection * newGeometrySelection() = 0;
1041  virtual HOM_GeometrySelection * newGeometrySelection(int64 val) = 0;
1042 
1043  virtual HOM_BinaryString convertClipData(HOM_BinaryString data,
1044  bool from_binary,
1045  bool from_blosc_compression,
1046  bool to_binary,
1047  bool to_blosc_compression) = 0;
1048 
1049  virtual HOM_BinaryString convertKeyframesToClipData(
1050  const std::map<std::string, std::vector<HOM_Keyframe *>> &keyframe_map,
1051  bool binary = true, bool use_blosc_compression = true) = 0;
1052 
1053  virtual std::string _clipInfo(HOM_BinaryString data, bool binary = true,
1054  bool blosc_compressed = true) = 0;
1055 
1056  virtual std::vector<HOM_ElemPtr<HOM_Node> > _nodesFromOPNodeList(int64 val) = 0;
1057  virtual std::vector<HOM_ElemPtr<HOM_DopData> >
1058  _dopDataList(int64 val) = 0;
1059  virtual std::vector<std::pair<HOM_ElemPtr<HOM_DopData>, HOM_ElemPtr<HOM_GeometrySelection> > >
1060  _dopDataPointList(int64 val) = 0;
1061  virtual std::vector<std::pair<HOM_ElemPtr<HOM_DopData>, HOM_ElemPtr<HOM_GeometrySelection> > >
1062  _dopDataPolyList(int64 val) = 0;
1063 
1064  virtual HOM_AttribDataId * newAttribDataId() = 0;
1065 
1066  virtual std::string userName(bool alpha=true) = 0;
1067 
1068  virtual std::string machineName(bool alpha=true) = 0;
1069 
1070  virtual HOM_GeometryDrawable * _newGeometryDrawable(int64 val) = 0;
1071 
1072  virtual HOM_Node * createAnimationLayers(const std::string &path) = 0;
1073  virtual HOM_Node * addAnimationLayer(HOM_Node &layermixer, const std::string &layername) = 0;
1074  virtual bool removeAnimationLayer(HOM_Node &layermixer, const std::string &layername, bool merge=false) = 0;
1075  virtual HOM_Node* createAnimationClip(const std::string &path, bool set_export) = 0;
1076 private:
1077  // HOMF_Module::createHOMModule() uses this to create the HOM_Module.
1078  static void (*theHOMCreator)();
1079 
1080  // A subclass of HOM_Module in the HOMF library will define the
1081  // implementation of HOM. Importing the python module will set the
1082  // implementation, so this function should only be called by HOMF_Module::
1083  // createHOMModule().
1084  friend class HOMF_Module;
1085  static void setImplementation(HOM_Module* implementation);
1086 
1087  // We could add a static method to access the implementation, but we
1088  // want to make it easy to access the HOM module from C++. So, the
1089  // global function HOM() needs access to the implementation.
1090  friend HOM_API HOM_Module& HOM();
1091  static HOM_Module *theImplementation;
1092 };
1093 
1094 
1095 // Use this function to automatically delete objects for functions that
1096 // return new objects. This lets you, for example, write code like
1097 // HOMdel(HOM().findNode("/obj/geo1"))->setName("geo2")
1098 template <typename T>
1100 { return UT_UniquePtr<T>(hom_object); }
1101 
1102 
1103 // This lock is used to synchronize HOM scripts running in a separate
1104 // thread and Houdini. Houdini's UI queue will give up the lock when it's
1105 // waiting for events and reacquire it when it handles an event.
1106 //
1107 // Note that this lock allows multiple threads in the same thread group to hold
1108 // it at the same time. By default, a thread started from Houdini is added to
1109 // the group containing the main thread. This way, since Houdini started the
1110 // thread, we can be confident that it will use other locks to synchronize
1111 // access to Houdini. This approach allows, for example, a volume SOP to
1112 // cook using multiple threads, evaluating Python in each thread while the
1113 // main thread holds the HOM lock, without deadlocking and without allowing
1114 // non-Houdini threads to acquire the HOM lock. (Note that the GIL will
1115 // synchronize access to Python's internals.)
1118 {
1119  // This is not thread-safe but should be ok because HOMgetLock() is called
1120  // pretty early on during startup when there is only one thread executing.
1121  if (!HOM_theHOMLock)
1122  HOM_theHOMLock = new UT_TaskRootLock();
1123 
1124  UT_ASSERT(HOM_theHOMLock);
1125  return *HOM_theHOMLock;
1126 }
1127 
1128 // The HOM implementation uses the HOM_AutoLock to make sure Houdini isn't busy
1129 // when they make calls into the Houdini libraries. Note that constructing
1130 // a HOM_AutoLock will release the python global interpreter lock (GIL) if
1131 // it was held before acquiring the HOM lock. This way, other python threads
1132 // can run if it needs to block waiting for the HOM lock.
1134 {
1135 public:
1137  {
1138  if (!HOMgetLock().hasLock())
1139  {
1140  HOMgetLock().lock();
1141  myLocked = true;
1142  }
1143  else
1144  myLocked = false;
1145  }
1146 
1148  {
1149  if (myLocked)
1150  HOMgetLock().unlock();
1151  }
1152 
1153 private:
1154 
1155  // It is important that we release the python global interpreter lock
1156  // (GIL) for the duration of waiting for, acquiring and holding onto
1157  // the HOM lock. This gives other threads that are either blocked
1158  // on the GIL or that will try to acquire the GIL a chance to continue
1159  // execution.
1160  //
1161  // If the current thread needs to access the Python API,
1162  // then it should explicitly acquire the GIL by creating a
1163  // PY_InterpreterAutoLock object. The PY_InterpreterAutoLock must be
1164  // constructed *after* the HOM_AutoLock or it will have no effect.
1165  //
1166  // This prevents deadlocks that occur when the current thread
1167  // spawns other threads which access the Python API and try to
1168  // acquire the GIL.
1169  //
1170  // Note that we will reacquire the GIL when the HOM auto lock is destructed.
1171  PY_InterpreterAutoUnlock myPyInterpAutoUnlock;
1172 
1173  // Boolean to determine if the auto lock actually locked the HOM lock.
1174  bool myLocked;
1175 };
1176 
1177 // The HOM implementation uses HOM_AutoUnlock to allow the main thread to
1178 // run while waiting for something to happen. Constructing a HOM_AutoUnlock
1179 // instance will release the HOM lock but not the Python GIL. When it's
1180 // destructed it will reacquire the HOM lock. Since it releases the HOM lock,
1181 // it's important that a HOM_AutoLock was already created in a containing
1182 // scope.
1183 //
1184 // Use HOM_AutoUnlock in conjunction with PY_InterpreterAutoUnlock to
1185 // also release the Python GIL. Be sure to create the HOM_AutoUnlock *after*
1186 // the PY_InterpreterAutoUnlock, so that when the auto locks are destructed
1187 // the HOM lock is reacquired before the Python GIL. Otherwise, it will grab
1188 // the GIL and then try to grab the HOM lock, and if another thread with the
1189 // HOM lock tries to run Python we'll end up with deadlock.
1191 {
1192 public:
1194  { HOMgetLock().unlock(); }
1195 
1197  { HOMgetLock().lock(); }
1198 };
1199 
1200 
1201 // These macros are used to help detect memory leaks when debugging is enabled.
1202 #ifdef HOM_DEBUG
1203 #define HOM_CONSTRUCT_OBJECT(pointer) \
1204  HOM().constructObject(pointer, typeid(*pointer));
1205 #define HOM_DESTRUCT_OBJECT(pointer) \
1206  HOM().destructObject(pointer, typeid(*pointer));
1207 #else
1208 #define HOM_CONSTRUCT_OBJECT(pointer)
1209 #define HOM_DESTRUCT_OBJECT(pointer)
1210 #endif
1211 
1212 // NOTE: These typedefs cannot actually be used in any method declaration
1213 // that SWIG needs to generate code for because it doesn't understand
1214 // them.
1215 // gcc gets a parse error if we try to give a default map value in the
1216 // signature, and the typedef avoids the error.
1217 typedef std::map<std::string, std::string> HOM_StdMapStringString;
1218 typedef std::map<HOM_EnumValue *, std::string> HOM_StdMapEnumString;
1219 
1220 
1221 // Houdini will call HOMextendLibrary() in HDK dso's so the user can install
1222 // C++ HOM extensions.
1223 extern "C" {
1225 }
1226 
1227 #endif //__HOM_Module_h__
GLbyte * weights
Definition: glew.h:7551
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
OIIO_API string_view getenv(string_view name)
GLuint const GLchar * name
Definition: glew.h:1814
GLclampf GLclampf GLclampf alpha
Definition: glew.h:1520
GLenum mode
Definition: glew.h:2163
#define SYS_VISIBILITY_EXPORT
UT_TaskRootLock & HOMgetLock()
Definition: HOM_Module.h:1117
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1252
GLuint GLenum GLenum transform
Definition: glew.h:14742
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
GLuint const GLfloat * val
Definition: glew.h:2794
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1252
UT_UniquePtr< T > HOMdel(T *hom_object)
Definition: HOM_Module.h:1099
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
Definition: HOM_ik.h:21
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
Definition: HOM_qt.h:20
GLenum condition
Definition: glew.h:12785
UT_TaskLockT< false > UT_TaskRootLock
Definition: UT_TaskLock.h:282
GLsizei GLenum * categories
Definition: glew.h:2581
HOM_API UT_TaskRootLock * HOM_theHOMLock
bool any(const vbool4 &v)
Definition: simd.h:3372
#define HOM_API
Definition: HOM_API.h:13
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
virtual ~HOM_Module()
Definition: HOM_Module.h:169
const GLuint GLenum const void * binary
Definition: glew.h:3502
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
Definition: HOM_ui.h:44
void
Definition: png.h:1083
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
GLuint color
Definition: glew.h:7902
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
GLuint GLsizei GLsizei GLchar * label
Definition: glew.h:8986
std::map< HOM_EnumValue *, std::string > HOM_StdMapEnumString
Definition: HOM_Module.h:1218
GLsizei const GLchar *const * path
Definition: glew.h:6461
GLsizei const GLchar *const * string
Definition: glew.h:1844
SYS_VISIBILITY_EXPORT void HOMextendLibrary()
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
std::string OIIO_API repeat(string_view str, int n)
Repeat a string formed by concatenating str n times.
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2579
GLsizei const void * pointer
Definition: glew.h:1523
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3446
virtual bool readFile(GA_Detail &g, const char *filename, const GA_LoadOptions *opts, UT_StringArray *errors) const
Class which defines an I/O interface to save/load geometry.
const GLfloat * params
Definition: glew.h:1531
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
SYS_VISIBILITY_EXPORT void newHandle(BM_ResourceManager *m)
void unlock()
Definition: UT_TaskLock.h:254
Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t)
Definition: ImathQuat.h:545
GLubyte * pattern
Definition: glew.h:5711
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
HOM_API HOM_Module & HOM()
GLenum GLint GLint * precision
Definition: glew.h:3500
GLsizei const GLfloat * value
Definition: glew.h:1849
static bool isImplementationSet()
Definition: HOM_Module.h:505
std::map< std::string, std::string > HOM_StdMapStringString
Definition: HOM_Module.h:1217
GLfloat units
Definition: glew.h:10289
UT_UniquePtr< UT_OptionEntry > UT_OptionEntryPtr
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
GLenum const void * paths
Definition: glew.h:13589