particle_cell_2D.h 1.93 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
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
#ifndef PARTCELL_H
#define PARTCELL_H

#include "particle_base.h"

#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include <iostream>

/* A particle cell is a particle base within a map, within a precise cell, the displacement function should indicate
   after each displacement wherein lies the new position of the particle */

namespace CGoGN
{

namespace Algo
{

namespace MovingObjects
{

template <typename PFP>
class ParticleCell2D : public ParticleBase
{
	public :
	typedef typename PFP::MAP Map;
	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::TVEC3 TAB_POS;

	Map& m;
	
	Dart d;

	TAB_POS m_positions;

	VEC3 prevPos;

	unsigned int state;

	DartMarker& obstacle;

43
44
	bool changeCell ;

45
	ParticleCell2D() {}
Pierre Kraemer's avatar
Pierre Kraemer committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

	ParticleCell2D(Map& map, Dart belonging_cell, VEC3 pos, TAB_POS tabPos, DartMarker& obst) : ParticleBase(pos), m(map), d(belonging_cell), m_positions(tabPos), obstacle(obst)
	{
		state = 2;
		prevPos = pos;
	}

	Dart getCell() { return d; }

	Geom::Orientation2D getOrientationEdge(const VEC3& point, Dart d);

	void display();

// 	template <unsigned int DD, typename TT>
// 	friend std::istream& operator>> (std::istream& in, Vector<DD,TT>& v) ;

	VEC3 pointInFace(Dart d);

	VEC3 intersectLineEdge(const VEC3& pA, const VEC3& pB, Dart d);

	Geom::Orientation2D getOrientationFace(VEC3 sourcePoint, VEC3 point, Dart d);

	void vertexState(const VEC3& current);

	void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge=Geom::ALIGNED);

	void faceState(const VEC3& current);

	void move(const VEC3& newCurrent)
	{
76
		changeCell = false ;
77
78
79
80
81
82
83
84
		if(!Geom::arePointsEquals(newCurrent, m_position)) {
			prevPos = m_position;

			switch(state) {
			case VERTEX_ORBIT : vertexState(newCurrent); break;
			case EDGE_ORBIT : 	edgeState(newCurrent);   break;
			case FACE_ORBIT : 	faceState(newCurrent);   break;
			}
85
86

			display();
Pierre Kraemer's avatar
Pierre Kraemer committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
		}
	}


};

#include "particle_cell_2D.hpp"

}

}

}

#endif