simplex-solver 3.2.2__cp39-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 (84) hide show
  1. simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
  2. simplex_solver-3.2.2.dist-info/METADATA +94 -0
  3. simplex_solver-3.2.2.dist-info/RECORD +84 -0
  4. simplex_solver-3.2.2.dist-info/WHEEL +5 -0
  5. simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
  6. simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  7. simplexui/__init__.py +86 -0
  8. simplexui/_version.py +1 -0
  9. simplexui/channelBox.py +867 -0
  10. simplexui/comboCheckDialog.py +396 -0
  11. simplexui/commands/__init__.py +16 -0
  12. simplexui/commands/alembicCommon.py +1148 -0
  13. simplexui/commands/alembic_walker.py +299 -0
  14. simplexui/commands/applyCorrectives.py +452 -0
  15. simplexui/commands/correctiveInterface.py +259 -0
  16. simplexui/commands/expandedExport.py +434 -0
  17. simplexui/commands/hdf5Convert.py +62 -0
  18. simplexui/commands/mayaCorrectiveInterface.py +159 -0
  19. simplexui/commands/mayatonumpy.py +416 -0
  20. simplexui/commands/mesh.py +1085 -0
  21. simplexui/commands/poseblendlib.py +168 -0
  22. simplexui/commands/reorderSimplexPoints.py +102 -0
  23. simplexui/commands/replaceDefinitionJson.py +74 -0
  24. simplexui/commands/rigidAlign.py +97 -0
  25. simplexui/commands/unsubdivide.py +1222 -0
  26. simplexui/commands/uvTransfer.py +976 -0
  27. simplexui/dragFilter.py +334 -0
  28. simplexui/falloffDialog.py +504 -0
  29. simplexui/img/ChefHead.png +0 -0
  30. simplexui/img/frozen.png +0 -0
  31. simplexui/interface/__init__.py +30 -0
  32. simplexui/interface/dummyInterface.py +1313 -0
  33. simplexui/interface/mayaInterface.py +2294 -0
  34. simplexui/interfaceModel.py +655 -0
  35. simplexui/interfaceModelTrees.py +456 -0
  36. simplexui/items/__init__.py +50 -0
  37. simplexui/items/accessor.py +145 -0
  38. simplexui/items/combo.py +645 -0
  39. simplexui/items/dragItem.py +44 -0
  40. simplexui/items/falloff.py +748 -0
  41. simplexui/items/group.py +267 -0
  42. simplexui/items/progression.py +613 -0
  43. simplexui/items/shape.py +384 -0
  44. simplexui/items/simplex.py +1734 -0
  45. simplexui/items/slider.py +632 -0
  46. simplexui/items/stack.py +147 -0
  47. simplexui/items/traversal.py +780 -0
  48. simplexui/items/treeItem.py +441 -0
  49. simplexui/main.pyw +22 -0
  50. simplexui/menu/__init__.py +73 -0
  51. simplexui/menu/dummyPlugins/__init__.py +16 -0
  52. simplexui/menu/genericPlugins/__init__.py +16 -0
  53. simplexui/menu/genericPlugins/_builtins.py +270 -0
  54. simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
  55. simplexui/menu/genericPlugins/exportSplit.py +67 -0
  56. simplexui/menu/genericPlugins/showFalloffs.py +26 -0
  57. simplexui/menu/genericPlugins/showTraversals.py +26 -0
  58. simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
  59. simplexui/menu/genericPlugins/unsubdivide.py +72 -0
  60. simplexui/menu/mayaPlugins/__init__.py +16 -0
  61. simplexui/menu/mayaPlugins/exportOther.py +53 -0
  62. simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
  63. simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
  64. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
  65. simplexui/menu/mayaPlugins/importObjs.py +199 -0
  66. simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
  67. simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
  68. simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
  69. simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
  70. simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
  71. simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
  72. simplexui/menu/mayaPlugins/tweakMix.py +136 -0
  73. simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
  74. simplexui/pysimplex.lib +0 -0
  75. simplexui/pysimplex.pyd +0 -0
  76. simplexui/simplexDialog.py +1547 -0
  77. simplexui/travCheckDialog.py +419 -0
  78. simplexui/traversalDialog.py +299 -0
  79. simplexui/ui/comboCheckDialog.ui +475 -0
  80. simplexui/ui/falloffDialog.ui +243 -0
  81. simplexui/ui/simplexDialog.ui +1458 -0
  82. simplexui/ui/travCheckDialog.ui +488 -0
  83. simplexui/ui/traversalDialog.ui +532 -0
  84. simplexui/utils.py +307 -0
@@ -0,0 +1,1313 @@
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
+ """A placeholder interface that takes arguments and does nothing with them"""
18
+
19
+ from __future__ import annotations
20
+
21
+ import copy
22
+ from contextlib import contextmanager
23
+ from functools import wraps
24
+
25
+ import numpy as np
26
+ from alembic.AbcGeom import OPolyMeshSchemaSample
27
+ from Qt import QtCore
28
+ from Qt.QtCore import Signal
29
+ from Qt.QtWidgets import QApplication
30
+
31
+ from ..commands.alembicCommon import (
32
+ getSampleArray,
33
+ getSampleArrayIndex,
34
+ getStaticMeshData,
35
+ getUvSample,
36
+ mkSampleIntArray,
37
+ mkSampleVertexPoints,
38
+ mkUvSample,
39
+ )
40
+
41
+
42
+ # UNDO STACK INTEGRATION
43
+ @contextmanager
44
+ def undoContext(inst=None):
45
+ """A context that wraps undo chunks
46
+
47
+ Parameters
48
+ ----------
49
+ inst : DCC
50
+ An instantiated DCC if available. (Default value = None)
51
+ """
52
+ if inst is None:
53
+ DCC.staticUndoOpen()
54
+ else:
55
+ inst.undoOpen()
56
+ try:
57
+ yield
58
+ finally:
59
+ if inst is None:
60
+ DCC.staticUndoClose()
61
+ else:
62
+ inst.undoClose()
63
+
64
+
65
+ def undoable(f):
66
+ """A decorator that wraps a function in an undoContext"""
67
+
68
+ @wraps(f)
69
+ def stacker(self, *args, **kwargs):
70
+ """The wrapper closure"""
71
+ with undoContext():
72
+ return f(self, *args, **kwargs)
73
+
74
+ return stacker
75
+
76
+
77
+ class DummyScene:
78
+ """A dcc scene containing existing dummy objects"""
79
+
80
+ def __init__(self) -> None:
81
+ self.items = {}
82
+
83
+ def get(
84
+ self,
85
+ tpe: type[DummyBlendshape]
86
+ | type[DummyFalloff]
87
+ | type[DummyMesh]
88
+ | type[DummyNode]
89
+ | type[DummySimplex],
90
+ name,
91
+ ):
92
+ return self.items.get(tpe, {}).get(name)
93
+
94
+ def add(self, item) -> None:
95
+ typeDict = self.items.setdefault(type(item), {})
96
+ typeDict[item.name] = item
97
+
98
+ def remove(self, item) -> None:
99
+ typeDict = self.items.setdefault(type(item), {})
100
+ typeDict.pop(item.name, None)
101
+
102
+
103
+ DB = DummyScene() # Default module level dummy scene
104
+
105
+
106
+ class DummyAttr:
107
+ """A generic named object attribute"""
108
+
109
+ def __init__(self, name, value: float, parent) -> None:
110
+ self.name = name
111
+ self.value = value
112
+ self.parent = parent
113
+ parent.attrs[name] = self
114
+
115
+
116
+ class DummyNode:
117
+ """A generic DCC node"""
118
+
119
+ def __init__(self, name: str, db=DB) -> None:
120
+ self.name = name
121
+ self.attrs = {}
122
+ self.ops = []
123
+ if db is not None:
124
+ db.add(self)
125
+
126
+
127
+ class DummySimplex(DummyNode):
128
+ """A generic simplex node"""
129
+
130
+ def __init__(self, name, parent, db: DummyScene = DB) -> None:
131
+ super().__init__(name, db)
132
+ self.definition = ""
133
+ parent.ops.append(self)
134
+
135
+
136
+ class DummyFalloff(DummyNode):
137
+ """A generic simplex node"""
138
+
139
+ def __init__(self, name, parent: DummyScene, db=DB) -> None:
140
+ super().__init__(name, db)
141
+ self.weightmap = None
142
+
143
+
144
+ class DummyShape:
145
+ """A generic named blendshape shape"""
146
+
147
+ def __init__(self, name, shapeNode) -> None:
148
+ self.name = name
149
+ self.value = 0.0
150
+ self.points = None
151
+ self.shapeNode = shapeNode
152
+ shapeNode.shapes[name] = self
153
+
154
+
155
+ class DummyBlendshape(DummyNode):
156
+ """A generic blendshape node"""
157
+
158
+ def __init__(self, name, parent, db: DummyScene = DB) -> None:
159
+ # TODO: Just reuse the DummyAttr instead of making an equivalent
160
+ super().__init__(name, db)
161
+ self.shapes = {}
162
+ parent.ops.append(self)
163
+
164
+
165
+ class DummyMesh(DummyNode):
166
+ """A generic mesh"""
167
+
168
+ def __init__(self, name, db=DB) -> None:
169
+ super().__init__(name, db)
170
+ self.importPath = ""
171
+ self.faces = None
172
+ self.counts = None
173
+ self.uvs = None
174
+ self.uvFaces = None
175
+ self.verts = None
176
+
177
+
178
+ class DCC:
179
+ program = "dummy"
180
+
181
+ def __init__(self, simplex, stack=None) -> None:
182
+ self.simplex = simplex # the abstract representation of the setup
183
+ self.name = simplex.name
184
+
185
+ self.scene = DummyScene()
186
+ self.mesh = None
187
+ self.ctrl = None
188
+ self.shapeNode = None
189
+ self.op = None
190
+
191
+ self._live = True
192
+ self._revision = 0
193
+ # self._shapes = {} # hold the shapes from the .smpx file as a dict
194
+ # self._faces = None # Faces for the mesh (Alembic-style)
195
+ # self._counts = None # Face counts for the mesh (Alembic-style)
196
+ # self._uvs = None # UV data for the mesh
197
+ # self._numVerts = None
198
+ self._falloffs = {} # weightPerVert values
199
+ self.sliderMul = self.simplex.sliderMul
200
+
201
+ def dummyLoad(self, other, pBar=None) -> None:
202
+ """Method to copy the information in a DCC to a DummyDCC
203
+
204
+ Parameters
205
+ ----------
206
+ other : DCC
207
+ The DCC to load into the dummy
208
+ pBar : QProgressDialog, optional
209
+ An optional progress dialog (Default value = None)
210
+
211
+ Returns
212
+ -------
213
+ : DummyDCC :
214
+ The new DummyDCC
215
+ """
216
+ assert self.simplex is not None
217
+ other.getAllShapeVertices(other.simplex.shapes, pBar=pBar)
218
+
219
+ # Load all the data onto the new dummy mesh
220
+ points, faces, counts, uvs, uvFaces = other.getMeshTopology(other.mesh)
221
+ dummyMesh = self.buildRawTopology(
222
+ other.name, points, faces, counts, uvs, uvFaces
223
+ )
224
+ self.loadNodes(self.simplex, dummyMesh)
225
+
226
+ # Re-create the dummy shapes and sliders
227
+ for shape in self.simplex.shapes:
228
+ shape.thing = DummyShape(shape.name, self.shapeNode)
229
+
230
+ for oShape, nShape in zip(other.simplex.shapes, self.simplex.shapes):
231
+ nShape.verts = copy.copy(oShape.verts)
232
+
233
+ self.pushAllShapeVertices(self.simplex.shapes)
234
+ restVerts = self.simplex.restShape.verts
235
+
236
+ for slider in self.simplex.sliders:
237
+ slider.thing = DummyAttr(slider.name, 0.0, self.ctrl)
238
+
239
+ for fo in self.simplex.falloffs:
240
+ fo.thing = DummyFalloff(fo.name, self.scene)
241
+ fo.verts = restVerts
242
+
243
+ def preLoad(self, simp, simpDict, create: bool = True, pBar=None) -> None:
244
+ """Code to execute before loading a simplex system into a dcc
245
+
246
+ Parameters
247
+ ----------
248
+ simp : Simplex
249
+ The simplex system that will be created
250
+ simpDict : dict
251
+ The dictionary definition of the simplex to be created
252
+ create : bool
253
+ Whether to create the missing objects in the DCC (Default value = True)
254
+ pBar : QProgressDialog, optional
255
+ An optional progress dialog (Default value = None)
256
+
257
+ Returns
258
+ -------
259
+ : object :
260
+ A generic python object to be used in the post-load
261
+ """
262
+ return None
263
+
264
+ def postLoad(self, simp, preRet) -> None:
265
+ """Code to execute after loading a simplex system into a dcc
266
+
267
+ Parameters
268
+ ----------
269
+ simp : Simplex
270
+ The simplex system that was created
271
+ preRet : object
272
+ The object returnd from the preload method
273
+ """
274
+ pass
275
+
276
+ def checkForErrors(self, window) -> None:
277
+ """Check for any DCC specific errors
278
+
279
+ Parameters
280
+ ----------
281
+ window : QMainWindow
282
+ The simplex window
283
+ """
284
+ pass
285
+
286
+ # System IO
287
+ @undoable
288
+ def loadNodes(self, simp, thing, create=True, pBar=None) -> None:
289
+ """Load the nodes from a simplex system onto a thing
290
+
291
+ Parameters
292
+ ----------
293
+ simp : Simplex
294
+ The system we're loading for
295
+ thing : object
296
+ The DCC thing we're reading
297
+ create : bool
298
+ Whether to create the missing nodes (Default value = True)
299
+ pBar : QProgressDialog, optional
300
+ An optional progress dialog (Default value = None)
301
+ """
302
+ if thing is None:
303
+ thing = DummyMesh(simp.name)
304
+
305
+ self.name = simp.name
306
+ self.mesh = thing
307
+ self.scene.add(self.mesh)
308
+
309
+ self.shapeNode = self.scene.get(DummyBlendshape, self.name)
310
+
311
+ if self.shapeNode is None:
312
+ if not create:
313
+ raise RuntimeError(
314
+ f"Blendshape operator not found with creation turned off: {self.name}"
315
+ )
316
+ self.shapeNode = DummyBlendshape(self.name, self.mesh, self.scene)
317
+
318
+ self.op = self.scene.get(DummySimplex, self.name)
319
+ if self.op is None:
320
+ if not create:
321
+ raise RuntimeError(
322
+ "Simplex operator not found with creation turned off"
323
+ )
324
+ self.op = DummySimplex(self.name, self.mesh, self.scene)
325
+
326
+ self.ctrl = self.scene.get(DummyNode, self.name)
327
+ if self.ctrl is None:
328
+ if not create:
329
+ raise RuntimeError("Control object not found with creation turned off")
330
+ self.ctrl = DummyNode(self.name, self.scene)
331
+
332
+ def loadConnections(self, simp, pBar=None) -> None:
333
+ """Load the connections that exist in a simplex system
334
+
335
+ Parameters
336
+ ----------
337
+ simp : Simplex
338
+ The simplex system to load connections for
339
+ pBar : QProgressDialog, optional
340
+ An optional progress dialog (Default value = None)
341
+ """
342
+ pass
343
+
344
+ def getShapeThing(self, shapeName):
345
+ """Get the DCC Thing for a given shape name
346
+
347
+ Parameters
348
+ ----------
349
+ shapeName : str
350
+ The name of the shape to get
351
+
352
+ Returns
353
+ -------
354
+ : object :
355
+ The DCC Thing
356
+ """
357
+ return self.shapeNode.shapes.get(shapeName)
358
+
359
+ def getSliderThing(self, sliderName):
360
+ """Get the DCC Thing for a given slider name
361
+
362
+ Parameters
363
+ ----------
364
+ sliderName : str
365
+ The name of the slider to get
366
+
367
+ Returns
368
+ -------
369
+ : object :
370
+ The DCC Thing
371
+ """
372
+ return self.ctrl.attrs.get(sliderName)
373
+
374
+ @staticmethod
375
+ @undoable
376
+ def buildRestAbc(abcMesh, name) -> DummyMesh:
377
+ """Build the rest Alembic node in the dcc
378
+
379
+ Parameters
380
+ ----------
381
+ abcMesh : IPolyMesh
382
+ The Alembic mesh object
383
+ name : str
384
+ The name of the object to create
385
+ """
386
+ mesh = DummyMesh(name) # don't add it to a scene
387
+ mesh.verts = getSampleArrayIndex(abcMesh, index=0)
388
+ faces, counts = getStaticMeshData(abcMesh)
389
+ uvs = getUvSample(abcMesh)
390
+
391
+ aryType = list if np is None else np.array
392
+ if uvs is not None:
393
+ mesh.uvs = aryType(uvs.getVals())
394
+ mesh.uvFaces = aryType(uvs.getIndices())
395
+ mesh.faces = aryType(faces)
396
+ mesh.counts = aryType(counts)
397
+
398
+ return mesh
399
+
400
+ @staticmethod
401
+ @undoable
402
+ def buildRawTopology(
403
+ name, points, faces, counts, uvs=None, uvFaces=None
404
+ ) -> DummyMesh:
405
+ """Build a mesh directly from raw numerical data"""
406
+ # TODO: Move this guy out to the rest of the DCC's
407
+ mesh = DummyMesh(name) # don't add it to a scene
408
+
409
+ aryType = list if np is None else np.array
410
+ mesh.verts = aryType(points)
411
+ mesh.faces = aryType(faces)
412
+ mesh.counts = aryType(counts)
413
+ if uvs is not None and uvFaces is not None:
414
+ mesh.uvs = aryType(uvs)
415
+ mesh.uvFaces = aryType(uvFaces)
416
+ return mesh
417
+
418
+ @staticmethod
419
+ def vertCount(mesh) -> int:
420
+ """Get the vert count of the given DCC Object
421
+
422
+ Parameters
423
+ ----------
424
+ mesh : object
425
+ The mesh to check
426
+
427
+ Returns
428
+ -------
429
+ : int :
430
+ The Number of verts
431
+ """
432
+ return len(mesh.verts)
433
+
434
+ @undoable
435
+ def loadAbcPoses(self, abcMesh, js, pBar=None) -> None:
436
+ """Load the joints/skin from an alembic file onto an already-created system
437
+
438
+ Parameters
439
+ ----------
440
+ abcMesh : IPolyMesh
441
+ The Alembic mesh to load shapes from
442
+ js : dict
443
+ The simplex definition dictionary
444
+ pBar : QProgressDialog, optional
445
+ An optional progress dialog (Default value = None)
446
+ """
447
+ pass
448
+
449
+ @undoable
450
+ def loadAbc(self, abcMesh, js, pBar=None) -> None:
451
+ """Load the shapes from an alembic file onto an already-created system
452
+
453
+ Parameters
454
+ ----------
455
+ abcMesh : IPolyMesh
456
+ The Alembic mesh to load shapes from
457
+ js : dict
458
+ The simplex definition dictionary
459
+ pBar : QProgressDialog, optional
460
+ An optional progress dialog (Default value = None)
461
+ """
462
+ shapes = js["shapes"]
463
+ if js["encodingVersion"] > 1:
464
+ shapes = [i["name"] for i in shapes]
465
+ pointPositions = getSampleArray(abcMesh)
466
+ for name, ppos in zip(shapes, pointPositions):
467
+ dummyShape = self.shapeNode.shapes[name]
468
+ dummyShape.points = ppos
469
+
470
+ def getAllShapeVertices(self, shapes, pBar=None) -> None:
471
+ """Load all shape vertices into the simplex system for processing
472
+
473
+ Parameters
474
+ ----------
475
+ shapes : [Shape, ...]
476
+ A list of simplex Shape objects to get positions for
477
+
478
+ pBar : QProgressDialog, optional
479
+ An optional progress dialog (Default value = None)
480
+ """
481
+ for shape in shapes:
482
+ verts = self.getShapeVertices(shape)
483
+ shape.verts = verts
484
+
485
+ def getShapeVertices(self, shape):
486
+ """Get the point positions of a shape
487
+
488
+ Parameters
489
+ ----------
490
+ shape : Shape
491
+ A simplex Shape object to get the vertices for
492
+
493
+ Returns
494
+ -------
495
+ : np.array :
496
+ A numpy array of the point positions
497
+ """
498
+ return shape.thing.points
499
+
500
+ def pushAllShapeVertices(self, shapes, pBar=None) -> None:
501
+ """Push the computed vertex positions for the given shapes back to the DCC
502
+
503
+ Parameters
504
+ ----------
505
+ shapes : [Shape, ...]
506
+ A list of simplex Shape objects
507
+
508
+ pBar : QProgressDialog, optional
509
+ An optional progress dialog (Default value = None)
510
+ """
511
+ for shape in shapes:
512
+ self.pushShapeVertices(shape)
513
+
514
+ def pushShapeVertices(self, shape) -> None:
515
+ """Push the computed vertex positions for the given shape back to the DCC
516
+ Parameters
517
+ ----------
518
+ shape : Shape
519
+ The Simplex Shape object to update
520
+ """
521
+ shape.thing.points = shape.verts
522
+
523
+ def loadMeshTopology(self) -> None:
524
+ """Load the mesh topology from the DCC into the simplex interface"""
525
+ # Here in Dummy I either have the data already or I don't, So nothing to do
526
+ pass
527
+
528
+ @staticmethod
529
+ def getMeshTopology(mesh, uvName=None):
530
+ """Get the topology of a mesh
531
+
532
+ Parameters
533
+ ----------
534
+ mesh : object
535
+ The DCC Mesh to read
536
+ uvName : str, optional
537
+ The name of the uv set to read
538
+
539
+ Returns
540
+ -------
541
+ : np.array :
542
+ The vertex array
543
+ : np.array :
544
+ The "faces" array
545
+ : np.array :
546
+ The "counts" array
547
+ : np.array :
548
+ The uv positions
549
+ : np.array :
550
+ The "uvFaces" array
551
+ """
552
+ return mesh.verts, mesh.faces, mesh.counts, mesh.uvs, mesh.uvFaces
553
+
554
+ def exportAbc(
555
+ self, dccMesh, abcMesh, js, world=False, ensureCorrect=False, pBar=None
556
+ ) -> None:
557
+ """Export a .smpx file
558
+
559
+ Parameters
560
+ ----------
561
+ dccMesh : object
562
+ The DCC Mesh to export
563
+ abcMesh : OPolyMesh
564
+ The Alembic output mesh
565
+ js : dict
566
+ The definition dictionary
567
+ world : bool
568
+ Do the export in worldspace (Default value = False)
569
+ pBar : QProgressDialog, optional
570
+ An optional progress dialog (Default value = None)
571
+ """
572
+ # export the data to alembic
573
+ if dccMesh is None:
574
+ dccMesh = self.mesh
575
+
576
+ shapeDict = {i.name: i for i in self.simplex.shapes}
577
+
578
+ shapeNames = js["shapes"]
579
+ if js["encodingVersion"] > 1:
580
+ shapeNames = [i["name"] for i in shapeNames]
581
+ shapes = [shapeDict[i] for i in shapeNames]
582
+ schema = abcMesh.getSchema()
583
+
584
+ if pBar is not None:
585
+ pBar.show()
586
+ pBar.setMaximum(len(shapes))
587
+ spacerName = "_" * max(list(map(len, shapeNames)))
588
+ pBar.setLabelText(f"Exporting:\n{spacerName}")
589
+ QApplication.processEvents()
590
+
591
+ faces = mkSampleIntArray(self.mesh.faces)
592
+ counts = mkSampleIntArray(self.mesh.counts)
593
+ uvs = None
594
+ if self.mesh.uvs is not None and self.mesh.uvFaces is not None:
595
+ uvs = mkUvSample(self.mesh.uvs, self.mesh.uvFaces)
596
+
597
+ for i, shape in enumerate(shapes):
598
+ if pBar is not None:
599
+ pBar.setLabelText(f"Exporting:\n{shape.name}")
600
+ pBar.setValue(i)
601
+ pBar.repaint() # Required to properly show the percentage. Don't know why
602
+ QApplication.processEvents()
603
+ if pBar.wasCanceled():
604
+ return
605
+ verts = mkSampleVertexPoints(shape.thing.points)
606
+ if uvs is not None:
607
+ # Alembic doesn't allow for uvs=None for some reason
608
+ abcSample = OPolyMeshSchemaSample(verts, faces, counts, uvs)
609
+ else:
610
+ abcSample = OPolyMeshSchemaSample(verts, faces, counts)
611
+ schema.set(abcSample)
612
+
613
+ def exportOtherAbc(
614
+ self, dccMesh, abcMesh, js, world: bool = False, pBar=None
615
+ ) -> None:
616
+ """Export a .smpx file of a mesh other than self.mesh
617
+
618
+ Parameters
619
+ ----------
620
+ dccMesh : object
621
+ The DCC Mesh to export
622
+ abcMesh : OPolyMesh
623
+ The Alembic output mesh
624
+ js : dict
625
+ The definition dictionary
626
+ world : bool
627
+ Do the export in worldspace (Default value = False)
628
+ pBar : QProgressDialog, optional
629
+ An optional progress dialog (Default value = None)
630
+ """
631
+ if dccMesh is None:
632
+ raise ValueError(
633
+ "Export Other requires an explicitly defined mesh to export"
634
+ )
635
+ self.exportAbc(
636
+ dccMesh, abcMesh, js, world=world, ensureCorrect=False, pBar=pBar
637
+ )
638
+
639
+ def deleteObj(self, dccMesh, path) -> None:
640
+ """Export a mesh to the given path"""
641
+ pass
642
+
643
+ def exportMesh(self, dccMesh, path) -> None:
644
+ """Export a mesh to the given path"""
645
+ pass
646
+
647
+ # Revision tracking
648
+ def getRevision(self) -> int:
649
+ """Get the simplex revision number"""
650
+ return self._revision
651
+
652
+ def incrementRevision(self) -> int:
653
+ """Increment the revision number"""
654
+ self._revision += 1
655
+ return self._revision
656
+
657
+ def setRevision(self, val) -> None:
658
+ """Manually set the revision numer
659
+
660
+ Parameters
661
+ ----------
662
+ val : int
663
+ The value to set
664
+ """
665
+ self._revision = val
666
+
667
+ # System level
668
+ @undoable
669
+ def renameSystem(self, name) -> None:
670
+ """Rename a simplex system
671
+
672
+ Parameters
673
+ ----------
674
+ name : str
675
+ The new name
676
+ """
677
+ # TODO
678
+ # oldName = self.name
679
+ self.name = name
680
+ # for dd in (DB.nodes, DB.ops, DB.bss, DB.meshes):
681
+ # oo = dd.get(oldName)
682
+ # if oo is not None:
683
+ # oo.name = self.name
684
+ # dd[self.name] = oo
685
+ # dd.pop(oldName, None)
686
+
687
+ @undoable
688
+ def deleteSystem(self) -> None:
689
+ """Delete the current system"""
690
+ # for dd in (DB.nodes, DB.ops, DB.bss, DB.meshes):
691
+ # if self.name in dd:
692
+ # dd.pop(self.name, None)
693
+ # TODO
694
+ self.name = None
695
+ self.simplex = None
696
+
697
+ # Shapes
698
+ @undoable
699
+ def createShape(self, shape, live: bool = False, offset: int = 10) -> DummyShape:
700
+ """Create a dcc shape
701
+
702
+ Parameters
703
+ ----------
704
+ shape : Shape
705
+ A simplex shape object
706
+ live : bool
707
+ Whether this shape is live-connected (Default value = False)
708
+ offset : float
709
+ The offset of the created shape (Default value = 10)
710
+ """
711
+ newShape = DummyShape(shape.name, self.shapeNode)
712
+ newShape.points = copy.copy(self.mesh.verts)
713
+ return newShape
714
+
715
+ @undoable
716
+ def extractWithDeltaShape(
717
+ self, shape, live: bool = True, offset: float = 10.0
718
+ ) -> None:
719
+ """Make a mesh representing a shape. Can be live or not.
720
+ Also, make a shapenode that is the delta of the change being made
721
+ """
722
+ pass
723
+
724
+ @undoable
725
+ def extractWithDeltaConnection(
726
+ self, shape, delta, value, live: bool = True, offset: float = 10.0
727
+ ) -> None:
728
+ """Extract a shape with a live partial delta added in.
729
+ Useful for updating progressive shapes
730
+ """
731
+ pass
732
+
733
+ @undoable
734
+ def extractShape(self, shape, live: bool = True, offset: float = 10.0) -> None:
735
+ """Make a mesh representing a shape. Can be live or not.
736
+ Can also store its starting shape and delta data
737
+ """
738
+ pass
739
+
740
+ @undoable
741
+ def connectShape(
742
+ self, shape, mesh=None, live: bool = False, delete: bool = False
743
+ ) -> None:
744
+ """Force a shape to match a mesh
745
+ The "connect shape" button is:
746
+ mesh=None, delete=True
747
+ The "match shape" button is:
748
+ mesh=someMesh, delete=False
749
+ There is a possibility of a "make live" button:
750
+ live=True, delete=False
751
+ """
752
+ pass
753
+
754
+ @undoable
755
+ def extractPosedShape(self, shape) -> None:
756
+ pass
757
+
758
+ @undoable
759
+ def zeroShape(self, shape) -> None:
760
+ """Set a shape back to rest
761
+
762
+ Parameters
763
+ ----------
764
+ shape : Shape
765
+ The simplex shpae to zero out
766
+ """
767
+ shape.thing.points = self.getShapeVertices(self.simplex.restShape)
768
+
769
+ @undoable
770
+ def deleteShape(self, toDelShape) -> None:
771
+ """Delete a shape from the system
772
+
773
+ Parameters
774
+ ----------
775
+ toDelShape :
776
+ """
777
+ self.shapeNode.shapes.pop(toDelShape.name, None)
778
+
779
+ @undoable
780
+ def renameShape(self, shape, name) -> None:
781
+ """Rename a shape
782
+
783
+ Parameters
784
+ ----------
785
+ shape : Shape
786
+ The simplex Shape object to rename
787
+ name : str
788
+ The new name
789
+ """
790
+ self.shapeNode.shapes.pop(shape.thing.name, None)
791
+ shape.thing.name = name
792
+ self.shapeNode.shapes[name] = shape.thing
793
+
794
+ @undoable
795
+ def convertShapeToCorrective(self, shape) -> None:
796
+ pass
797
+
798
+ # Falloffs
799
+ def createFalloff(self, falloff) -> None:
800
+ """Create a per-vert falloff weightmap
801
+
802
+ Parameters
803
+ ----------
804
+ falloff : Falloff
805
+ The simplex Falloff object to create
806
+ """
807
+ fo = DummyFalloff(falloff.name, self.scene)
808
+ fo.weights = np.zeros(len(self.mesh.verts))
809
+
810
+ def duplicateFalloff(self, falloff, newFalloff) -> None:
811
+ """Create a new falloff from an already existing one
812
+
813
+ Parameters
814
+ ----------
815
+ falloff : Falloff
816
+ The already existing falloff
817
+ newFalloff : Falloff
818
+ The newly created falloff to store the newly duplicated data
819
+ """
820
+ fo = DummyFalloff(newFalloff.name, self.scene)
821
+ fo.weights = copy.copy(falloff.thing.weights)
822
+
823
+ def deleteFalloff(self, falloff) -> None:
824
+ """Delete a falloff object
825
+
826
+ Parameters
827
+ ----------
828
+ falloff : Falloff
829
+ The Falloff object to delete
830
+ """
831
+ self.scene.remove(falloff.thing)
832
+
833
+ def setFalloffData(
834
+ self, falloff, splitType, axis, minVal, minHandle, maxHandle, maxVal, mapName
835
+ ) -> None:
836
+ """Set the data of a falloff object"""
837
+ # TODO: set the per-vert falloffs
838
+ pass # for eventual live splits
839
+
840
+ def getFalloffThing(self, falloff):
841
+ """Get the thing for a given falloff
842
+
843
+ Parameters
844
+ ----------
845
+ falloff : Falloff
846
+ The simplex falloff object to get
847
+ """
848
+ return self.scene.get(DummyFalloff, falloff.name)
849
+
850
+ # Sliders
851
+ @undoable
852
+ def createSlider(self, slider) -> DummyAttr:
853
+ """Create a slider object
854
+
855
+ Parameters
856
+ ----------
857
+ slider : Slider
858
+ The simplex slider object to create
859
+ """
860
+ return DummyAttr(slider.name, 0.0, self.ctrl)
861
+
862
+ @undoable
863
+ def renameSlider(self, slider, name) -> None:
864
+ """Rename a slider
865
+
866
+ Parameters
867
+ ----------
868
+ slider : Slider
869
+ The slider to rename
870
+ name : str
871
+ The new name
872
+ """
873
+ self.ctrl.attrs.pop(slider.thing.name, None)
874
+ self.ctrl.attrs[name] = slider.thing
875
+ slider.thing.name = name
876
+
877
+ @undoable
878
+ def setSliderRange(self, slider) -> None:
879
+ """Set the min and max of a slider
880
+
881
+ Parameters
882
+ ----------
883
+ slider : Slider
884
+ The slider to set
885
+ """
886
+ pass
887
+
888
+ @undoable
889
+ def deleteSlider(self, toDelSlider) -> None:
890
+ """Delete a slider
891
+
892
+ Parameters
893
+ ----------
894
+ toDelSlider : Slider
895
+ The slider to delete
896
+ """
897
+ self.ctrl.attrs.pop(toDelSlider.name, None)
898
+
899
+ @undoable
900
+ def addProgFalloff(self, prog, falloff) -> None:
901
+ pass # for eventual live splits
902
+
903
+ @undoable
904
+ def removeProgFalloff(self, prog, falloff) -> None:
905
+ pass # for eventual live splits
906
+
907
+ @undoable
908
+ def setSlidersWeights(self, sliders, weights) -> None:
909
+ """Set the values for the given sliders
910
+
911
+ Parameters
912
+ ----------
913
+ sliders : [Slider, ...]
914
+ The sliders to set values for
915
+ weights : [float, ...]
916
+ The values to set
917
+ """
918
+ for slider, val in zip(sliders, weights):
919
+ slider.thing.value = val
920
+
921
+ @undoable
922
+ def setSliderWeight(self, slider, weight) -> None:
923
+ """Set the value for a given slider
924
+
925
+ Parameters
926
+ ----------
927
+ slider : Slider
928
+ The slider
929
+ weight : float
930
+ The value
931
+ """
932
+ slider.thing.value = weight
933
+
934
+ @undoable
935
+ def updateSlidersRange(self, sliders) -> None:
936
+ """Update the range of the given sliders"""
937
+ pass
938
+
939
+ @undoable
940
+ def extractTraversalShape(
941
+ self, trav, shape, live: bool = True, offset: float = 10.0
942
+ ) -> None:
943
+ """Extract a shape from a traversal progression"""
944
+ pass
945
+
946
+ @undoable
947
+ def connectTraversalShape(
948
+ self, trav, shape, mesh=None, live: bool = True, delete: bool = False
949
+ ) -> None:
950
+ """Connect a shape to a traversal progression"""
951
+ pass
952
+
953
+ # Combos
954
+ @undoable
955
+ def extractComboShape(
956
+ self, combo, shape, live: bool = True, offset: float = 10.0
957
+ ) -> None:
958
+ """Extract a shape from a combo progression"""
959
+ pass
960
+
961
+ @undoable
962
+ def connectComboShape(
963
+ self, combo, shape, mesh=None, live: bool = True, delete: bool = False
964
+ ) -> None:
965
+ """Connect a shape to a combo progression"""
966
+ pass
967
+
968
+ @staticmethod
969
+ def setDisabled(op) -> None:
970
+ """Disable the output of any simplex systems
971
+
972
+ Parameters
973
+ ----------
974
+ op : The operator to disable
975
+
976
+ Returns
977
+ -------
978
+ : object :
979
+ Some object that will allow us to re-enable the system
980
+ """
981
+ return None
982
+
983
+ @staticmethod
984
+ def reEnable(helpers) -> None:
985
+ """Re-enable a simplex system
986
+
987
+ Parameters
988
+ ----------
989
+ helpers : object
990
+ The helper object returned from setDisabled
991
+ """
992
+ pass
993
+
994
+ @undoable
995
+ def renameCombo(self, combo, name) -> None:
996
+ """Set the name of a Combo
997
+
998
+ Parameters
999
+ ----------
1000
+ combo : Combo
1001
+ The combo to rename
1002
+ name : str
1003
+ The new name
1004
+ """
1005
+ pass
1006
+
1007
+ # Data Access
1008
+ @staticmethod
1009
+ def getSimplexOperators():
1010
+ """Get all simplex operators in the DCC"""
1011
+ return list(DB.ops.values())
1012
+
1013
+ @staticmethod
1014
+ def getSimplexOperatorsByName(name):
1015
+ """Get a simplex operator
1016
+
1017
+ Parameters
1018
+ ----------
1019
+ name : str
1020
+ The name to search for
1021
+
1022
+ Returns
1023
+ -------
1024
+ : object :
1025
+ The simplex operator for the DCC
1026
+ """
1027
+ return DB.ops.get(name)
1028
+
1029
+ @staticmethod
1030
+ def getSimplexOperatorsOnObject(thing) -> list[DummySimplex]:
1031
+ """Get all simplex operators controlling an object
1032
+
1033
+ Parameters
1034
+ ----------
1035
+ thing : object
1036
+ A dcc object to check for simplex operators
1037
+
1038
+ Returns
1039
+ -------
1040
+ : [object, ...] :
1041
+ A list of simplex operators
1042
+ """
1043
+ return [o for o in thing.ops if isinstance(o, DummySimplex)]
1044
+
1045
+ @staticmethod
1046
+ def getSimplexString(op):
1047
+ """Get the simplex string from the given operator
1048
+
1049
+ Parameters
1050
+ ----------
1051
+ op : object
1052
+ The Simplex operator to get the definition from
1053
+
1054
+ Returns
1055
+ -------
1056
+ : str :
1057
+ The simplex definition
1058
+ """
1059
+ return op.definition
1060
+
1061
+ @staticmethod
1062
+ def getSimplexStringOnThing(thing, systemName):
1063
+ """Get the definition on an object by name
1064
+
1065
+ Parameters
1066
+ ----------
1067
+ thing : object
1068
+ The DCC object to check for a simplex operator
1069
+ systemName : str
1070
+ The system name to check for
1071
+
1072
+ Returns
1073
+ -------
1074
+ : str :
1075
+ The simplex definition
1076
+ """
1077
+ for op in thing.ops:
1078
+ if op.name == systemName:
1079
+ return op.definition
1080
+ return None
1081
+
1082
+ @staticmethod
1083
+ def setSimplexString(op, val) -> None:
1084
+ """Set the definition string on an object
1085
+
1086
+ Parameters
1087
+ ----------
1088
+ op : object
1089
+ The operator to set the definition on
1090
+ val : str
1091
+ The definition to set
1092
+ """
1093
+ op.definition = val
1094
+
1095
+ @staticmethod
1096
+ def selectObject(thing) -> None:
1097
+ """Select an object in the DCC"""
1098
+ pass
1099
+
1100
+ def selectCtrl(self) -> None:
1101
+ """Select the system's control object"""
1102
+ pass
1103
+
1104
+ @staticmethod
1105
+ def getObjectByName(name):
1106
+ """Get an object by name
1107
+
1108
+ Parameters
1109
+ ----------
1110
+ name : str
1111
+ The name to search for
1112
+
1113
+ Returns
1114
+ -------
1115
+ : object :
1116
+ The found object
1117
+ """
1118
+ # TODO: maybe also filter by type??
1119
+ # return DB.meshes.get(name)
1120
+ return DB.get(DummyMesh, name)
1121
+
1122
+ @staticmethod
1123
+ def getObjectName(thing):
1124
+ """Get the name of an object
1125
+
1126
+ Parameters
1127
+ ----------
1128
+ thing : object
1129
+ The dcc object to get the name for
1130
+
1131
+ Returns
1132
+ -------
1133
+ : str :
1134
+ The Object Name
1135
+ """
1136
+ return thing.name
1137
+
1138
+ @staticmethod
1139
+ def staticUndoOpen() -> None:
1140
+ """Open an undo chunk without knowledge of Simplex"""
1141
+ pass
1142
+
1143
+ @staticmethod
1144
+ def staticUndoClose() -> None:
1145
+ """Close an undo chunk without knowledge of Simplex"""
1146
+ pass
1147
+
1148
+ def undoOpen(self) -> None:
1149
+ """Open an undo chunk with knowledge of Simplex"""
1150
+ pass
1151
+
1152
+ def undoClose(self) -> None:
1153
+ """Close an undo chunk with knowledge of Simplex"""
1154
+ pass
1155
+
1156
+ @classmethod
1157
+ def getPersistentFalloff(cls, thing):
1158
+ """Get a representation of the given object that won't get deleted or garbage collected
1159
+
1160
+ Parameters
1161
+ ----------
1162
+ thing : object
1163
+ The thing to get a persistent representation of
1164
+
1165
+ Returns
1166
+ -------
1167
+ : object :
1168
+ The requested persistent object
1169
+ """
1170
+ return cls.getObjectName(thing)
1171
+
1172
+ @classmethod
1173
+ def loadPersistentFalloff(cls, thing):
1174
+ """Get the usable representation of the given persistent thing
1175
+
1176
+ Parameters
1177
+ ----------
1178
+ thing : object
1179
+ A persistent representation
1180
+
1181
+ Returns
1182
+ -------
1183
+ : object :
1184
+ The requested volatile object
1185
+ """
1186
+ return cls.getObjectByName(thing)
1187
+
1188
+ @classmethod
1189
+ def getPersistentShape(cls, thing):
1190
+ """Get a representation of the given object that won't get deleted or garbage collected
1191
+
1192
+ Parameters
1193
+ ----------
1194
+ thing : object
1195
+ The thing to get a persistent representation of
1196
+
1197
+ Returns
1198
+ -------
1199
+ : object :
1200
+ The requested persistent object
1201
+ """
1202
+ return cls.getObjectName(thing)
1203
+
1204
+ @classmethod
1205
+ def loadPersistentShape(cls, thing):
1206
+ """Get the usable representation of the given persistent thing
1207
+
1208
+ Parameters
1209
+ ----------
1210
+ thing : object
1211
+ A persistent representation
1212
+
1213
+ Returns
1214
+ -------
1215
+ : object :
1216
+ The requested volatile object
1217
+ """
1218
+ return cls.getObjectByName(thing)
1219
+
1220
+ @classmethod
1221
+ def getPersistentSlider(cls, thing):
1222
+ """Get a representation of the given object that won't get deleted or garbage collected
1223
+
1224
+ Parameters
1225
+ ----------
1226
+ thing : object
1227
+ The thing to get a persistent representation of
1228
+
1229
+ Returns
1230
+ -------
1231
+ : object :
1232
+ The requested persistent object
1233
+ """
1234
+ return cls.getObjectName(thing)
1235
+
1236
+ @classmethod
1237
+ def loadPersistentSlider(cls, thing):
1238
+ """Get the usable representation of the given persistent thing
1239
+
1240
+ Parameters
1241
+ ----------
1242
+ thing : object
1243
+ A persistent representation
1244
+
1245
+ Returns
1246
+ -------
1247
+ : object :
1248
+ The requested volatile object
1249
+ """
1250
+ return cls.getObjectByName(thing)
1251
+
1252
+ @staticmethod
1253
+ def getSelectedObjects() -> list[DummyNode]:
1254
+ """Get the selected objects"""
1255
+ # Here in the dummy interface, we short-circuit this
1256
+ # And return a default selected object called "thing"
1257
+ return [DummyNode("thing")]
1258
+
1259
+ def getFreezeThing(self, combo):
1260
+ return []
1261
+
1262
+
1263
+ class SliderDispatch(QtCore.QObject):
1264
+ valueChanged = Signal()
1265
+
1266
+ def __init__(self, node, parent=None) -> None:
1267
+ super().__init__(parent)
1268
+
1269
+ def emitValueChanged(self, *args, **kwargs) -> None:
1270
+ self.valueChanged.emit()
1271
+
1272
+
1273
+ class Dispatch(QtCore.QObject):
1274
+ beforeNew = Signal()
1275
+ afterNew = Signal()
1276
+ beforeOpen = Signal()
1277
+ afterOpen = Signal()
1278
+ undo = Signal()
1279
+ redo = Signal()
1280
+
1281
+ def __init__(self, parent=None) -> None:
1282
+ super().__init__(parent)
1283
+
1284
+ def connectCallbacks(self) -> None:
1285
+ pass
1286
+
1287
+ def disconnectCallbacks(self) -> None:
1288
+ pass
1289
+
1290
+ def emitBeforeNew(self, *args, **kwargs) -> None:
1291
+ self.beforeNew.emit()
1292
+
1293
+ def emitAfterNew(self, *args, **kwargs) -> None:
1294
+ self.afterNew.emit()
1295
+
1296
+ def emitBeforeOpen(self, *args, **kwargs) -> None:
1297
+ self.beforeOpen.emit()
1298
+
1299
+ def emitAfterOpen(self, *args, **kwargs) -> None:
1300
+ self.afterOpen.emit()
1301
+
1302
+ def emitUndo(self, *args, **kwargs) -> None:
1303
+ self.undo.emit()
1304
+
1305
+ def emitRedo(self, *args, **kwargs) -> None:
1306
+ self.redo.emit()
1307
+
1308
+
1309
+ DISPATCH = Dispatch()
1310
+
1311
+
1312
+ def rootWindow() -> None:
1313
+ return None