forked from sideeffects/HoudiniEngineForMaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
86 lines (65 loc) · 2.37 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef __util_h__
#define __util_h__
#include <maya/MObject.h>
#include <maya/MString.h>
#include <maya/MIntArray.h>
#include <maya/MFloatArray.h>
#include <vector>
#include <HAPI/HAPI.h>
class MDGModifier;
class MFnDagNode;
class HAPIError: public std::exception
{
public:
HAPIError() throw();
HAPIError( const HAPIError & error ) throw();
HAPIError( MString msg ) throw();
virtual ~HAPIError() throw() {}
virtual const char* what() const throw();
protected:
mutable MString myBuffer;
MString myMessage;
};
class MayaError: public std::exception
{
public:
MayaError() throw();
MayaError( const MayaError & error ) throw();
MayaError( MStatus stat ) throw();
virtual ~MayaError() throw() {}
virtual const char* what() const throw();
virtual MStatus status();
protected:
mutable MString myBuffer;
MStatus myStat;
};
class Util {
public:
static MString getString(int handle);
static MString getAttrNameFromParm(const HAPI_ParmInfo &parm);
static void reverseWindingOrderInt(MIntArray& data, MIntArray& faceCounts);
static void reverseWindingOrderFloat(MFloatArray& data, MIntArray& faceCounts);
static bool hasHAPICallFailed(HAPI_Result stat);
// Throws an exception if an error occurred
static void checkHAPIStatus(HAPI_Result stat);
static void checkMayaStatus(MStatus stat);
static void statusCheckLoop();
static void showProgressWindow(const MString & title, const MString & status, int progress);
static void updateProgressWindow(const MString & status, int progress);
static void hideProgressWindow();
// Prints the error message if an error occurred.
static void printHAPIStatus(HAPI_Result stat);
static void printMayaStatus(MStatus stat);
static MObject findNodeByName(const MString &name);
static MObject findDagChild(const MFnDagNode &dag, const MString &name);
static MStatus createNodeByModifierCommand(
MDGModifier &dgModifier,
const MString &command,
MObject &object,
unsigned int index = 0
);
static MString replaceString(const MString &str, const MString &searchStr, const MString &newChar);
// Returns true if the parm was found.
static int findParm(std::vector<HAPI_ParmInfo>& parms, MString name);
};
#endif