Commit 9a66c2b7 authored by Thomas Pitiot 's avatar Thomas Pitiot

correction aprticules 3D

parent 7354a84f
......@@ -44,8 +44,8 @@ public :
MAP& m;
const TAB_POS& position;
const TAB_FACE& face_center;
const TAB_VOL& volume_center;
const TAB_FACE* face_center;
const TAB_VOL* volume_center;
......@@ -58,15 +58,15 @@ public :
ParticleCell3D(MAP& map) : m(map)
{}
ParticleCell3D(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos,const TAB_FACE& fa_center = NULL,
const TAB_VOL& vol_center=NULL) :
ParticleCell3D(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos,const TAB_FACE * fa_center = nullptr,
const TAB_VOL * vol_center=nullptr) :
Algo::MovingObjects::ParticleBase<PFP>(pos),
m(map),
position(tabPos),
d(belonging_cell)
d(belonging_cell),
volume_center(vol_center),
face_center(fa_center)
{
if(vol_center) volume_center(vol_center);
if(fa_center) face_center(fa_center);
reset_positionFace();
reset_positionVolume();
this->setState(VOLUME);
......
......@@ -22,7 +22,7 @@
* *
*******************************************************************************/
#define DEBUG
// #define DEBUG
namespace CGoGN
{
......@@ -49,15 +49,30 @@ void ParticleCell3D<PFP>::display()
template <typename PFP>
void ParticleCell3D<PFP>:: reset_positionFace()
{
this->m_positionFace=Algo::Surface::Geometry::faceCentroid<PFP>(m,d,position);
if(this->face_center)
{
this->m_positionFace=(*face_center)[d];
}
else
{
this->m_positionFace=Algo::Surface::Geometry::faceCentroid<PFP>(m,d,position);
}
}
template <typename PFP>
void ParticleCell3D<PFP>:: reset_positionVolume()
{
this->m_positionVolume=Algo::Surface::Geometry::volumeCentroid<PFP>(m,d,position);
}
if(this->volume_center)
{
this->m_positionVolume=(*volume_center)[d];
}
else
{
this->m_positionVolume=Algo::Surface::Geometry::volumeCentroid<PFP>(m,d,position);
}
}
template <typename PFP>
inline Geom::Orientation3D ParticleCell3D<PFP>::isLeftENextVertex(const VEC3& c, Dart d, const VEC3& base)
{
......@@ -83,6 +98,9 @@ inline Geom::Orientation3D ParticleCell3D<PFP>::whichSideOfFace(const VEC3& c, D
template <typename PFP>
Geom::Orientation3D ParticleCell3D<PFP>::whichSideOfPlanVolume(const VEC3& c, Dart d, const VEC3& base, const VEC3& top)
{
#ifdef DEBUG
std::cout << "Test side of plan in volume (obj,d,position[d],positionFace,positionVolume, test)" <<c<<" || "<<d<<" || "<<position[d]<<" || "<<base<<" || "<<top<<" || "<<Geom::Plane3D<typename PFP::REAL>(top, position[d], base).orient(c)<< std::endl;
#endif
return Geom::Plane3D<typename PFP::REAL>(top, position[d], base).orient(c);
}
......@@ -636,29 +654,30 @@ void ParticleCell3D<PFP>::placeOnRightFaceAndRightEdge(const VEC3& current,bool
switch(whichSideOfPlanVolume(current,d,this->m_positionFace,this->m_positionVolume))
{
case Geom::OVER :
case Geom::UNDER :
aDroite=true; if(!aGauche)d=m.phi1(d);
break;
case Geom::UNDER :
case Geom::OVER :
aGauche=true;d=m.phi_1(d);
break;
case Geom::ON : aGauche=true;
aDroite=true;
*casON=true;
case Geom::ON : if(aGauche ||aDroite)//si on est ON des le debut on ne peut pas etre sur de la face
*casON=true;
else // donc on tourne dans une direction pour donner un nouveau départ
d=m.phi1(d);
break;
default : CGoGNout<<"erreur detection orientation"<<__LINE__<<__FILE__<<CGoGNendl; break;
}
} while ((!aDroite||!aGauche)&&d!=dd&&!*casON);
switch(whichSideOfPlanVolume(current,m.phi1(d),position[d],this->m_positionVolume))
switch(whichSideOfPlanVolume(current,m.phi1(d),position[d],this->m_positionVolume)) // ensuite on teste par rapport au plan defini par le centre du volume et l'arete visée
{
case Geom::OVER : d=m.phi2(d);
case Geom::OVER : d=m.phi2(d); // si on est au dessus on change de face
reset_positionFace();
palceOnRightFaceAndRightEdge(current,casON,enDessous);
placeOnRightFaceAndRightEdge(current,casON,enDessous);
return;
case Geom::UNDER :*enDessous=true;
case Geom::UNDER :*enDessous=true; // si on est en dessous on l'indique
break;
case Geom::ON :
case Geom::ON : // si on c'est qu'on aura pas enDessous a vrai
break;
default : CGoGNout<<"erreur detection orientation"<<__LINE__<<__FILE__<<CGoGNendl; break;
......@@ -680,7 +699,7 @@ void ParticleCell3D<PFP>::volumeState(const VEC3& current)
placeOnRightFaceAndRightEdge(current,&casON,&enDessous);
Geom::Orientation3D wsof =whichSideOfFace(current,d);
switch (wsof) {
case Geom::OVER :
case Geom::UNDER :
this->m_position = current;
this->setState(VOLUME);
break;
......
......@@ -29,12 +29,15 @@ template <typename PFP>
class ParticleCell3DMemo : public Algo::Volume::MovingObjects::ParticleCell3D<PFP>
{
public :
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<VEC3, MAP> TAB_POS;
ParticleCell3DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleCell3D<PFP>(map, belonging_cell, pos, tabPos)
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<VEC3, MAP> TAB_POS;
typedef FaceAttribute<VEC3,MAP> TAB_FACE;
typedef VolumeAttribute<VEC3,MAP> TAB_VOL;
ParticleCell3DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos,const TAB_FACE * fa_center = nullptr,
const TAB_VOL * vol_center=nullptr) :
ParticleCell3D<PFP>(map, belonging_cell, pos, tabPos,fa_center,vol_center)
{
}
......
......@@ -293,7 +293,7 @@ void ParticleCell3DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<MAP,
#endif
if(!memo_cross.isMarked(this->d)) memo_cross.mark(this->d);
this->crossCell = CROSS_FACE ;
this->m_positionFace = this->pointInFace(this->d);
if(wsof==Geom::ON)
wsof = this->whichSideOfFace(current,this->d);
......@@ -414,7 +414,7 @@ void ParticleCell3DMemo<PFP>::volumeState(const VEC3& current, CellMarkerMemo<MA
this->placeOnRightFaceAndRightEdge(current,&casON,&enDessous);
Geom::Orientation3D wsof =this->whichSideOfFace(current,this->d);
switch (wsof) {
case Geom::OVER :
case Geom::UNDER :
this->m_position = current;
this->setState(VOLUME);
break;
......@@ -437,7 +437,7 @@ void ParticleCell3DMemo<PFP>::volumeState(const VEC3& current, CellMarkerMemo<MA
}
return;
default : // under l'obj est de l'autre coté de la face
default : // over l'obj est de l'autre coté de la face
Algo::Surface::Geometry::intersectionLineConvexFace<PFP>(this->m,this->d,this->position,this->m_position,current-this->m_position,this->m_position);
if(enDessous)
{
......
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