40 #include <boost/filesystem.hpp> 41 #include <gtest/gtest.h> 42 #include "resources/config.h" 63 "file://" + (boost::filesystem::path(TEST_RESOURCES_DIR) /
"/cube.stl").
string()));
108 for (
int i = 0; i < 100; ++i)
116 EXPECT_TRUE(found) <<
"No point inside the meshes was found (very unlikely)";
131 bool intersects =
false;
132 for (
int i = 0; i < 100; ++i)
149 if (vi1.size() > 0 && vi2.size() > 0)
159 EXPECT_TRUE(intersects) <<
"No ray intersects the meshes (very unlikely)";
175 Eigen::Vector3d center1, center2;
176 double radius1, radius2;
201 int main(
int argc,
char** argv)
203 testing::InitGoogleTest(&argc, argv);
204 return RUN_ALL_TESTS();
virtual bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=NULL, unsigned int count=0) const =0
Check if a ray intersects the body, and find the set of intersections, in order, along the ray...
~CompareMeshVsPrimitive()
std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > vector_Vector3d
bool containsPoint(double x, double y, double z, bool verbose=false) const
Check if a point is inside the body.
TEST_F(CompareMeshVsPrimitive, ContainsPoint)
#define EXPECT_NEAR(a, b, prec)
Definition of a convex mesh. Convex hull is computed for a given shape::Mesh.
std::vector< shapes::Mesh * > shape_meshes
double uniformReal(double lower_bound, double upper_bound)
int main(int argc, char **argv)
virtual bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result)
Sample a point that is included in the body using a given random number generator.
void computeShapeBoundingSphere(const Shape *shape, Eigen::Vector3d ¢er, double &radius)
Compute a sphere bounding a shape.
Mesh * createMeshFromResource(const std::string &resource)
Load a mesh from a resource that contains a mesh that can be loaded by assimp.
Definition of a triangle mesh By convention the "center" of the shape is at the origin. For a mesh this implies that the AABB of the mesh is centered at the origin. Some methods may not work with arbitrary meshes whose AABB is not centered at the origin.
Definition of a box Aligned with the XYZ axes.
random_numbers::RandomNumberGenerator rng
std::vector< bodies::Body * > loaded_convex_meshes
Mesh * createMeshFromShape(const Shape *shape)
Construct a mesh from a primitive shape that is NOT already a mesh. This call allocates a new object...
std::vector< bodies::Body * > shape_convex_meshes
std::vector< shapes::Mesh * > loaded_meshes
#define EXPECT_TRUE(args)
A body is a shape + its pose. Point inclusion, ray intersection can be tested, volumes and bounding s...