hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
connected-component.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Florent Lamiraux
4 //
5 // This file is part of hpp-core
6 // hpp-core is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-core is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CORE_CONNECTED_COMPONENT_HH
20 # define HPP_CORE_CONNECTED_COMPONENT_HH
21 
22 # include <hpp/core/fwd.hh>
23 # include <hpp/core/config.hh>
24 # include <hpp/core/node.hh>
25 
26 namespace hpp {
27  namespace core {
31  class HPP_CORE_DLLAPI ConnectedComponent {
32  public:
34  typedef std::set <RawPtr_t> RawPtrs_t;
35 
36  // variable for ranking connected components
37  static unsigned int globalFinishTime_;
39  {
41  ConnectedComponentPtr_t shPtr (ptr);
42  ptr->init (shPtr);
43  return shPtr;
44  }
49  virtual void merge (const ConnectedComponentPtr_t& other);
50 
51  virtual ~ConnectedComponent() {}
52 
55  virtual void addNode (const NodePtr_t& node)
56  {
57  nodes_.push_back (node);
58  }
60  const NodeVector_t& nodes () const
61  {
62  return nodes_;
63  }
64 
67 
70  bool canReach (const ConnectedComponentPtr_t& cc);
71 
72 
77  bool canReach (const ConnectedComponentPtr_t& cc,
78  RawPtrs_t& cc2Tocc1);
79 
80  // Get connected components reachable from this
81  const RawPtrs_t& reachableTo () const
82  {
83  return reachableTo_;
84  }
85 
86  // Get connected components that can reach this
87  const RawPtrs_t& reachableFrom () const
88  {
89  return reachableFrom_;
90  }
92 
94  {
95  return weak_.lock ();
96  }
97 
98  protected:
100  ConnectedComponent () : nodes_ (), explored_ (false), weak_ ()
101  {
102  nodes_.reserve (1000);
103  }
104  void init (const ConnectedComponentPtr_t& shPtr){
105  weak_ = shPtr;
106  }
107  private:
108  static void clean (RawPtrs_t& set);
109 
110  NodeVector_t nodes_;
111  // List of CCs from which this connected component can be reached
112  RawPtrs_t reachableFrom_;
113  // List of CCs that can be reached from this connected component
114  RawPtrs_t reachableTo_;
115  // status variable to indicate whether or not CC has been visited
116  mutable bool explored_;
117  ConnectedComponentWkPtr_t weak_;
118  friend class Roadmap;
119  }; // class ConnectedComponent
120  } // namespace core
121 } // namespace hpp
122 #endif // HPP_CORE_CONNECTED_COMPONENT_HH
const RawPtrs_t & reachableTo() const
Definition: connected-component.hh:81
virtual void addNode(const NodePtr_t &node)
Definition: connected-component.hh:55
boost::shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:107
ConnectedComponent * RawPtr_t
Definition: connected-component.hh:33
virtual ~ConnectedComponent()
Definition: connected-component.hh:51
static unsigned int globalFinishTime_
Definition: connected-component.hh:37
Definition: node.hh:34
void init(const ConnectedComponentPtr_t &shPtr)
Definition: connected-component.hh:104
Definition: connected-component.hh:31
std::set< RawPtr_t > RawPtrs_t
Definition: connected-component.hh:34
const RawPtrs_t & reachableFrom() const
Definition: connected-component.hh:87
std::vector< NodePtr_t > NodeVector_t
Definition: fwd.hh:165
ConnectedComponent()
Constructor.
Definition: connected-component.hh:100
const NodeVector_t & nodes() const
Access to the nodes.
Definition: connected-component.hh:60
Definition: roadmap.hh:35
static ConnectedComponentPtr_t create()
Definition: connected-component.hh:38