particle_cell_2D.h 1.98 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
#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
{

Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
23
24
25
26
27
28
enum {
	NO_CROSS,
	CROSS_EDGE,
	CROSS_OTHER
};

Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
template <typename PFP>
class ParticleCell2D : public ParticleBase
{
Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
32
public :
Pierre Kraemer's avatar
Pierre Kraemer committed
33
34
35
36
37
	typedef typename PFP::MAP Map;
	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::TVEC3 TAB_POS;

	Map& m;
Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
38
39

	const TAB_POS& m_positions;
Pierre Kraemer's avatar
Pierre Kraemer committed
40
41
	
	Dart d;
Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
42
	Dart lastCrossed;
Pierre Kraemer's avatar
Pierre Kraemer committed
43
44
45

	unsigned int state;

Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
46
	unsigned int crossCell ;
Pierre Kraemer's avatar
Pierre Kraemer committed
47

Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
48
49
	ParticleCell2D(Map& map) : m(map)
	{}
50

Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
51
	ParticleCell2D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
Thomas's avatar
Thomas committed
52
		ParticleBase(pos), m(map), m_positions(tabPos), d(belonging_cell), lastCrossed(belonging_cell), state(FACE_ORBIT), crossCell(NO_CROSS)
Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
53
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

	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)
	{
Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
78
79
80
		crossCell = NO_CROSS ;
		if(!Geom::arePointsEquals(newCurrent, m_position))
		{
81
82
83
84
85
			switch(state) {
			case VERTEX_ORBIT : vertexState(newCurrent); break;
			case EDGE_ORBIT : 	edgeState(newCurrent);   break;
			case FACE_ORBIT : 	faceState(newCurrent);   break;
			}
86
87

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

#include "particle_cell_2D.hpp"

}

}

}

#endif