particle_cell_3D.h 2.58 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
#ifndef PARTCELL_H
#define PARTCELL_H

#include "particle_base.h"

#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include "Geometry/plane_3d.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
{

21
22
23
namespace Volume
{

Thomas's avatar
Thomas committed
24
25
26
namespace MovingObjects
{

27
28
29
30
31
32
enum {
	NO_CROSS,
	CROSS_FACE,
	CROSS_OTHER
};

Thomas's avatar
Thomas committed
33
template <typename PFP>
Sylvain Thery's avatar
Sylvain Thery committed
34
class ParticleCell3D : public Algo::MovingObjects::ParticleBase
Thomas's avatar
Thomas committed
35
36
37
38
{
public :
	typedef typename PFP::MAP Map;
	typedef typename PFP::VEC3 VEC3;
39
	typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
Thomas's avatar
Thomas committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

	Map& m;

	const TAB_POS& position;

	Dart d;
	Dart lastCrossed;

	VEC3 m_positionFace;

	unsigned int state;

	unsigned int crossCell ;

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

	ParticleCell3D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
Sylvain Thery's avatar
Sylvain Thery committed
58
		Algo::MovingObjects::ParticleBase(pos), m(map), position(tabPos), d(belonging_cell), state(3)
Thomas's avatar
Thomas committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
	{
		m_positionFace = pointInFace(d);
	}

	void display();

	Dart getCell() { return d; }

	VEC3 pointInFace(Dart d);

	Geom::Orientation3D isLeftENextVertex(VEC3 c, Dart d, VEC3 base);

	bool isRightVertex(VEC3 c, Dart d, VEC3 base);

	Geom::Orientation3D whichSideOfFace(VEC3 c, Dart d);

	Geom::Orientation3D isLeftL1DVol(VEC3 c, Dart d, VEC3 base, VEC3 top);

	Geom::Orientation3D isRightDVol(VEC3 c, Dart d, VEC3 base, VEC3 top);

	Geom::Orientation3D isAbove(VEC3 c, Dart d, VEC3 top);

	int isLeftL1DFace(VEC3 c, Dart d, VEC3 base, VEC3 normal);

	bool isRightDFace(VEC3 c, Dart d, VEC3 base, VEC3 normal);

85
	Dart nextDartOfVertexNotMarked(Dart d, CellMarkerGen& mark);
Thomas's avatar
Thomas committed
86
87
88

	Dart nextNonPlanar(Dart d);

89
	Dart nextFaceNotMarked(Dart d,CellMarkerGen& mark);
Thomas's avatar
Thomas committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

	Geom::Orientation3D whichSideOfEdge(VEC3 c, Dart d);

	bool isOnHalfEdge(VEC3 c, Dart d);

	void vertexState(const VEC3& current);

	void edgeState(const VEC3& current);

	void faceState(const VEC3& current, Geom::Orientation3D sideOfFace=Geom::ON);

	void volumeState(const VEC3& current);

	void volumeSpecialCase(const VEC3& current);


	void move(const VEC3& newCurrent)
	{
108
109
		crossCell = NO_CROSS ;

Thomas's avatar
Thomas committed
110
111
112
		if(!Geom::arePointsEquals(newCurrent, m_position))
		{
			switch(state) {
113
114
115
116
			case VERTEX : vertexState(newCurrent); break;
			case EDGE : 	edgeState(newCurrent);   break;
			case FACE : 	faceState(newCurrent);   break;
			case VOLUME : volumeState(newCurrent);   break;
Thomas's avatar
Thomas committed
117
118
119
120
121
122
123
124
125
126
			}

			display();
		}
	}
};

}
}
}
127
128
129
130
}

#include "particle_cell_3D.hpp"

Thomas's avatar
Thomas committed
131
132

#endif