Skip to content

Commit

Permalink
[core] Add property to know if node's outputs can be loaded in 3D Viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
cbentejac committed Jun 13, 2023
1 parent 7e6ce90 commit 0c22bbb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,11 +1124,27 @@ def canBeCanceled(self):
self.globalExecMode == "LOCAL" and self.statusInThisSession())

def hasImageOutputAttribute(self):
"""
Return True if at least one attribute has the 'image' semantic (and can thus be loaded in the 2D Viewer), False otherwise.
"""
for attr in self._attributes:
if attr.enabled and attr.isOutput and attr.desc.semantic == "image":
return True
return False

def has3DOutputAttribute(self):
"""
Return True if at least one attribute is a File that can be loaded in the 3D Viewer, False otherwise.
"""
# List of supported extensions, taken from Viewer3DSettings
supportedExts = ['.obj', '.stl', '.fbx', '.gltf', '.abc']
for attr in self._attributes:
# If the attribute is a File attribute, it is an instance of str and can be iterated over
hasSupportedExt = isinstance(attr.value, str) and any(ext in attr.value for ext in supportedExts)
if attr.enabled and attr.isOutput and hasSupportedExt:
return True
return False


name = Property(str, getName, constant=True)
nodeType = Property(str, nodeType.fget, constant=True)
Expand Down Expand Up @@ -1174,7 +1190,7 @@ def hasImageOutputAttribute(self):

outputAttrEnabledChanged = Signal()
hasImageOutput = Property(bool, hasImageOutputAttribute, notify=outputAttrEnabledChanged)

has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)

class Node(BaseNode):
"""
Expand Down

0 comments on commit 0c22bbb

Please sign in to comment.