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.24 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
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#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
	typedef typename PFP::MAP Map;
	typedef typename PFP::VEC3 VEC3;
35
	typedef AttributeHandler<typename PFP::VEC3, VERTEX> TAB_POS;
Pierre Kraemer's avatar
Pierre Kraemer committed
36
37

	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) :
52
		ParticleBase(pos), m(map), m_positions(tabPos), d(belonging_cell), lastCrossed(belonging_cell), state(FACE), 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

	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);

74
75
76
	//just an orientation test : check which dart is aimed to leave the current face to reach an other position
	Dart faceOrientationState(const VEC3& toward);

Pierre Kraemer's avatar
Pierre Kraemer committed
77
78
	void faceState(const VEC3& current);

Thomas's avatar
Thomas committed
79
80
81
82
83
	virtual unsigned int getState()
	{
		return state;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
84
85
	void move(const VEC3& newCurrent)
	{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
86
87
88
		crossCell = NO_CROSS ;
		if(!Geom::arePointsEquals(newCurrent, m_position))
		{
89
			switch(state) {
90
91
92
			case VERTEX : vertexState(newCurrent); break;
			case EDGE : 	edgeState(newCurrent);   break;
			case FACE : 	faceState(newCurrent);   break;
93
			}
94
95

			display();
Pierre Kraemer's avatar
Pierre Kraemer committed
96
		}
Thomas's avatar
Thomas committed
97
98
		else
			m_position = newCurrent;
Pierre Kraemer's avatar
Pierre Kraemer committed
99
100
101
102
103
104
105
106
107
108
109
110
	}
};

#include "particle_cell_2D.hpp"

}

}

}

#endif