particle_cell_2D.h 2.23 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 20 21 22

namespace CGoGN
{

namespace Algo
{

namespace MovingObjects
{

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

Pierre Kraemer's avatar
Pierre Kraemer committed
28
template <typename PFP>
David Cazier's avatar
-  
David Cazier committed
29
class ParticleCell2D : public ParticleBase<PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
30
{
David Cazier's avatar
-  
David Cazier committed
31 32
public:
	typedef typename PFP::MAP Map ;
Pierre Kraemer's avatar
Pierre Kraemer committed
33
	typedef typename PFP::VEC3 VEC3;
34
	typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
Pierre Kraemer's avatar
Pierre Kraemer committed
35

David Cazier's avatar
-  
David Cazier committed
36
	Map& m ;
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
37

David Cazier's avatar
-  
David Cazier committed
38
	const TAB_POS& positionAttribut ;
Pierre Kraemer's avatar
Pierre Kraemer committed
39

David Cazier's avatar
-  
David Cazier committed
40 41
	Dart d ;
	Dart lastCrossed ;
Pierre Kraemer's avatar
Pierre Kraemer committed
42

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
43
	unsigned int crossCell ;
Pierre Kraemer's avatar
Pierre Kraemer committed
44

David Cazier's avatar
-  
David Cazier committed
45 46 47 48
//	ParticleCell2D(Map& map) :
//		m(map)
//	{
//	}
49

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

David Cazier's avatar
-  
David Cazier committed
60 61 62 63
	Dart getCell()
	{
		return d ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
64

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

David Cazier's avatar
-  
David Cazier committed
67
	void display() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70 71

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

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

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

David Cazier's avatar
-  
David Cazier committed
76
	Geom::Orientation2D getOrientationFace(VEC3 sourcePoint, VEC3 point, Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
77

David Cazier's avatar
-  
David Cazier committed
78
	void vertexState(const VEC3& current) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
79

David Cazier's avatar
-  
David Cazier committed
80
	void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
81

82
	//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
83
	Dart faceOrientationState(const VEC3& toward) ;
84

David Cazier's avatar
-  
David Cazier committed
85
	void faceState(const VEC3& current) ;
Thomas's avatar
Thomas committed
86

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

David Cazier's avatar
-  
David Cazier committed
105
			display() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
106
		}
Thomas's avatar
Thomas committed
107
		else
David Cazier's avatar
-  
David Cazier committed
108
			this->ParticleBase<PFP>::move(goal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
109
	}
David Cazier's avatar
-  
David Cazier committed
110
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
111 112 113 114 115 116 117 118 119 120

#include "particle_cell_2D.hpp"

}

}

}

#endif