OrientedPoint.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @author Martin Miller (martin dot miller at student dot kit dot edu)
17* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18* GNU General Public License
19*/
20
21#include "OrientedPoint.h"
22
23using namespace armarx;
24using namespace Eigen;
25
27{
28 px = 0;
29 py = 0;
30 pz = 0;
31
32 nx = 0;
33 ny = 0;
34 nz = 0;
35}
36
37OrientedPoint::OrientedPoint(const Vector3f& position, const Vector3f& normal)
38{
39 px = position(0);
40 py = position(1);
41 pz = position(2);
42
43 nx = normal(0);
44 ny = normal(1);
45 nz = normal(2);
46}
47
49 ::Ice::Float py,
50 ::Ice::Float pz,
51 ::Ice::Float nx,
52 ::Ice::Float ny,
53 ::Ice::Float nz)
54{
55 this->px = px;
56 this->py = py;
57 this->pz = pz;
58
59 this->nx = nx;
60 this->ny = ny;
61 this->nz = nz;
62}
63
64Vector3f
66{
67 Vector3f p;
68 p << this->px, this->py, this->pz;
69 return p;
70}
71
72Vector3f
74{
75 Vector3f n;
76 n << this->nx, this->ny, this->nz;
77 return n;
78}
79
80std::string
81OrientedPoint::output(const Ice::Current& c) const
82{
83 Eigen::IOFormat vecfmt(Eigen::FullPrecision, 0, "", ", ", "", "", "(", ")");
84 std::stringstream s;
85 s << positionToEigen().format(vecfmt) << ", " << normalToEigen().format(vecfmt);
86 return s.str();
87}
88
89void
90OrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current&) const
91{
92 AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
93
94 obj->setFloat("px", px);
95 obj->setFloat("py", py);
96 obj->setFloat("pz", pz);
97
98 obj->setFloat("nx", nx);
99 obj->setFloat("ny", ny);
100 obj->setFloat("nz", nz);
101}
102
103void
104OrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current& c)
105{
106 AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
107
108 px = obj->getFloat("px");
109 py = obj->getFloat("py");
110 pz = obj->getFloat("pz");
111
112 nx = obj->getFloat("nx");
113 ny = obj->getFloat("ny");
114 nz = obj->getFloat("nz");
115}
constexpr T c
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
virtual Eigen::Vector3f normalToEigen() const
virtual Eigen::Vector3f positionToEigen() const
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< AbstractObjectSerializer > AbstractObjectSerializerPtr