File: State.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 (50 lines) | stat: -rw-r--r-- 1,837 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
48
49
50
// 2009 © Václav Šmilauer <eudoxos@arcig.cz>
#include <core/State.hpp>

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

CREATE_LOGGER(State);
CREATE_LOGGER(ThermalState);

void State::setDOFfromVector3r(Vector3r disp, Vector3r rot)
{
	blockedDOFs = ((disp[0] == 1.0) ? DOF_X : 0) | ((disp[1] == 1.0) ? DOF_Y : 0) | ((disp[2] == 1.0) ? DOF_Z : 0) | ((rot[0] == 1.0) ? DOF_RX : 0)
	        | ((rot[1] == 1.0) ? DOF_RY : 0) | ((rot[2] == 1.0) ? DOF_RZ : 0);
}

std::string State::blockedDOFs_vec_get() const
{
	std::string ret;
#define _SET_DOF(DOF_ANY, ch)                                                                                                                                  \
	if ((blockedDOFs & State::DOF_ANY) != 0) ret.push_back(ch);
	_SET_DOF(DOF_X, 'x');
	_SET_DOF(DOF_Y, 'y');
	_SET_DOF(DOF_Z, 'z');

	_SET_DOF(DOF_RX, 'X');
	_SET_DOF(DOF_RY, 'Y');
	_SET_DOF(DOF_RZ, 'Z');
#undef _SET_DOF
	return ret;
}

void State::blockedDOFs_vec_set(const std::string& dofs)
{
	blockedDOFs = 0;
	for (char c : dofs) {
#define _GET_DOF(DOF_ANY, ch)                                                                                                                                  \
	if (c == ch) {                                                                                                                                         \
		blockedDOFs |= State::DOF_ANY;                                                                                                                 \
		continue;                                                                                                                                      \
	}
		_GET_DOF(DOF_X, 'x');
		_GET_DOF(DOF_Y, 'y');
		_GET_DOF(DOF_Z, 'z');
		_GET_DOF(DOF_RX, 'X');
		_GET_DOF(DOF_RY, 'Y');
		_GET_DOF(DOF_RZ, 'Z');
#undef _GET_DOF
	}
}

} // namespace yade