Unverified Commit 0a9d1ff0 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #196 from jcarpent/devel

Add testing on Windows for v142 compiler
parents e63c3492 2e103c8b
name: Build FCL for Windows via Conda
name: Build FCL for Windows (CLANG) via Conda
on: [push,pull_request]
jobs:
......
name: Build FCL for Windows (v142) via Conda
on: [push,pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [windows-latest]
include:
- name: windows-latest
os: windows-2019
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
run: |
git submodule update --init
- uses: goanpeca/setup-miniconda@v1
with:
activate-environment: fcl
environment-file: .github/workflows/conda/conda-env.yml
python-version: 3.7
- name: Install cmake and update conda
run: |
conda install cmake -c main
- name: Build FCL
shell: cmd /C CALL {0}
run: |
:: unset extra Boost envs
set Boost_ROOT=
set BOOST_ROOT_1_69_0=
set BOOST_ROOT_1_72_0=
set PATH=%PATH:C:\hostedtoolcache\windows\Boost\1.72.0;=%
call "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
:: Create build
mkdir build
pushd build
:: Configure
set PKG_CONFIG_PATH=%CONDA_PREFIX%\Library\share\pkgconfig:%CONDA_PREFIX%\Library\share\pkgconfig
cmake ^
-G "Visual Studio 16 2019" -T "v142" -DCMAKE_GENERATOR_PLATFORM=x64 ^
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^
-DCMAKE_BUILD_TYPE=Release ^
-DPYTHON_SITELIB=%CONDA_PREFIX%\Lib\site-packages ^
-DPYTHON_EXECUTABLE=%CONDA_PREFIX%\python.exe ^
-DBUILD_PYTHON_INTERFACE=ON ^
..
:: Build and Install
cmake --build . --config Release --target install
:: Testing
ctest --output-on-failure -C Release -V
:: Test Python import
cd ..
python -c "import hppfcl"
......@@ -41,7 +41,6 @@
#include <hpp/fcl/BVH/BVH_model.h>
namespace hpp
{
namespace fcl
......@@ -49,7 +48,33 @@ namespace fcl
/// @brief Extract the part of the BVHModel that is inside an AABB.
/// A triangle in collision with the AABB is considered inside.
template<typename BV>
HPP_FCL_DLLAPI BVHModel<BV>* BVHExtract(const BVHModel<BV>& model, const Transform3f& pose, const AABB& aabb);
HPP_FCL_DLLAPI
BVHModel<BV>* BVHExtract(const BVHModel<BV>& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<OBB >* BVHExtract(const BVHModel<OBB >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<AABB >* BVHExtract(const BVHModel<AABB >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<RSS >* BVHExtract(const BVHModel<RSS >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<kIOS >* BVHExtract(const BVHModel<kIOS >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<OBBRSS >* BVHExtract(const BVHModel<OBBRSS >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<KDOP<16> >* BVHExtract(const BVHModel<KDOP<16> >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<KDOP<18> >* BVHExtract(const BVHModel<KDOP<18> >& model, const Transform3f& pose, const AABB& aabb);
template<>
HPP_FCL_DLLAPI
BVHModel<KDOP<24> >* BVHExtract(const BVHModel<KDOP<24> >& model, const Transform3f& pose, const AABB& aabb);
/// @brief Compute the covariance matrix for a set or subset of points. if ts = null, then indices refer to points directly; otherwise refer to triangles
HPP_FCL_DLLAPI void getCovariance(Vec3f* ps, Vec3f* ps2, Triangle* ts, unsigned int* indices, int n, Matrix3f& M);
......
......@@ -53,8 +53,6 @@ namespace hpp
namespace fcl
{
const int GST_INDEP HPP_FCL_DEPRECATED = 0;
/// @brief Contact information returned by collision
struct HPP_FCL_DLLAPI Contact
{
......@@ -215,14 +213,6 @@ struct HPP_FCL_DLLAPI CollisionRequest : QueryRequest
/// See \ref hpp_fcl_collision_and_distance_lower_bound_computation
FCL_REAL break_distance;
explicit CollisionRequest(size_t num_max_contacts_,
bool enable_contact_ = false,
bool enable_distance_lower_bound_ = false,
size_t num_max_cost_sources_ = 1,
bool enable_cost_ = false,
bool use_approximate_cost_ = true)
HPP_FCL_DEPRECATED;
explicit CollisionRequest(const CollisionRequestFlag flag, size_t num_max_contacts_) :
num_max_contacts(num_max_contacts_),
enable_contact(flag & CONTACT),
......@@ -349,17 +339,6 @@ struct HPP_FCL_DLLAPI DistanceRequest : QueryRequest
FCL_REAL rel_err; // relative error, between 0 and 1
FCL_REAL abs_err; // absoluate error
/// \deprecated the last argument should be removed.
DistanceRequest(bool enable_nearest_points_,
FCL_REAL rel_err_,
FCL_REAL abs_err_,
int /*unused*/) HPP_FCL_DEPRECATED :
enable_nearest_points(enable_nearest_points_),
rel_err(rel_err_),
abs_err(abs_err_)
{
}
/// \param enable_nearest_points_ enables the nearest points computation.
/// \param rel_err_
/// \param abs_err_
......@@ -498,11 +477,11 @@ public:
&& b2 == other.b2;
// TODO: check also that two GeometryObject are indeed equal.
if ((o1 != NULL) xor (other.o1 != NULL)) return false;
if ((o1 != NULL) ^ (other.o1 != NULL)) return false;
is_same &= (o1 == other.o1);
// else if (o1 != NULL and other.o1 != NULL) is_same &= *o1 == *other.o1;
if ((o2 != NULL) xor (other.o2 != NULL)) return false;
if ((o2 != NULL) ^ (other.o2 != NULL)) return false;
is_same &= (o2 == other.o2);
// else if (o2 != NULL and other.o2 != NULL) is_same &= *o2 == *other.o2;
......
......@@ -289,13 +289,6 @@ public:
t.setIdentity();
}
/// @brief get geometry from the object instance
HPP_FCL_DEPRECATED
const CollisionGeometry* getCollisionGeometry() const
{
return cgeom.get();
}
/// @brief get geometry from the object instance
const boost::shared_ptr<const CollisionGeometry>& collisionGeometry() const
{
......
......@@ -420,7 +420,7 @@ HPP_FCL_DLLAPI bool GJKSolver::shapeDistance<S1, S2> \
#undef SHAPE_DISTANCE_SPECIALIZATION
#undef SHAPE_DISTANCE_SPECIALIZATION_BASE
#if __cplusplus < 201103L
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc99-extensions"
#endif
......@@ -549,7 +549,7 @@ HPP_FCL_DLLAPI bool GJKSolver::shapeDistance<S1, S2> \
#undef HPP_FCL_DECLARE_SHAPE_DISTANCE_PAIR
/// \}
#if __cplusplus < 201103L
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
#pragma GCC diagnostic pop
#endif
}
......
......@@ -45,93 +45,126 @@ namespace hpp
namespace fcl
{
template<typename BV>
BVHModel<BV>* BVHExtract(const BVHModel<BV>& model, const Transform3f& pose, const AABB& _aabb)
namespace details
{
assert(model.getModelType() == BVH_MODEL_TRIANGLES);
const Matrix3f& q = pose.getRotation();
AABB aabb = translate (_aabb, - pose.getTranslation());
Transform3f box_pose; Box box;
constructBox(_aabb, box, box_pose);
box_pose = pose.inverseTimes (box_pose);
GJKSolver gjk;
// Check what triangles should be kept.
// TODO use the BV hierarchy
std::vector<bool> keep_vertex(model.num_vertices, false);
std::vector<bool> keep_tri (model.num_tris, false);
std::size_t ntri = 0;
for (std::size_t i = 0; i < (std::size_t) model.num_tris; ++i) {
const Triangle& t = model.tri_indices[i];
bool keep_this_tri = keep_vertex[t[0]] || keep_vertex[t[1]] || keep_vertex[t[2]];
if (!keep_this_tri) {
for (std::size_t j = 0; j < 3; ++j) {
if (aabb.contain(q * model.vertices[t[(int)j]])) {
template<typename BV>
BVHModel<BV>* BVHExtract(const BVHModel<BV>& model, const Transform3f& pose, const AABB& _aabb)
{
assert(model.getModelType() == BVH_MODEL_TRIANGLES);
const Matrix3f& q = pose.getRotation();
AABB aabb = translate (_aabb, - pose.getTranslation());
Transform3f box_pose; Box box;
constructBox(_aabb, box, box_pose);
box_pose = pose.inverseTimes (box_pose);
GJKSolver gjk;
// Check what triangles should be kept.
// TODO use the BV hierarchy
std::vector<bool> keep_vertex(model.num_vertices, false);
std::vector<bool> keep_tri (model.num_tris, false);
std::size_t ntri = 0;
for (std::size_t i = 0; i < (std::size_t) model.num_tris; ++i) {
const Triangle& t = model.tri_indices[i];
bool keep_this_tri = keep_vertex[t[0]] || keep_vertex[t[1]] || keep_vertex[t[2]];
if (!keep_this_tri) {
for (std::size_t j = 0; j < 3; ++j) {
if (aabb.contain(q * model.vertices[t[(int)j]])) {
keep_this_tri = true;
break;
}
}
const Vec3f& p0 = model.vertices[t[0]];
const Vec3f& p1 = model.vertices[t[1]];
const Vec3f& p2 = model.vertices[t[2]];
Vec3f c1, c2, normal;
FCL_REAL distance;
if (!keep_this_tri && gjk.shapeTriangleInteraction
(box, box_pose, p0, p1, p2, Transform3f (), distance, c1, c2,
normal)) {
keep_this_tri = true;
break;
}
}
const Vec3f& p0 = model.vertices[t[0]];
const Vec3f& p1 = model.vertices[t[1]];
const Vec3f& p2 = model.vertices[t[2]];
Vec3f c1, c2, normal;
FCL_REAL distance;
if (!keep_this_tri && gjk.shapeTriangleInteraction
(box, box_pose, p0, p1, p2, Transform3f (), distance, c1, c2,
normal)) {
keep_this_tri = true;
if (keep_this_tri) {
keep_vertex[t[0]] = keep_vertex[t[1]] = keep_vertex[t[2]] = true;
keep_tri[i] = true;
ntri++;
}
}
if (keep_this_tri) {
keep_vertex[t[0]] = keep_vertex[t[1]] = keep_vertex[t[2]] = true;
keep_tri[i] = true;
ntri++;
if (ntri == 0) return NULL;
BVHModel<BV>* new_model (new BVHModel<BV>());
new_model->beginModel((int)ntri,
std::min((int)ntri * 3, (int)model.num_vertices));
std::vector<std::size_t> idxConversion (model.num_vertices);
assert(new_model->num_vertices == 0);
for (std::size_t i = 0; i < keep_vertex.size(); ++i) {
if (keep_vertex[i]) {
idxConversion[i] = new_model->num_vertices;
new_model->vertices[new_model->num_vertices] = model.vertices[i];
new_model->num_vertices++;
}
}
}
if (ntri == 0) return NULL;
BVHModel<BV>* new_model (new BVHModel<BV>());
new_model->beginModel((int)ntri,
std::min((int)ntri * 3, (int)model.num_vertices));
std::vector<std::size_t> idxConversion (model.num_vertices);
assert(new_model->num_vertices == 0);
for (std::size_t i = 0; i < keep_vertex.size(); ++i) {
if (keep_vertex[i]) {
idxConversion[i] = new_model->num_vertices;
new_model->vertices[new_model->num_vertices] = model.vertices[i];
new_model->num_vertices++;
assert(new_model->num_tris == 0);
for (std::size_t i = 0; i < keep_tri.size(); ++i) {
if (keep_tri[i]) {
new_model->tri_indices[new_model->num_tris].set (
idxConversion[model.tri_indices[i][0]],
idxConversion[model.tri_indices[i][1]],
idxConversion[model.tri_indices[i][2]]
);
new_model->num_tris++;
}
}
}
assert(new_model->num_tris == 0);
for (std::size_t i = 0; i < keep_tri.size(); ++i) {
if (keep_tri[i]) {
new_model->tri_indices[new_model->num_tris].set (
idxConversion[model.tri_indices[i][0]],
idxConversion[model.tri_indices[i][1]],
idxConversion[model.tri_indices[i][2]]
);
new_model->num_tris++;
if (new_model->endModel() != BVH_OK) {
delete new_model;
return NULL;
}
return new_model;
}
if (new_model->endModel() != BVH_OK) {
delete new_model;
return NULL;
}
return new_model;
}
template BVHModel<OBB >* BVHExtract(const BVHModel<OBB >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<AABB >* BVHExtract(const BVHModel<AABB >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<RSS >* BVHExtract(const BVHModel<RSS >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<kIOS >* BVHExtract(const BVHModel<kIOS >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<OBBRSS >* BVHExtract(const BVHModel<OBBRSS >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<KDOP<16> >* BVHExtract(const BVHModel<KDOP<16> >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<KDOP<18> >* BVHExtract(const BVHModel<KDOP<18> >& model, const Transform3f& pose, const AABB& aabb);
template BVHModel<KDOP<24> >* BVHExtract(const BVHModel<KDOP<24> >& model, const Transform3f& pose, const AABB& aabb);
template<>
BVHModel<OBB >* BVHExtract(const BVHModel<OBB >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<>
BVHModel<AABB >* BVHExtract(const BVHModel<AABB >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<>
BVHModel<RSS >* BVHExtract(const BVHModel<RSS >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<>
BVHModel<kIOS >* BVHExtract(const BVHModel<kIOS >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<>
BVHModel<OBBRSS >* BVHExtract(const BVHModel<OBBRSS >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<> BVHModel<KDOP<16> >* BVHExtract(const BVHModel<KDOP<16> >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<> BVHModel<KDOP<18> >* BVHExtract(const BVHModel<KDOP<18> >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
template<> BVHModel<KDOP<24> >* BVHExtract(const BVHModel<KDOP<24> >& model, const Transform3f& pose, const AABB& aabb)
{
return details::BVHExtract(model,pose,aabb);
}
void getCovariance(Vec3f* ps, Vec3f* ps2, Triangle* ts, unsigned int* indices, int n, Matrix3f& M)
{
......
......@@ -52,16 +52,6 @@ bool DistanceRequest::isSatisfied(const DistanceResult& result) const
return (result.min_distance <= 0);
}
CollisionRequest::CollisionRequest
(size_t num_max_contacts_, bool enable_contact_,
bool enable_distance_lower_bound_, size_t /*num_max_cost_sources_*/,
bool /*enable_cost_*/, bool /*use_approximate_cost_*/) :
num_max_contacts(num_max_contacts_),
enable_contact(enable_contact_),
enable_distance_lower_bound (enable_distance_lower_bound_),
security_margin (0),
break_distance (1e-3)
{}
}
} // namespace hpp
......@@ -32,7 +32,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if __cplusplus < 201103L
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
#define nullptr NULL
#endif
#include <hpp/fcl/mesh_loader/assimp.h>
......@@ -40,7 +40,7 @@
// Assimp >= 5.0 is forcing the use of C++11 keywords. A fix has been submitted https://github.com/assimp/assimp/pull/2758.
// The next lines fixes the bug for current version of hpp-fcl.
#include <assimp/defs.h>
#if __cplusplus < 201103L && defined(AI_NO_EXCEPT)
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) && defined(AI_NO_EXCEPT)
#undef AI_NO_EXCEPT
#define AI_NO_EXCEPT
#endif
......
......@@ -14,7 +14,9 @@ macro(add_fcl_test test_name source)
Boost::timer
utility
)
target_compile_options(${test_name} PRIVATE "-Wno-c99-extensions")
IF(NOT WIN32)
target_compile_options(${test_name} PRIVATE "-Wno-c99-extensions")
ENDIF(NOT WIN32)
if(HPP_FCL_HAS_QHULL)
target_compile_options(${test_name} PRIVATE -DHPP_FCL_HAS_QHULL)
endif()
......
Markdown is supported
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