File: Interaction.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 (52 lines) | stat: -rw-r--r-- 1,599 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
51
52
/*************************************************************************
*  Copyright (C) 2004 by Olivier Galizzi                                 *
*  olivier.galizzi@imag.fr                                               *
*  Copyright (C) 2004 by Janek Kozicki                                   *
*  cosurgi@berlios.de                                                    *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/

#include "Interaction.hpp"

#include <core/Scene.hpp>

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

Interaction::Interaction(Body::id_t newId1, Body::id_t newId2)
        : id1(newId1)
        , id2(newId2)
        , cellDist(Vector3i(0, 0, 0))
{
	reset();
}

bool Interaction::isFresh(Scene* rb) { return iterMadeReal == rb->iter; }

void Interaction::init()
{
	iterMadeReal            = -1;
	functorCache.geomExists = true;
	isActive                = true;
}

void Interaction::reset()
{
	geom                  = shared_ptr<IGeom>();
	phys                  = shared_ptr<IPhys>();
	functorCache.geom     = nullptr;
	functorCache.phys     = nullptr;
	functorCache.constLaw = nullptr;
	init();
}


void Interaction::swapOrder()
{
	if (geom || phys) { throw std::logic_error("Bodies in interaction cannot be swapped if they have geom or phys."); }
	std::swap(id1, id2);
	cellDist *= -1;
}

} // namespace yade