g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d
vertex_point_xy.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_point_xy.h
"
28
29
#ifdef G2O_HAVE_OPENGL
30
#include "
g2o/stuff/opengl_primitives.h
"
31
#include "
g2o/stuff/opengl_wrapper.h
"
32
#endif
33
34
#include <typeinfo>
35
36
#include "
g2o/stuff/macros.h
"
37
38
namespace
g2o
{
39
40
VertexPointXY::VertexPointXY
() :
BaseVertex
<2,
Vector2
>() {
41
_estimate
.setZero();
42
}
43
44
bool
VertexPointXY::read
(std::istream& is) {
45
return
internal::readVector
(is,
_estimate
);
46
}
47
48
bool
VertexPointXY::write
(std::ostream& os)
const
{
49
return
internal::writeVector
(os,
estimate
());
50
}
51
52
VertexPointXYWriteGnuplotAction::VertexPointXYWriteGnuplotAction
()
53
:
WriteGnuplotAction
(typeid(
VertexPointXY
).
name
()) {}
54
55
HyperGraphElementAction
*
VertexPointXYWriteGnuplotAction::operator()
(
56
HyperGraph::HyperGraphElement
* element,
57
HyperGraphElementAction::Parameters
* params_) {
58
if
(
typeid
(*element).name() !=
_typeName
)
return
nullptr
;
59
60
WriteGnuplotAction::Parameters
* params =
61
static_cast<
WriteGnuplotAction::Parameters
*
>
(params_);
62
if
(!params->
os
) {
63
return
nullptr
;
64
}
65
66
VertexPointXY
* v =
static_cast<
VertexPointXY
*
>
(element);
67
*(params->
os
) << v->
estimate
().x() <<
" "
<< v->
estimate
().y() << std::endl;
68
return
this
;
69
}
70
71
#ifdef G2O_HAVE_OPENGL
72
VertexPointXYDrawAction::VertexPointXYDrawAction()
73
:
DrawAction
(typeid(
VertexPointXY
).name()), _pointSize(nullptr) {}
74
75
bool
VertexPointXYDrawAction::refreshPropertyPtrs(
76
HyperGraphElementAction::Parameters* params_) {
77
if
(!
DrawAction::refreshPropertyPtrs
(params_))
return
false
;
78
if
(_previousParams) {
79
_pointSize = _previousParams->makeProperty<
FloatProperty
>(
80
_typeName +
"::POINT_SIZE"
, 1.);
81
}
else
{
82
_pointSize = 0;
83
}
84
return
true
;
85
}
86
87
HyperGraphElementAction
* VertexPointXYDrawAction::operator()(
88
HyperGraph::HyperGraphElement
* element,
89
HyperGraphElementAction::Parameters
* params) {
90
if
(
typeid
(*element).name() != _typeName)
return
nullptr
;
91
initializeDrawActionsCache();
92
refreshPropertyPtrs(params);
93
if
(!_previousParams)
return
this
;
94
95
if
(_show && !_show->value())
return
this
;
96
VertexPointXY
* that =
static_cast<
VertexPointXY
*
>
(element);
97
98
glPushMatrix();
99
glPushAttrib(GL_ENABLE_BIT | GL_POINT_BIT);
100
glDisable(GL_LIGHTING);
101
glColor3f(
LANDMARK_VERTEX_COLOR
);
102
float
ps = _pointSize ? _pointSize->value() : 1.0f;
103
glTranslatef((
float
)that->estimate()(0), (
float
)that->estimate()(1), 0.0f);
104
opengl::drawPoint
(ps);
105
glPopAttrib();
106
drawCache(that->cacheContainer(), params);
107
drawUserData(that->userData(), params);
108
glPopMatrix();
109
return
this
;
110
}
111
#endif
112
113
}
// namespace g2o
g2o::BaseVertex< 2, Vector2 >::BaseVertex
BaseVertex()
Definition
base_vertex.h:29
g2o::BaseVertex< 2, Vector2 >::estimate
const EstimateType & estimate() const
Definition
base_vertex.h:127
g2o::BaseVertex< 2, Vector2 >::_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::VertexPointXYWriteGnuplotAction::operator()
virtual HyperGraphElementAction * operator()(HyperGraph::HyperGraphElement *element, HyperGraphElementAction::Parameters *params_)
Definition
vertex_point_xy.cpp:55
g2o::VertexPointXYWriteGnuplotAction::VertexPointXYWriteGnuplotAction
VertexPointXYWriteGnuplotAction()
Definition
vertex_point_xy.cpp:52
g2o::VertexPointXY
Definition
vertex_point_xy.h:39
g2o::VertexPointXY::write
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition
vertex_point_xy.cpp:48
g2o::VertexPointXY::VertexPointXY
VertexPointXY()
Definition
vertex_point_xy.cpp:40
g2o::VertexPointXY::read
virtual bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition
vertex_point_xy.cpp:44
g2o::WriteGnuplotAction::WriteGnuplotAction
WriteGnuplotAction(const std::string &typeName_)
Definition
hyper_graph_action.cpp:206
macros.h
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::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
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_point_xy.h
Generated on
for g2o by
1.17.0