g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam3d
vertex_pointxyz.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#include "
vertex_pointxyz.h
"
28
29
#include <stdio.h>
30
31
#ifdef G2O_HAVE_OPENGL
32
#include "
g2o/stuff/opengl_primitives.h
"
33
#include "
g2o/stuff/opengl_wrapper.h
"
34
#endif
35
36
#include <typeinfo>
37
38
namespace
g2o
{
39
40
bool
VertexPointXYZ::read
(std::istream& is) {
41
return
internal::readVector
(is,
_estimate
);
42
}
43
44
bool
VertexPointXYZ::write
(std::ostream& os)
const
{
45
return
internal::writeVector
(os,
estimate
());
46
}
47
48
#ifdef G2O_HAVE_OPENGL
49
VertexPointXYZDrawAction::VertexPointXYZDrawAction()
50
:
DrawAction
(typeid(
VertexPointXYZ
).name()), _pointSize(nullptr) {}
51
52
bool
VertexPointXYZDrawAction::refreshPropertyPtrs(
53
HyperGraphElementAction::Parameters* params_) {
54
if
(!
DrawAction::refreshPropertyPtrs
(params_))
return
false
;
55
if
(_previousParams) {
56
_pointSize = _previousParams->makeProperty<
FloatProperty
>(
57
_typeName +
"::POINT_SIZE"
, 1.);
58
}
else
{
59
_pointSize =
nullptr
;
60
}
61
return
true
;
62
}
63
64
HyperGraphElementAction
* VertexPointXYZDrawAction::operator()(
65
HyperGraph::HyperGraphElement
* element,
66
HyperGraphElementAction::Parameters
* params) {
67
if
(
typeid
(*element).name() != _typeName)
return
nullptr
;
68
initializeDrawActionsCache();
69
refreshPropertyPtrs(params);
70
if
(!_previousParams)
return
this
;
71
72
if
(_show && !_show->value())
return
this
;
73
VertexPointXYZ
* that =
static_cast<
VertexPointXYZ
*
>
(element);
74
75
glPushMatrix();
76
glPushAttrib(GL_ENABLE_BIT | GL_POINT_BIT);
77
glDisable(GL_LIGHTING);
78
glColor3f(
LANDMARK_VERTEX_COLOR
);
79
float
ps = _pointSize ? _pointSize->value() : 1.f;
80
glTranslatef((
float
)that->estimate()(0), (
float
)that->estimate()(1),
81
(
float
)that->estimate()(2));
82
opengl::drawPoint
(ps);
83
glPopAttrib();
84
drawCache(that->cacheContainer(), params);
85
drawUserData(that->userData(), params);
86
glPopMatrix();
87
return
this
;
88
}
89
#endif
90
91
VertexPointXYZWriteGnuplotAction::VertexPointXYZWriteGnuplotAction
()
92
:
WriteGnuplotAction
(typeid(
VertexPointXYZ
).
name
()) {}
93
94
HyperGraphElementAction
*
VertexPointXYZWriteGnuplotAction::operator()
(
95
HyperGraph::HyperGraphElement
* element,
96
HyperGraphElementAction::Parameters
* params_) {
97
if
(
typeid
(*element).name() !=
_typeName
)
return
nullptr
;
98
WriteGnuplotAction::Parameters
* params =
99
static_cast<
WriteGnuplotAction::Parameters
*
>
(params_);
100
if
(!params->
os
) {
101
return
nullptr
;
102
}
103
104
VertexPointXYZ
* v =
static_cast<
VertexPointXYZ
*
>
(element);
105
*(params->
os
) << v->
estimate
().x() <<
" "
<< v->
estimate
().y() <<
" "
106
<< v->
estimate
().z() <<
" "
<< std::endl;
107
return
this
;
108
}
109
110
}
// namespace g2o
g2o::BaseVertex< 3, Vector3 >::estimate
const EstimateType & estimate() const
Definition
base_vertex.h:127
g2o::BaseVertex< 3, Vector3 >::_estimate
EstimateType _estimate
Definition
base_vertex.h:137
g2o::DrawAction
draw actions
Definition
hyper_graph_action.h:201
g2o::DrawAction::refreshPropertyPtrs
virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters *params_)
Definition
hyper_graph_action.cpp:221
g2o::HyperGraphElementAction
Abstract action that operates on a graph entity.
Definition
hyper_graph_action.h:74
g2o::HyperGraphElementAction::name
const std::string & name() const
returns the name of an action, e.g "draw"
Definition
hyper_graph_action.h:101
g2o::HyperGraphElementAction::_typeName
std::string _typeName
Definition
hyper_graph_action.h:107
g2o::VertexPointXYZWriteGnuplotAction::VertexPointXYZWriteGnuplotAction
VertexPointXYZWriteGnuplotAction()
Definition
vertex_pointxyz.cpp:91
g2o::VertexPointXYZWriteGnuplotAction::operator()
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, HyperGraphElementAction::Parameters *params_)
Definition
vertex_pointxyz.cpp:94
g2o::VertexPointXYZ
Vertex for a tracked point in space.
Definition
vertex_pointxyz.h:38
g2o::VertexPointXYZ::read
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition
vertex_pointxyz.cpp:40
g2o::VertexPointXYZ::write
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition
vertex_pointxyz.cpp:44
g2o::WriteGnuplotAction::WriteGnuplotAction
WriteGnuplotAction(const std::string &typeName_)
Definition
hyper_graph_action.cpp:206
g2o::internal::writeVector
bool writeVector(std::ostream &os, const Eigen::DenseBase< Derived > &b)
Definition
io_helper.h:36
g2o::internal::readVector
bool readVector(std::istream &is, Eigen::DenseBase< Derived > &b)
Definition
io_helper.h:42
g2o::opengl::drawPoint
void drawPoint(float pointSize)
Definition
opengl_primitives.cpp:297
g2o
Definition
dl_wrapper.cpp:55
g2o::FloatProperty
Property< float > FloatProperty
Definition
property.h:150
opengl_primitives.h
LANDMARK_VERTEX_COLOR
#define LANDMARK_VERTEX_COLOR
Definition
opengl_primitives.h:149
opengl_wrapper.h
g2o::HyperGraphElementAction::Parameters
Definition
hyper_graph_action.h:76
g2o::HyperGraph::HyperGraphElement
Definition
hyper_graph.h:80
g2o::WriteGnuplotAction::Parameters
Definition
hyper_graph_action.h:191
g2o::WriteGnuplotAction::Parameters::os
std::ostream * os
Definition
hyper_graph_action.h:192
vertex_pointxyz.h
Generated on
for g2o by
1.17.0