simplex-solver 3.0.18__37-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 (81) hide show
  1. pysimplex.pyd +0 -0
  2. simplex_solver-3.0.18.dist-info/METADATA +87 -0
  3. simplex_solver-3.0.18.dist-info/RECORD +81 -0
  4. simplex_solver-3.0.18.dist-info/WHEEL +5 -0
  5. simplex_solver-3.0.18.dist-info/licenses/LICENSE +165 -0
  6. simplexui/__init__.py +54 -0
  7. simplexui/channelBox.py +862 -0
  8. simplexui/comboCheckDialog.py +335 -0
  9. simplexui/commands/__init__.py +16 -0
  10. simplexui/commands/alembicCommon.py +1045 -0
  11. simplexui/commands/applyCorrectives.py +455 -0
  12. simplexui/commands/buildIceXML.py +443 -0
  13. simplexui/commands/correctiveInterface.py +271 -0
  14. simplexui/commands/expandedExport.py +435 -0
  15. simplexui/commands/hdf5Convert.py +62 -0
  16. simplexui/commands/mayaCorrectiveInterface.py +164 -0
  17. simplexui/commands/mesh.py +1086 -0
  18. simplexui/commands/reorderSimplexPoints.py +103 -0
  19. simplexui/commands/rigidAlign.py +103 -0
  20. simplexui/commands/setDelta.xsicompound +60 -0
  21. simplexui/commands/smpxBlend.py +634 -0
  22. simplexui/commands/unsubdivide.py +1232 -0
  23. simplexui/commands/uvTransfer.py +986 -0
  24. simplexui/commands/xsiCorrectiveInterface.py +136 -0
  25. simplexui/dragFilter.py +299 -0
  26. simplexui/falloffDialog.py +476 -0
  27. simplexui/img/ChefHead.png +0 -0
  28. simplexui/img/frozen.png +0 -0
  29. simplexui/interface/__init__.py +30 -0
  30. simplexui/interface/dummyInterface.py +1564 -0
  31. simplexui/interface/mayaInterface.py +3197 -0
  32. simplexui/interface/xsiInterface.py +2944 -0
  33. simplexui/interfaceModel.py +1040 -0
  34. simplexui/interfaceModelTrees.py +439 -0
  35. simplexui/interfaceModel_Test.py +259 -0
  36. simplexui/items/__init__.py +26 -0
  37. simplexui/items/accessor.py +217 -0
  38. simplexui/items/combo.py +855 -0
  39. simplexui/items/falloff.py +780 -0
  40. simplexui/items/group.py +295 -0
  41. simplexui/items/progression.py +745 -0
  42. simplexui/items/shape.py +444 -0
  43. simplexui/items/simplex.py +1747 -0
  44. simplexui/items/slider.py +741 -0
  45. simplexui/items/stack.py +156 -0
  46. simplexui/items/traversal.py +969 -0
  47. simplexui/main.pyw +22 -0
  48. simplexui/menu/__init__.py +73 -0
  49. simplexui/menu/dummyPlugins/__init__.py +16 -0
  50. simplexui/menu/genericPlugins/__init__.py +16 -0
  51. simplexui/menu/genericPlugins/_builtins.py +260 -0
  52. simplexui/menu/genericPlugins/checkPossibleCombos.py +47 -0
  53. simplexui/menu/genericPlugins/exportSplit.py +61 -0
  54. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  55. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  56. simplexui/menu/genericPlugins/simplexUvTransfer.py +109 -0
  57. simplexui/menu/genericPlugins/unsubdivide.py +71 -0
  58. simplexui/menu/mayaPlugins/__init__.py +16 -0
  59. simplexui/menu/mayaPlugins/exportOther.py +45 -0
  60. simplexui/menu/mayaPlugins/extractProgressives.py +67 -0
  61. simplexui/menu/mayaPlugins/freezeCombo.py +251 -0
  62. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +100 -0
  63. simplexui/menu/mayaPlugins/importObjs.py +196 -0
  64. simplexui/menu/mayaPlugins/linearizeTraversal.py +49 -0
  65. simplexui/menu/mayaPlugins/makeShelfBtn.py +69 -0
  66. simplexui/menu/mayaPlugins/relaxToSelection.py +77 -0
  67. simplexui/menu/mayaPlugins/reloadDefinition.py +34 -0
  68. simplexui/menu/mayaPlugins/snapToNeutral.py +74 -0
  69. simplexui/menu/mayaPlugins/softSelectToCluster.py +204 -0
  70. simplexui/menu/mayaPlugins/tweakMix.py +138 -0
  71. simplexui/menu/mayaPlugins/updateRestShape.py +107 -0
  72. simplexui/menu/xsiPlugins/__init__.py +16 -0
  73. simplexui/simplexDialog.py +1391 -0
  74. simplexui/travCheckDialog.py +393 -0
  75. simplexui/traversalDialog.py +277 -0
  76. simplexui/ui/comboCheckDialog.ui +475 -0
  77. simplexui/ui/falloffDialog.ui +243 -0
  78. simplexui/ui/simplexDialog.ui +1458 -0
  79. simplexui/ui/travCheckDialog.ui +488 -0
  80. simplexui/ui/traversalDialog.ui +532 -0
  81. simplexui/utils.py +320 -0
@@ -0,0 +1,271 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import absolute_import
19
+
20
+ import six
21
+ from six.moves import zip
22
+
23
+ from Qt.QtWidgets import QApplication
24
+
25
+ try:
26
+ import numpy as np
27
+ except ImportError:
28
+ pass
29
+
30
+ try:
31
+ from .mayaCorrectiveInterface import getShiftValues, resetPose, setPose
32
+
33
+ dcc = "maya"
34
+ except ImportError:
35
+ from .xsiCorrectiveInterface import getShiftValues, resetPose, setPose
36
+
37
+ dcc = "xsi"
38
+
39
+
40
+ def getRefForPoses(mesh, poses, multipliers):
41
+ """Given a set of poses and a multiplier, get the reference
42
+
43
+ Parameters
44
+ ----------
45
+ mesh : object
46
+ The DCC object
47
+ poses : [[(str, float), ...], ...]
48
+ Property/value pairs for different rig poses
49
+ multiplier : float
50
+ The percent of the pose to apply
51
+
52
+ Returns
53
+ -------
54
+ : np.array
55
+ The point reference matrices in pose
56
+
57
+ """
58
+
59
+ for pose, mul in zip(poses, multipliers):
60
+ setPose(pose, mul)
61
+
62
+ ref = getDeformReference(mesh)
63
+
64
+ for pose in poses:
65
+ resetPose(pose)
66
+ return ref
67
+
68
+
69
+ def getDeformReference(mesh):
70
+ """Build the 4x4 deformation reference matrices given a mesh
71
+
72
+ Parameters
73
+ ----------
74
+ mesh : object
75
+ The DCC mesh object
76
+
77
+ Returns
78
+ -------
79
+ : np.array:
80
+ The point reference matrices in pose
81
+
82
+ """
83
+ zero, oneX, oneY, oneZ = getShiftValues(mesh)
84
+
85
+ zero = np.array(zero)
86
+ dx = np.array(oneX) - zero
87
+ dy = np.array(oneY) - zero
88
+ dz = np.array(oneZ) - zero
89
+
90
+ # Maya has numpy 1.09, but np.stack comes from 1.10
91
+ # mats = np.stack((dx, dy, dz, zero), axis=1)
92
+
93
+ # Make the new axis to concatenate on
94
+ zero = zero[:, None]
95
+ dx = dx[:, None]
96
+ dy = dy[:, None]
97
+ dz = dz[:, None]
98
+ mats = np.concatenate((dx, dy, dz, zero), axis=1)
99
+
100
+ # Turn the Nx4x3 matrix into a Nx4x4
101
+ zzz = np.zeros((len(mats), 4, 1))
102
+ zzz[:, 3] = 1.0
103
+ mats = np.concatenate((mats, zzz), axis=2)
104
+
105
+ return mats
106
+
107
+
108
+ def buildCorrectiveReferences(mesh, simplex, poses, sliders, pBar=None):
109
+ """Take correlated poses and sliders, and expand down the
110
+ simplex combo tree, building references for each required shape
111
+
112
+ Parameters
113
+ ----------
114
+ mesh : object
115
+ The DCC mesh object
116
+ simplex : Simplex
117
+ The Simplex system
118
+ poses : [[(str, float), ...], ...]
119
+ Property/value pairs for different rig poses
120
+ sliders : [Slider, ...]
121
+ Simplex slider objects that are controlled by the poses
122
+ pBar : QProgressDialog, optional
123
+ An optional progress dialog
124
+
125
+ Returns
126
+ -------
127
+ : np.array
128
+ The output matrix-per-point arrays
129
+ : [Shape, ...]
130
+ The shapes active
131
+ : [int, ...]
132
+ The Reference pose per shape
133
+ """
134
+ # cache the pose search
135
+
136
+ # Pre-cache the combo search
137
+ allCombosBySliderValue = {}
138
+ for c in simplex.combos:
139
+ for p in c.pairs:
140
+ allCombosBySliderValue.setdefault((p.slider, p.value), []).append(c)
141
+
142
+ # This is only my subset set of downstreams
143
+ # Get the downstreams by slider and value
144
+ sliderValuesByCombo = {}
145
+ for slider in sliders:
146
+ for p in slider.prog.pairs:
147
+ combos = allCombosBySliderValue.get((slider, p.value), [])
148
+ for combo in combos:
149
+ sliderValuesByCombo.setdefault(combo, []).append((slider, p.value))
150
+
151
+ # out = []
152
+ refCache = {}
153
+ refs, shapes, refIdxs = [], [], []
154
+
155
+ # get the slider outputs
156
+ if pBar is not None:
157
+ pBar.setLabelText("Building Shape References")
158
+ pBar.setValue(0)
159
+ mv = 0
160
+ for slider in sliders:
161
+ for p in slider.prog.pairs:
162
+ if not p.shape.isRest:
163
+ mv += 1
164
+ pBar.setMaximum(mv)
165
+ QApplication.processEvents()
166
+
167
+ # Make sure to export the rest reference first
168
+ ref = getRefForPoses(mesh, [], [])
169
+ refIdxs.append(len(refs))
170
+ cacheKey = frozenset([("", 0.0)])
171
+ refCache[cacheKey] = len(refs)
172
+ refs.append(ref)
173
+ shapes.append(simplex.restShape)
174
+
175
+ # Now export everything else
176
+ poseBySlider = {}
177
+ for slider, pose in zip(sliders, poses):
178
+ poseBySlider[slider] = pose
179
+ for p in slider.prog.pairs:
180
+ if not p.shape.isRest:
181
+ if pBar is not None:
182
+ pBar.setValue(pBar.value())
183
+ QApplication.processEvents()
184
+ cacheKey = frozenset([(slider, p.value)])
185
+ if cacheKey in refCache:
186
+ idx = refCache[cacheKey]
187
+ refIdxs.append(idx)
188
+ else:
189
+ ref = getRefForPoses(mesh, [pose], [p.value])
190
+ refIdxs.append(len(refs))
191
+ refCache[cacheKey] = len(refs)
192
+ refs.append(ref)
193
+ shapes.append(p.shape)
194
+
195
+ # Get the combo outputs
196
+ if pBar is not None:
197
+ pBar.setLabelText("Building Combo References")
198
+ pBar.setValue(0)
199
+ mv = 0
200
+ for combo in six.iterkeys(sliderValuesByCombo):
201
+ for p in combo.prog.pairs:
202
+ if not p.shape.isRest:
203
+ mv += 1
204
+ pBar.setMaximum(mv)
205
+ QApplication.processEvents()
206
+
207
+ for combo, sliderVals in six.iteritems(sliderValuesByCombo):
208
+ # components = frozenset(sliderVals)
209
+ poses = [poseBySlider[s] for s, _ in sliderVals]
210
+ for p in combo.prog.pairs:
211
+ if not p.shape.isRest:
212
+ if pBar is not None:
213
+ pBar.setValue(pBar.value())
214
+ QApplication.processEvents()
215
+
216
+ cacheKey = frozenset(sliderVals)
217
+ if cacheKey in refCache:
218
+ idx = refCache[cacheKey]
219
+ refIdxs.append(idx)
220
+ else:
221
+ vals = [p.value * v[1] for v in sliderVals]
222
+ ref = getRefForPoses(mesh, poses, vals)
223
+ refIdxs.append(len(refs))
224
+ refCache[cacheKey] = len(refs)
225
+ refs.append(ref)
226
+ shapes.append(p.shape)
227
+
228
+ return np.array(refs), shapes, refIdxs
229
+
230
+
231
+ def outputCorrectiveReferences(
232
+ outNames, outRefs, simplex, mesh, poses, sliders, pBar=None
233
+ ):
234
+ """Output the proper files for an external corrective application
235
+
236
+ Parameters
237
+ ----------
238
+ outNames : str
239
+ The filepath for the output shape and reference indices
240
+ outRefs : str
241
+ The filepath for the deformation references
242
+ simplex : Simplex
243
+ A simplex system
244
+ mesh : object
245
+ The mesh object to deform
246
+ poses : [[(str, float), ...], ...]
247
+ Lists of parameter
248
+ sliders : [Slider, ...]
249
+ The simplex sliders that correspond to the poses
250
+ pBar : QProgressDialog, optional
251
+ An optional progress dialog
252
+
253
+ Returns
254
+ -------
255
+
256
+ """
257
+ refs, shapes, refIdxs = buildCorrectiveReferences(
258
+ mesh, simplex, poses, sliders, pBar
259
+ )
260
+
261
+ if pBar is not None:
262
+ pBar.setLabelText("Writing Names")
263
+ QApplication.processEvents()
264
+ nameWrite = ["{};{}".format(s.name, r) for s, r, in zip(shapes, refIdxs)]
265
+ with open(outNames, "w") as f:
266
+ f.write("\n".join(nameWrite))
267
+
268
+ if pBar is not None:
269
+ pBar.setLabelText("Writing References")
270
+ QApplication.processEvents()
271
+ refs.dump(outRefs)
@@ -0,0 +1,435 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import absolute_import
19
+
20
+ import six
21
+ from pysimplex import PySimplex
22
+
23
+ from ..interface.mayaInterface import DCC, disconnected
24
+ from ..items import Combo, Slider, Traversal
25
+ from .alembicCommon import buildSmpx
26
+
27
+ try:
28
+ import numpy as np
29
+ except ImportError:
30
+ pass
31
+
32
+
33
+ def _setSliders(ctrl, val, svs):
34
+ slis, vals = svs.setdefault(ctrl.simplex, ([], []))
35
+
36
+ if isinstance(ctrl, Slider):
37
+ slis.append(ctrl)
38
+ vals.append(val)
39
+ elif isinstance(ctrl, Combo):
40
+ for cp in ctrl.pairs:
41
+ slis.append(cp.slider)
42
+ vals.append(cp.value * abs(val))
43
+ elif isinstance(ctrl, Traversal):
44
+ # set the ctrl.multiplierCtrl.controller to 1
45
+ multCtrl = ctrl.multiplierCtrl.controller
46
+ multVal = ctrl.multiplierCtrl.value if val != 0.0 else 0.0
47
+ progCtrl = ctrl.progressCtrl.controller
48
+ _setSliders(multCtrl, multVal, svs)
49
+ _setSliders(progCtrl, val, svs)
50
+
51
+
52
+ def setSliderGroup(ctrls, val):
53
+ """Set a group of controls to a given value
54
+
55
+ Parameters
56
+ ----------
57
+ ctrls : [object, ...]
58
+ A list of simplex objects
59
+ val : float
60
+ The value to set
61
+
62
+ Returns
63
+ -------
64
+
65
+ """
66
+ svs = {}
67
+ for ctrl in ctrls:
68
+ _setSliders(ctrl, val, svs)
69
+
70
+ for smpx, (slis, vals) in six.iteritems(svs):
71
+ smpx.setSlidersWeights(slis, vals)
72
+
73
+
74
+ def clientPartition(master, clients):
75
+ """
76
+
77
+ Parameters
78
+ ----------
79
+ master : Simplex
80
+ The master simplex system
81
+ clients : [Simplex, ...]
82
+ The client simplex systems
83
+
84
+ Returns
85
+ -------
86
+ : {str: [Slider, ...]}
87
+ Dictionary of name to slider
88
+ : {str: [Combo, ...]}
89
+ Dictionary of name to combo
90
+ : {str: [Traversal, ...]}
91
+ Dictionary of name to traversal
92
+
93
+ """
94
+ sliders, combos, traversals = {}, {}, {}
95
+ for cli in [master] + clients:
96
+ for sli in cli.sliders:
97
+ sliders.setdefault(sli.name, []).append(sli)
98
+
99
+ for com in cli.combos:
100
+ combos.setdefault(com.name, []).append(com)
101
+
102
+ for trav in cli.traversals:
103
+ traversals.setdefault(trav.name, []).append(trav)
104
+ return sliders, combos, traversals
105
+
106
+
107
+ def zeroAll(smpxs):
108
+ """Set all sliders on the given simplex systems to 0
109
+
110
+ Parameters
111
+ ----------
112
+ smpxs : [Simplex, ...]
113
+ A list of Simplex systems
114
+
115
+ Returns
116
+ -------
117
+
118
+ """
119
+ for smpx in smpxs:
120
+ smpx.setSlidersWeights(smpx.sliders, [0.0] * len(smpx.sliders))
121
+
122
+
123
+ def getExpandedData(master, clients, mesh):
124
+ """Get the fully expanded shape data for each slider, combo, and traversal
125
+ at each of its underlying shapes
126
+
127
+ Parameters
128
+ ----------
129
+ master : Simplex
130
+ The master simplex system
131
+ clients : [Simplex, ...]
132
+ The client simplex systems
133
+ mesh : str
134
+ The name of the maya shape node
135
+
136
+ Returns
137
+ -------
138
+ : np.array
139
+ The rest shape point positions
140
+ : np.array
141
+ The slider shape point positions
142
+ : np.array
143
+ The combo shape point positions
144
+ : np.array
145
+ The traversal shape point positions
146
+
147
+ """
148
+ # zero everything
149
+ zeroAll([master] + clients)
150
+ sliPart, cmbPart, travPart = clientPartition(master, clients)
151
+ sliderShapes = {}
152
+ for slider in master.sliders:
153
+ ss = {}
154
+ sliderShapes[slider] = ss
155
+ for pp in slider.prog.pairs:
156
+ if pp.shape.isRest:
157
+ continue
158
+ setSliderGroup(sliPart[slider.name], pp.value)
159
+ ss[pp] = DCC.getNumpyShape(mesh)
160
+ setSliderGroup(sliPart[slider.name], 0.0)
161
+
162
+ # Disable traversals
163
+ zeroAll([master] + clients)
164
+ travShapeThings = []
165
+ comboShapes = {}
166
+ for trav in master.traversals:
167
+ for pp in trav.prog.pairs:
168
+ if pp.shape.isRest:
169
+ continue
170
+ travShapeThings.append(pp.shape)
171
+ travShapeThings = [i.thing for i in travShapeThings]
172
+
173
+ # Get the combos with traversals disconnected
174
+ with disconnected(travShapeThings):
175
+ for combo in master.combos:
176
+ ss = {}
177
+ comboShapes[combo] = ss
178
+ for pp in combo.prog.pairs:
179
+ if pp.shape.isRest:
180
+ continue
181
+ setSliderGroup(cmbPart[combo.name], pp.value)
182
+ ss[pp] = DCC.getNumpyShape(mesh)
183
+ setSliderGroup(cmbPart[combo.name], 0.0)
184
+
185
+ zeroAll([master] + clients)
186
+ travShapes = {}
187
+ for trav in master.traversals:
188
+ ss = {}
189
+ travShapes[trav] = ss
190
+ progCtrl = trav.progressCtrl.controller
191
+ progVal = trav.progressCtrl.value
192
+ for pp in progCtrl.prog.pairs:
193
+ if pp.shape.isRest:
194
+ continue
195
+ if pp.value * progVal <= 0.0:
196
+ # Traversals only activate if the progression is in the same
197
+ # pos/neg direction as the value. Otherwise we just skip
198
+ continue
199
+
200
+ setSliderGroup(travPart[trav.name], pp.value)
201
+ ss[pp] = DCC.getNumpyShape(mesh)
202
+ setSliderGroup(travPart[trav.name], 0.0)
203
+
204
+ zeroAll([master] + clients)
205
+ restShape = DCC.getNumpyShape(mesh)
206
+
207
+ return restShape, sliderShapes, comboShapes, travShapes
208
+
209
+
210
+ def _setInputs(inVec, item, indexBySlider, value):
211
+ """Being clever
212
+ Sliders or Combos just set the value and return
213
+ Traversals recursively call this function with the controllers (that only either sliders or combos)
214
+ """
215
+ if isinstance(item, Slider):
216
+ inVec[indexBySlider[item]] = value
217
+ return inVec
218
+ elif isinstance(item, Combo):
219
+ for pair in item.pairs:
220
+ inVec[indexBySlider[pair.slider]] = pair.value * abs(value)
221
+ return inVec
222
+ elif isinstance(item, Traversal):
223
+ inVec = _setInputs(
224
+ inVec,
225
+ item.multiplierCtrl.controller,
226
+ indexBySlider,
227
+ item.multiplierCtrl.value,
228
+ )
229
+ inVec = _setInputs(
230
+ inVec,
231
+ item.progressCtrl.controller,
232
+ indexBySlider,
233
+ item.progressCtrl.value * value,
234
+ )
235
+ return inVec
236
+ raise ValueError(
237
+ "Not a Slider, Combo, or Traversal. Got type {0}: {1}".format(type(item), item)
238
+ )
239
+
240
+
241
+ def _buildSolverInputs(simplex, item, value, indexBySlider):
242
+ """Build an input vector for the solver that will
243
+ produce a required progression value on an item
244
+ """
245
+ inVec = [0.0] * len(simplex.sliders)
246
+ return _setInputs(inVec, item, indexBySlider, value)
247
+
248
+
249
+ def getTravDepth(trav):
250
+ """Get the depth of a traversal object
251
+
252
+ Parameters
253
+ ----------
254
+ trav : Traversal
255
+ The traversal object
256
+
257
+ Returns
258
+ -------
259
+ : int
260
+ The depth of the given Traversal
261
+
262
+ """
263
+ inputs = []
264
+ mult = trav.multiplierCtrl.controller
265
+ prog = trav.progressCtrl.controller
266
+ for item in (mult, prog):
267
+ if isinstance(item, Slider):
268
+ inputs.append(item)
269
+ elif isinstance(item, Combo):
270
+ for cp in item.pairs:
271
+ inputs.append(cp.slider)
272
+ return len(set(inputs))
273
+
274
+
275
+ def parseExpandedData(smpx, restShape, sliderShapes, comboShapes, travShapes):
276
+ """Turn the expanded data into shapeDeltas connected to the actual Shape objects
277
+
278
+ Parameters
279
+ ----------
280
+ smpx : Simplex
281
+ A simplex system
282
+ restShape : np.array
283
+ The rest point positions
284
+ sliderShapes : np.array
285
+ The slider shape point positions
286
+ comboShapes : np.array
287
+ The combo shape point positions
288
+ travShapes : np.array
289
+ The traversal shape point positions
290
+
291
+ Returns
292
+ -------
293
+ : np.array
294
+ The point positions for a new set of shapes
295
+
296
+ """
297
+ solver = PySimplex(smpx.dump())
298
+ shapeArray = np.zeros((len(smpx.shapes), len(restShape), 3))
299
+
300
+ indexBySlider = {s: i for i, s in enumerate(smpx.sliders)}
301
+ indexByShape = {s: i for i, s in enumerate(smpx.shapes)}
302
+
303
+ floatShapeSet = set(smpx.getFloatingShapes())
304
+ floatIdxs = sorted(set([indexByShape[s] for s in floatShapeSet]))
305
+ travShapeSet = set([pp.shape for t in smpx.traversals for pp in t.prog.pairs])
306
+ travIdxs = sorted(set([indexByShape[s] for s in travShapeSet]))
307
+
308
+ # Sliders are simple, just set their shapes directly
309
+ for ppDict in six.itervalues(sliderShapes):
310
+ for pp, shp in six.iteritems(ppDict):
311
+ shapeArray[indexByShape[pp.shape]] = shp - restShape
312
+
313
+ # First sort the combos by depth
314
+ comboByDepth = {}
315
+ for combo in smpx.combos:
316
+ comboByDepth.setdefault(len(combo.pairs), []).append(combo)
317
+
318
+ for depth in sorted(comboByDepth.keys()):
319
+ for combo in comboByDepth[depth]:
320
+ for pp, shp in six.iteritems(comboShapes[combo]):
321
+ inVec = _buildSolverInputs(smpx, combo, pp.value, indexBySlider)
322
+ outVec = np.array(solver.solve(inVec))
323
+ outVec[np.where(np.isclose(outVec, 0.0))] = 0.0
324
+ outVec[np.where(np.isclose(outVec, 1.0))] = 1.0
325
+ outVec[indexByShape[pp.shape]] = 0.0
326
+
327
+ # ignore any traversals
328
+ outVec[travIdxs] = 0.0
329
+
330
+ # ignore floaters if we're not currently checking floaters
331
+ if pp.shape not in floatShapeSet:
332
+ outVec[floatIdxs] = 0.0
333
+
334
+ # set the shape delta to the output
335
+ baseShape = np.dot(outVec, shapeArray.swapaxes(0, 1))
336
+ shapeArray[indexByShape[pp.shape]] = shp - restShape - baseShape
337
+
338
+ # First the traversals by depth
339
+ travByDepth = {}
340
+ for trav in smpx.traversals:
341
+ travByDepth.setdefault(getTravDepth(trav), []).append(trav)
342
+
343
+ for depth in sorted(travByDepth.keys()):
344
+ for trav in travByDepth[depth]:
345
+ for pp, shp in six.iteritems(travShapes[trav]):
346
+ inVec = _buildSolverInputs(smpx, trav, pp.value, indexBySlider)
347
+ outVec = np.array(solver.solve(inVec))
348
+ outVec[np.where(np.isclose(outVec, 0.0))] = 0.0
349
+ outVec[np.where(np.isclose(outVec, 1.0))] = 1.0
350
+ outVec[indexByShape[pp.shape]] = 0.0
351
+
352
+ # set the shape delta to the output
353
+ baseShape = np.dot(outVec, shapeArray.swapaxes(0, 1))
354
+ shapeArray[indexByShape[pp.shape]] = shp - restShape - baseShape
355
+ return shapeArray
356
+
357
+
358
+ def buildShapeArray(mesh, master, clients):
359
+ """Build the outpu shape array
360
+
361
+ Parameters
362
+ ----------
363
+ mesh : str
364
+ The maya shape node name
365
+ master : Simplex
366
+ The master simplex system
367
+ clients :
368
+ The client simplex systems
369
+
370
+ Returns
371
+ -------
372
+ : np.array
373
+ The full output shape array
374
+
375
+ """
376
+ restShape, sliderShapes, comboShapes, travShapes = getExpandedData(
377
+ master, clients, mesh
378
+ )
379
+ shapeArray = parseExpandedData(
380
+ master, restShape, sliderShapes, comboShapes, travShapes
381
+ )
382
+ shapeArray += restShape[None, ...]
383
+ return shapeArray
384
+
385
+
386
+ def expandedExportAbc(path, mesh, master, clients=()):
387
+ """Export the alembic by re-building the deltas from all of the full shapes
388
+ This is required for delta-mushing a system, because the sum of mushed shapes
389
+ is not the same as the mushed sum-of-shapes
390
+
391
+ Parameters
392
+ ----------
393
+ path : str
394
+ Output path for the .smpx
395
+ mesh : str
396
+ The maya shape node name
397
+ master : Simplex
398
+ The master simplex system
399
+ clients : [Simplex, ...]
400
+ The client simplex systems
401
+
402
+ Returns
403
+ -------
404
+
405
+ """
406
+ # Convert clients to a list if need be
407
+ if not clients:
408
+ clients = []
409
+ elif not isinstance(clients, list):
410
+ if isinstance(clients, tuple):
411
+ clients = list(clients)
412
+ else:
413
+ clients = [clients]
414
+
415
+ faces, counts, uvs = DCC.getAbcFaces(mesh)
416
+ shapeArray = buildShapeArray(mesh, master, clients)
417
+ jsString = str(master.dump())
418
+
419
+ buildSmpx(
420
+ path,
421
+ shapeArray,
422
+ faces,
423
+ jsString,
424
+ master.name,
425
+ faceCounts=counts,
426
+ uvs=uvs,
427
+ )
428
+
429
+
430
+ if __name__ == "__main__":
431
+ # get the smpx from the UI
432
+ master = Simplex.buildSystemFromMesh("Face_SIMPLEX", "Face")
433
+ client = Simplex.buildSystemFromMesh("Face_SIMPLEX2", "Face2")
434
+ outPath = r"D:\Users\tyler\Desktop\TEST\expanded.smpx"
435
+ expandedExportAbc(outPath, "Face_SIMPLEX", master, client)