particle_cell_3D.h 2.66 KB
Newer Older
Thomas's avatar
Thomas committed
1
2
3
#ifndef PARTCELL_H
#define PARTCELL_H

4
#include "Algo/MovingObjects/particle_base.h"
Thomas's avatar
Thomas committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#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>
34
class ParticleCell3D : public Algo::MovingObjects::ParticleBase<PFP>
Thomas's avatar
Thomas committed
35
36
37
38
{
public :
	typedef typename PFP::MAP Map;
	typedef typename PFP::VEC3 VEC3;
39
	typedef VertexAttribute<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) :
58
59
60
61
62
		Algo::MovingObjects::ParticleBase<PFP>(pos),
		m(map),
		position(tabPos),
		d(belonging_cell),
		state(3)
Thomas's avatar
Thomas committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
	{
		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);

89
	Dart nextDartOfVertexNotMarked(Dart d, CellMarkerGen& mark);
Thomas's avatar
Thomas committed
90
91
92

	Dart nextNonPlanar(Dart d);

93
	Dart nextFaceNotMarked(Dart d,CellMarkerGen& mark);
Thomas's avatar
Thomas committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

	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)
	{
112
113
		crossCell = NO_CROSS ;

114
		if(!Geom::arePointsEquals(newCurrent, this->getPosition()))
Thomas's avatar
Thomas committed
115
116
		{
			switch(state) {
117
118
119
120
			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
121
122
123
124
125
126
127
			}

			display();
		}
	}
};

128
129
130
131
} //MovingObjects
} //Volume
} //Algo
} //CGoGN
132
133
134

#include "particle_cell_3D.hpp"

Thomas's avatar
Thomas committed
135
136

#endif