Commit bc52f045 authored by Thomas Pitiot 's avatar Thomas Pitiot

changements subdivision, init en gros cube a subdiviser pour les tests de vertexstate des paticules

parent 5c811f0b
No preview for this file type
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
VEC3 mapMaxY; VEC3 mapMaxY;
VEC3 mapMinZ; VEC3 mapMinZ;
VEC3 mapMaxZ; VEC3 mapMaxZ;
bool subdivideVolume(Dart d); bool subdivideVolume(Dart d );
Dart getBelongingCell(const PFP::VEC3& pos); Dart getBelongingCell(const PFP::VEC3& pos);
......
...@@ -45,7 +45,7 @@ void EnvMap::init(int argc, char **argv) ...@@ -45,7 +45,7 @@ void EnvMap::init(int argc, char **argv)
int nb = 5; int nb = 1;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
...@@ -527,23 +527,56 @@ void EnvMap::popSegment(Segment* o) ...@@ -527,23 +527,56 @@ void EnvMap::popSegment(Segment* o)
bool EnvMap::subdivideVolume(Dart dglobal) bool EnvMap::subdivideVolume(Dart dglobal)
{ {
unsigned int max = map.getMaxLevel() ;
map.setCurrentLevel(max) ;
unsigned int vLevel = map.volumeLevel(dglobal);
Dart old = map.volumeOldestDart(dglobal);
// la subdivision ne doit pas mettre plus d'un level de différence entre des cellules adjacentes
// on commence donc par subdiviser les voisins qui ont trop de différence
Traversor3WF<typename PFP::MAP> traF(map, old);
for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
{
Dart nv = map.phi3(dit);
if(!map.isBoundaryMarked(3, nv))
if(map.volumeLevel(nv) == vLevel - 1)
subdivideVolume(nv);
}
// on commence ensuite a subdiviser
bool res =false; bool res =false;
#ifdef IHMap #ifdef IHMap
CGoGNout<<"debut refine"<<CGoGNendl; CGoGNout<<"debut refine"<<CGoGNendl;
unsigned int max = map.getMaxLevel() ;
map.setCurrentLevel(max) ; map.setCurrentLevel(max) ;
#ifdef DEBUG_affichage
std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << std::endl; std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << std::endl;
#endif
ARETES oldobst(RegisteredEdges[dglobal]) ; ARETES oldobst(RegisteredEdges[dglobal]) ;
for (Segment * o : oldobst)
{
#ifdef DEBUG_affichage
ArticulatedObject * mo = o->nid;
CGoGNout<<"pop obst inside (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
this->popSegment(o) ;
}
ARETES oldNeighborObst(RegisteredNeighborEdges[dglobal]) ; ARETES oldNeighborObst(RegisteredNeighborEdges[dglobal]) ;
for (Segment * s : oldobst) for (Segment * o : oldNeighborObst)
this->popSegment(s) ; {
for (Segment * s : oldNeighborObst) #ifdef DEBUG_affichage
this->popSegment(s) ; ArticulatedObject * mo = o->nid;
CGoGNout<<"pop obst voisin (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
this->popSegment(o) ;
}
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"tests pour subdivision"<< CGoGNendl; CGoGNout<<"tests pour subdivision"<< CGoGNendl;
#endif #endif
...@@ -552,32 +585,44 @@ bool EnvMap::subdivideVolume(Dart dglobal) ...@@ -552,32 +585,44 @@ bool EnvMap::subdivideVolume(Dart dglobal)
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"debut subdivision"<< CGoGNendl; CGoGNout<<"debut subdivision"<< CGoGNendl;
#endif #endif
Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position); Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position,false);
res=true; res=true;
} }
map.setCurrentLevel(map.getMaxLevel()) ; map.setCurrentLevel(map.getMaxLevel()) ;
map.check(); map.check();
#ifdef DEBUG_affichage
std::cout << "after level = "<< map.getMaxLevel() << std::endl; std::cout << "after level = "<< map.getMaxLevel() << std::endl;
#endif
//same for adjacent obstacles // optimiser //same for adjacent obstacles // optimiser
for (Segment * s : oldNeighborObst) for (Segment * o : oldNeighborObst)
{ {
FirstRegistrationSegment(s) ; #ifdef DEBUG_affichage
ArticulatedObject * mo = o->nid;
CGoGNout<<"reenregistrement obst voisin (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
FirstRegistrationSegment(o) ;
} }
//same for obstacles contained //same for obstacles contained
for (Segment * s : oldobst) for (Segment * o : oldobst)
{ {
// CGoGNout<<"reseting Obstacles"<<CGoGNendl; #ifdef DEBUG_affichage
resetPartSubdiv(s); ArticulatedObject * mo = o->nid;
FirstRegistrationSegment(s); CGoGNout<<"reenregistrement obst inside (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
resetPartSubdiv(o);
FirstRegistrationSegment(o);
} }
CGoGNout<<"fin refine"<<CGoGNendl; CGoGNout<<"fin refine principal"<<CGoGNendl;
#endif #endif
return res; return res;
......
...@@ -260,10 +260,12 @@ void Needle::refine() ...@@ -260,10 +260,12 @@ void Needle::refine()
Dart volume = parts_[0]->d; Dart volume = parts_[0]->d;
volume = sim_->envMap_.map.volumeOldestDart(volume); volume = sim_->envMap_.map.volumeOldestDart(volume);
PFP::VEC3 edge = Algo::Surface::Geometry::vectorOutOfDart<PFP>(sim_->envMap_.map, volume, sim_->envMap_.position) ; PFP::VEC3 edge = Algo::Surface::Geometry::vectorOutOfDart<PFP>(sim_->envMap_.map, volume, sim_->envMap_.position) ;
if(edge.norm2() > 1.0f ) if(edge.norm2() > 2.0f )
{ {
if(sim_->envMap_.subdivideVolume(volume)) if(sim_->envMap_.subdivideVolume(volume))
refine(); {
// refine();
}
} }
......
...@@ -55,35 +55,35 @@ void Simulator::initFixedObjects() ...@@ -55,35 +55,35 @@ void Simulator::initFixedObjects()
p.second=envMap_.getBelongingCell(pos); p.second=envMap_.getBelongingCell(pos);
startingPoints.push_back(p); startingPoints.push_back(p);
// pos=VEC3(4,-2,3); pos=VEC3(4,-2,3);
// p.first=pos; p.first=pos;
// p.second=envMap_.getBelongingCell(pos); p.second=envMap_.getBelongingCell(pos);
// startingPoints.push_back(p); startingPoints.push_back(p);
// pos=VEC3(1,-1,1); pos=VEC3(1,-1,1);
// p.first=pos; p.first=pos;
// p.second=envMap_.getBelongingCell(pos); p.second=envMap_.getBelongingCell(pos);
// startingPoints.push_back(p); startingPoints.push_back(p);
// pos=VEC3(2,-2.5f,0.5f); pos=VEC3(2,-2.5f,0.5f);
// p.first=pos; p.first=pos;
// p.second=envMap_.getBelongingCell(pos); p.second=envMap_.getBelongingCell(pos);
// startingPoints.push_back(p); startingPoints.push_back(p);
ind.first=0; ind.first=0;
ind.second=1; ind.second=1;
segmentParts.push_back(ind); segmentParts.push_back(ind);
// ind.first=2; ind.first=2;
// ind.second=3; ind.second=3;
// segmentParts.push_back(ind); segmentParts.push_back(ind);
// ind.first=0; ind.first=0;
// ind.second=2; ind.second=2;
// segmentParts.push_back(ind); segmentParts.push_back(ind);
// ind.first=0; ind.first=0;
// ind.second=4; ind.second=4;
// segmentParts.push_back(ind); segmentParts.push_back(ind);
ArticulatedObject * obj = new Tree(this,startingPoints,segmentParts); ArticulatedObject * obj = new Tree(this,startingPoints,segmentParts);
......
...@@ -311,11 +311,11 @@ void Volusion::cb_redraw() ...@@ -311,11 +311,11 @@ void Volusion::cb_redraw()
for(auto particule : simul.aiguille->parts_) for(auto particule : simul.aiguille->parts_)
{ {
VEC3 p = particule->getPosition(); VEC3 p = particule->getPosition();
if(i==0) // if(i==0)
{ // {
m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f); // m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f);
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); // m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
} // }
data[i] = p; data[i] = p;
i++; i++;
} }
......
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