hpp-core  4.10.1
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 # include <hpp/util/serialization-fwd.hh>
26 
27 namespace hpp {
28  namespace core {
33  public:
35  typedef std::set <RawPtr_t> RawPtrs_t;
36 
37  // variable for ranking connected components
38  static unsigned int globalFinishTime_;
40  {
42  ConnectedComponentPtr_t shPtr (ptr);
43  ptr->init (shPtr);
44  return shPtr;
45  }
50  virtual void merge (const ConnectedComponentPtr_t& other);
51 
52  virtual ~ConnectedComponent() {}
53 
56  virtual void addNode (const NodePtr_t& node)
57  {
58  nodes_.push_back (node);
59  }
61  const NodeVector_t& nodes () const
62  {
63  return nodes_;
64  }
65 
68 
71  bool canReach (const ConnectedComponentPtr_t& cc);
72 
73 
78  bool canReach (const ConnectedComponentPtr_t& cc,
79  RawPtrs_t& cc2Tocc1);
80 
81  // Get connected components reachable from this
82  const RawPtrs_t& reachableTo () const
83  {
84  return reachableTo_;
85  }
86 
87  // Get connected components that can reach this
88  const RawPtrs_t& reachableFrom () const
89  {
90  return reachableFrom_;
91  }
93 
95  {
96  return weak_.lock ();
97  }
98 
99  protected:
101  ConnectedComponent () : nodes_ (), explored_ (false), weak_ ()
102  {
103  nodes_.reserve (1000);
104  }
105  void init (const ConnectedComponentPtr_t& shPtr){
106  weak_ = shPtr;
107  }
108  private:
109  static void clean (RawPtrs_t& set);
110 
111  NodeVector_t nodes_;
112  // List of CCs from which this connected component can be reached
113  RawPtrs_t reachableFrom_;
114  // List of CCs that can be reached from this connected component
115  RawPtrs_t reachableTo_;
116  // status variable to indicate whether or not CC has been visited
117  mutable bool explored_;
118  ConnectedComponentWkPtr_t weak_;
119  friend class Roadmap;
120 
121  HPP_SERIALIZABLE();
122  }; // class ConnectedComponent
123  } // namespace core
124 } // namespace hpp
125 #endif // HPP_CORE_CONNECTED_COMPONENT_HH
Definition: basic-configuration-shooter.hh:26
const RawPtrs_t & reachableTo() const
Definition: connected-component.hh:82
virtual void addNode(const NodePtr_t &node)
Definition: connected-component.hh:56
boost::shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:107
ConnectedComponent * RawPtr_t
Definition: connected-component.hh:34
virtual ~ConnectedComponent()
Definition: connected-component.hh:52
static unsigned int globalFinishTime_
Definition: connected-component.hh:38
Definition: node.hh:35
void init(const ConnectedComponentPtr_t &shPtr)
Definition: connected-component.hh:105
Definition: connected-component.hh:32
std::set< RawPtr_t > RawPtrs_t
Definition: connected-component.hh:35
const RawPtrs_t & reachableFrom() const
Definition: connected-component.hh:88
std::vector< NodePtr_t > NodeVector_t
Definition: fwd.hh:165
ConnectedComponent()
Constructor.
Definition: connected-component.hh:101
const NodeVector_t & nodes() const
Access to the nodes.
Definition: connected-component.hh:61
#define HPP_CORE_DLLAPI
Definition: config.hh:64
Definition: roadmap.hh:37
static ConnectedComponentPtr_t create()
Definition: connected-component.hh:39