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_2DandHalf.h 1.93 KB
Newer Older
Thomas's avatar
Thomas 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
43
44
45
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
#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
{

enum {
	NO_CROSS,
	CROSS_EDGE,
	CROSS_OTHER
};

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

	Map& m;

	const TAB_POS& m_positions;

	Dart d;
	Dart lastCrossed;

	unsigned int state;

	unsigned int crossCell ;

	ParticleCell2DAndHalf(Map& map) : m(map)
	{}

	ParticleCell2DAndHalf(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
		ParticleBase(pos), m(map), m_positions(tabPos), d(belonging_cell), lastCrossed(belonging_cell), state(FACE), crossCell(NO_CROSS)
	{}

	Dart getCell() { return d; }

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

	void display();

	VEC3 pointInFace(Dart d);

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

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

	void vertexState(VEC3 current);

	void edgeState(VEC3 current, Geom::Orientation3D sideOfEdge=Geom::ON);

	void faceState(VEC3 current);

Thomas's avatar
Thomas committed
73
74
75
76
77
	virtual unsigned int getState()
	{
		return state;
	}

Thomas's avatar
Thomas committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
	void move(const VEC3& newCurrent)
	{
		crossCell = NO_CROSS ;
		if(!Geom::arePointsEquals(newCurrent, m_position))
		{
			switch(state) {
			case VERTEX : 	vertexState(newCurrent); break;
			case EDGE : 	edgeState(newCurrent);   break;
			case FACE : 	faceState(newCurrent);   break;
			}

			display();
		}
		else
			m_position = newCurrent;
	}
};

#include "particle_cell_2DandHalf.hpp"

}

}

}

#endif