simplex-solver 3.1.0__39-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. simplex_solver-3.1.0.dist-info/METADATA +90 -0
  2. simplex_solver-3.1.0.dist-info/RECORD +79 -0
  3. simplex_solver-3.1.0.dist-info/WHEEL +5 -0
  4. simplexui/__init__.py +53 -0
  5. simplexui/_version.py +1 -0
  6. simplexui/channelBox.py +858 -0
  7. simplexui/comboCheckDialog.py +343 -0
  8. simplexui/commands/__init__.py +16 -0
  9. simplexui/commands/alembicCommon.py +991 -0
  10. simplexui/commands/applyCorrectives.py +451 -0
  11. simplexui/commands/correctiveInterface.py +261 -0
  12. simplexui/commands/expandedExport.py +436 -0
  13. simplexui/commands/hdf5Convert.py +60 -0
  14. simplexui/commands/mayaCorrectiveInterface.py +161 -0
  15. simplexui/commands/mayatonumpy.py +375 -0
  16. simplexui/commands/mesh.py +1081 -0
  17. simplexui/commands/numpytoimath.py +319 -0
  18. simplexui/commands/poseblendlib.py +166 -0
  19. simplexui/commands/reorderSimplexPoints.py +102 -0
  20. simplexui/commands/rigidAlign.py +99 -0
  21. simplexui/commands/smpxBlend.py +629 -0
  22. simplexui/commands/unsubdivide.py +1227 -0
  23. simplexui/commands/uvTransfer.py +977 -0
  24. simplexui/dragFilter.py +299 -0
  25. simplexui/falloffDialog.py +471 -0
  26. simplexui/img/ChefHead.png +0 -0
  27. simplexui/img/frozen.png +0 -0
  28. simplexui/interface/__init__.py +28 -0
  29. simplexui/interface/dummyInterface.py +1585 -0
  30. simplexui/interface/mayaInterface.py +3271 -0
  31. simplexui/interfaceModel.py +1053 -0
  32. simplexui/interfaceModelTrees.py +441 -0
  33. simplexui/items/__init__.py +42 -0
  34. simplexui/items/accessor.py +213 -0
  35. simplexui/items/combo.py +852 -0
  36. simplexui/items/falloff.py +778 -0
  37. simplexui/items/group.py +297 -0
  38. simplexui/items/progression.py +743 -0
  39. simplexui/items/shape.py +443 -0
  40. simplexui/items/simplex.py +1764 -0
  41. simplexui/items/slider.py +738 -0
  42. simplexui/items/stack.py +154 -0
  43. simplexui/items/traversal.py +966 -0
  44. simplexui/main.pyw +22 -0
  45. simplexui/menu/__init__.py +69 -0
  46. simplexui/menu/dummyPlugins/__init__.py +16 -0
  47. simplexui/menu/genericPlugins/__init__.py +16 -0
  48. simplexui/menu/genericPlugins/_builtins.py +268 -0
  49. simplexui/menu/genericPlugins/checkPossibleCombos.py +45 -0
  50. simplexui/menu/genericPlugins/exportSplit.py +59 -0
  51. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  52. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  53. simplexui/menu/genericPlugins/simplexUvTransfer.py +107 -0
  54. simplexui/menu/genericPlugins/unsubdivide.py +70 -0
  55. simplexui/menu/mayaPlugins/__init__.py +16 -0
  56. simplexui/menu/mayaPlugins/exportOther.py +43 -0
  57. simplexui/menu/mayaPlugins/extractProgressives.py +65 -0
  58. simplexui/menu/mayaPlugins/freezeCombo.py +245 -0
  59. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +97 -0
  60. simplexui/menu/mayaPlugins/importObjs.py +193 -0
  61. simplexui/menu/mayaPlugins/linearizeTraversal.py +48 -0
  62. simplexui/menu/mayaPlugins/makeShelfBtn.py +65 -0
  63. simplexui/menu/mayaPlugins/relaxToSelection.py +75 -0
  64. simplexui/menu/mayaPlugins/reloadDefinition.py +33 -0
  65. simplexui/menu/mayaPlugins/snapToNeutral.py +72 -0
  66. simplexui/menu/mayaPlugins/softSelectToCluster.py +200 -0
  67. simplexui/menu/mayaPlugins/tweakMix.py +134 -0
  68. simplexui/menu/mayaPlugins/updateRestShape.py +105 -0
  69. simplexui/pysimplex.dll.a +0 -0
  70. simplexui/pysimplex.pyd +0 -0
  71. simplexui/simplexDialog.py +1454 -0
  72. simplexui/travCheckDialog.py +397 -0
  73. simplexui/traversalDialog.py +271 -0
  74. simplexui/ui/comboCheckDialog.ui +475 -0
  75. simplexui/ui/falloffDialog.ui +243 -0
  76. simplexui/ui/simplexDialog.ui +1458 -0
  77. simplexui/ui/travCheckDialog.ui +488 -0
  78. simplexui/ui/traversalDialog.ui +532 -0
  79. simplexui/utils.py +320 -0
@@ -0,0 +1,375 @@
1
+ from maya import OpenMaya as om
2
+ import numpy as np
3
+ from ctypes import c_float, c_double, c_int, c_uint
4
+
5
+ # fmt: off
6
+ _CONVERT_DICT = {
7
+ om.MPointArray: (float, 4, c_double, om.MScriptUtil.asDouble4Ptr),
8
+ om.MFloatPointArray: (float, 4, c_float , om.MScriptUtil.asFloat4Ptr),
9
+ om.MVectorArray: (float, 3, c_double, om.MScriptUtil.asDouble3Ptr),
10
+ om.MFloatVectorArray: (float, 3, c_float , om.MScriptUtil.asFloat3Ptr),
11
+ om.MDoubleArray: (float, 1, c_double, om.MScriptUtil.asDoublePtr),
12
+ om.MFloatArray: (float, 1, c_float , om.MScriptUtil.asFloatPtr),
13
+ om.MIntArray: (int , 1, c_int , om.MScriptUtil.asIntPtr),
14
+ om.MUintArray: (int , 1, c_uint , om.MScriptUtil.asUintPtr),
15
+ }
16
+ # fmt: on
17
+
18
+
19
+ def _swigConnect(mArray, count, util):
20
+ """
21
+ Use an MScriptUtil to build SWIG array that we can read from and write to.
22
+ Make sure to get the MScriptUtil from outside this function, otherwise
23
+ it may be garbage collected
24
+ The _CONVERT_DICT holds {mayaType: (pyType, numComps, cType, ptrType)} where
25
+ pyType: The type that is used to fill the MScriptUtil array.
26
+ numComps: The number of components. So a double4Ptr would be 4
27
+ cType: The ctypes type used to read the data
28
+ ptrType: An unbound method on MScriptUtil to cast the pointer to the correct type
29
+ I can still call that unbound method by manually passing the usually-implicit
30
+ self argument (which will be an instance of MScriptUtil)
31
+ """
32
+ pyTyp, comps, ctp, ptrTyp = _CONVERT_DICT[type(mArray)]
33
+ cc = count * comps
34
+ util.createFromList([pyTyp()] * cc, cc)
35
+
36
+ # passing util as 'self' to call the unbound method
37
+ ptr = ptrTyp(util)
38
+ mArray.get(ptr)
39
+
40
+ if comps == 1:
41
+ cdata = ctp * count
42
+ else:
43
+ # Multiplication follows some strange rules here
44
+ # I would expect (ctype*3)*N to be an Nx3 array (ctype*3 repeated N times)
45
+ # However, it gets converted to a 3xN array
46
+ cdata = (ctp * comps) * count
47
+
48
+ # int(ptr) gives the memory address
49
+ cta = cdata.from_address(int(ptr))
50
+
51
+ # This makes numpy look at the same memory as the ctypes array
52
+ # so we can both read from and write to that data through numpy
53
+ npArray = np.ctypeslib.as_array(cta)
54
+ return npArray, ptr
55
+
56
+
57
+ def _swigConnectMatrix(mat, ctp):
58
+ # With a matrix, you can just get the double[4][4] without an MScriptUtil
59
+ ptr = mat.matrix
60
+ cdata = ctp * 4 * 4
61
+
62
+ # int(ptr) gives the memory address
63
+ cta = cdata.from_address(int(ptr))
64
+
65
+ # This makes numpy look at the same memory as the ctypes array
66
+ # so we can both read from and write to that data through numpy
67
+ npArray = np.ctypeslib.as_array(cta)
68
+ return npArray, ptr
69
+
70
+
71
+ def mayaToNumpy(mArray):
72
+ """Convert a maya array to a numpy array
73
+
74
+ Parameters
75
+ ----------
76
+ ary : MArray
77
+ The maya array to convert to a numpy array
78
+
79
+ Returns
80
+ -------
81
+ : np.array :
82
+ A numpy array that contains the data from mArray
83
+
84
+ """
85
+ if isinstance(mArray, om.MMatrix):
86
+ npArray, _ = _swigConnectMatrix(mArray, c_double)
87
+ elif isinstance(mArray, om.MFloatMatrix):
88
+ npArray, _ = _swigConnectMatrix(mArray, c_float)
89
+ else:
90
+ util = om.MScriptUtil()
91
+ count = mArray.length()
92
+ npArray, _ = _swigConnect(mArray, count, util)
93
+ return np.copy(npArray)
94
+
95
+
96
+ def numpyToMaya(ary, mType):
97
+ """Convert a numpy array to a specific maya type array
98
+
99
+ Parameters
100
+ ----------
101
+ ary : np.array
102
+ The numpy array to convert to a maya array
103
+ mType : type
104
+ The maya type to convert to out of: MPointArray, MFloatPointArray, MVectorArray,
105
+ MFloatVectorArray, MDoubleArray, MFloatArray, MIntArray, MUintArray
106
+
107
+ Returns
108
+ -------
109
+ : mType :
110
+ An array of the provided type that contains the data from ary
111
+
112
+ """
113
+ # Handle matrices separately
114
+ if mType in (om.MMatrix, om.MFloatMatrix):
115
+ ctp = c_double if mType == om.MMatrix else c_float
116
+ if ary.shape != (4, 4):
117
+ msg = "Numpy array must have the proper shape. For matrix types that shape must be (4, 4). Got {0}"
118
+ raise ValueError(msg.format(ary.shape))
119
+ tmpMat = mType()
120
+ npArray, ptr = _swigConnectMatrix(tmpMat, ctp)
121
+ np.copyto(npArray, ary)
122
+ return mType(ptr)
123
+
124
+ # Add a little shape checking
125
+ comps = _CONVERT_DICT[mType][1]
126
+ if comps == 1:
127
+ if len(ary.shape) != 1:
128
+ raise ValueError("Numpy array must be 1D to convert to the given maya type")
129
+ else:
130
+ if len(ary.shape) != 2:
131
+ raise ValueError("Numpy array must be 2D to convert to the given maya type")
132
+ if ary.shape[1] != comps:
133
+ msg = "Numpy array must have the proper shape. Dimension 2 has size {0}, but needs size {1}"
134
+ raise ValueError(msg.format(ary.shape[1], comps))
135
+ count = ary.shape[0]
136
+ tmpAry = mType(count)
137
+ util = om.MScriptUtil()
138
+ npArray, ptr = _swigConnect(tmpAry, count, util)
139
+ np.copyto(npArray, ary)
140
+ return mType(ptr, count)
141
+
142
+
143
+ # fmt: off
144
+ _NTYPE_DICT = {
145
+ om.MFnNumericData.kInvalid: (om.MDataHandle.asDouble, om.MDataHandle.setDouble),
146
+ om.MFnNumericData.kFloat: (om.MDataHandle.asDouble, om.MDataHandle.setDouble),
147
+ om.MFnNumericData.kDouble: (om.MDataHandle.asDouble, om.MDataHandle.setDouble),
148
+ om.MFnNumericData.kByte: (om.MDataHandle.asInt, om.MDataHandle.setInt),
149
+ om.MFnNumericData.kChar: (om.MDataHandle.asChar, om.MDataHandle.setChar),
150
+ om.MFnNumericData.kShort: (om.MDataHandle.asShort, om.MDataHandle.setShort),
151
+ om.MFnNumericData.kInt: (om.MDataHandle.asInt, om.MDataHandle.setInt),
152
+ #om.MFnNumericData.kInt64: (om.MDataHandle.asInt, om.MDataHandle.setInt64),
153
+ om.MFnNumericData.kAddr: (om.MDataHandle.asInt, om.MDataHandle.setInt),
154
+ om.MFnNumericData.kLong: (om.MDataHandle.asInt, om.MDataHandle.setInt),
155
+ om.MFnNumericData.kBoolean: (om.MDataHandle.asBool, om.MDataHandle.setBool),
156
+
157
+ om.MFnNumericData.k2Short: (om.MDataHandle.asShort2, om.MDataHandle.set2Short),
158
+ om.MFnNumericData.k2Long: (om.MDataHandle.asInt2, om.MDataHandle.set2Int),
159
+ om.MFnNumericData.k2Int: (om.MDataHandle.asInt2, om.MDataHandle.set2Int),
160
+ om.MFnNumericData.k3Short: (om.MDataHandle.asShort3, om.MDataHandle.set3Short),
161
+ om.MFnNumericData.k3Long: (om.MDataHandle.asInt3, om.MDataHandle.set3Int),
162
+ om.MFnNumericData.k3Int: (om.MDataHandle.asInt3, om.MDataHandle.set3Int),
163
+ om.MFnNumericData.k2Float: (om.MDataHandle.asFloat2, om.MDataHandle.set2Float),
164
+ om.MFnNumericData.k2Double: (om.MDataHandle.asDouble2, om.MDataHandle.set2Double),
165
+ om.MFnNumericData.k3Float: (om.MDataHandle.asFloat3, om.MDataHandle.set3Float),
166
+ om.MFnNumericData.k3Double: (om.MDataHandle.asDouble3, om.MDataHandle.set3Double),
167
+ }
168
+
169
+ _DTYPE_DICT = {
170
+ om.MFn.kPointArrayData: (om.MFnPointArrayData, om.MPointArray),
171
+ om.MFn.kDoubleArrayData: (om.MFnDoubleArrayData, om.MDoubleArray),
172
+ om.MFn.kFloatArrayData: (om.MFnFloatArrayData, om.MFloatArray),
173
+ om.MFn.kIntArrayData: (om.MFnIntArrayData, om.MIntArray),
174
+ om.MFn.kUInt64ArrayData: (om.MFnUInt64ArrayData, om.MPointArray),
175
+ om.MFn.kVectorArrayData: (om.MFnVectorArrayData, om.MVectorArray),
176
+ }
177
+ # fmt: on
178
+
179
+
180
+ def getNumpyAttr(attrName):
181
+ """Read attribute data directly from the plugs into numpy
182
+
183
+ This function will read most numeric data types directly into numpy arrays
184
+ However, some simple data types (floats, vectors, etc...) have api accessors
185
+ that return python tuples. These will not be turned into numpy arrays.
186
+ And really, if you're getting simple data like that, just use cmds.getAttr
187
+
188
+ Parameters
189
+ ----------
190
+ attrName : str or om.MPlug
191
+ The name of the attribute to get (For instance "pSphere2.translate", or "group1.pim[0]")
192
+ Or the MPlug itself
193
+
194
+ Returns
195
+ -------
196
+ : object :
197
+ The numerical data from the provided plug. A np.array, float, int, or tuple
198
+
199
+ """
200
+ if isinstance(attrName, str):
201
+ sl = om.MSelectionList()
202
+ sl.add(attrName)
203
+ plug = om.MPlug()
204
+ sl.getPlug(0, plug)
205
+ elif isinstance(attrName, om.MPlug):
206
+ plug = attrName
207
+ else:
208
+ raise ValueError("AttrName is not a name or a plug")
209
+
210
+ # First just check if the data is numeric
211
+ mdh = plug.asMDataHandle()
212
+ if mdh.isNumeric():
213
+ # So, at this point, you should really just use getattr
214
+ ntype = mdh.numericType()
215
+ if ntype in _NTYPE_DICT:
216
+ return _NTYPE_DICT[ntype][0](mdh)
217
+ elif ntype == om.MFnNumericData.k4Double:
218
+ NotImplementedError("Haven't implemented double4 access yet")
219
+ else:
220
+ raise RuntimeError(
221
+ "I don't know how to access data from the given attribute"
222
+ )
223
+ else:
224
+ # The data is more complex than a simple number.
225
+ try:
226
+ pmo = plug.asMObject()
227
+ except RuntimeError as e:
228
+ # raise a more descriptive error. And make sure to actually print the plug name
229
+ raise RuntimeError(
230
+ "I don't know how to access data from the given attribute"
231
+ ) from e
232
+ apiType = pmo.apiType()
233
+
234
+ # A list of types that I can just pass to mayaToNumpy
235
+ if apiType in _DTYPE_DICT:
236
+ fn, dtype = _DTYPE_DICT[apiType]
237
+ fnPmo = fn(pmo)
238
+ ary = fnPmo.array()
239
+ return mayaToNumpy(ary)
240
+
241
+ elif apiType == om.MFn.kComponentListData:
242
+ fnPmo = om.MFnComponentListData(pmo)
243
+ mirs = []
244
+ mir = om.MIntArray()
245
+ for attrIndex in range(fnPmo.length()):
246
+ fnEL = om.MFnSingleIndexedComponent(fnPmo[attrIndex])
247
+ fnEL.getElements(mir)
248
+ mirs.append(mayaToNumpy(mir))
249
+ if not mirs:
250
+ return np.array([], dtype=int)
251
+ return np.concatenate(mirs)
252
+
253
+ elif apiType == om.MFn.kMatrixData:
254
+ fnPmo = om.MFnMatrixData(pmo)
255
+ mat = fnPmo.matrix()
256
+ return mayaToNumpy(mat)
257
+ else:
258
+ apiTypeStr = pmo.apiTypeStr()
259
+ raise NotImplementedError(
260
+ "I don't know how to handle {0} yet".format(apiTypeStr)
261
+ )
262
+ raise NotImplementedError("Fell all the way through")
263
+
264
+
265
+ def setNumpyAttr(attrName, value):
266
+ """Write a numpy array directly into a maya plug
267
+
268
+ This function will handle most numeric plug types.
269
+ But for single float, individual point, etc.. types, consider using cmds.setAttr
270
+
271
+ THIS DOES NOT SUPPORT UNDO
272
+
273
+ Parameters
274
+ ----------
275
+ attrName : str or om.MPlug
276
+ The name of the attribute to get (For instance "pSphere2.translate", or "group1.pim[0]")
277
+ Or the MPlug itself
278
+ value : int, float, tuple, np.array
279
+ The correctly typed value to set on the attribute
280
+ """
281
+ if isinstance(attrName, str):
282
+ sl = om.MSelectionList()
283
+ sl.add(attrName)
284
+ plug = om.MPlug()
285
+ sl.getPlug(0, plug)
286
+ elif isinstance(attrName, om.MPlug):
287
+ plug = attrName
288
+ else:
289
+ raise ValueError("Data must be string or MPlug. Got {0}".format(type(attrName)))
290
+
291
+ # First just check if the data is numeric
292
+ mdh = plug.asMDataHandle()
293
+ if mdh.isNumeric():
294
+ # So, at this point, you should really just use setattr
295
+ ntype = mdh.numericType()
296
+ if ntype in _NTYPE_DICT:
297
+ _NTYPE_DICT[ntype][1](mdh, *value)
298
+ plug.setMObject(mdh.data())
299
+ elif ntype == om.MFnNumericData.k4Double:
300
+ NotImplementedError("Haven't implemented double4 access yet")
301
+ else:
302
+ raise RuntimeError("I don't know how to set data on the given attribute")
303
+ else:
304
+ # The data is more complex than a simple number.
305
+ try:
306
+ pmo = plug.asMObject()
307
+ except RuntimeError as e:
308
+ # raise a more descriptive error. And make sure to actually print the plug name
309
+ raise RuntimeError(
310
+ "I don't know how to access data from the given attribute"
311
+ ) from e
312
+ apiType = pmo.apiType()
313
+
314
+ if apiType in _DTYPE_DICT:
315
+ # build the pointArrayData
316
+ fnType, mType = _DTYPE_DICT[apiType]
317
+ fn = fnType()
318
+ mPts = numpyToMaya(value, mType)
319
+ dataObj = fn.create(mPts)
320
+ plug.setMObject(dataObj)
321
+ return
322
+
323
+ elif apiType == om.MFn.kComponentListData:
324
+ fnCompList = om.MFnComponentListData()
325
+ compList = fnCompList.create()
326
+ fnIdx = om.MFnSingleIndexedComponent()
327
+ idxObj = fnIdx.create(om.MFn.kMeshVertComponent)
328
+ mIdxs = numpyToMaya(value, om.MIntArray)
329
+ fnIdx.addElements(mIdxs)
330
+ fnCompList.add(idxObj)
331
+ plug.setMObject(compList)
332
+ return
333
+ else:
334
+ apiTypeStr = pmo.apiTypeStr()
335
+ raise NotImplementedError(
336
+ "I don't know how to handle {0} yet".format(apiTypeStr)
337
+ )
338
+
339
+ raise NotImplementedError("WTF? How did you get here??")
340
+
341
+
342
+ ################################################################################
343
+
344
+
345
+ def test():
346
+ import time
347
+ from maya import cmds
348
+
349
+ meshName = "pSphere1"
350
+ bsName = "blendShape1"
351
+ meshIdx = 0
352
+ bsIdx = 0
353
+
354
+ # A quick test showing how to build a numpy array
355
+ # containing the deltas for a shape on a blendshape node
356
+ numVerts = cmds.polyEvaluate(meshName, vertex=True)
357
+ baseAttr = "{0}.it[{1}].itg[{2}].iti[6000]".format(bsName, meshIdx, bsIdx)
358
+ inPtAttr = baseAttr + ".inputPointsTarget"
359
+ inCompAttr = baseAttr + ".inputComponentsTarget"
360
+
361
+ start = time.time()
362
+ points = getNumpyAttr(inPtAttr)
363
+ idxs = getNumpyAttr(inCompAttr)
364
+ ret = np.zeros((numVerts, 4))
365
+ ret[idxs] = points
366
+ end = time.time()
367
+
368
+ print("IDXS", idxs.shape)
369
+ print("OUT", points.shape)
370
+ print("RET", ret.shape)
371
+ print("TOOK", end - start)
372
+
373
+
374
+ if __name__ == "__main__":
375
+ test()