Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PCL_GRAPH_HANDLER_H_
00042 #define PCL_GRAPH_HANDLER_H_
00043
00044 #include <pcl/registration/vertex_estimates.h>
00045 #include <pcl/registration/edge_measurements.h>
00046 #include <pcl/exceptions.h>
00047 #include "boost/graph/graph_traits.hpp"
00048
00049 namespace pcl
00050 {
00051 namespace registration
00052 {
00081 template <typename GraphT>
00082 class GraphHandler
00083 {
00084 public:
00085 typedef boost::shared_ptr<GraphHandler<GraphT> > Ptr;
00086 typedef boost::shared_ptr<const GraphHandler<GraphT> > ConstPtr;
00087 typedef boost::shared_ptr<GraphT> GraphPtr;
00088 typedef boost::shared_ptr<const GraphT> GraphConstPtr;
00089
00090 typedef typename boost::graph_traits<GraphT>::vertex_descriptor Vertex;
00091 typedef typename boost::graph_traits<GraphT>::edge_descriptor Edge;
00092
00094 GraphHandler () : graph_impl_ (new GraphT ())
00095 {
00096 if (!init ())
00097 throw InitFailedException ("Graph Initialization Failed", __FILE__, "pcl::registration::GraphHandler::GraphHandler ()", __LINE__);
00098 }
00099
00101 ~GraphHandler ()
00102 {
00103 deinit ();
00104 }
00105
00107 inline void
00108 clear ()
00109 {
00110 deinit ();
00111 graph_impl_.reset (new GraphT ());
00112 if (!init ())
00113 throw InitFailedException ("Graph Initialization Failed", __FILE__, "pcl::registration::GraphHandler::clear ()", __LINE__);
00114 }
00115
00117 inline GraphConstPtr
00118 getGraph () const
00119 {
00120 return graph_impl_;
00121 }
00122
00124 inline GraphPtr
00125 getGraph ()
00126 {
00127 return graph_impl_;
00128 }
00129
00135 template <class PointT> inline Vertex
00136 addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr& cloud, const Eigen::Matrix4f& pose)
00137 {
00138 return add_vertex (PoseEstimate<PointT> (cloud, pose), *graph_impl_);
00139 }
00140
00145 template <class EstimateT> inline Vertex
00146 addGenericVertex (const EstimateT& estimate)
00147 {
00148 return add_vertex (estimate, *graph_impl_);
00149 }
00150
00158 template <class InformationT> inline Edge
00159 addPoseConstraint ( const Vertex& v_start, const Vertex& v_end,
00160 const Eigen::Matrix4f& relative_transformation,
00161 const InformationT& information_matrix)
00162 {
00163 return add_edge ( PoseMeasurement<Vertex, InformationT> (v_start, v_end, relative_transformation, information_matrix),
00164 *graph_impl_);
00165 }
00166
00171 template <class MeasurementT> inline Edge
00172 addGenericConstraint (const MeasurementT& measurement)
00173 {
00174 return add_edge (measurement, *graph_impl_);
00175 }
00176
00180 inline void
00181 removeVertex (const Vertex& v)
00182 {
00183 remove_vertex (v.v_, *graph_impl_);
00184 }
00185
00189 inline void
00190 removeConstraint (const Edge& e)
00191 {
00192 remove_edge(e.e_, *graph_impl_);
00193 }
00194
00195 protected:
00197 inline bool
00198 init ()
00199 {
00200 return true;
00201 }
00202
00204 inline bool
00205 deinit ()
00206 {
00207 return true;
00208 }
00209
00210 private:
00211 GraphPtr graph_impl_;
00212 };
00213 }
00214 }
00215
00216 #endif // PCL_GRAPH_HANDLER_H_