Skip to content

Commit

Permalink
SupportFunc: properly export symbols with DLLAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
lmontaut committed May 13, 2024
1 parent 4011b3f commit 6b8afd6
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 94 deletions.
138 changes: 57 additions & 81 deletions include/hpp/fcl/narrowphase/support_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ enum SupportOptions {
/// sphere radii. Please see `MinkowskiDiff::set(const ShapeBase*, const
/// ShapeBase*)` for more details.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI Vec3f getSupport(const ShapeBase* shape, const Vec3f& dir,
int& hint);
Vec3f getSupport(const ShapeBase* shape, const Vec3f& dir, int& hint);

/// @brief Stores temporary data for the computation of support points.
struct HPP_FCL_DLLAPI ShapeSupportData {
Expand All @@ -94,54 +93,47 @@ struct HPP_FCL_DLLAPI ShapeSupportData {

/// @brief Triangle support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const TriangleP* triangle, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const TriangleP* triangle, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);

/// @brief Box support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Box* box, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Box* box, const Vec3f& dir, Vec3f& support,
int& /*unused*/, ShapeSupportData& /*unused*/);

/// @brief Sphere support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Sphere* sphere, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Sphere* sphere, const Vec3f& dir, Vec3f& support,
int& /*unused*/, ShapeSupportData& /*unused*/);

/// @brief Ellipsoid support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Ellipsoid* ellipsoid,
const Vec3f& dir, Vec3f& support,
int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Ellipsoid* ellipsoid, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);

/// @brief Capsule support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Capsule* capsule, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Capsule* capsule, const Vec3f& dir, Vec3f& support,
int& /*unused*/, ShapeSupportData& /*unused*/);

/// @brief Cone support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Cone* cone, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Cone* cone, const Vec3f& dir, Vec3f& support,
int& /*unused*/, ShapeSupportData& /*unused*/);

/// @brief Cylinder support function.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const Cylinder* cylinder, const Vec3f& dir,
Vec3f& support, int& /*unused*/,
ShapeSupportData& /*unused*/);
void getShapeSupport(const Cylinder* cylinder, const Vec3f& dir, Vec3f& support,
int& /*unused*/, ShapeSupportData& /*unused*/);

/// @brief ConvexBase support function.
/// @note See @ref LargeConvex and SmallConvex to see how to optimize
/// ConvexBase's support computation.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const ConvexBase* convex, const Vec3f& dir,
Vec3f& support, int& hint,
ShapeSupportData& /*unused*/);
void getShapeSupport(const ConvexBase* convex, const Vec3f& dir, Vec3f& support,
int& hint, ShapeSupportData& /*unused*/);

/// @brief Cast a `ConvexBase` to a `LargeConvex` to use the log version of
/// `getShapeSupport`. This is **much** faster than the linear version of
Expand All @@ -154,15 +146,13 @@ struct SmallConvex : ShapeBase {};

/// @brief Support function for large ConvexBase (>32 vertices).
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const SmallConvex* convex, const Vec3f& dir,
Vec3f& support, int& hint,
ShapeSupportData& data);
void getShapeSupport(const SmallConvex* convex, const Vec3f& dir,
Vec3f& support, int& hint, ShapeSupportData& data);

/// @brief Support function for small ConvexBase (<32 vertices).
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupport(const LargeConvex* convex, const Vec3f& dir,
Vec3f& support, int& hint,
ShapeSupportData& support_data);
void getShapeSupport(const LargeConvex* convex, const Vec3f& dir,
Vec3f& support, int& hint, ShapeSupportData& support_data);

// ============================================================================
// ========================== SUPPORT SET FUNCTIONS ===========================
Expand Down Expand Up @@ -203,10 +193,8 @@ HPP_FCL_DLLAPI void getShapeSupport(const LargeConvex* convex, const Vec3f& dir,
/// `WithSweptSphere`, the support functions take into account the shapes' swept
/// sphere radii.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getSupportSet(const ShapeBase* shape,
SupportSet& support_set, int& hint,
size_t num_sampled_supports = 6,
FCL_REAL tol = 1e-3);
void getSupportSet(const ShapeBase* shape, SupportSet& support_set, int& hint,
size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);

/// @brief Same as @ref getSupportSet(const ShapeBase*, const FCL_REAL,
/// SupportSet&, const int) but also constructs the support set frame from
Expand All @@ -229,94 +217,82 @@ void getSupportSet(const ShapeBase* shape, const Vec3f& dir,
/// @brief Triangle support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const TriangleP* triangle,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const TriangleP* triangle, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Box support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Box* box, SupportSet& support_set,
int& /*unused*/,
ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const Box* box, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Sphere support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Sphere* sphere,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL /*unused*/);
void getShapeSupportSet(const Sphere* sphere, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL /*unused*/);

/// @brief Ellipsoid support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Ellipsoid* ellipsoid,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL /*unused*/);
void getShapeSupportSet(const Ellipsoid* ellipsoid, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL /*unused*/);

/// @brief Capsule support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Capsule* capsule,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const Capsule* capsule, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Cone support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Cone* cone,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t num_sampled_supports = 6,
FCL_REAL tol = 1e-3);
void getShapeSupportSet(const Cone* cone, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);

/// @brief Cylinder support set function.
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const Cylinder* cylinder,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t num_sampled_supports = 6,
FCL_REAL tol = 1e-3);
void getShapeSupportSet(const Cylinder* cylinder, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t num_sampled_supports = 6, FCL_REAL tol = 1e-3);

/// @brief ConvexBase support set function.
/// Assumes the support set frame has already been computed.
/// @note See @ref LargeConvex and SmallConvex to see how to optimize
/// ConvexBase's support computation.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const ConvexBase* convex,
SupportSet& support_set, int& hint,
ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const ConvexBase* convex, SupportSet& support_set,
int& hint, ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Support set function for large ConvexBase (>32 vertices).
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const SmallConvex* convex,
SupportSet& support_set, int& /*unused*/,
ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const SmallConvex* convex, SupportSet& support_set,
int& /*unused*/, ShapeSupportData& /*unused*/,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Support set function for small ConvexBase (<32 vertices).
/// Assumes the support set frame has already been computed.
template <int _SupportOptions = SupportOptions::NoSweptSphere>
HPP_FCL_DLLAPI void getShapeSupportSet(const LargeConvex* convex,
SupportSet& support_set, int& hint,
ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);
void getShapeSupportSet(const LargeConvex* convex, SupportSet& support_set,
int& hint, ShapeSupportData& support_data,
size_t /*unused*/, FCL_REAL tol = 1e-3);

/// @brief Computes the convex-hull of support_set. For now, this function is
/// only needed for Box and ConvexBase.
/// @param[in] cloud data which contains the 2d points of the support set which
/// convex-hull we want to compute.
/// @param[out] 2d points of the the support set's convex-hull.
HPP_FCL_DLLAPI void computeSupportSetConvexHull(SupportSet::Polygon& cloud,
SupportSet::Polygon& cvx_hull);
void computeSupportSetConvexHull(SupportSet::Polygon& cloud,
SupportSet::Polygon& cvx_hull);

} // namespace details

Expand Down
29 changes: 16 additions & 13 deletions src/narrowphase/support_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ Vec3f getSupport(const ShapeBase* shape, const Vec3f& dir, int& hint) {

// Explicit instantiation
// clang-format off
template Vec3f getSupport<SupportOptions::NoSweptSphere>(const ShapeBase*, const Vec3f&, int&);
template HPP_FCL_DLLAPI Vec3f getSupport<SupportOptions::NoSweptSphere>(const ShapeBase*, const Vec3f&, int&);

template Vec3f getSupport<SupportOptions::WithSweptSphere>(const ShapeBase*, const Vec3f&, int&);
template HPP_FCL_DLLAPI Vec3f getSupport<SupportOptions::WithSweptSphere>(const ShapeBase*, const Vec3f&, int&);
// clang-format on

// ============================================================================
#define getShapeSupportTplInstantiation(ShapeType) \
template void getShapeSupport<SupportOptions::NoSweptSphere>( \
const ShapeType* shape_, const Vec3f& dir, Vec3f& support, int& hint, \
ShapeSupportData& support_data); \
\
template void getShapeSupport<SupportOptions::WithSweptSphere>( \
const ShapeType* shape_, const Vec3f& dir, Vec3f& support, int& hint, \
#define getShapeSupportTplInstantiation(ShapeType) \
template HPP_FCL_DLLAPI void getShapeSupport<SupportOptions::NoSweptSphere>( \
const ShapeType* shape_, const Vec3f& dir, Vec3f& support, int& hint, \
ShapeSupportData& support_data); \
\
template HPP_FCL_DLLAPI void \
getShapeSupport<SupportOptions::WithSweptSphere>( \
const ShapeType* shape_, const Vec3f& dir, Vec3f& support, int& hint, \
ShapeSupportData& support_data);

// ============================================================================
Expand Down Expand Up @@ -485,18 +486,20 @@ void getSupportSet(const ShapeBase* shape, SupportSet& support_set, int& hint,

// Explicit instantiation
// clang-format off
template void getSupportSet<SupportOptions::NoSweptSphere>(const ShapeBase*, SupportSet&, int&, size_t, FCL_REAL);
template HPP_FCL_DLLAPI void getSupportSet<SupportOptions::NoSweptSphere>(const ShapeBase*, SupportSet&, int&, size_t, FCL_REAL);

template void getSupportSet<SupportOptions::WithSweptSphere>(const ShapeBase*, SupportSet&, int&, size_t, FCL_REAL);
template HPP_FCL_DLLAPI void getSupportSet<SupportOptions::WithSweptSphere>(const ShapeBase*, SupportSet&, int&, size_t, FCL_REAL);
// clang-format on

// ============================================================================
#define getShapeSupportSetTplInstantiation(ShapeType) \
template void getShapeSupportSet<SupportOptions::NoSweptSphere>( \
template HPP_FCL_DLLAPI void \
getShapeSupportSet<SupportOptions::NoSweptSphere>( \
const ShapeType* shape_, SupportSet& support_set, int& hint, \
ShapeSupportData& data, size_t num_sampled_supports, FCL_REAL tol); \
\
template void getShapeSupportSet<SupportOptions::WithSweptSphere>( \
template HPP_FCL_DLLAPI void \
getShapeSupportSet<SupportOptions::WithSweptSphere>( \
const ShapeType* shape_, SupportSet& support_set, int& hint, \
ShapeSupportData& data, size_t num_sampled_supports, FCL_REAL tol);

Expand Down

0 comments on commit 6b8afd6

Please sign in to comment.