Re: [eigen] Build Failure

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 11/04/10 19:11:28, Benoit Jacob wrote:
> Sorry, it's a bug from my ei_xxx ---> internal::xxx renaming changes,
> sorry i don't have time to fix it now :-(
> 
>  Benoit

I've added some lines from BVH.cpp and now it compiles.
Is they version of BHV_Example.cpp in the attachment acceptable?

Helmut.

> 2010/11/4 Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>:
> > Hi,
> >
> > I've just tried to build (doc) the current HG-Eigen version.
> > But I get
> >
> > [ 96%] Building CXX object unsupported/doc/examples/CMakeFiles/
> > example_FFT.dir/FFT.cpp.o
> > /OBJ/Math/Eigen/unsupported/doc/examples/BVH_Example.cpp:8: error:
> > 'Box2d Eigen::internal::bounding_box(const Eigen::Vector2d&)' 
> should
> > have been declared inside 'Eigen::internal'
> > make[3]: *** [unsupported/doc/examples/CMakeFiles/
> > example_BVH_Example.dir/BVH_Example.cpp.o] Error 1
> > make[2]: *** [unsupported/doc/examples/CMakeFiles/
> > example_BVH_Example.dir/all] Error 2
> >
> > Is this a bug or am I missing something?
> >
> > Many thanks for looking into it,
> > Helmut.
> >
> >
> >
> 
> 
> 
> 



-- 
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
#include <Eigen/StdVector>
#include <unsupported/Eigen/BVH>
#include <iostream>

using namespace Eigen;
typedef AlignedBox<double, 2> Box2d;

template<int Dim>
struct Ball
{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(double, Dim)

  typedef Matrix<double, Dim, 1> VectorType;

  Ball() {}
  Ball(const VectorType &c, double r) : center(c), radius(r) {}

  VectorType center;
  double radius;
};

namespace Eigen {
namespace internal {
template<typename Scalar, int Dim> AlignedBox<Scalar, Dim> bounding_box(const Matrix<Scalar, Dim, 1> &v) { return AlignedBox<Scalar, Dim>(v); }
template<int Dim> AlignedBox<double, Dim> bounding_box(const Ball<Dim> &b)
{ return AlignedBox<double, Dim>(b.center.array() - b.radius, b.center.array() + b.radius); }
}}

struct PointPointMinimizer //how to compute squared distances between points and rectangles
{
  PointPointMinimizer() : calls(0) {}
  typedef double Scalar;

  double minimumOnVolumeVolume(const Box2d &r1, const Box2d &r2) { ++calls; return r1.squaredExteriorDistance(r2); }
  double minimumOnVolumeObject(const Box2d &r, const Vector2d &v) { ++calls; return r.squaredExteriorDistance(v); }
  double minimumOnObjectVolume(const Vector2d &v, const Box2d &r) { ++calls; return r.squaredExteriorDistance(v); }
  double minimumOnObjectObject(const Vector2d &v1, const Vector2d &v2) { ++calls; return (v1 - v2).squaredNorm(); }

  int calls;
};

int main()
{
  typedef std::vector<Vector2d, aligned_allocator<Vector2d> > StdVectorOfVector2d;
  StdVectorOfVector2d redPoints, bluePoints;
  for(int i = 0; i < 100; ++i) { //initialize random set of red points and blue points
    redPoints.push_back(Vector2d::Random());
    bluePoints.push_back(Vector2d::Random());
  }

  PointPointMinimizer minimizer;
  double minDistSq = std::numeric_limits<double>::max();

  //brute force to find closest red-blue pair
  for(int i = 0; i < (int)redPoints.size(); ++i)
    for(int j = 0; j < (int)bluePoints.size(); ++j)
      minDistSq = std::min(minDistSq, minimizer.minimumOnObjectObject(redPoints[i], bluePoints[j]));
  std::cout << "Brute force distance = " << sqrt(minDistSq) << ", calls = " << minimizer.calls << std::endl;

  //using BVH to find closest red-blue pair
  minimizer.calls = 0;
  KdBVH<double, 2, Vector2d> redTree(redPoints.begin(), redPoints.end()), blueTree(bluePoints.begin(), bluePoints.end()); //construct the trees
  minDistSq = BVMinimize(redTree, blueTree, minimizer); //actual BVH minimization call
  std::cout << "BVH distance         = " << sqrt(minDistSq) << ", calls = " << minimizer.calls << std::endl;

  return 0;
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/