File: Body.cpp

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (47 lines) | stat: -rw-r--r-- 1,820 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#include <core/Body.hpp>
#include <core/InteractionContainer.hpp>
#include <core/Omega.hpp>
#include <core/Scene.hpp>

namespace yade { // Cannot have #include directive inside.

//! This could be -1 if id_t is re-typedef'ed as `int'
// note about possible switch to std::optional / boost::optional and std::nullopt / boost::none here:
//    InsertionSortCollider::insertionSortParallel rests on assuption that this is signed. Negative values are used.
const Body::id_t Body::ID_NONE = Body::id_t(-1);

const shared_ptr<Body>& Body::byId(Body::id_t _id, Scene* rb) { return (*((rb ? rb : Omega::instance().getScene().get())->bodies))[_id]; }
const shared_ptr<Body>& Body::byId(Body::id_t _id, shared_ptr<Scene> rb) { return (*(rb->bodies))[_id]; }

// return list of interactions of this particle
boost::python::list Body::py_intrs()
{
	boost::python::list ret;
	for (Body::MapId2IntrT::iterator it = this->intrs.begin(), end = this->intrs.end(); it != end; ++it) { //Iterate over all bodie's interactions
		if (!(*it).second->isReal()) continue;
		ret.append((*it).second);
	}
	return ret;
}

// return number of interactions of this particle
unsigned int Body::coordNumber() const
{
	unsigned int intrSize = 0;
	for (auto it = this->intrs.begin(), end = this->intrs.end(); it != end; ++it) { //Iterate over all bodie's interactions
		if (!(*it).second->isReal()) continue;
		intrSize++;
	}
	return intrSize;
}


bool Body::maskOk(int mask) const { return (mask == 0 || ((groupMask & mask) != 0)); }
bool Body::maskCompatible(int mask) const { return (groupMask & mask) != 0; }
#ifdef YADE_MASK_ARBITRARY
bool Body::maskOk(const mask_t& mask) const { return (mask == 0 || ((groupMask & mask) != 0)); }
bool Body::maskCompatible(const mask_t& mask) const { return (groupMask & mask) != 0; }
#endif

} // namespace yade