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