Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

particle_cell_2D.h 2.45 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
#ifndef PARTCELL_H
#define PARTCELL_H

4
#include "Algo/MovingObjects/particle_base.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
David Cazier's avatar
-  
David Cazier committed
7
8
9
10
11
12
#include "Algo/Geometry/orientation.h"

/* 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
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
13
14
15
16
17
18
19

namespace CGoGN
{

namespace Algo
{

20
21
22
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
23
24
25
namespace MovingObjects
{

26
#ifndef PARTCELL25D_H
David Cazier's avatar
-  
David Cazier committed
27
28
29
30
enum
{
	NO_CROSS, CROSS_EDGE, CROSS_OTHER
} ;
31
#endif
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
32

Pierre Kraemer's avatar
Pierre Kraemer committed
33
template <typename PFP>
34
class ParticleCell2D : public Algo::MovingObjects::ParticleBase<PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
35
{
David Cazier's avatar
-  
David Cazier committed
36
public:
David Cazier's avatar
David Cazier committed
37
38
39
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef VertexAttribute<VEC3> TAB_POS ;
Pierre Kraemer's avatar
Pierre Kraemer committed
40

David Cazier's avatar
David Cazier committed
41
	MAP& m ;
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
42

David Cazier's avatar
-  
David Cazier committed
43
	const TAB_POS& positionAttribut ;
Pierre Kraemer's avatar
Pierre Kraemer committed
44

David Cazier's avatar
-  
David Cazier committed
45
46
	Dart d ;
	Dart lastCrossed ;
Pierre Kraemer's avatar
Pierre Kraemer committed
47

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
48
	unsigned int crossCell ;
Pierre Kraemer's avatar
Pierre Kraemer committed
49

David Cazier's avatar
David Cazier committed
50
	ParticleCell2D(MAP& map, Dart belonging_cell, const VEC3& pos, const TAB_POS& tabPos) :
Thomas Jund's avatar
Thomas Jund committed
51
		Algo::MovingObjects::ParticleBase<PFP>(pos),
David Cazier's avatar
-  
David Cazier committed
52
53
54
55
56
57
58
		m(map),
		positionAttribut(tabPos),
		d(belonging_cell),
		lastCrossed(belonging_cell),
		crossCell(NO_CROSS)
	{
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
59

60
61
62
63
	~ParticleCell2D()
	{
	}

David Cazier's avatar
-  
David Cazier committed
64
65
66
67
	Dart getCell()
	{
		return d ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
68

David Cazier's avatar
-  
David Cazier committed
69
	Geom::Orientation2D getOrientationEdge(const VEC3& point, Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
70

David Cazier's avatar
-  
David Cazier committed
71
	void display() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
72
73
74
75

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

David Cazier's avatar
-  
David Cazier committed
76
	VEC3 pointInFace(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
77

David Cazier's avatar
-  
David Cazier committed
78
	VEC3 intersectLineEdge(const VEC3& pA, const VEC3& pB, Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
79

David Cazier's avatar
David Cazier committed
80
	Geom::Orientation2D getOrientationFace(VEC3 sourcePoint, Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
81

82
	virtual void vertexState(const VEC3& current) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
83

84
	virtual void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
85

86
	//just an orientation test : check which dart is aimed to leave the current face to reach an other position
David Cazier's avatar
-  
David Cazier committed
87
	Dart faceOrientationState(const VEC3& toward) ;
88

89
	virtual void faceState(const VEC3& current) ;
Thomas's avatar
Thomas committed
90

David Cazier's avatar
-  
David Cazier committed
91
	void move(const VEC3& goal)
Pierre Kraemer's avatar
Pierre Kraemer committed
92
	{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
93
		crossCell = NO_CROSS ;
David Cazier's avatar
-  
David Cazier committed
94
		if (!Geom::arePointsEquals(goal, this->getPosition()))
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
95
		{
David Cazier's avatar
-  
David Cazier committed
96
97
98
99
100
101
102
103
104
105
106
			switch (this->getState())
			{
				case VERTEX :
					vertexState(goal) ;
					break ;
				case EDGE :
					edgeState(goal) ;
					break ;
				case FACE :
					faceState(goal) ;
					break ;
107
			}
108

David Cazier's avatar
-  
David Cazier committed
109
			display() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
110
		}
Thomas's avatar
Thomas committed
111
		else
David Cazier's avatar
David Cazier committed
112
113
		{
			// TODO Des petits pas répétés peuvent faire sortir de la cellule actuelle
Thomas Jund's avatar
Thomas Jund committed
114
			this->Algo::MovingObjects::ParticleBase<PFP>::move(goal) ;
David Cazier's avatar
David Cazier committed
115
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
116
	}
David Cazier's avatar
-  
David Cazier committed
117
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
118

119
120
121
122
} //MovingObjects
} //Surface
} //Algo
} //CGoGN
123
124

#include "particle_cell_2D.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
125
126

#endif