← Back to team overview

yade-dev team mailing list archive

[Bug 1804621] Re: bodyNumInteractionsHistogram broken

 

After a bit more investigation the problem I see it that it is assumed everywhere that aabb's are tuples, and they are used for constructive solid geometry.
If predicate.aabb() is a tuple then aabbExtrema() must be a tuple as well, else the interface is heterogeneous and the extrema are incompatible with everything else (although it can still work in lucky cases because of intersections in the interfaces of tuples and lists).
Aabb type would then have to be changed in many places if we were changing it, and this is not limited to _packPredicates.cpp. See for instance cloudBestFitOBB() in _packObb.cpp. I still didn't spot all of them.

Although it was theoretically a good move to switch from tuple to
wrapped vector<double>, it doesn't seem so wise now given the number of
changes it implies.

Considering your very initial need which was IIRC to get the aabb of
spheres I would suggest to either extract the values from the tuple, or
to declare an additional function with same code as in 1db13fb11 (it
could then be re-used inside aabbExtrema() to avoid duplication).

        Real inf=std::numeric_limits<Real>::infinity();
	Vector3r minimum(inf,inf,inf),maximum(-inf,-inf,-inf);
	FOREACH(const shared_ptr<Body>& b, *Omega::instance().getScene()->bodies){
		if(!b) continue;
		shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape); if(!s) continue;
		Vector3r rrr(s->radius,s->radius,s->radius);
		minimum=minimum.cwiseMin(b->state->pos-(centers?Vector3r::Zero():rrr));
		maximum=maximum.cwiseMax(b->state->pos+(centers?Vector3r::Zero():rrr));
	}
	Vector3r dim=maximum-minimum;
	vector<Vector3r> ret;
	ret.push_back(minimum+.5*cutoff*dim);
	ret.push_back(maximum-.5*cutoff*dim);

Cheers

Bruno

-- 
You received this bug notification because you are a member of Yade
developers, which is subscribed to Yade.
https://bugs.launchpad.net/bugs/1804621

Title:
  bodyNumInteractionsHistogram broken

Status in Yade:
  Fix Released

Bug description:
  See https://answers.launchpad.net/yade/+question/676284 and:

  #####################
  O.bodies.append(sphere((0,0,0),1,dynamic=False))
  O.bodies.append(sphere((0,0,1.9),1,dynamic=False))

  O.step()

  print 'BodyNumInteractions Histogram', bodyNumInteractionsHistogram(aabbExtrema())
  ####################

  which returns (with trunk version) :

  ArgumentError: Python argument types in
      yade._utils.bodyNumInteractionsHistogram(list)
  did not match C++ signature:
      bodyNumInteractionsHistogram(boost::python::tuple aabb, bool contactOnly=False)

  
  because my commit [*] changed the Python return type of aabbExtrema() from tuple to list.

  
  Possible (and easiest) fix would be to change all corresponding py::tuple aabb from py::list aabb. Agree ? 

  Or do we want this function to deal with Python tuples and not lists
  ?..


  Jérôme

  [*]
  https://github.com/yade/trunk/commit/1db13fb1183b9e294dc9761da76cfa4fc2791cc1

To manage notifications about this bug go to:
https://bugs.launchpad.net/yade/+bug/1804621/+subscriptions


References