Commit d648ed89 authored by pitiot's avatar pitiot

up

parent a745baa5
No preview for this file type
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#define ENV_MAP_H #define ENV_MAP_H
#define DEBUG_affichage
//#define DEBUG
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
...@@ -26,8 +28,6 @@ ...@@ -26,8 +28,6 @@
//#include "Algo/ImplicitHierarchicalMesh/subdivision3.hxx" //#include "Algo/ImplicitHierarchicalMesh/subdivision3.hxx"
//#define DEBUG_affichage
//#define DEBUG
/////////////////particules /////////////////particules
#include "Algo/MovingObjects/particle_cell_3D_memo.h" #include "Algo/MovingObjects/particle_cell_3D_memo.h"
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
void pushSegmentInCellAsNeighbor(Segment* o, Dart d); void pushSegmentInCellAsNeighbor(Segment* o, Dart d);
void popSegmentInCellAsNeighbor(Segment* o, Dart d); void popSegmentInCellAsNeighbor(Segment* o, Dart d);
void resetPartSubdiv(Segment* o);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -149,6 +149,7 @@ protected: ...@@ -149,6 +149,7 @@ protected:
void cb_mouseMove(int buttons, int x, int y); void cb_mouseMove(int buttons, int x, int y);
void cb_mousePress(int button, int x, int y); void cb_mousePress(int button, int x, int y);
void cb_mouseRelease(int button, int x, int y); void cb_mouseRelease(int button, int x, int y);
void cb_keyPress(int code);
void cb_Open(); void cb_Open();
void animate() ; void animate() ;
......
...@@ -136,23 +136,6 @@ void EnvMap::init(int argc, char **argv) ...@@ -136,23 +136,6 @@ void EnvMap::init(int argc, char **argv)
} }
void EnvMap::subdivideVolume(Dart dglobal)
{
unsigned int max = map.getMaxLevel() ;
map.setCurrentLevel(max) ;
std::cout << "dglobal = " << dglobal << std::endl;
if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= max && !map.volumeIsSubdivided(dglobal))
Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position);
map.setCurrentLevel(map.getMaxLevel()) ;
CGoGNout << "current level : " << map.getCurrentLevel() << CGoGNendl;
}
VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face) // renvoie la normale a la face pointant vers l'extérieur du volume VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face) // renvoie la normale a la face pointant vers l'extérieur du volume
{ {
...@@ -401,7 +384,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en ...@@ -401,7 +384,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en
int n1 = o->indexPart1; int n1 = o->indexPart1;
int n2 = o->indexPart2; int n2 = o->indexPart2;
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"First Registration arete "<<n<<CGoGNendl; CGoGNout<<"First Registration arete "<<o->index<<CGoGNendl;
#endif #endif
VEC3 p1 = o->p1; VEC3 p1 = o->p1;
VEC3 p2 = o->p2; VEC3 p2 = o->p2;
...@@ -462,6 +445,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) ...@@ -462,6 +445,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl; CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
#endif #endif
} }
...@@ -496,6 +487,14 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c ...@@ -496,6 +487,14 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
} }
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl; CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
#endif #endif
} }
...@@ -523,181 +522,106 @@ void EnvMap::popSegment(Segment* o) ...@@ -523,181 +522,106 @@ void EnvMap::popSegment(Segment* o)
mo->neighbor_cells[n].clear(); mo->neighbor_cells[n].clear();
} }
} }
//
//
//void EnvMap::refine() void EnvMap::subdivideVolume(Dart dglobal)
//{ {
//// CGoGNout<<"refine"<<CGoGNendl;
// for (std::vector<Dart>::iterator it = refineCandidate.begin(); it != refineCandidate.end(); ++it) CGoGNout<<"debut refine"<<CGoGNendl;
// { unsigned int max = map.getMaxLevel() ;
// Dart d = (*it) ; map.setCurrentLevel(max) ;
// refineMark.unmark(d) ;
//
// //if the number of agents is big enough std::cout << "dglobal = " << dglobal << "level = "<< max << std::endl;
// if (agentvect[d].size() > nbAgentsToSubdivide)
// {
// int fLevel = -1 ; ARETES oldobst(RegisteredEdges[dglobal]) ;
// Dart old = map.faceOldestDart(d) ; ARETES oldNeighborObst(RegisteredNeighborEdges[dglobal]) ;
//
// bool subdivisable = true ; for (Segment * s : oldobst)
// this->popSegment(s) ;
// //check if faces resulting from a subdivision are big enough for (Segment * s : oldNeighborObst)
// std::pair<bool, bool>& sf = subdivisableFace[old] ; this->popSegment(s) ;
// if (sf.first == true)
// subdivisable = sf.second ; if(!map.isBoundaryMarked(3,dglobal) )
// else {
// { #ifdef DEBUG_affichage
//// float minSizeSq = minCellSize * minCellSize ; // diametre de vision de l'agent au carré CGoGNout<<"debut subdivision"<< CGoGNendl;
// float minSizeSq = Agent::neighborDistSq_; #endif
// Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position);
// fLevel = map.faceLevel(old) ;
// map.setCurrentLevel(fLevel) ; }
// PFP::VEC3 fCenter = Algo::Surface::Geometry::faceCentroid<PFP>(map, old, position) ;
// Dart fd = old ; map.setCurrentLevel(map.getMaxLevel()) ;
// do map.check();
// { std::cout << "after level = "<< map.getMaxLevel() << std::endl;
// PFP::VEC3& p = position[fd] ;
// PFP::VEC3 edge = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map, fd, position) ; //same for adjacent obstacles // optimiser
// PFP::VEC3 proj = fCenter - (p + (edge * (fCenter - p) / edge.norm2()) * edge) ; for (Segment * s : oldNeighborObst)
// if (proj.norm2() < minSizeSq) {
// { FirstRegistrationSegment(s) ;
// subdivisable = false ; }
// break ; //same for obstacles contained
// } for (Segment * s : oldobst)
// fd = map.phi1(fd) ; {
// } while (fd != old) ; // CGoGNout<<"reseting Obstacles"<<CGoGNendl;
// map.setCurrentLevel(map.getMaxLevel()) ; resetPartSubdiv(s);
// FirstRegistrationSegment(s);
// sf.first = true ;
// sf.second = subdivisable ; }
// }
//
// if (subdivisable)
// {
// if (fLevel == -1) CGoGNout<<"fin refine"<<CGoGNendl;
// fLevel = map.faceLevel(old) ;
// }
// sf.first = false ;
// void EnvMap::resetPartSubdiv(Segment* o)
// PFP::AGENTS oldAgents(agentvect[old]) ; {
// PFP::SegmentVECT oldObst(RegisteredEdges[old]) ;
// PFP::SegmentVECT oldNeighborObst(neighborRegisteredEdges[old]) ; ArticulatedObject * mo = o->nid;
//
// for (PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait) if (mo != NULL)
// { {
// popAgentInCells(*ait, old) ;
// } VEC3 pos = mo->parts_[o->indexPart1]->getPosition();
// for (PFP::SegmentVECT::iterator ait = oldObst.begin(); ait != oldObst.end(); ++ait) VEC3 pos2 = mo->parts_[o->indexPart2]->getPosition();
// this->popSegment(*ait) ; Dart d1 =mo->parts_[o->indexPart1]->d;
// for (PFP::SegmentVECT::iterator ait = oldNeighborObst.begin();ait != oldNeighborObst.end(); ++ait) Dart d2 =mo->parts_[o->indexPart2]->d;
// this->popSegment(*ait) ;
// neighborAgentvect[old].clear() ; #ifdef DEBUG_affichage
// CGoGNout<<"Reset part subdiv (segment ,ind1, pos1, d1, ind2, pos2, d2) : "<<o->index<<" || "<<o->indexPart1<<" || "<<pos<<" || "<<d1<<" || "<<o->indexPart2<<" || "<<pos2<<" || "<<d2<<CGoGNendl;
// map.setCurrentLevel(fLevel) ; CGoGNout<<"Faces centroids : "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d1,position)<<" || "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d2,position)<<CGoGNendl;
// Algo::Surface::IHM::subdivideFace<PFP>(map, old, position) ;
// CellMarkerStore<FACE> newF(map) ; #endif
// unsigned int degree = 0 ;
// Dart dd = old ; mo->parts_[o->indexPart1]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d1,position)) ;
// do #ifdef DEBUG_affichage
// { CGoGNout<<"part1 moved to centroid ,d : "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
// ++degree ;
// newF.mark(dd) ; #endif
// dd = map.phi1(dd) ; mo->parts_[o->indexPart1]->setState(VOLUME) ;
// } while (dd != old) ; mo->parts_[o->indexPart1]->move(pos) ;
// map.setCurrentLevel(fLevel+1) ; #ifdef DEBUG_affichage
// if (degree == 3) CGoGNout<<"part1 moved in the end (destination, arrivée,d) : "<<pos<<" || "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
// {
// Dart centerFace = map.phi2(map.phi1(old)) ; #endif
// newF.mark(centerFace) ; mo->parts_[o->indexPart2]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d2,position)) ;
// } #ifdef DEBUG_affichage
// CGoGNout<<"part2 moved to centroid ,d : "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
// map.setCurrentLevel(map.getMaxLevel()) ;
// //retrieve neighbors agents from onering cells #endif
// dd = old ; mo->parts_[o->indexPart2]->setState(VOLUME) ;
// do mo->parts_[o->indexPart2]->move(pos2) ;
// { #ifdef DEBUG_affichage
// Dart d3 = dd ; CGoGNout<<"part2 moved in the end (destination, arrivée,d) : "<<pos2<<" || "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
//
// do #endif
// { }
// Dart d4 = map.alpha1(map.alpha1(d3)) ;
// PFP::AGENTS& nad3 = neighborAgentvect[d3] ; }
// while (d4 != d3)
// {
// if (!newF.isMarked(d4))
// {
// PFP::AGENTS& ad4 = agentvect[d4] ;
// nad3.insert(nad3.end(), ad4.begin(), ad4.end()) ;
// }
// d4 = map.alpha1(d4) ;
// }
// d3 = map.phi1(d3) ;
// } while (d3 != dd) ;
//
// map.setCurrentLevel(fLevel) ;
// dd = map.phi1(dd) ;
// map.setCurrentLevel(map.getMaxLevel()) ;
// } while (dd != old) ;
//
//
//
// if (degree == 3)
// {
// map.setCurrentLevel(fLevel+1) ;
// Dart centerFace = map.phi2(map.phi1(old)) ;
// map.setCurrentLevel(map.getMaxLevel()) ;
// Dart d3 = centerFace ;
// do
// {
// Dart d4 = map.alpha1(map.alpha1(d3)) ;
// PFP::AGENTS& nad3 = neighborAgentvect[d3] ;
// while (d4 != d3)
// {
// if (!newF.isMarked(d4))
// {
// PFP::AGENTS& ad4 = agentvect[d4] ;
// nad3.insert(neighborAgentvect[d3].end(), ad4.begin(), ad4.end()) ;
// }
// d4 = map.alpha1(d4) ;
// }
// d3 = map.phi1(d3) ;
// } while (d3 != centerFace) ;
// }
//
// //agents contained in the subdivided cell are pushed correctly
// for (PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
// {
//// CGoGNout<<"reseting Agents"<<CGoGNendl;
// resetAgentInFace(*ait) ;
// pushAgentInCells(*ait, (*ait)->part_.d) ;
// }
//
// //same for Segments contained
// for (PFP::SegmentVECT::iterator ait = oldObst.begin(); ait != oldObst.end(); ++ait)
// {
//// CGoGNout<<"reseting Segments"<<CGoGNendl;
// resetPartSubdiv(*ait);
// pushSegmentInSetOfCells(*ait);
//
// }
//
// //same for adjacent Segments
// for (PFP::SegmentVECT::iterator ait = oldNeighborObst.begin();
// ait != oldNeighborObst.end(); ++ait)
// {
// pushSegmentInSetOfCells(*ait) ;
// }
//
//
//// CGoGNout<<"fin refine"<<CGoGNendl;
// }
// }
// }
// refineCandidate.clear() ;
//
//}
//
//
//void EnvMap::coarse() //void EnvMap::coarse()
//{ //{
//// CGoGNout<<"coarse"<<CGoGNendl; //// CGoGNout<<"coarse"<<CGoGNendl;
......
...@@ -109,6 +109,7 @@ void Simulator::initMovingObject() ...@@ -109,6 +109,7 @@ void Simulator::initMovingObject()
std::pair<VEC3, Dart> startingPoint ; std::pair<VEC3, Dart> startingPoint ;
Dart d=envMap_.map.indexDart(40); Dart d=envMap_.map.indexDart(40);
startingPoint.first=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(envMap_.map,d,envMap_.position); startingPoint.first=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(envMap_.map,d,envMap_.position);
// startingPoint.first=VEC3(-2.5f,-2.5f,2.5f);
startingPoint.second=d; startingPoint.second=d;
aiguille=new Needle(this,startingPoint); aiguille=new Needle(this,startingPoint);
} }
......
...@@ -148,6 +148,25 @@ void Volusion::slider_released() ...@@ -148,6 +148,25 @@ void Volusion::slider_released()
updateGL(); updateGL();
} }
void Volusion::cb_keyPress(int code)
{
switch(code)
{
case 'r' :
{
simul.aiguille->refine();
m_MovingObjectVBO->updateData(simul.envMap_.position);
updateGL() ;
break;
}
}
}
void Volusion::cb_Open() void Volusion::cb_Open()
{ {
std::string filters("all (*.*)") ; std::string filters("all (*.*)") ;
...@@ -209,7 +228,7 @@ void Volusion::cb_initGL() ...@@ -209,7 +228,7 @@ void Volusion::cb_initGL()
m_MovingObjectVBO = new Utils::VBO(); m_MovingObjectVBO = new Utils::VBO();
m_MovingObjectVBO->setDataSize(3); m_MovingObjectVBO->setDataSize(3);
m_MovingObjectVBO->allocate(simul.aiguille->nbVertices); m_MovingObjectVBO->allocate(10000);
//initialisation aiguille //initialisation aiguille
...@@ -267,7 +286,11 @@ void Volusion::cb_redraw() ...@@ -267,7 +286,11 @@ void Volusion::cb_redraw()
m_ds->begin(GL_LINE_STRIP); m_ds->begin(GL_LINE_STRIP);
m_ds->lineWidth(10.0f); m_ds->lineWidth(10.0f);
if(simul.aiguille->nbEdges>0)
{
VEC3 origin = simul.aiguille->Segments_[0]->p1;
m_ds->vertex(origin);
}
for(Segment * s : simul.aiguille->Segments_) for(Segment * s : simul.aiguille->Segments_)
{ {
m_ds->color3f(s->r,s->g,s->b); m_ds->color3f(s->r,s->g,s->b);
...@@ -275,8 +298,7 @@ void Volusion::cb_redraw() ...@@ -275,8 +298,7 @@ void Volusion::cb_redraw()
m_ds->vertex(p); m_ds->vertex(p);
} }
m_ds->color3f(0,0.5f,1.0f); m_ds->color3f(0,0.5f,1.0f);
m_ds->vertex(simul.aiguille->parts_[1]->getPosition());
m_ds->vertex(simul.aiguille->parts_[0]->getPosition());
m_ds->end(); m_ds->end();
m_ds->endList(); m_ds->endList();
...@@ -285,12 +307,13 @@ void Volusion::cb_redraw() ...@@ -285,12 +307,13 @@ void Volusion::cb_redraw()
// float f; // float f;
// VEC3 cylinder_axis =cylinder->getAxisScale(2,f); // VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr()); PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
int n= simul.aiguille->nbVertices; int i=0;
for(int i = 0; i< n; i ++) for(auto particule : simul.aiguille->parts_)
{ {
VEC3 p = simul.aiguille->parts_[i]->getPosition(); VEC3 p = particule->getPosition();
data[i] = p; data[i] = p;
i++;
} }
...@@ -366,14 +389,20 @@ void Volusion::cb_redraw() ...@@ -366,14 +389,20 @@ void Volusion::cb_redraw()
} }
if (draw_dart && dartSlider < (simul.envMap_.map.end().index)) if (draw_dart)
{ {
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
dock.spinBox_dart->setRange(0, simul.envMap_.map.end().index) ;
if( dartSlider < (simul.envMap_.map.end().index))
{
m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f); m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f);
}
} }
if(render_belonging) if(render_belonging)
{ {
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
if (dock.comboBoxEdge->count()<simul.aiguille->nbEdges) if (dock.comboBoxEdge->count()<simul.aiguille->nbEdges)
{ {
dock.comboBoxEdge->clear(); dock.comboBoxEdge->clear();
...@@ -430,6 +459,7 @@ void Volusion::cb_redraw() ...@@ -430,6 +459,7 @@ void Volusion::cb_redraw()
if(render_neighbors) if(render_neighbors)
{ {
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
if(val_comboEdge==0) if(val_comboEdge==0)
{ {
for(unsigned int i =0;i<simul.aiguille->nbEdges;i++) for(unsigned int i =0;i<simul.aiguille->nbEdges;i++)
...@@ -465,8 +495,10 @@ void Volusion::cb_redraw() ...@@ -465,8 +495,10 @@ void Volusion::cb_redraw()
} }
if (render_topo) if (render_topo)
{ {
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
m_topo_render->drawTopo(); m_topo_render->drawTopo();
} }
...@@ -474,6 +506,7 @@ void Volusion::cb_redraw() ...@@ -474,6 +506,7 @@ void Volusion::cb_redraw()
if (render_edges) if (render_edges)
{ {
glLineWidth(2.0f); glLineWidth(2.0f);
m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
m_explode_render->drawEdges(); m_explode_render->drawEdges();
} }
......
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