Commit d27dd8ca authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Remove FakeContainer and deprecated method and class using it.

parent 2606911e
......@@ -75,8 +75,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/pinocchio/joint.hh
include/hpp/pinocchio/frame.hh
include/hpp/pinocchio/body.hh
include/hpp/pinocchio/fake-container.hh
include/hpp/pinocchio/device-object-vector.hh
include/hpp/pinocchio/gripper.hh
include/hpp/pinocchio/configuration.hh
include/hpp/pinocchio/collision-object.hh
......
......@@ -26,7 +26,6 @@
# include <hpp/pinocchio/config.hh>
# include <hpp/pinocchio/fwd.hh>
# include <hpp/pinocchio/device-object-vector.hh>
namespace hpp {
namespace pinocchio {
......@@ -68,9 +67,6 @@ namespace hpp {
/// \name Inner/outer objects
/// \{
/// \deprecated Use nbInnerObjects and innerObjectAt instead
ObjectVector_t innerObjects () const HPP_PINOCCHIO_DEPRECATED;
/// Number of inner objects.
size_type nbInnerObjects () const;
......@@ -83,9 +79,6 @@ namespace hpp {
/// the body to the origin of the joint that holds the body.
value_type radius () const;
/// \deprecated Use nbOuterObjects and outerObjectAt instead
ObjectVector_t outerObjects () const HPP_PINOCCHIO_DEPRECATED;
/// Number of outer objects.
size_type nbOuterObjects () const;
......
//
// Copyright (c) 2016 CNRS
// Author: NMansard from Florent Lamiraux
//
//
// This file is part of hpp-pinocchio
// hpp-pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_PINOCCHIO_OBJECT_ITERATOR_HH
#define HPP_PINOCCHIO_OBJECT_ITERATOR_HH
# include <vector>
# include <hpp/pinocchio/fwd.hh>
# include <hpp/pinocchio/config.hh>
# include <hpp/pinocchio/deprecated.hh>
# include <hpp/pinocchio/fake-container.hh>
namespace hpp {
namespace pinocchio {
/// Iterator over all inner objects of a Device.
/// \deprecated Use Device::nbObjects and Device::objectAt
struct DeviceObjectVector
: public FakeContainer<CollisionObjectPtr_t,CollisionObjectConstPtr_t>
{
DeviceObjectVector(DeviceWkPtr_t device)
: FakeContainer<CollisionObjectPtr_t,CollisionObjectConstPtr_t>(device) {}
DeviceObjectVector() {}
virtual CollisionObjectPtr_t at(const size_type i) ;
virtual CollisionObjectConstPtr_t at(const size_type i) const ;
virtual size_type size() const ;
void selfAssert(size_type i = 0) const;
} HPP_PINOCCHIO_DEPRECATED; // struct DeviceObjectVector
/* --- CONTAINER -------------------------------------------------------- */
struct ObjectVector
: public FakeContainer<CollisionObjectPtr_t,CollisionObjectConstPtr_t>
{
typedef se3::JointIndex JointIndex;
JointIndex jointIndex;
InOutType inOutType;
ObjectVector(DeviceWkPtr_t device,const JointIndex i, InOutType inout)
: FakeContainer<CollisionObjectPtr_t,CollisionObjectConstPtr_t>(device)
, jointIndex(i), inOutType(inout) {}
ObjectVector() {}
virtual CollisionObjectPtr_t at(const size_type i) ;
virtual CollisionObjectConstPtr_t at(const size_type i) const ;
virtual size_type size() const ;
void selfAssert(size_type i = 0) const;
private:
typedef std::vector<se3::GeomIndex> GeomIndexList;
const GeomIndexList & geometries() const;
} HPP_PINOCCHIO_DEPRECATED;
/** Fake std::vector<Joint>, used to comply with the actual structure of hpp::model.
*
* You can use it for the following loop:
* for (JointVector_t::const_iterator it = jv.begin ();
* it != jv.end (); ++it)
* cout << (*it)->name;
*/
struct JointVector
: public FakeContainer<JointPtr_t,JointConstPtr_t>
{
JointVector(DeviceWkPtr_t device) : FakeContainer<JointPtr_t,JointConstPtr_t>(device) {}
JointVector() {}
virtual ~JointVector() {}
virtual JointPtr_t at(const size_type i) ;
virtual JointConstPtr_t at(const size_type i) const ;
virtual size_type size() const ;
virtual size_type iend() const ;
void selfAssert(size_type i = 0) const;
} HPP_PINOCCHIO_DEPRECATED;
} // namespace pinocchio
} // namespace hpp
#endif // HPP_PINOCCHIO_OBJECT_ITERATOR_HH
//
// Copyright (c) 2016 CNRS
// Author: NMansard from Florent Lamiraux
//
//
// This file is part of hpp-pinocchio
// hpp-pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_PINOCCHIO_FAKECONTAINER_HH
# define HPP_PINOCCHIO_FAKECONTAINER_HH
# include <hpp/pinocchio/config.hh>
# include <hpp/pinocchio/fwd.hh>
namespace hpp {
namespace pinocchio {
template< typename T_,typename Tconst_ >
struct HPP_PINOCCHIO_DLLAPI FakeContainer
{
typedef T_ T;
typedef Tconst_ Tconst;
virtual ~FakeContainer() {}
virtual T at(const size_type) = 0;
virtual Tconst at(const size_type) const = 0;
virtual size_type size() const = 0;
virtual size_type ibegin() const { return 0; }
virtual size_type iend () const { return size(); }
DeviceWkPtr_t deviceWkPtr_;
FakeContainer( DeviceWkPtr_t device ) : deviceWkPtr_(device) {}
FakeContainer() : deviceWkPtr_() {}
struct iterator
{
FakeContainer & ref;
size_type idx;
iterator(FakeContainer & ref,size_type idx) : ref(ref),idx(idx) {}
iterator& operator++ () { ++idx; return *this; }
iterator operator++ (int) { iterator copy = *this; idx++; return copy; }
iterator& operator-- () { --idx; return *this; }
iterator operator-- (int) { iterator copy = *this; idx--; return copy; }
T operator* () { return ref.at(idx); }
bool operator== (const iterator & i2) { return idx==i2.idx; }
bool operator!= (const iterator & i2) { return idx!=i2.idx; };
};
struct const_iterator
{
const FakeContainer & ref;
size_type idx;
const_iterator(const FakeContainer & ref,size_type idx) : ref(ref),idx(idx) {}
const_iterator(const iterator & it) : ref(it.ref),idx(it.idx) {}
const_iterator& operator++ () { ++idx; return *this; }
const_iterator operator++ (int) { const_iterator copy = *this; idx++; return copy; }
const_iterator& operator-- () { --idx; return *this; }
const_iterator operator-- (int) { const_iterator copy = *this; idx--; return copy; }
Tconst operator* () { return ref.at(idx); }
bool operator== (const const_iterator & i2){ return idx==i2.idx; }
bool operator!= (const const_iterator & i2){ return idx!=i2.idx; }
};
iterator begin() { return iterator (*this,ibegin() ); }
iterator end() { return iterator (*this,iend() ); }
iterator rbegin() { return iterator (*this,iend()-1 ); }
iterator rend() { return iterator (*this,ibegin()-1); }
const_iterator begin() const { return const_iterator(*this,ibegin() ); }
const_iterator end() const { return const_iterator(*this,iend() ); }
const_iterator rbegin() const { return const_iterator(*this,iend()-1 ); }
const_iterator rend() const { return const_iterator(*this,ibegin()-1); }
T operator[](const size_type idx) { return at(idx); }
Tconst operator[](const size_type idx) const { return at(idx); }
DevicePtr_t device () const { assert(!deviceWkPtr_.expired()); return deviceWkPtr_.lock(); }
};
} // namespace pinocchio
} // namespace hpp
#endif // HPP_PINOCCHIO_FAKECONTAINER_HH
......@@ -29,7 +29,6 @@ SET(LIBRARY_SOURCES
frame.cc
collision-object.cc
body.cc
device-object-vector.cc
gripper.cc
center-of-mass-computation.cc
configuration.cc
......
......@@ -121,11 +121,6 @@ namespace hpp {
device->geomData().innerObjects[jointIndex][i]));
}
ObjectVector_t Body::innerObjects () const
{
return ObjectVector_t (devicePtr, jointIndex, INNER);
}
value_type Body::radius () const
{
selfAssert();
......@@ -150,11 +145,6 @@ namespace hpp {
return CollisionObjectPtr_t(new CollisionObject(device,
device->geomData().outerObjects[jointIndex][i]));
}
ObjectVector_t Body::outerObjects () const
{
return ObjectVector_t (devicePtr, jointIndex, OUTER);
}
} // namespace pinocchio
} // namespace hpp
//
// Copyright (c) 2016 CNRS
// Author: NMansard from Florent Lamiraux
//
//
// This file is part of hpp-pinocchio
// hpp-pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-pinocchio If not, see
// <http://www.gnu.org/licenses/>.
# include <hpp/pinocchio/device-object-vector.hh>
# include <pinocchio/multibody/geometry.hpp>
# include <hpp/pinocchio/joint.hh>
# include <hpp/pinocchio/device.hh>
# include <hpp/pinocchio/collision-object.hh>
# define UNUSED(x) (void)(x)
namespace hpp {
namespace pinocchio {
CollisionObjectPtr_t DeviceObjectVector::at(const size_type i)
{
selfAssert();
return CollisionObjectPtr_t (new CollisionObject(device(),i));
}
CollisionObjectConstPtr_t DeviceObjectVector::at(const size_type i) const
{
selfAssert();
return CollisionObjectConstPtr_t (new CollisionObject(device(),i));
}
size_type DeviceObjectVector::size() const
{ return device()->geomModel().ngeoms; }
void DeviceObjectVector::selfAssert(size_type i) const
{
assert(device());
assert(i<size());
UNUSED(i);
}
/* --- ObjectVector --------------------------------------------------------- */
CollisionObjectPtr_t ObjectVector::at(const size_type i)
{
return CollisionObjectPtr_t(new CollisionObject(device(), geometries()[i]));
}
CollisionObjectConstPtr_t ObjectVector::at(const size_type i) const
{
return CollisionObjectConstPtr_t(new CollisionObject(device(), geometries()[i]));
}
size_type ObjectVector::size() const
{
return geometries().size();
}
void ObjectVector::selfAssert(size_type i) const
{
assert(device());
assert(std::size_t(jointIndex)<device()->model().joints.size());
assert(i<size());
UNUSED(i);
}
const ObjectVector::GeomIndexList & ObjectVector::geometries() const
{
if(inOutType==INNER) return device()->geomData().innerObjects[jointIndex];
else return device()->geomData().outerObjects[jointIndex];
}
/* --- JointVector --------------------------------------------------------- */
/* Access to pinocchio index + 1 because pinocchio first joint is the universe. */
JointPtr_t JointVector::at(const size_type i)
{ selfAssert(i); return Joint::create(device(),i+1); }
/* Access to pinocchio index + 1 because pinocchio first joint is the universe. */
JointConstPtr_t JointVector::at(const size_type i) const
{ selfAssert(i); return Joint::create(device(),i+1); }
size_type JointVector::size() const
{ return device()->model().joints.size() - 1; }
size_type JointVector::iend() const
{ return size(); }
void JointVector::selfAssert(size_type i) const
{
assert(device());
assert(i>=ibegin());
assert(i<iend());
UNUSED(i);
}
} // namespace pinocchio
} // namespace hpp
......@@ -22,7 +22,7 @@
template <typename T>
void compute (T& t, std::size_t i)
{
t = 2*i;
t = 2*(T)i;
}
template <typename T>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment