GCC Code Coverage Report


Directory: ./
File: src/transform-writer.cc
Date: 2024-12-20 15:53:58
Exec Total Coverage
Lines: 0 24 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 // Copyright (c) 2015, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17 #include <gepetto/viewer/node.h>
18 #include <gepetto/viewer/transform-writer.h>
19
20 namespace gepetto {
21 namespace viewer {
22 namespace {
23 const char indent[] = " ";
24 }
25
26 void TransformWriter::newFrame() {
27 writeNewFrame();
28 frameCount_++;
29 }
30
31 void BasicTransformWriter::writeNewFrame() {
32 file_ << "FRAME=" << frameCount_ << "\n";
33 }
34
35 void BasicTransformWriter::writeTransform(const char* objName,
36 const osgVector3& vec,
37 const osgQuat& quat) {
38 file_ << objName << "=" << vec[0] << ", " << vec[1] << ", " << vec[2] << ", "
39 << quat.w() << ", " << quat.x() << ", " << quat.y() << ", " << quat.z()
40 << "\n";
41 }
42
43 void YamlTransformWriter::writeNewFrame() {
44 file_ << "frame_" << frameCount_ << ":\n";
45 }
46
47 void YamlTransformWriter::writeTransform(const char* objName,
48 const osgVector3& vec,
49 const osgQuat& quat) {
50 file_ << indent << objName << ": [" << vec[0] << ", " << vec[1] << ", "
51 << vec[2] << ", " << quat.w() << ", " << quat.x() << ", " << quat.y()
52 << ", " << quat.z() << "]\n";
53 }
54
55 void TransformWriterVisitor::apply(Node& node) {
56 const Configuration& cfg = node.getGlobalTransform();
57 writer_->writeTransform(node.getID().c_str(), cfg.position, cfg.quat);
58 traverse(node);
59 }
60
61 void TransformWriterVisitor::captureFrame(Node& node) {
62 writer_->openFile();
63 writer_->newFrame();
64 apply(node);
65 writer_->closeFile();
66 }
67
68 } // namespace viewer
69 } // namespace gepetto
70