Commit 9d618d97 authored by Etienne Schmitt's avatar Etienne Schmitt

Merge branch 'develop' of icube-forge.unistra.fr:pitiot/volusion into develop

# Conflicts:
#	include/env_map.h
#	src/env_map.cpp
Signed-off-by: Etienne Schmitt's avatarÉtienne Schmitt <etienne.schmitt@inria.fr>
parents e3b6c3f3 a2215104
......@@ -181,7 +181,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));
}
}
......
......@@ -39,7 +39,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;
......@@ -59,7 +60,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)
......@@ -80,7 +82,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;
......@@ -100,7 +103,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)
......
......@@ -270,7 +270,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en
if (mo != NULL)
{
int n1 = o->indexPart1;
int n2 = o->indexPart2;
// int n2 = o->indexPart2;
#ifdef DEBUG_affichage
CGoGNout<<"First Registration arete "<<o->index<<CGoGNendl;
#endif
......@@ -278,7 +278,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en
VEC3 p2 = o->p2;
Dart d1=mo->parts_[n1]->d;
Dart d2=mo->parts_[n2]->d;
// Dart d2=mo->parts_[n2]->d;
std::vector<Dart> memo;
......@@ -318,7 +318,7 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
d=map.volumeOldestDart(d);
addElementToVector(RegisteredEdges[d],o);
mo->belonging_cells[n].push_back(d);
......@@ -355,26 +355,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(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)
{
if (!map.isBoundaryMarked<3>(*it))
for (Dart d : mo->neighbor_cells[n])
{
addElementToVector(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;
......@@ -399,18 +398,16 @@ void EnvMap::popSegment(Segment* o)
if (mo != NULL)
{
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(), end = mo->belonging_cells[n].end() ; it != end ; ++it)
for (Dart d : mo->belonging_cells[n])
{
removeElementFromVector(RegisteredEdges[*it], o) ;
mo->removeGeneralCell (*it);
removeElementFromVector(RegisteredEdges[d], o) ;
mo->removeGeneralCell (d);
}
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(), end = mo->neighbor_cells[n].end() ; it != end ; ++it)
{
if (!map.isBoundaryMarked<3>(*it))
for (Dart d : mo->neighbor_cells[n])
{
removeElementFromVector(RegisteredNeighborEdges[*it], o) ;
mo->removeGeneralNeighbor (*it);
}
removeElementFromVector(RegisteredNeighborEdges[d], o) ;
mo->removeGeneralNeighbor (d);
}
mo->belonging_cells[n].clear();
mo->neighbor_cells[n].clear();
......@@ -457,6 +454,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);
......@@ -464,6 +462,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);
......@@ -524,18 +523,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)
{
if (!map.isBoundaryMarked<3>(*it))
for (Dart d : mo->neighbor_cells[n])
{
popTriangleInCellAsNeighbor(o,*it);
mo->removeGeneralNeighbor (*it);
}
popTriangleInCellAsNeighbor(o,d);
mo->removeGeneralNeighbor (d);
}
mo->belonging_cells[n].clear();
mo->neighbor_cells[n].clear();
......@@ -605,11 +603,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]) ;
......@@ -619,16 +620,20 @@ 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();
duration_pop = endPop - startPop;
std::cout << "pop duration : " << duration_pop.count() << "s\n";
if(duration_pop.count()>0.035)std::cout << "pop duration : " << duration_pop.count() << "s\n";
const std::chrono::time_point<std::chrono::system_clock> startSubdiv = std::chrono::system_clock::now();
......@@ -640,14 +645,28 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
const std::chrono::time_point<std::chrono::system_clock> endSubdiv = std::chrono::system_clock::now();
duration_subdiv = endSubdiv - startSubdiv;
std::cout << "subdiv duration : " << duration_subdiv.count() << "s\n";
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);
......@@ -655,15 +674,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
......@@ -676,11 +720,13 @@ 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
for (Segment * o : oldobst)
{
......@@ -691,8 +737,11 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
const std::chrono::time_point<std::chrono::system_clock> endPush = std::chrono::system_clock::now();
duration_push = endPush - startPush;
std::cout << "push triangle duration : " << std::chrono::duration<double> (endPushTriangle - startPush).count() << "s\n";
std::cout << "push duration : " << duration_push.count() << "s\n";
std::chrono::duration<double> duration_triangle= (endPushTriangle - startPush);
std::chrono::duration<double> duration_segment= (endPush - endPushSegmentNeighbors);
std::chrono::duration<double> duration_segmentNeighbor= (endPushSegmentNeighbors - endPushTriangle);
if(duration_triangle.count()>0.035)std::cout << "push triangle duration : " << duration_triangle.count() << "s\n";
if(duration_push.count()>0.035)std::cout << "push duration : " << duration_push.count() << "\n dont pour les segments présents : "<<duration_segment.count() <<"s\n et pour les voisins :"<<duration_segmentNeighbor.count() <<"s\n";
#endif
......
......@@ -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