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.

Commit 3a243906 authored by pitiot's avatar pitiot
Browse files

REmise à jour particules mémo

parent 69653d4f
...@@ -33,7 +33,7 @@ class ParticleCell2DMemo : public ParticleCell2D<PFP> ...@@ -33,7 +33,7 @@ class ParticleCell2DMemo : public ParticleCell2D<PFP>
ParticleCell2DMemo() {}; ParticleCell2DMemo() {};
ParticleCell2DMemo(Map& map, Dart belonging_cell, VEC3 pos, TAB_POS tabPos, DartMarker& obst) : ParticleCell2D<PFP>(map,belonging_cell,pos,tabPos,obst) ParticleCell2DMemo(Map& map, Dart belonging_cell, VEC3 pos,const TAB_POS& tabPos) : ParticleCell2D<PFP>(map,belonging_cell,pos,tabPos)
{}; {};
void vertexState(const VEC3& current); void vertexState(const VEC3& current);
......
...@@ -3,161 +3,241 @@ ...@@ -3,161 +3,241 @@
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::move(const VEC3& newCurrent) void ParticleCell2DMemo<PFP>::move(const VEC3& newCurrent)
{ {
this->prevPos = this->m_position; this->crossCell = NO_CROSS ;
if(!Geom::arePointsEquals(newCurrent, this->m_position))
switch(this->state) { {
case VERTEX : vertexState(newCurrent); break; switch(this->state) {
case EDGE : edgeState(newCurrent); break; case VERTEX : vertexState(newCurrent); break;
case FACE : faceState(newCurrent); break; case EDGE : edgeState(newCurrent); break;
} case FACE : faceState(newCurrent); break;
}
this->display(); // display();
}
else
this->m_position = newCurrent;
// this->display();
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current) void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "vertexState" << this->d << CGoGNendl; CGoGNout << "vertexState" << d << CGoGNendl;
#endif #endif
if(Algo::Geometry::isPointOnVertex<PFP>(this->m, this->d, this->m_positions, current)) { assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2]));
this->crossCell = CROSS_OTHER;
if(Algo::Geometry::isPointOnVertex<PFP>(this->m,this->d,this->m_positions,current))
{
this->state = VERTEX; this->state = VERTEX;
this->m_position = current;
return; return;
} }
else { else
{
//orientation step //orientation step
if(getOrientationEdge(current, this->m.phi2_1(this->d))!=Geom::RIGHT) { if(this->m_positions[this->d][0] == this->m_positions[this->m.phi1(this->d)][0] && this->m_positions[this->d][1] == this->m_positions[this->m.phi1(this->d)][1])
this->d = this->m.phi2_1(this->d);
if(getOrientationEdge(current,this->m.phi2_1(this->d)) != Geom::RIGHT)
{
Dart dd_vert = this->d; Dart dd_vert = this->d;
do { do
this->d = this->m.phi2_1( this->d ); {
}while(getOrientationEdge(current, this->m.phi2_1( this->d ))!=Geom::RIGHT && dd_vert!=this->d); this->d = this->m.phi2_1(this->d);
if(this->m_positions[this->d][0] == this->m_positions[this->m.phi1(this->d)][0] && this->m_positions[this->d][1] == this->m_positions[this->m.phi1(this->d)][1])
this->d = this->m.phi2_1(this->d);
} while(getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT && dd_vert != this->d);
if(dd_vert==this->d) { if(dd_vert == this->d)
this->state = VERTEX; {
return; //orbit with 2 edges : point on one edge
if(this->m.phi2_1(this->m.phi2_1(this->d)) == this->d)
{
if(!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m,this->d,this->m_positions,current))
this->d = this->m.phi2_1(this->d);
}
else
{
this->m_position = current;
this->state = VERTEX;
return;
}
} }
} }
else { else
while(getOrientationEdge(current,this->d)==Geom::RIGHT) { {
this->d = this->m.phi12( this->d ); Dart dd_vert = this->m.phi2_1(this->d);
while(getOrientationEdge(current, this->d) == Geom::RIGHT && dd_vert != this->d)
{
this->d = this->m.phi12(this->d);
if(this->m_positions[this->d][0] == this->m_positions[this->m.phi1(this->d)][0] && this->m_positions[this->d][1] == this->m_positions[this->m.phi1(this->d)][1])
this->d = this->m.phi12(this->d);
} }
} }
//displacement step //displacement step
memo_cross.push_back( this->d ); memo_cross.push_back(this->d);
// if(!this->m.isMarked(this->d,this->obstacle)) { if(getOrientationEdge(current, this->d) == Geom::ALIGNED && Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->d, this->m_positions, current))
if(getOrientationEdge(current,this->d)==Geom::ALIGNED) edgeState(current);
edgeState(current); else
else {
faceState(current); this->d = this->m.phi1(this->d);
faceState(current);
} }
// } }
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge) void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "edgeState" << this->d << CGoGNendl; CGoGNout << "edgeState" << d << CGoGNendl;
#endif #endif
memo_cross.push_back( this->d ); memo_cross.push_back(this->d);
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2]));
// assert(Algo::Geometry::isPointOnEdge<PFP>(m,d,m_positions,m_position));
if(this->crossCell == NO_CROSS)
{
this->crossCell = CROSS_EDGE;
this->lastCrossed = this->d;
}
else
this->crossCell = CROSS_OTHER;
if(sideOfEdge==Geom::ALIGNED) if(sideOfEdge == Geom::ALIGNED)
sideOfEdge = getOrientationEdge(current,this->d); sideOfEdge = getOrientationEdge(current, this->d);
switch(sideOfEdge) { switch(sideOfEdge)
{
case Geom::LEFT : case Geom::LEFT :
if(!this->obstacle.isMarked(this->d)) { this->d = this->m.phi1(this->d);
this->d = this->m.phi1( this->d ); faceState(current);
faceState(current); return;
return;
}
case Geom::RIGHT: case Geom::RIGHT:
if(!this->obstacle.isMarked(this->m.phi2( this->d ))) { this->d = this->m.phi1(this->m.phi2(this->d));
this->d = this->m.phi1(this->m.phi2( this->d )); faceState(current);
faceState(current); return;
return; default :
} this->state = EDGE;
default : this->state = EDGE;
} }
if(!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->d, this->m_positions,current)) { if(!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->d, this->m_positions, current))
this->prevPos = this->m_position; {
this->m_position = this->m_positions[this->d]; this->m_position = this->m_positions[this->d];
vertexState(current); vertexState(current);
return; return;
} }
else if(!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->m.phi2( this->d ), this->m_positions,current)) { else if(!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->m.phi2(this->d), this->m_positions, current))
this->d = this->m.phi2( this->d ); {
this->prevPos = this->m_position; this->d = this->m.phi2(this->d);
this->m_position = this->m_positions[this->d]; this->m_position = this->m_positions[this->d];
vertexState(current); vertexState(current);
return; return;
} }
this->m_position = current;
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "faceState" << this->d << CGoGNendl; CGoGNout << "faceState" << d << CGoGNendl;
#endif #endif
memo_cross.push_back( this->d ); memo_cross.push_back(this->d);
Dart dd=this->d; assert(std::isfinite(this->m_position[0]) && std::isfinite(this->m_position[1]) && std::isfinite(this->m_position[2]));
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2]));
//orientation step // assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true));
if(getOrientationFace(current, this->m_position, this->m.phi1( this->d ))!=Geom::RIGHT) {
this->d = this->m.phi1( this->d ); Dart dd = this->d;
while(getOrientationFace(current, this->m_position, this->m.phi1( this->d ))!=Geom::RIGHT && dd!=this->d) float wsoe = getOrientationFace(current, this->m_position, this->m.phi1(this->d));
this->d = this->m.phi1( this->d );
// orientation step
//source and position to reach are the same : verify if no edge is crossed this->due to numerical approximation if(wsoe != Geom::RIGHT)
if(dd==this->d) { {
do { this->d = this->m.phi1(this->d);
switch (getOrientationEdge(current,this->d)) { wsoe = getOrientationFace(current, this->m_position, this->m.phi1(this->d));
case Geom::LEFT : this->d=this->m.phi1( this->d ); while(wsoe != Geom::RIGHT && dd != this->d)
{
this->d = this->m.phi1(this->d);
wsoe = getOrientationFace(current, this->m_position, this->m.phi1(this->d));
}
// source and position to reach are the same : verify if no edge is crossed due to numerical approximation
if(dd == this->d)
{
do
{
switch (getOrientationEdge(current, this->d))
{
case Geom::LEFT: this->d = this->m.phi1(this->d);
break; break;
case Geom::ALIGNED :this->m_position = current; case Geom::ALIGNED: this->m_position = current;
edgeState(current); edgeState(current);
return; return;
default : this->m_position = intersectLineEdge(current, this->m_position,this->d); case Geom::RIGHT:
if(!this->obstacle.isMarked(this->m.phi2( this->d ))) // CGoGNout << "smthg went bad " << m_position << " " << current << CGoGNendl;
edgeState(current); // CGoGNout << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi1(d)] << CGoGNendl;
else this->m_position = intersectLineEdge(current, this->m_position, this->d);
this->state = EDGE; // CGoGNout << " " << m_position << CGoGNendl;
edgeState(current,Geom::RIGHT);
return; return;
} }
}while(this->d!=dd); } while(this->d != dd);
this->prevPos = this->m_position;
this->m_position = current; this->m_position = current;
this->state = FACE; this->state = FACE;
// m_position = Algo::Geometry::faceCentroid<PFP>(m,d,m_positions);
// d = m.phi1(d);
// m_position = pointInFace(d);
// faceState(current);
// m_position = m_positions[d];
// vertexState(current);
return; return;
} }
// take the orientation with d1 : in case we are going through a vertex
wsoe = getOrientationFace(current, this->m_position,this->d);
} }
else { else
while(getOrientationFace(current, this->m_position,this->d)==Geom::RIGHT && this->m.phi_1( this->d )!=dd) {
this->d = this->m.phi_1( this->d ); wsoe = getOrientationFace(current,this->m_position,this->d);
while(wsoe == Geom::RIGHT && this->m.phi_1(this->d) != dd)
//in case of numerical incoherence {
if(this->m.phi_1( this->d )==dd) { this->d = this->m.phi_1(this->d);
this->d = this->m.phi_1( this->d ); wsoe = getOrientationFace(current, this->m_position, this->d);
do { }
switch (getOrientationEdge(current,this->d)) {
case Geom::LEFT : this->d=this->m.phi1( this->d ); // in case of numerical incoherence
break; if(this->m.phi_1(this->d) == dd && wsoe == Geom::RIGHT)
case Geom::ALIGNED :this->m_position = current; {
edgeState(current); this->d = this->m.phi_1(this->d);
return; do
default : this->m_position = intersectLineEdge(current, this->m_position,this->d); {
if(!this->obstacle.isMarked(this->m.phi2( this->d ))) switch (getOrientationEdge(current, this->d))
edgeState(current); {
else case Geom::LEFT :
this->state = EDGE; this->d = this->m.phi1(this->d);
return; break;
case Geom::ALIGNED :
// CGoGNout << "pic" << CGoGNendl;
this->m_position = current;
edgeState(current);
return;
case Geom::RIGHT :
// CGoGNout << "smthg went bad(2) " << m_position << CGoGNendl;
this->m_position = intersectLineEdge(current, this->m_position, this->d);
// CGoGNout << " " << m_position << CGoGNendl;
edgeState(current, Geom::RIGHT);
return;
} }
} while(this->d!=dd); } while(this->d != dd);
this->m_position = current; this->m_position = current;
this->state = FACE; this->state = FACE;
...@@ -165,20 +245,41 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) ...@@ -165,20 +245,41 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
} }
} }
this->prevPos = this->m_position;
//displacement step //displacement step
switch (getOrientationEdge(current,this->d)) { memo_cross.push_back(this->d);
case Geom::LEFT : this->m_position = current; switch (getOrientationEdge(current, this->d))
this->state = FACE;; {
break; case Geom::LEFT :
case Geom::ALIGNED :this->m_position = current; this->m_position = current;
this->state = EDGE; this->state = FACE;;
break; break;
default : this->m_position = intersectLineEdge(current, this->m_position,this->d); // case Geom::ALIGNED :
if(!this->obstacle.isMarked(this->m.phi2( this->d ))) // if(wsoe==Geom::ALIGNED) {
edgeState(current); // m_position = m_positions[d];
else // vertexState(current);
this->state = EDGE; // }
// else {
// CGoGNout << "poc" << CGoGNendl;
// m_position = current;
// state = EDGE;
// }
// break;
default :
if(wsoe == Geom::ALIGNED)
{
this->d = this->m.phi1(this->d); //to check
this->m_position = this->m_positions[this->d];
vertexState(current);
}
else
{
// CGoGNout << "wsoe : " << wsoe << CGoGNendl;
// CGoGNout << "current " << current << " " << m_position << CGoGNendl;
// CGoGNout << "d " << d << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi2(d)] << CGoGNendl;
this->m_position = intersectLineEdge(current, this->m_position, this->d);
// CGoGNout << " inter : " << m_position << CGoGNendl;
edgeState(current, Geom::RIGHT);
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment