Commit 40ad7bf6 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Merge pull request #84 from LucileRemigy/refactoring

Organize documentation
parents 0594e6db 7c3f7a0f
......@@ -38,6 +38,8 @@
#ifndef HPP_FCL_INTERSECT_H
#define HPP_FCL_INTERSECT_H
/// @cond INTERNAL
#include <hpp/fcl/math/transform.h>
#include <boost/math/special_functions/erf.hpp>
......@@ -107,9 +109,9 @@ public:
Vec3f& VEC, Vec3f& X, Vec3f& Y);
/// Compute squared distance between triangles
/// \param S and T are two triangles
/// \retval P, Q closest points if triangles do not intersect.
/// \return squared distance if triangles do not intersect, 0 otherwise.
/// @param S and T are two triangles
/// @retval P, Q closest points if triangles do not intersect.
/// @return squared distance if triangles do not intersect, 0 otherwise.
/// If the triangles are disjoint, P and Q give the closet points of
/// S and T respectively. However,
/// if the triangles overlap, P and Q are basically a random pair of points
......@@ -124,10 +126,10 @@ public:
Vec3f& P, Vec3f& Q);
/// Compute squared distance between triangles
/// \param S and T are two triangles
/// \param R, Tl, rotation and translation applied to T,
/// \retval P, Q closest points if triangles do not intersect.
/// \return squared distance if triangles do not intersect, 0 otherwise.
/// @param S and T are two triangles
/// @param R, Tl, rotation and translation applied to T,
/// @retval P, Q closest points if triangles do not intersect.
/// @return squared distance if triangles do not intersect, 0 otherwise.
/// If the triangles are disjoint, P and Q give the closet points of
/// S and T respectively. However,
/// if the triangles overlap, P and Q are basically a random pair of points
......@@ -138,10 +140,10 @@ public:
Vec3f& P, Vec3f& Q);
/// Compute squared distance between triangles
/// \param S and T are two triangles
/// \param tf, rotation and translation applied to T,
/// \retval P, Q closest points if triangles do not intersect.
/// \return squared distance if triangles do not intersect, 0 otherwise.
/// @param S and T are two triangles
/// @param tf, rotation and translation applied to T,
/// @retval P, Q closest points if triangles do not intersect.
/// @return squared distance if triangles do not intersect, 0 otherwise.
/// If the triangles are disjoint, P and Q give the closet points of
/// S and T respectively. However,
/// if the triangles overlap, P and Q are basically a random pair of points
......@@ -153,10 +155,10 @@ public:
/// Compute squared distance between triangles
/// \param S1, S2, S3 and T1, T2, T3 are triangle vertices
/// \param R, Tl, rotation and translation applied to T1, T2, T3,
/// \retval P, Q closest points if triangles do not intersect.
/// \return squared distance if triangles do not intersect, 0 otherwise.
/// @param S1, S2, S3 and T1, T2, T3 are triangle vertices
/// @param R, Tl, rotation and translation applied to T1, T2, T3,
/// @retval P, Q closest points if triangles do not intersect.
/// @return squared distance if triangles do not intersect, 0 otherwise.
/// If the triangles are disjoint, P and Q give the closet points of
/// S and T respectively. However,
/// if the triangles overlap, P and Q are basically a random pair of points
......@@ -169,10 +171,10 @@ public:
Vec3f& P, Vec3f& Q);
/// Compute squared distance between triangles
/// \param S1, S2, S3 and T1, T2, T3 are triangle vertices
/// \param tf, rotation and translation applied to T1, T2, T3,
/// \retval P, Q closest points if triangles do not intersect.
/// \return squared distance if triangles do not intersect, 0 otherwise.
/// @param S1, S2, S3 and T1, T2, T3 are triangle vertices
/// @param tf, rotation and translation applied to T1, T2, T3,
/// @retval P, Q closest points if triangles do not intersect.
/// @return squared distance if triangles do not intersect, 0 otherwise.
/// If the triangles are disjoint, P and Q give the closet points of
/// S and T respectively. However,
/// if the triangles overlap, P and Q are basically a random pair of points
......@@ -186,10 +188,10 @@ public:
};
}
} // namespace hpp
/// @endcond
#endif
......@@ -273,7 +273,7 @@ namespace fcl {
return (dist >=0);
}
/** \brief the minimum distance from a point to a line */
/** @brief the minimum distance from a point to a line */
inline FCL_REAL segmentSqrDistance
(const Vec3f& from, const Vec3f& to,const Vec3f& p, Vec3f& nearest)
{
......@@ -2092,11 +2092,11 @@ namespace fcl {
}
/// Taken from book Real Time Collision Detection, from Christer Ericson
/// \param pb the closest point to the sphere center on the box surface
/// \param ps when colliding, matches pb, which is inside the sphere.
/// @param pb the closest point to the sphere center on the box surface
/// @param ps when colliding, matches pb, which is inside the sphere.
/// when not colliding, the closest point on the sphere
/// \param normal direction of motion of the box
/// \return true if the distance is negative (the shape overlaps).
/// @param normal direction of motion of the box
/// @return true if the distance is negative (the shape overlaps).
inline bool boxSphereDistance(const Box & b, const Transform3f& tfb,
const Sphere& s, const Transform3f& tfs,
FCL_REAL& dist, Vec3f& pb, Vec3f& ps,
......
......@@ -1126,7 +1126,7 @@ EPA::SimplexF* EPA::newFace(SimplexV* a, SimplexV* b, SimplexV* c, bool forced)
return NULL;
}
/** \brief Find the best polytope face to split */
/** @brief Find the best polytope face to split */
EPA::SimplexF* EPA::findBest()
{
SimplexF* minf = hull.root;
......@@ -1258,7 +1258,7 @@ EPA::Status EPA::evaluate(GJK& gjk, const Vec3f& guess)
}
/** \brief the goal is to add a face connecting vertex w and face edge f[e] */
/** @brief the goal is to add a face connecting vertex w and face edge f[e] */
bool EPA::expand(size_t pass, SimplexV* w, SimplexF* f, size_t e, SimplexHorizon& horizon)
{
static const size_t nexti[] = {1, 2, 0};
......
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2014, CNRS-LAAS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Florent Lamiraux */
#include <hpp/fcl/collision_func_matrix.h>
#include "traversal/traversal_node_setup.h"
#include <../src/collision_node.h>
#include <hpp/fcl/narrowphase/narrowphase.h>
#include "distance_func_matrix.h"
namespace hpp
{
namespace fcl
{
template <typename TypeA, typename TypeB>
struct TraversalTraits
{
};
template <typename T_SH>
struct TraversalTraits <T_SH, OcTree>
{
typedef ShapeOcTreeCollisionTraversalNode<T_SH, GJKSolver> CollisionTraversal_t;
};
template <typename T_SH>
struct TraversalTraits <OcTree, T_SH>
{
typedef OcTreeShapeCollisionTraversalNode<T_SH, GJKSolver> CollisionTraversal_t;
};
template <>
struct TraversalTraits <OcTree, OcTree>
{
typedef OcTreeCollisionTraversalNode<GJKSolver> CollisionTraversal_t;
};
template <typename T_BVH>
struct TraversalTraits <OcTree, BVHModel<T_BVH>>
{
typedef OcTreeMeshCollisionTraversalNode<T_BVH, GJKSolver> CollisionTraversal_t;
};
template <typename T_BVH>
struct TraversalTraits <BVHModel<T_BVH>, OcTree>
{
typedef MeshOcTreeCollisionTraversalNode<T_BVH, GJKSolver> CollisionTraversal_t;
};
}
} //hpp
\ No newline at end of file
......@@ -34,10 +34,11 @@
/** \author Joseph Mirabel */
#ifndef HPP_FCL_TRAVERSAL_DETAILS_TRAVERSAL_H
#define HPP_FCL_TRAVERSAL_DETAILS_TRAVERSAL_H
/// @cond INTERNAL
namespace hpp
{
namespace fcl
......@@ -73,4 +74,6 @@ namespace details
} // namespace hpp
/// @endcond
#endif
......@@ -38,6 +38,8 @@
#ifndef HPP_FCL_TRAVERSAL_NODE_BASE_H
#define HPP_FCL_TRAVERSAL_NODE_BASE_H
/// @cond INTERNAL
#include <hpp/fcl/data_types.h>
#include <hpp/fcl/math/transform.h>
#include <hpp/fcl/collision_data.h>
......@@ -48,6 +50,7 @@ namespace fcl
{
/// @brief Node structure encoding the information required for traversal.
class TraversalNodeBase
{
public:
......@@ -88,6 +91,10 @@ public:
Transform3f tf2;
};
/// @defgroup Traversal_For_Collision
/// regroup class about traversal for distance.
/// @{
/// @brief Node structure encoding the information required for collision traversal.
class CollisionTraversalNodeBase : public TraversalNodeBase
{
......@@ -101,8 +108,8 @@ public:
virtual bool BVDisjoints(int b1, int b2) const = 0;
/// BV test between b1 and b2
/// \param b1, b2 Bounding volumes to test,
/// \retval sqrDistLowerBound square of a lower bound of the minimal
/// @param b1, b2 Bounding volumes to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
virtual bool BVDisjoints(int b1, int b2, FCL_REAL& sqrDistLowerBound) const = 0;
......@@ -128,6 +135,12 @@ public:
bool enable_statistics;
};
/// @}
/// @defgroup Traversal_For_Distance
/// regroup class about traversal for distance.
/// @{
/// @brief Node structure encoding the information required for distance traversal.
class DistanceTraversalNodeBase : public TraversalNodeBase
{
......@@ -137,8 +150,8 @@ public:
virtual ~DistanceTraversalNodeBase();
/// @brief BV test between b1 and b2
/// \return a lower bound of the distance between the two BV.
/// \note except for OBB, this method returns the distance.
/// @return a lower bound of the distance between the two BV.
/// @note except for OBB, this method returns the distance.
virtual FCL_REAL BVDistanceLowerBound(int b1, int b2) const;
/// @brief Leaf test between node b1 and b2, if they are both leafs
......@@ -159,8 +172,13 @@ public:
/// @brief Whether stores statistics
bool enable_statistics;
};
///@}
}
} // namespace hpp
#endif
/// @endcond
#endif
\ No newline at end of file
......@@ -39,6 +39,8 @@
#ifndef HPP_FCL_TRAVERSAL_NODE_MESH_SHAPE_H
#define HPP_FCL_TRAVERSAL_NODE_MESH_SHAPE_H
/// @cond INTERNAL
#include <hpp/fcl/collision_data.h>
#include <hpp/fcl/shape/geometric_shapes.h>
#include "../src/shape/geometric_shapes_utility.h"
......@@ -52,6 +54,9 @@ namespace hpp
namespace fcl
{
/// @addtogroup Traversal_For_Collision
/// @{
/// @brief Traversal node for collision between BVH and shape
template<typename BV, typename S>
class BVHShapeCollisionTraversalNode : public CollisionTraversalNodeBase
......@@ -176,8 +181,8 @@ public:
}
/// test between BV b1 and shape
/// \param b1 BV to test,
/// \retval sqrDistLowerBound square of a lower bound of the minimal
/// @param b1 BV to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
/// @brief BV culling test in one BVTT node
bool BVDisjoints(int b1, int /*b2*/, FCL_REAL& sqrDistLowerBound) const
......@@ -326,7 +331,7 @@ public:
}
/// BV test between b1 and b2
/// \param b2 Bounding volumes to test,
/// @param b2 Bounding volumes to test,
bool BVDisjoints(int /*b1*/, int b2) const
{
if(this->enable_statistics) this->num_bv_tests++;
......@@ -337,8 +342,8 @@ public:
}
/// BV test between b1 and b2
/// \param b2 Bounding volumes to test,
/// \retval sqrDistLowerBound square of a lower bound of the minimal
/// @param b2 Bounding volumes to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
bool BVDisjoints(int /*b1*/, int b2, FCL_REAL& sqrDistLowerBound) const
{
......@@ -459,6 +464,11 @@ public:
}
};
/// @}
/// @addtogroup Traversal_For_Distance
/// @{
/// @brief Traversal node for distance computation between BVH and shape
template<typename BV, typename S>
class BVHShapeDistanceTraversalNode : public DistanceTraversalNodeBase
......@@ -681,7 +691,7 @@ static inline void distancePreprocessOrientedNode(const BVHModel<BV>* model1,
/// @brief Traversal node for distance between mesh and shape, when mesh BVH is one of the oriented node (RSS, OBBRSS, kIOS)
/// @brief Traversal node for distance between mesh and shape, when mesh BVH is one of the oriented node (RSS, kIOS, OBBRSS)
template<typename S>
class MeshShapeDistanceTraversalNodeRSS : public MeshShapeDistanceTraversalNode<RSS, S>
{
......@@ -838,6 +848,7 @@ public:
const GJKSolver* nsolver;
};
/// @brief Traversal node for distance between shape and mesh, when mesh BVH is one of the oriented node (RSS, kIOS, OBBRSS)
template<typename S>
class ShapeMeshDistanceTraversalNodeRSS : public ShapeMeshDistanceTraversalNode<S, RSS>
{
......@@ -933,8 +944,13 @@ public:
}
};
/// @}
}
} // namespace hpp
/// @endcond
#endif
......@@ -35,10 +35,11 @@
/** \author Jia Pan */
#ifndef HPP_FCL_TRAVERSAL_NODE_MESHES_H
#define HPP_FCL_TRAVERSAL_NODE_MESHES_H
/// @cond INTERNAL
#include <hpp/fcl/collision_data.h>
#include "traversal_node_base.h"
#include <hpp/fcl/BV/BV_node.h>
......@@ -55,11 +56,14 @@
#include <vector>
#include <cassert>
namespace hpp
{
namespace fcl
{
/// @addtogroup Traversal_For_Collision
/// @{
/// @brief Traversal node for collision between BVH models
template<typename BV>
class BVHCollisionTraversalNode : public CollisionTraversalNodeBase
......@@ -168,8 +172,8 @@ public:
}
/// BV test between b1 and b2
/// \param b1, b2 Bounding volumes to test,
/// \retval sqrDistLowerBound square of a lower bound of the minimal
/// @param b1, b2 Bounding volumes to test,
/// @retval sqrDistLowerBound square of a lower bound of the minimal
/// distance between bounding volumes.
bool BVDisjoints(int b1, int b2, FCL_REAL& sqrDistLowerBound) const
{
......@@ -188,8 +192,8 @@ public:
/// Intersection testing between leaves (two triangles)
///
/// \param b1, b2 id of primitive in bounding volume hierarchy
/// \retval sqrDistLowerBound squared lower bound of distance between
/// @param b1, b2 id of primitive in bounding volume hierarchy
/// @retval sqrDistLowerBound squared lower bound of distance between
/// primitives if they are not in collision.
///
/// This method supports a security margin. If the distance between
......@@ -197,7 +201,7 @@ public:
/// considered as in collision. in this case a contact point is
/// returned in the CollisionResult.
///
/// \note If the distance between objects is less than the security margin,
/// @note If the distance between objects is less than the security margin,
/// and the object are not colliding, the penetration depth is
/// negative.
void leafCollides(int b1, int b2, FCL_REAL& sqrDistLowerBound) const
......@@ -269,6 +273,8 @@ typedef MeshCollisionTraversalNode<RSS , 0> MeshCollisionTraversalNodeRSS ;
typedef MeshCollisionTraversalNode<kIOS , 0> MeshCollisionTraversalNodekIOS ;
typedef MeshCollisionTraversalNode<OBBRSS, 0> MeshCollisionTraversalNodeOBBRSS;
/// @}
namespace details
{
template<typename BV> struct DistanceTraversalBVDistanceLowerBound_impl
......@@ -295,6 +301,9 @@ namespace details
};
} // namespace details
/// @addtogroup Traversal_For_Distance
/// @{
/// @brief Traversal node for distance computation between BVH models
template<typename BV>
class BVHDistanceTraversalNode : public DistanceTraversalNodeBase
......@@ -502,6 +511,8 @@ public:
Vec3f T;
};
/// @}
/// @brief for OBB and RSS, there is local coordinate of BV, so normal need to be transformed
namespace details
{
......@@ -518,11 +529,12 @@ inline const Matrix3f& getBVAxes<OBBRSS>(const OBBRSS& bv)
return bv.obb.axes;
}
}
}
} // namespace hpp
/// @endcond
#endif
......@@ -38,6 +38,8 @@
#ifndef HPP_FCL_TRAVERSAL_NODE_OCTREE_H
#define HPP_FCL_TRAVERSAL_NODE_OCTREE_H
/// @cond INTERNAL
#include <hpp/fcl/collision_data.h>
#include "traversal_node_base.h"
#include <hpp/fcl/narrowphase/narrowphase.h>
......@@ -885,8 +887,8 @@ private:
}
};
/// @addtogroup Traversal_For_Collision
/// @{
/// @brief Traversal node for octree collision
class OcTreeCollisionTraversalNode : public CollisionTraversalNodeBase
......@@ -924,40 +926,6 @@ public:
const OcTreeSolver* otsolver;
};
/// @brief Traversal node for octree distance
class OcTreeDistanceTraversalNode : public DistanceTraversalNodeBase
{
public:
OcTreeDistanceTraversalNode()
{
model1 = NULL;
model2 = NULL;
otsolver = NULL;
}
FCL_REAL BVDistanceLowerBound(int, int) const
{
return -1;
}
bool BVDistanceLowerBound(int, int, FCL_REAL&) const
{
return false;
}
void leafComputeDistance(int, int) const
{
otsolver->OcTreeDistance(model1, model2, tf1, tf2, request, *result);
}
const OcTree* model1;
const OcTree* model2;
const OcTreeSolver* otsolver;
};
/// @brief Traversal node for shape-octree collision
template<typename S>
class ShapeOcTreeCollisionTraversalNode : public CollisionTraversalNodeBase
......@@ -996,6 +964,7 @@ public:
};
/// @brief Traversal node for octree-shape collision
template<typename S>
class OcTreeShapeCollisionTraversalNode : public CollisionTraversalNodeBase
{
......@@ -1032,71 +1001,90 @@ public:
const OcTreeSolver* otsolver;
};
/// @brief Traversal node for shape-octree distance
template<typename S>
class ShapeOcTreeDistanceTraversalNode : public DistanceTraversalNodeBase
/// @brief Traversal node for mesh-octree collision
template<typename BV>
class MeshOcTreeCollisionTraversalNode : public CollisionTraversalNodeBase
{
public:
ShapeOcTreeDistanceTraversalNode()
MeshOcTreeCollisionTraversalNode(const CollisionRequest& request) :
CollisionTraversalNodeBase (request)
{
model1 = NULL;
model2 = NULL;
otsolver = NULL;
}
FCL_REAL BVDistanceLowerBound(int, int) const
bool BVDisjoints(int, int) const
{
return -1;
return false;
}
void leafComputeDistance(int, int) const
bool BVDisjoints(int, int, FCL_REAL&) const
{
otsolver->OcTreeShapeDistance(model2, *model1, tf2, tf1, request, *result);
return false;
}
const S* model1;
void leafCollides(int, int, FCL_REAL&) const
{
otsolver->OcTreeMeshIntersect(model2, model1, tf2, tf1, request, *result);
}
const BVHModel<BV>* model1;
const OcTree* model2;
Transform3f tf1, tf2;
const OcTreeSolver* otsolver;
};
/// @brief Traversal node for octree-shape distance
template<typename S>
class OcTreeShapeDistanceTraversalNode : public DistanceTraversalNodeBase