DNA Calib 1.1
Project brief
Functions | Variables
examples/CommandSequence.cpp File Reference
#include "dnacalib/DNACalib.h"
#include <iostream>
#include <vector>
Include dependency graph for examples/CommandSequence.cpp:

Functions

int main (int argc, char **argv)
 

Variables

static const char * usage = "Usage: commandsequence.exe <path-to-dna-file-to-edit>\n"
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
10 {
11 if (argc < 2) {
12 std::cout << "Provide input dna file!" << std::endl;
13 std::cout << usage << std::endl;
14 return -1;
15 }
16
17 const char* inputDNA = argv[1];
18 auto inStream = dnac::makeScoped<dnac::FileStream>(inputDNA,
19 dnac::FileStream::AccessMode::Read,
20 dnac::FileStream::OpenMode::Binary);
21 auto reader = dnac::makeScoped<dnac::BinaryStreamReader>(inStream.get());
22 reader->read();
23
24 if (!dnac::Status::isOk()) {
25 std::cout << "Could not read input DNA file!\n";
26 return -1;
27 }
28
29 auto dnaReader = dnac::makeScoped<dnac::DNACalibDNAReader>(reader.get());
30
31 // Create command sequence instance
33
34 // Prepare a bunch of commands
35 std::vector<dnac::Vector3> positions;
36 std::vector<float> masks;
40 dnac::RenameJointCommand renameJointA("clavicle_l", "cubicle_l");
41 dnac::RenameJointCommand renameJointB(10, "upperarm_corrosiveRoot_l");
42
43 // Add commands to the command sequence
44 cmdSeq.add(&setMeshAPos, &renameJointA);
45 cmdSeq.add(&renameJointB);
46
47 // Execute command sequence
48 cmdSeq.run(dnaReader.get());
49
50 // Reconfigure individual commands that are already in the command sequence
51 renameJointB.setName("FACIAL_L_12IPV_NeckBackB2", "FACIAL_L_12IPTV_NickelBackB52");
52
53 // Modify command sequence (turn an unconditional command into a conditional command)
54 cmdSeq.remove(&renameJointA);
55 auto guardedRenameJointA =
57 return (output->getJointCount() > 6);
58 });
59 cmdSeq.add(&guardedRenameJointA);
60
61 // Execute modified command sequence
62 cmdSeq.run(dnaReader.get());
63
64 return 0;
65}
virtual std::uint16_t getJointCount() const =0
CommandSequence is used to run a sequence of commands on the same DNA.
Definition: CommandSequence.h:20
DNACAPI void run(DNACalibDNAReader *output) override
Definition: src/dnacalib/commands/CommandSequence.cpp:57
DNACAPI void add(Command *command)
Method for adding a command to a sequence of commands to run.
Definition: src/dnacalib/commands/CommandSequence.cpp:61
DNACAPI void remove(Command *command)
Method for removing a command from the sequence of commands to run.
Definition: src/dnacalib/commands/CommandSequence.cpp:71
Definition: DNACalibDNAReader.h:12
RenameJointCommand is used to rename a joint.
Definition: RenameJointCommand.h:18
SetVertexPositionsCommand is used to change vertex positions values.
Definition: SetVertexPositionsCommand.h:19
static bool isOk()
Definition: Status.cpp:13
A view over a continuous sequence of objects.
Definition: ArrayView.h:55
static const char * usage
Definition: examples/CommandSequence.cpp:8
ConditionalCommand< TCommand, TCondition > makeConditional(TCommand *command, TCondition condition)
Definition: ConditionalCommand.h:70

References dnac::CommandSequence::add(), dna::DefinitionReader::getJointCount(), dnac::Interpolate, sc::Status::isOk(), dnac::makeConditional(), dnac::CommandSequence::remove(), dnac::CommandSequence::run(), dnac::RenameJointCommand::setName(), and usage.

Variable Documentation

◆ usage

const char* usage = "Usage: commandsequence.exe <path-to-dna-file-to-edit>\n"
static

Referenced by main().