Commit d57bdab0 authored by David Cazier's avatar David Cazier

Merge SA2

parent 18f74232
......@@ -22,10 +22,6 @@ ENDIF(WIN32)
#define exec to compile
QT4_WRAP_CPP(tutoriel_moc ../tutoriel.h)
add_executable( tutoriel ../tutoriel.cpp ${tutoriel_moc})
target_link_libraries( tutoriel
${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP(frame_manip_moc ../frame_manip.h)
add_executable( frame_manip ../frame_manip.cpp ${frame_manip_moc})
......
......@@ -18,33 +18,36 @@ template <typename PFP>
class ParticleBase
{
private:
typename PFP::VEC3 m_position;
unsigned int m_state;
typename PFP::VEC3 m_position ;
unsigned int m_state ;
public :
ParticleBase(typename PFP::VEC3 position) :
m_position(position),
m_state(FACE)
public:
ParticleBase(const typename PFP::VEC3& position) :
m_position(position), m_state(FACE)
{
}
void setState(unsigned int state) {
m_state = state;
void setState(unsigned int state)
{
m_state = state ;
}
unsigned int getState()
{
return m_state;
return m_state ;
}
bool move(typename PFP::VEC3 position)
bool move(const typename PFP::VEC3& position)
{
m_position = position;
return true;
m_position = position ;
return true ;
}
typename PFP::VEC3 getPosition() { return m_position; }
};
const typename PFP::VEC3& getPosition()
{
return m_position ;
}
} ;
} // namespace MovingObjects
......
......@@ -29,11 +29,11 @@ template <typename PFP>
class ParticleCell2D : public ParticleBase<PFP>
{
public:
typedef typename PFP::MAP Map ;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef VertexAttribute<VEC3> TAB_POS ;
Map& m ;
MAP& m ;
const TAB_POS& positionAttribut ;
......@@ -42,12 +42,7 @@ public:
unsigned int crossCell ;
// ParticleCell2D(Map& map) :
// m(map)
// {
// }
ParticleCell2D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleCell2D(MAP& map, Dart belonging_cell, const VEC3& pos, const TAB_POS& tabPos) :
ParticleBase<PFP>(pos),
m(map),
positionAttribut(tabPos),
......@@ -105,7 +100,10 @@ public:
display() ;
}
else
{
// TODO Des petits pas répétés peuvent faire sortir de la cellule actuelle
this->ParticleBase<PFP>::move(goal) ;
}
}
} ;
......
......@@ -73,24 +73,24 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& goal)
else
{
//orientation step
if(m_positions[d][0] == m_positions[m.phi1(d)][0] && m_positions[d][1] == m_positions[m.phi1(d)][1])
if(positionAttribut[d][0] == positionAttribut[m.phi1(d)][0] && positionAttribut[d][1] == positionAttribut[m.phi1(d)][1])
d = m.phi2_1(d);
if(getOrientationEdge(current,m.phi2_1(d)) != Geom::RIGHT)
if(getOrientationEdge(goal,m.phi2_1(d)) != Geom::RIGHT)
{
Dart dd_vert = d ;
do
{
d = m.phi2_1(d);
if(m_positions[d][0] == m_positions[m.phi1(d)][0] && m_positions[d][1] == m_positions[m.phi1(d)][1])
if(positionAttribut[d][0] == positionAttribut[m.phi1(d)][0] && positionAttribut[d][1] == positionAttribut[m.phi1(d)][1])
d = m.phi2_1(d);
} while(getOrientationEdge(current, m.phi2_1(d)) != Geom::RIGHT && dd_vert != d);
} while(getOrientationEdge(goal, m.phi2_1(d)) != Geom::RIGHT && dd_vert != d);
if (dd_vert == d)
{
//orbit with 2 edges : point on one edge
if(m.phi2_1(m.phi2_1(d)) == d)
{
if(!Algo::Geometry::isPointOnHalfEdge<PFP>(m,d,m_positions,current))
if(!Algo::Geometry::isPointOnHalfEdge<PFP>(m,d,positionAttribut,goal))
d = m.phi2_1(d);
}
else
......@@ -104,10 +104,10 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& goal)
else
{
Dart dd_vert = m.phi2_1(d);
while(getOrientationEdge(current, d) == Geom::RIGHT && dd_vert != d)
while(getOrientationEdge(goal, d) == Geom::RIGHT && dd_vert != d)
{
d = m.phi12(d);
if(m_positions[d][0] == m_positions[m.phi1(d)][0] && m_positions[d][1] == m_positions[m.phi1(d)][1])
if(positionAttribut[d][0] == positionAttribut[m.phi1(d)][0] && positionAttribut[d][1] == positionAttribut[m.phi1(d)][1])
d = m.phi12(d);
}
}
......
......@@ -9,7 +9,7 @@
#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 */
after each displacement wherein lies the new position of the particle */
namespace CGoGN
{
......@@ -24,26 +24,32 @@ template <typename PFP>
class ParticleCell2DMemo : public ParticleCell2D<PFP>
{
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
public:
typedef typename PFP::MAP MAP ;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS ;
std::list<Dart> memo_cross;
std::list<Dart> memo_cross ;
ParticleCell2DMemo() {};
private:
ParticleCell2DMemo()
{
}
ParticleCell2DMemo(Map& map, Dart belonging_cell, VEC3 pos, TAB_POS tabPos, DartMarker& obst) : ParticleCell2D<PFP>(map,belonging_cell,pos,tabPos,obst)
{};
public:
ParticleCell2DMemo(MAP& map, Dart belonging_cell, const VEC3& pos, const TAB_POS& tabPos,
DartMarker& obst) :
ParticleCell2D<PFP>(map, belonging_cell, pos, tabPos, obst)
{
}
void vertexState(const VEC3& current);
void vertexState(const VEC3& current) ;
void edgeState(const VEC3& current,Geom::Orientation2D sideOfEdge=Geom::ALIGNED);
void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
void faceState(const VEC3& current);
void faceState(const VEC3& current) ;
void move(const VEC3& newCurrent);
};
void move(const VEC3& goal) ;
} ;
#include "particle_cell_2D_memo.hpp"
//namespace
......
template <typename PFP>
void ParticleCell2DMemo<PFP>::move(const VEC3& newCurrent)
void ParticleCell2DMemo<PFP>::move(const VEC3& goal)
{
this->prevPos = this->m_position;
switch(this->state) {
case VERTEX : vertexState(newCurrent); break;
case EDGE : edgeState(newCurrent); break;
case FACE : faceState(newCurrent); break;
switch (this->getState())
{
case VERTEX :
vertexState(goal) ;
break ;
case EDGE :
edgeState(goal) ;
break ;
case FACE :
faceState(goal) ;
break ;
}
this->display();
this->display() ;
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current)
{
#ifdef DEBUG
CGoGNout << "vertexState" << this->d << CGoGNendl;
#endif
if(Algo::Geometry::isPointOnVertex<PFP>(this->m, this->d, this->m_positions, current)) {
this->state = VERTEX;
return;
#ifdef DEBUG
CGoGNout << "vertexState" << this->d << CGoGNendl ;
#endif
if (Algo::Geometry::isPointOnVertex < PFP > (this->m, this->d, this->positionAttribut, current))
{
this->setState(VERTEX) ;
return ;
}
else {
else
{
//orientation step
if(getOrientationEdge(current, this->m.phi2_1(this->d))!=Geom::RIGHT) {
Dart dd_vert = this->d;
do {
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) {
this->state = VERTEX;
return;
if (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT)
{
Dart dd_vert = this->d ;
do
{
this->d = this->m.phi2_1(this->d) ;
} while (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT
&& dd_vert != this->d) ;
if (dd_vert == this->d)
{
this->setState(VERTEX) ;
return ;
}
}
else {
while(getOrientationEdge(current,this->d)==Geom::RIGHT) {
this->d = this->m.phi12( this->d );
else
{
while (this->getOrientationEdge(current, this->d) == Geom::RIGHT)
{
this->d = this->m.phi12(this->d) ;
}
}
//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)
edgeState(current);
else
faceState(current);
}
if (this->getOrientationEdge(current, this->d) == Geom::ALIGNED)
edgeState(current) ;
else
faceState(current) ;
}
// }
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge)
{
#ifdef DEBUG
CGoGNout << "edgeState" << this->d << CGoGNendl;
#endif
memo_cross.push_back( this->d );
#ifdef DEBUG
CGoGNout << "edgeState" << this->d << CGoGNendl ;
#endif
memo_cross.push_back(this->d) ;
if(sideOfEdge==Geom::ALIGNED)
sideOfEdge = getOrientationEdge(current,this->d);
if (sideOfEdge == Geom::ALIGNED) sideOfEdge = this->getOrientationEdge(current, this->d) ;
switch(sideOfEdge) {
switch (sideOfEdge)
{
case Geom::LEFT :
if(!this->obstacle.isMarked(this->d)) {
this->d = this->m.phi1( this->d );
faceState(current);
return;
}
case Geom::RIGHT:
if(!this->obstacle.isMarked(this->m.phi2( this->d ))) {
this->d = this->m.phi1(this->m.phi2( this->d ));
faceState(current);
return;
}
default : this->state = EDGE;
if (!this->obstacle.isMarked(this->d))
{
this->d = this->m.phi1(this->d) ;
faceState(current) ;
return ;
}
case Geom::RIGHT :
if (!this->obstacle.isMarked(this->m.phi2(this->d)))
{
this->d = this->m.phi1(this->m.phi2(this->d)) ;
faceState(current) ;
return ;
}
default :
this->setState(EDGE) ;
}
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];
vertexState(current);
return;
if (!Algo::Geometry::isPointOnHalfEdge<PFP> (this->m, this->d, this->positionAttribut, current))
{
this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ;
vertexState(current) ;
return ;
}
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->m_position = this->m_positions[this->d];
vertexState(current);
return;
else if (!Algo::Geometry::isPointOnHalfEdge<PFP> (this->m, this->m.phi2(this->d), this->positionAttribut, current))
{
this->d = this->m.phi2(this->d) ;
this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ;
vertexState(current) ;
return ;
}
}
......@@ -100,84 +115,102 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D
template <typename PFP>
void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
{
#ifdef DEBUG
CGoGNout << "faceState" << this->d << CGoGNendl;
#endif
memo_cross.push_back( this->d );
Dart dd=this->d;
#ifdef DEBUG
CGoGNout << "faceState" << this->d << CGoGNendl ;
#endif
memo_cross.push_back(this->d) ;
Dart dd = this->d ;
//orientation step
if(getOrientationFace(current, this->m_position, this->m.phi1( this->d ))!=Geom::RIGHT) {
this->d = this->m.phi1( this->d );
while(getOrientationFace(current, this->m_position, this->m.phi1( this->d ))!=Geom::RIGHT && dd!=this->d)
this->d = this->m.phi1( this->d );
//source and position to reach are the same : verify if no edge is crossed this->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;
case Geom::ALIGNED :this->m_position = current;
edgeState(current);
return;
default : this->m_position = intersectLineEdge(current, this->m_position,this->d);
if(!this->obstacle.isMarked(this->m.phi2( this->d )))
edgeState(current);
else
this->state = EDGE;
return;
if (this->getOrientationFace(current, this->getPosition(), this->m.phi1(this->d)) != Geom::RIGHT)
{
this->d = this->m.phi1(this->d) ;
while (this->getOrientationFace(current, this->getPosition(), this->m.phi1(this->d)) != Geom::RIGHT
&& dd != this->d)
this->d = this->m.phi1(this->d) ;
//source and position to reach are the same : verify if no edge is crossed this->due to numerical approximation
if (dd == this->d)
{
do
{
switch (this->getOrientationEdge(current, this->d))
{
case Geom::LEFT :
this->d = this->m.phi1(this->d) ;
break ;
case Geom::ALIGNED :
this->ParticleBase<PFP>::move(current) ;
edgeState(current) ;
return ;
default :
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
if (!this->obstacle.isMarked(this->m.phi2(this->d)))
edgeState(current) ;
else
this->setState(EDGE) ;
return ;
}
}while(this->d!=dd);
this->prevPos = this->m_position;
this->m_position = current;
this->state = FACE;
return;
} while (this->d != dd) ;
this->ParticleBase<PFP>::move(current) ;
this->setState(FACE) ;
return ;
}
}
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 );
else
{
while (this->getOrientationFace(current, this->getPosition(), this->d) == Geom::RIGHT
&& this->m.phi_1(this->d) != dd)
this->d = this->m.phi_1(this->d) ;
//in case of numerical incoherence
if(this->m.phi_1( this->d )==dd) {
this->d = this->m.phi_1( this->d );
do {
switch (getOrientationEdge(current,this->d)) {
case Geom::LEFT : this->d=this->m.phi1( this->d );
break;
case Geom::ALIGNED :this->m_position = current;
edgeState(current);
return;
default : this->m_position = intersectLineEdge(current, this->m_position,this->d);
if(!this->obstacle.isMarked(this->m.phi2( this->d )))
edgeState(current);
else
this->state = EDGE;
return;
if (this->m.phi_1(this->d) == dd)
{
this->d = this->m.phi_1(this->d) ;
do
{
switch (this->getOrientationEdge(current, this->d))
{
case Geom::LEFT :
this->d = this->m.phi1(this->d) ;
break ;
case Geom::ALIGNED :
this->ParticleBase<PFP>::move(current) ;
edgeState(current) ;
return ;
default :
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
if (!this->obstacle.isMarked(this->m.phi2(this->d)))
edgeState(current) ;
else
this->setState(EDGE) ;
return ;
}
} while(this->d!=dd);
} while (this->d != dd) ;
this->m_position = current;
this->state = FACE;
return;
this->ParticleBase<PFP>::move(current) ;
this->setState(FACE) ;
return ;
}
}
this->prevPos = this->m_position;
//displacement step
switch (getOrientationEdge(current,this->d)) {
case Geom::LEFT : this->m_position = current;
this->state = FACE;;
break;
case Geom::ALIGNED :this->m_position = current;
this->state = EDGE;
break;
default : this->m_position = intersectLineEdge(current, this->m_position,this->d);
if(!this->obstacle.isMarked(this->m.phi2( this->d )))
edgeState(current);
else
this->state = EDGE;
switch (this->getOrientationEdge(current, this->d))
{
case Geom::LEFT :
this->ParticleBase<PFP>::move(current) ;
this->setState(FACE) ;
;
break ;
case Geom::ALIGNED :
this->ParticleBase<PFP>::move(current) ;
this->setState(EDGE) ;
break ;
default :
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
if (!this->obstacle.isMarked(this->m.phi2(this->d)))
edgeState(current) ;
else
this->setState(EDGE) ;
}
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/