DNA Calib 1.1
Project brief
Functions
remove_joint Namespace Reference

Functions

def loadDNA (path)
 
def saveDNA (reader, path)
 
def getJoints (dna)
 
def printJoints (dna)
 
def calibrateDNA (inputPath, outputPath)
 
def main ()
 

Function Documentation

◆ calibrateDNA()

def remove_joint.calibrateDNA (   inputPath,
  outputPath 
)
38def calibrateDNA(inputPath, outputPath):
39 dna = loadDNA(inputPath)
40
41 # Copies DNA contents and will serve as input/output parameter to command
42 calibrated = dnac.DNACalibDNAReader(dna)
43
44 original_joints = getJoints(calibrated)
45
46 # An example joint to remove
47 joint_index = 314
48 joint_name = calibrated.getJointName(joint_index)
49
50 # Removes joint with specified index
51 command = dnac.RemoveJointCommand(joint_index)
52
53 # Modifies calibrated DNA in-place
54 command.run(calibrated)
55
56 modified_joints = getJoints(calibrated)
57
58 if ((len(modified_joints) != (len(original_joints) - 1)) or (joint_name in modified_joints)):
59 raise RuntimeError("Joint not removed properly!")
60
61 print("Successfully removed joint `{}`.".format(joint_name))
62
63 print("Saving DNA...")
64 saveDNA(calibrated, outputPath)
65
66 print("Done.")
67
Definition: DNACalibDNAReader.h:12
RemoveJointCommand is used to remove joints.
Definition: RemoveJointCommand.h:18
def saveDNA(reader, path)
Definition: remove_joint.py:18
def calibrateDNA(inputPath, outputPath)
Definition: remove_joint.py:38
def loadDNA(path)
Definition: remove_joint.py:8
def getJoints(dna)
Definition: remove_joint.py:28

References getJoints(), loadDNA(), and saveDNA().

Referenced by main().

◆ getJoints()

def remove_joint.getJoints (   dna)
28def getJoints(dna):
29 joints = []
30 for jointIndex in range(dna.getJointCount()):
31 joints.append(dna.getJointName(jointIndex))
32 return joints
33

Referenced by calibrateDNA().

◆ loadDNA()

def remove_joint.loadDNA (   path)
8def loadDNA(path):
9 stream = dna.FileStream(path, dna.FileStream.AccessMode_Read, dna.FileStream.OpenMode_Binary)
10 reader = dna.BinaryStreamReader(stream, dna.DataLayer_All)
11 reader.read()
12 if not dna.Status.isOk():
13 status = dna.Status.get()
14 raise RuntimeError("Error loading DNA: {}".format(status.message))
15 return reader
16
17
Definition: BinaryStreamReader.h:12
Standard file stream.
Definition: FileStream.h:13

Referenced by calibrateDNA().

◆ main()

def remove_joint.main ( )
68def main():
69 parser = argparse.ArgumentParser(description="DNACalib remove joint example")
70 parser.add_argument('input_dna',
71 metavar='input-dna',
72 help='Path to DNA file to load')
73 parser.add_argument('output_dna',
74 metavar='output-dna',
75 help='Path where to save modified DNA file')
76
77 args = parser.parse_args()
78
79 calibrateDNA(args.input_dna, args.output_dna)
80
81
def main()
Definition: remove_joint.py:68

References calibrateDNA(), and main().

Referenced by main().

◆ printJoints()

def remove_joint.printJoints (   dna)
34def printJoints(dna):
35 for jointIndex in range(dna.getJointCount()):
36 print(dna.getJointName(jointIndex))
37
def printJoints(dna)
Definition: remove_joint.py:34

◆ saveDNA()

def remove_joint.saveDNA (   reader,
  path 
)
18def saveDNA(reader, path):
19 stream = dna.FileStream(path, dna.FileStream.AccessMode_Write, dna.FileStream.OpenMode_Binary)
20 writer = dna.BinaryStreamWriter(stream)
21 writer.setFrom(reader)
22 writer.write()
23
24 if not dna.Status.isOk():
25 status = dna.Status.get()
26 raise RuntimeError("Error saving DNA: {}".format(status.message))
27
Definition: BinaryStreamWriter.h:11

Referenced by calibrateDNA().