Commit 8828ff4e authored by pitiot's avatar pitiot
Browse files

ajout cellmarkermemo

parent 4b06724c
...@@ -96,6 +96,19 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& goal) ...@@ -96,6 +96,19 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& goal)
} }
else else
{ {
//checking : case with 3 orthogonal darts and point on an edge
do
{
if(Algo::Geometry::isPointOnHalfEdge<PFP>(m,d,positionAttribut,goal)
&& Algo::Geometry::isPointOnHalfEdge<PFP>(m,this->m.phi2(d),positionAttribut,goal))
{
edgeState(goal) ;
return;
}
this->d = this->m.phi2_1(this->d) ;
} while (this->getOrientationEdge(goal, this->m.phi2_1(this->d)) != Geom::RIGHT && dd_vert != this->d) ;
this->setState(VERTEX) ; this->setState(VERTEX) ;
this->ParticleBase < PFP > ::move(goal) ; this->ParticleBase < PFP > ::move(goal) ;
return ; return ;
......
#ifndef PARTCELL2DMEMO_H #ifndef PARTCELL2DMEMO_H
#define PARTCELL2DMEMO_H #define PARTCELL2DMEMO_H
#define DEBUG
#include "particle_cell_2D.h" #include "particle_cell_2D.h"
#include "Algo/Geometry/inclusion.h" #include "Algo/Geometry/inclusion.h"
...@@ -29,34 +29,27 @@ public: ...@@ -29,34 +29,27 @@ public:
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS ; typedef VertexAttribute<typename PFP::VEC3> TAB_POS ;
std::list<Dart> memo_cross ;
bool detect_vertex ;
bool detect_edge ;
bool detect_face ;
private: private:
ParticleCell2DMemo() : ParticleCell2DMemo(){
detect_vertex(false), detect_edge(false), detect_face(true)
{
} }
public: public:
ParticleCell2DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) : ParticleCell2DMemo(MAP& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
ParticleCell2D<PFP>(map, belonging_cell, pos, tabPos), ParticleCell2D<PFP>(map, belonging_cell, pos, tabPos)
detect_vertex(false),
detect_edge(false),
detect_face(true)
{ {
} }
void vertexState(const VEC3& current) ; void vertexState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross) ;
void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ; void edgeState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
void faceState(const VEC3& current) ; void faceState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross) ;
void move(const VEC3& goal) ; void move(const VEC3& goal, CellMarkerMemo<FACE> * memo_cross) ;
std::vector<Dart> get_memo(const VEC3& goal);
} ; } ;
#include "particle_cell_2D_memo.hpp" #include "particle_cell_2D_memo.hpp"
......
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::move(const VEC3& goal) void ParticleCell2DMemo<PFP>::move(const VEC3& goal, CellMarkerMemo<FACE> * memo_cross)
{ {
this->crossCell = NO_CROSS ; this->crossCell = NO_CROSS ;
if (!Geom::arePointsEquals(goal, this->getPosition())) if (!Geom::arePointsEquals(goal, this->getPosition()))
...@@ -7,13 +7,13 @@ void ParticleCell2DMemo<PFP>::move(const VEC3& goal) ...@@ -7,13 +7,13 @@ void ParticleCell2DMemo<PFP>::move(const VEC3& goal)
switch (this->getState()) switch (this->getState())
{ {
case VERTEX : case VERTEX :
vertexState(goal) ; vertexState(goal,memo_cross) ;
break ; break ;
case EDGE : case EDGE :
edgeState(goal) ; edgeState(goal,memo_cross) ;
break ; break ;
case FACE : case FACE :
faceState(goal) ; faceState(goal,memo_cross) ;
break ; break ;
} }
} }
...@@ -22,13 +22,22 @@ void ParticleCell2DMemo<PFP>::move(const VEC3& goal) ...@@ -22,13 +22,22 @@ void ParticleCell2DMemo<PFP>::move(const VEC3& goal)
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current) std::vector<Dart> ParticleCell2DMemo<PFP>::get_memo(const VEC3& goal)
{
CellMarkerMemo<FACE> memo_cross(this->m);
memo_cross.mark(this->d);
this->move(goal,&memo_cross);
return memo_cross.get_markedCells();
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "vertexState" << d << CGoGNendl ; CGoGNout << "vertexState" << d << CGoGNendl ;
#endif #endif
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ; assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
(*memo_cross).mark(this->d);
this->crossCell = CROSS_OTHER ; this->crossCell = CROSS_OTHER ;
if (Algo::Geometry::isPointOnVertex < PFP > (this->m, this->d, this->positionAttribut, current)) if (Algo::Geometry::isPointOnVertex < PFP > (this->m, this->d, this->positionAttribut, current))
...@@ -40,34 +49,41 @@ void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current) ...@@ -40,34 +49,41 @@ void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current)
else else
{ {
//orientation step //orientation step
if (this->positionAttribut[this->d][0] == this->positionAttribut[this->m.phi1(this->d)][0] if (this->positionAttribut[this->d][0] == this->positionAttribut[this->m.phi1(this->d)][0] && this->positionAttribut[this->d][1] == this->positionAttribut[this->m.phi1(this->d)][1])
&& this->positionAttribut[this->d][1] this->d = this->m.phi2_1(this->d) ;
== this->positionAttribut[this->m.phi1(this->d)][1]) this->d = this->m.phi2_1(
this->d) ;
if (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT) if (this->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) ; this->d = this->m.phi2_1(this->d) ;
if (this->positionAttribut[this->d][0] if (this->positionAttribut[this->d][0] == this->positionAttribut[this->m.phi1(this->d)][0]
== this->positionAttribut[this->m.phi1(this->d)][0] && this->positionAttribut[this->d][1]== this->positionAttribut[this->m.phi1(this->d)][1])
&& this->positionAttribut[this->d][1] this->d = this->m.phi2_1(this->d) ;
== this->positionAttribut[this->m.phi1(this->d)][1]) this->d = this->m.phi2_1(this->d) ; } while (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT && dd_vert != this->d) ;
} while (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT
&& dd_vert != this->d) ;
if (dd_vert == this->d) if (dd_vert == this->d)
{ {
//orbit with 2 edges : point on one edge //orbit with 2 edges : point on one edge
if (this->m.phi2_1(this->m.phi2_1(this->d)) == this->d) if (this->m.phi2_1(this->m.phi2_1(this->d)) == this->d)
{ {
if (!Algo::Geometry::isPointOnHalfEdge < PFP if (!Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->d, this->positionAttribut, current))
> (this->m, this->d, this->positionAttribut, current)) this->d = this->m.phi2_1( this->d = this->m.phi2_1(this->d) ;
this->d) ;
} }
else else
{ {
//checking : case with 3 orthogonal darts and point on an edge
do
{
if(Algo::Geometry::isPointOnHalfEdge<PFP>(this->m,this->d,this->positionAttribut,current)
&& Algo::Geometry::isPointOnHalfEdge<PFP>(this->m,this->m.phi2(this->d),this->positionAttribut,current))
{
this->edgeState(current,memo_cross) ;
return;
}
this->d = this->m.phi2_1(this->d) ;
} while (this->getOrientationEdge(current, this->m.phi2_1(this->d)) != Geom::RIGHT && dd_vert != this->d) ;
this->ParticleBase<PFP>::move(current) ; this->ParticleBase<PFP>::move(current) ;
this->setState(VERTEX) ; this->setState(VERTEX) ;
return ; return ;
...@@ -80,38 +96,34 @@ void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current) ...@@ -80,38 +96,34 @@ void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current)
while (this->getOrientationEdge(current, this->d) == Geom::RIGHT && dd_vert != this->d) while (this->getOrientationEdge(current, this->d) == Geom::RIGHT && dd_vert != this->d)
{ {
this->d = this->m.phi12(this->d) ; this->d = this->m.phi12(this->d) ;
if (this->positionAttribut[this->d][0] if (this->positionAttribut[this->d][0] == this->positionAttribut[this->m.phi1(this->d)][0]
== this->positionAttribut[this->m.phi1(this->d)][0] && this->positionAttribut[this->d][1] == this->positionAttribut[this->m.phi1(this->d)][1])
&& this->positionAttribut[this->d][1] this->d = this->m.phi12(this->d) ;
== this->positionAttribut[this->m.phi1(this->d)][1]) this->d = this->m.phi12(
this->d) ;
} }
} }
//displacement step //displacement step
if (detect_vertex) memo_cross.push_back(this->d) ;
if (this->getOrientationEdge(current, this->d) == Geom::ALIGNED if (this->getOrientationEdge(current, this->d) == Geom::ALIGNED
&& Algo::Geometry::isPointOnHalfEdge < PFP && Algo::Geometry::isPointOnHalfEdge<PFP>(this->m, this->d, this->positionAttribut, current))
> (this->m, this->d, this->positionAttribut, current)) edgeState(current,memo_cross) ;
edgeState(current) ;
else else
{ {
this->d = this->m.phi1(this->d) ; this->d = this->m.phi1(this->d) ;
faceState(current) ; faceState(current,memo_cross) ;
} }
} }
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge) void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<FACE>* memo_cross, Geom::Orientation2D sideOfEdge)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "edgeState" << d << CGoGNendl ; CGoGNout << "edgeState" << d << CGoGNendl ;
#endif #endif
if (detect_edge) memo_cross.push_back(this->d) ;
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ; assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
// assert(Algo::Geometry::isPointOnEdge<PFP>(m,d,m_positions,m_position)); // assert(Algo::Geometry::isPointOnEdge<PFP>(m,d,m_positions,m_position));
(*memo_cross).mark(this->d);
if (this->crossCell == NO_CROSS) if (this->crossCell == NO_CROSS)
{ {
this->crossCell = CROSS_EDGE ; this->crossCell = CROSS_EDGE ;
...@@ -126,11 +138,11 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D ...@@ -126,11 +138,11 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D
{ {
case Geom::LEFT : case Geom::LEFT :
this->d = this->m.phi1(this->d) ; this->d = this->m.phi1(this->d) ;
faceState(current) ; faceState(current,memo_cross) ;
return ; return ;
case Geom::RIGHT : case Geom::RIGHT :
this->d = this->m.phi1(this->m.phi2(this->d)) ; this->d = this->m.phi1(this->m.phi2(this->d)) ;
faceState(current) ; faceState(current,memo_cross) ;
return ; return ;
default : default :
this->setState(EDGE) ; this->setState(EDGE) ;
...@@ -141,7 +153,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D ...@@ -141,7 +153,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D
> (this->m, this->d, this->positionAttribut, current)) > (this->m, this->d, this->positionAttribut, current))
{ {
this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ; this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ;
vertexState(current) ; vertexState(current,memo_cross) ;
return ; return ;
} }
else if (!Algo::Geometry::isPointOnHalfEdge < PFP else if (!Algo::Geometry::isPointOnHalfEdge < PFP
...@@ -149,7 +161,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D ...@@ -149,7 +161,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D
{ {
this->d = this->m.phi2(this->d) ; this->d = this->m.phi2(this->d) ;
this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ; this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ;
vertexState(current) ; vertexState(current,memo_cross) ;
return ; return ;
} }
...@@ -157,18 +169,18 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D ...@@ -157,18 +169,18 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, Geom::Orientation2D
} }
template <typename PFP> template <typename PFP>
void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) void ParticleCell2DMemo<PFP>::faceState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross)
{ {
#ifdef DEBUG #ifdef DEBUG
CGoGNout << "faceState" << d << CGoGNendl ; CGoGNout << "faceState" << d << CGoGNendl ;
#endif #endif
if (detect_face) memo_cross.push_back(this->d) ;
assert( assert(
std::isfinite(this->getPosition()[0]) && std::isfinite(this->getPosition()[1]) std::isfinite(this->getPosition()[0]) && std::isfinite(this->getPosition()[1])
&& std::isfinite(this->getPosition()[2])) ; && std::isfinite(this->getPosition()[2])) ;
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ; assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
// assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true)); // assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true));
(*memo_cross).mark(this->d);
Dart dd = this->d ; Dart dd = this->d ;
float wsoe = this->getOrientationFace(current, this->m.phi1(this->d)) ; float wsoe = this->getOrientationFace(current, this->m.phi1(this->d)) ;
...@@ -195,16 +207,16 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) ...@@ -195,16 +207,16 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
break ; break ;
case Geom::ALIGNED : case Geom::ALIGNED :
this->ParticleBase<PFP>::move(current) ; this->ParticleBase<PFP>::move(current) ;
edgeState(current) ; edgeState(current,memo_cross) ;
return ; return ;
case Geom::RIGHT : case Geom::RIGHT :
// CGoGNout << "smthg went bad " << m_position << " " << current << CGoGNendl; // CGoGNout << "smthg went bad " << m_position << " " << current << CGoGNendl;
// CGoGNout << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi1(d)] << CGoGNendl; // CGoGNout << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi1(d)] << CGoGNendl;
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ; this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
// CGoGNout << " " << m_position << CGoGNendl; // CGoGNout << " " << m_position << CGoGNendl;
edgeState(current, Geom::RIGHT) ; edgeState(current,memo_cross, Geom::RIGHT) ;
return ; return ;
} }
} while (this->d != dd) ; } while (this->d != dd) ;
this->ParticleBase<PFP>::move(current); this->ParticleBase<PFP>::move(current);
...@@ -245,13 +257,13 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) ...@@ -245,13 +257,13 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
case Geom::ALIGNED : case Geom::ALIGNED :
// CGoGNout << "pic" << CGoGNendl; // CGoGNout << "pic" << CGoGNendl;
this->ParticleBase<PFP>::move(current) ; this->ParticleBase<PFP>::move(current) ;
edgeState(current) ; edgeState(current,memo_cross) ;
return ; return ;
case Geom::RIGHT : case Geom::RIGHT :
// CGoGNout << "smthg went bad(2) " << m_position << CGoGNendl; // CGoGNout << "smthg went bad(2) " << m_position << CGoGNendl;
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ; this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
// CGoGNout << " " << m_position << CGoGNendl; // CGoGNout << " " << m_position << CGoGNendl;
edgeState(current, Geom::RIGHT) ; edgeState(current,memo_cross ,Geom::RIGHT) ;
return ; return ;
} }
} while (this->d != dd) ; } while (this->d != dd) ;
...@@ -287,12 +299,12 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current) ...@@ -287,12 +299,12 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current)
this->d = this->m.phi1(this->d) ; //to check this->d = this->m.phi1(this->d) ; //to check
this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ; this->ParticleBase<PFP>::move(this->positionAttribut[this->d]) ;
vertexState(current) ; vertexState(current,memo_cross) ;
} }
else else
{ {
this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ; this->ParticleBase<PFP>::move(this->intersectLineEdge(current, this->getPosition(), this->d)) ;
edgeState(current, Geom::RIGHT) ; edgeState(current,memo_cross, Geom::RIGHT) ;
} }
} }
......
...@@ -307,7 +307,55 @@ public: ...@@ -307,7 +307,55 @@ public:
this->m_markVector->operator[](*it).unsetMark(this->m_mark) ; this->m_markVector->operator[](*it).unsetMark(this->m_mark) ;
} }
}; };
/**
* class that allows the marking of Darts
* the marked Darts are stored to optimize the unmarking task at destruction
* \warning no default constructor
*/
template <unsigned int CELL>
class CellMarkerMemo: public CellMarkerBase<CELL>
{
protected:
std::vector<Dart> m_markedDarts ;
public:
CellMarkerMemo(GenericMap& map, unsigned int thread = 0) : CellMarkerBase<CELL>(map, thread)
{}
virtual ~CellMarkerMemo()
{
unmarkAll() ;
// assert(isAllUnmarked);
CGoGN_ASSERT(this->isAllUnmarked())
}
protected:
CellMarkerMemo(const CellMarkerMemo& cm) : CellMarkerBase<CELL>(cm)
{}
public:
void mark(Dart d)
{
if(!this->isMarked(d))
{
CellMarkerBase<CELL>::mark(d) ;
m_markedDarts.push_back(d) ;
}
}
void unmarkAll()
{
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL);
for (std::vector<Dart>::iterator it = m_markedDarts.begin(); it != m_markedDarts.end(); ++it)
this->m_markVector->operator[](this->m_map.template getEmbedding<CELL>(*it)).unsetMark(this->m_mark) ;
}
std::vector<Dart> get_markedCells()
{
return m_markedDarts;
}
};
/** /**
* class that allows the marking of cells * class that allows the marking of cells
* the markers are not unmarked at destruction * the markers are not unmarked at destruction
......
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