mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-06 11:27:19 +02:00
Add abstract InitNode
InitNode is an abstract class which is meant to be inherited by all the initialization nodes (such as CameraInit), included those that might be created by the user. InitNode contains methods that can be reimplemented by the children classes if necessary. This abstract class allows to keep on using scripts such as meshroom_batch without having to modify them specifically or being limited to using a CameraInit node.
This commit is contained in:
parent
96b4ec8d1d
commit
659c8a05ed
4 changed files with 111 additions and 38 deletions
|
@ -527,3 +527,55 @@ class CommandLineNode(Node):
|
|||
finally:
|
||||
chunk.subprocess = None
|
||||
|
||||
|
||||
# Test abstract node
|
||||
class InitNode:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, node, inputs, recursiveInputs):
|
||||
"""
|
||||
Initialize the attributes that are needed for a node to start running.
|
||||
|
||||
Args:
|
||||
node (Node): the node whose attributes must be initialized
|
||||
inputs (list): the user-provided list of input files/directories
|
||||
recursiveInputs (list): the user-provided list of input directories to search recursively for images
|
||||
"""
|
||||
pass
|
||||
|
||||
def resetAttributes(self, node, attributeNames):
|
||||
"""
|
||||
Reset the values of the provided attributes for a node.
|
||||
|
||||
Args:
|
||||
node (Node): the node whose attributes are to be reset
|
||||
attributeNames (list): the list containing the names of the attributes to reset
|
||||
"""
|
||||
for attrName in attributeNames:
|
||||
if node.hasAttribute(attrName):
|
||||
node.attribute(attrName).resetValue()
|
||||
|
||||
def extendAttributes(self, node, attributesDict):
|
||||
"""
|
||||
Extend the values of the provided attributes for a node.
|
||||
|
||||
Args:
|
||||
node (Node): the node whose attributes are to be extended
|
||||
attributesDict (dict): the dictionary containing the attributes' names (as keys) and the values to extend with
|
||||
"""
|
||||
for attr in attributesDict.keys():
|
||||
if node.hasAttribute(attr):
|
||||
node.attribute(attr).extend(attributesDict[attr])
|
||||
|
||||
def setAttributes(self, node, attributesDict):
|
||||
"""
|
||||
Set the values of the provided attributes for a node.
|
||||
|
||||
Args:
|
||||
node (Node): the node whose attributes are to be extended
|
||||
attributesDict (dict): the dictionary containing the attributes' names (as keys) and the values to set
|
||||
"""
|
||||
for attr in attributesDict:
|
||||
if node.hasAttribute(attr):
|
||||
node.attribute(attr).value = attributesDict[attr]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue