Commit a2215104 authored by Thomas Pitiot 's avatar Thomas Pitiot

la cata des enregistrements

parent e7780e3e
......@@ -125,10 +125,14 @@ public:
**************************************/
//////////////////// BASIC OPERATIONS ////////////////////////////////////////////////////////////////
template <typename T>
inline void addElementToVector(std::vector<T>& a, T ag)
inline bool addElementToVector(std::vector<T>& a, T ag)
{
assert(std::find(a.begin(), a.end(), ag) == a.end());
a.push_back(ag) ;
if(std::find(a.begin(), a.end(), ag) == a.end())
{
a.push_back(ag) ;
return true;
}
return false;
}
template <typename T>
......@@ -182,7 +186,7 @@ inline void EnvMap::FindNeighborCells (const std::vector<Dart>& belonging_cells,
if (!map.isBoundaryMarked<3>(d) && !memo_mark.isMarked(d) && !OneRingMark.isMarked(d) )
{
OneRingMark.mark(d);
(*neighbor_cells).push_back(d);
(*neighbor_cells).push_back(map.volumeOldestDart(d));
}
}
......
......@@ -11,7 +11,8 @@ void ArticulatedObject::addGeneralCell ( Dart d)
bool added = false;
for(std::pair<Dart,int> pere : general_belonging)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second ++;
added= true;
......@@ -31,7 +32,8 @@ bool ArticulatedObject::removeGeneralCell (Dart d)
{
for(std::pair<Dart,int> pere : general_belonging)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second--;
if(pere.second==0)
......@@ -52,7 +54,8 @@ void ArticulatedObject::addGeneralNeighbor ( Dart d)
bool added = false;
for(std::pair<Dart,int> pere : general_neighbors)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second ++;
added= true;
......@@ -72,7 +75,8 @@ bool ArticulatedObject::removeGeneralNeighbor (Dart d)
{
for(std::pair<Dart,int> pere : general_neighbors)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second--;
if(pere.second==0)
......
......@@ -317,7 +317,7 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
d=map.volumeOldestDart(d);
addElementToVector<Segment*>(RegisteredEdges[d],o);
mo->belonging_cells[n].push_back(d);
......@@ -354,26 +354,25 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
// assert( memo_cross.size() > 1);
ArticulatedObject * mo = o->nid;
mo->belonging_cells[n] = memo_cross;
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{
addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell ( (*it));
for (Dart d :memo_cross)
{
d=map.volumeOldestDart(d);
mo->belonging_cells[n].push_back(d);
addElementToVector(RegisteredEdges[d],o);
mo->addGeneralCell (d);
#ifdef DEBUG_affichage
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;
CGoGNout<<"cellule du belong :"<<(d)<<CGoGNendl;
#endif
}
FindNeighborCells(mo->belonging_cells[n], &(mo->neighbor_cells[n]));
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
for (Dart d : mo->neighbor_cells[n])
{
if (!map.isBoundaryMarked<3>(*it))
{
addElementToVector<Segment*>(RegisteredNeighborEdges[*it],o);
mo->addGeneralNeighbor ( (*it));
}
addElementToVector<Segment*>(RegisteredNeighborEdges[d],o);
mo->addGeneralNeighbor ( (d));
}
#ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
......@@ -398,18 +397,16 @@ void EnvMap::popSegment(Segment* o)
if (mo != NULL)
{
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
for (Dart d : mo->belonging_cells[n])
{
removeElementFromVector<Segment*>(RegisteredEdges[*it], o) ;
mo->removeGeneralCell (*it);
removeElementFromVector(RegisteredEdges[d], o) ;
mo->removeGeneralCell (d);
}
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
for (Dart d : mo->neighbor_cells[n])
{
if (!map.isBoundaryMarked<3>(*it))
{
removeElementFromVector<Segment*>(RegisteredNeighborEdges[*it], o) ;
mo->removeGeneralNeighbor (*it);
}
removeElementFromVector(RegisteredNeighborEdges[d], o) ;
mo->removeGeneralNeighbor (d);
}
mo->belonging_cells[n].clear();
mo->neighbor_cells[n].clear();
......@@ -456,6 +453,7 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle
for(Dart d : inside.get_markedCells()) // and register them
{
d=map.volumeOldestDart(d);
pushTriangleInCell(o,d);
(mo->belonging_cells[o->indexTri]).push_back(d);
mo->addGeneralCell ( d);
......@@ -463,6 +461,7 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle
markNeighbors(&inside,&neighbor,(mo->belonging_cells[o->indexTri])); // then mark neighbors
for(Dart d : neighbor.get_markedCells()) // and register them
{
d=map.volumeOldestDart(d);
pushTriangleInCellAsNeighbor(o,d);
(mo->neighbor_cells[o->indexTri]).push_back(d);
mo->addGeneralNeighbor ( d);
......@@ -523,18 +522,17 @@ void EnvMap::popTriangle(Triangle* o)
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
for (Dart d : mo->belonging_cells[n])
{
popTriangleInCell(o,*it);
mo->removeGeneralCell (*it);
popTriangleInCell(o,d);
mo->removeGeneralCell (d);
}
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
for (Dart d : mo->neighbor_cells[n])
{
if (!map.isBoundaryMarked<3>(*it))
{
popTriangleInCellAsNeighbor(o,*it);
mo->removeGeneralNeighbor (*it);
}
popTriangleInCellAsNeighbor(o,d);
mo->removeGeneralNeighbor (d);
}
mo->belonging_cells[n].clear();
mo->neighbor_cells[n].clear();
......@@ -604,11 +602,14 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
this->popSegment(o) ;
}
ARETES oldNeighborObst(RegisteredNeighborEdges[dglobal]) ;
ARETES oldNeighborObst(RegisteredNeighborEdges[old]) ;
for (Segment * o : oldNeighborObst)
{
this->popSegment(o) ;
// this->popSegment(o) ; // old version
removeElementFromVector(RegisteredNeighborEdges[old], o) ;
removeElementFromVector(o->nid->neighbor_cells[o->index],old);
o->nid->removeGeneralNeighbor (old);
}
TRIANGLES oldTrian(RegisteredTriangles[dglobal]) ;
......@@ -618,11 +619,15 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
this->popTriangle(o) ;
}
TRIANGLES oldTrianNeighbor(RegisteredNeighborTriangles[dglobal]) ;
TRIANGLES oldTrianNeighbor(RegisteredNeighborTriangles[old]) ;
for (Triangle * o : oldTrianNeighbor)
{
this->popTriangle(o) ;
// this->popTriangle(o) ; // old version
removeElementFromVector(RegisteredNeighborTriangles[old], o) ;
removeElementFromVector(o->surf->neighbor_cells[o->indexTri],old);
o->surf->removeGeneralNeighbor (old);
}
const std::chrono::time_point<std::chrono::system_clock> endPop = std::chrono::system_clock::now();
......@@ -641,12 +646,26 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
duration_subdiv = endSubdiv - startSubdiv;
if(duration_subdiv.count()>0.035)std::cout << "subdiv duration : " << duration_subdiv.count() << "s\n";
map.setCurrentLevel(vLevel+1);
CellMarkerMemo<MAP,VOLUME> newVolumes(map);
Dart start = old;
do // on marque les nouvelles cellules ! attention TODO cas des volumes qui n'ont aucune arete en commun avec le volume d'origine
{
map.setCurrentLevel(vLevel+1);
newVolumes.mark(start);
map.setCurrentLevel(vLevel);
start=map.phi1(start);
}while(start !=old);
map.setCurrentLevel(map.getMaxLevel()) ;
// map.check();
for (Dart d : volumesAdjacentByVertex3(map,(dglobal))) // parcours des sous cellules créees par la subdivision pour mettre a jour l'attribut facecenter a remplacer par un traverseur de sous cellules IHM
for (Dart d : newVolumes.get_markedCells())
{
for ( Face f : facesIncidentToVolume3(map,d))
for ( Face f : facesIncidentToVolume3(map,d)) // maj des attributs de face et volume de la carte
{
facecenter[f]=Algo::Surface::Geometry::faceCentroid<PFP, VertexAttribute<VEC3, MAP>>(map,f,position);
......@@ -654,15 +673,40 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
VEC3 center=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d,position);
color[d] = VEC3((center[0]-mapMinX)/(mapMaxX-mapMinX),(center[1]-mapMinY)/(mapMaxY-mapMinY),(center[2]-mapMinZ)/(mapMaxZ-mapMinZ));
// reenregistrement des voisins
for(Vol v : volumesAdjacentByVertex3(map,d))
{
if(!newVolumes.isMarked(v))
{
for(Segment * s : RegisteredEdges[v])
{
if(addElementToVector(RegisteredNeighborEdges[d],s))
{
s->nid->neighbor_cells[s->index].push_back(d);
}
}
for(Triangle * t : RegisteredTriangles[v])
{
if(addElementToVector(RegisteredNeighborTriangles[d],t))
{
t->surf->neighbor_cells[t->indexTri].push_back(d);
}
}
}
}
}
const std::chrono::time_point<std::chrono::system_clock> startPush = std::chrono::system_clock::now();
//same for adjacent triangles // optimiser
for (Triangle * o : oldTrianNeighbor)
{
this->FirstRegistrationTriangle(o) ;
}
// //same for adjacent triangles // optimiser
// for (Triangle * o : oldTrianNeighbor)
// {
//// this->FirstRegistrationTriangle(o) ; // old version
// }
//same for triangles // optimiser
......@@ -675,11 +719,11 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
const std::chrono::time_point<std::chrono::system_clock> endPushTriangle = std::chrono::system_clock::now();
//same for adjacent obstacles // optimiser
for (Segment * o : oldNeighborObst)
{
FirstRegistrationSegment(o) ;
}
// //same for adjacent obstacles // optimiser
// for (Segment * o : oldNeighborObst)
// {
//// FirstRegistrationSegment(o) ; // old version
// }
const std::chrono::time_point<std::chrono::system_clock> endPushSegmentNeighbors = std::chrono::system_clock::now();
//same for obstacles contained
......
......@@ -287,7 +287,8 @@ void Surface::addGeneralCell ( Dart d)
bool added = false;
for(std::pair<Dart,int> pere : general_belonging)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second ++;
added= true;
......@@ -307,7 +308,8 @@ bool Surface::removeGeneralCell (Dart d)
{
for(std::pair<Dart,int> pere : general_belonging)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second--;
if(pere.second==0)
......@@ -328,7 +330,8 @@ void Surface::addGeneralNeighbor ( Dart d)
bool added = false;
for(std::pair<Dart,int> pere : general_neighbors)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second ++;
added= true;
......@@ -348,7 +351,8 @@ bool Surface::removeGeneralNeighbor (Dart d)
{
for(std::pair<Dart,int> pere : general_neighbors)
{
if(sim_->envMap_.map.sameVolume(pere.first,d))
// if(sim_->envMap_.map.sameVolume(pere.first,d))
if(pere.first==d)
{
pere.second--;
if(pere.second==0)
......
......@@ -569,7 +569,8 @@ void Volusion::displayObj()
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
for (Surface * o : simul.surfaces)
{
for(unsigned int i =0;i<o->nbTriangles;i++)
unsigned int i=0;
// for(unsigned int i =0;i<o->nbTriangles;i++)
{
// m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
for(auto it = o->belonging_cells[i].begin(); it !=o->belonging_cells[i].end();++it)
......@@ -607,8 +608,10 @@ void Volusion::displayObj()
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
for (Surface * o : simul.surfaces)
{
for(unsigned int i =0;i<o->nbTriangles;i++)
unsigned int i=0;
// for(unsigned int i =0;i<o->nbTriangles;i++)
{
// m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
for(auto it = o->neighbor_cells[i].begin(); it !=o->neighbor_cells[i].end();++it)
{
......
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