Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some missing features in base classes #275

Merged
merged 8 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/hpp/fcl/BV/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class HPP_FCL_DLLAPI AABB
{
}

AABB(const AABB & other) = default;

AABB & update(const Vec3f& a, const Vec3f& b)
{
min_ = a.cwiseMin(b); max_ = a.cwiseMax(b);
Expand All @@ -98,6 +100,11 @@ class HPP_FCL_DLLAPI AABB
{
return min_ == other.min_ && max_ == other.max_;
}

bool operator!=(const AABB & other) const
{
return !(*this == other);
}

/// @name Bounding volume API
/// Common API to BVs.
Expand Down
8 changes: 6 additions & 2 deletions include/hpp/fcl/shape/details/convex.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ template <typename PolygonT>
Convex<PolygonT> * Convex<PolygonT>::clone() const
{
Vec3f * cloned_points = new Vec3f[num_points];
memcpy(cloned_points, polygons, sizeof(Vec3f) * num_points);
memcpy(cloned_points, points, sizeof(Vec3f) * num_points);
jcarpent marked this conversation as resolved.
Show resolved Hide resolved

PolygonT * cloned_polygons = new PolygonT[num_polygons];
memcpy(cloned_polygons, polygons, sizeof(PolygonT) * num_polygons);
return new Convex(true, cloned_points, num_points, cloned_polygons, num_polygons);;

Convex * copy_ptr = new Convex(true, cloned_points, num_points, cloned_polygons, num_polygons);

copy_ptr->ShapeBase::operator=(*this);
return copy_ptr;
}

template <typename PolygonT>
Expand Down
1 change: 1 addition & 0 deletions include/hpp/fcl/shape/geometric_shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ class HPP_FCL_DLLAPI ConvexBase : public ShapeBase
memcpy((void*)copy.points, points, sizeof(Vec3f) * (size_t)copy.num_points);
}
copy.own_storage_ = true;
copy.ShapeBase::operator=(*this);

return copy_ptr;
}
Expand Down
13 changes: 13 additions & 0 deletions python/collision-geometries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void exposeCollisionGeometries ()
"A class describing the AABB collision structure, which is a box in 3D space determined by two diagonal points",
no_init)
.def(init<>(bp::arg("self"), "Default constructor"))
.def(init<AABB>(bp::args("self","other"), "Copy constructor"))
.def(init<Vec3f>(bp::args("self","v"),"Creating an AABB at position v with zero size."))
.def(init<Vec3f,Vec3f>(bp::args("self","a","b"),"Creating an AABB with two endpoints a and b."))
.def(init<AABB,Vec3f>(bp::args("self","core","delta"),"Creating an AABB centered as core and is of half-dimension delta."))
Expand Down Expand Up @@ -471,6 +472,18 @@ void exposeCollisionGeometries ()
// bp::args("self","other"),
// "Distance between two AABBs.")

.add_property("min_",
bp::make_function(+[](AABB & self) -> Vec3f & { return self.min_; }, bp::return_internal_reference<>()),
bp::make_function(+[](AABB & self, const Vec3f & min_) -> void { self.min_ = min_; }),
"The min point in the AABB.")
.add_property("max_",
bp::make_function(+[](AABB & self) -> Vec3f & { return self.max_; }, bp::return_internal_reference<>()),
bp::make_function(+[](AABB & self, const Vec3f & max_) -> void { self.max_ = max_; }),
"The max point in the AABB.")

.def(bp::self == bp::self)
.def(bp::self != bp::self)

.def(bp::self + bp::self)
.def(bp::self += bp::self)
.def(bp::self += Vec3f())
Expand Down
2 changes: 2 additions & 0 deletions src/shape/geometric_shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ ConvexBase::ConvexBase(const ConvexBase& other) :
c_nneighbors += neighbors[i].count();
nneighbors_ = new unsigned int[c_nneighbors];
memcpy(nneighbors_, other.nneighbors_, sizeof(unsigned int) * c_nneighbors);

ShapeBase::operator=(*this);
}

ConvexBase::~ConvexBase ()
Expand Down