diff --git a/gmon.out b/gmon.out index 597c0d8d4336496d97fe5dab8679f96eb2048963..21cb76eb6d0ae6ecda457c07aeacd0aff3681e87 100644 Binary files a/gmon.out and b/gmon.out differ diff --git a/include/env_map.h b/include/env_map.h index 6f0574a44b1921dd1a8cb5c5f0aa7bf27b6f7838..c8ffb955c2b744462ad9bc621586677acd0ac8d6 100644 --- a/include/env_map.h +++ b/include/env_map.h @@ -2,6 +2,8 @@ #define ENV_MAP_H +#define DEBUG_affichage +//#define DEBUG #include #include @@ -26,8 +28,6 @@ //#include "Algo/ImplicitHierarchicalMesh/subdivision3.hxx" -//#define DEBUG_affichage -//#define DEBUG /////////////////particules #include "Algo/MovingObjects/particle_cell_3D_memo.h" @@ -87,7 +87,7 @@ public: void pushSegmentInCellAsNeighbor(Segment* o, Dart d); void popSegmentInCellAsNeighbor(Segment* o, Dart d); - + void resetPartSubdiv(Segment* o); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/viewer.h b/include/viewer.h index b39a7f9cd9019ad53ef76339581f15a86442f549..4f4262bb4f0a1af8ba522e7fecabf402d0a4c98c 100644 --- a/include/viewer.h +++ b/include/viewer.h @@ -149,6 +149,7 @@ protected: void cb_mouseMove(int buttons, int x, int y); void cb_mousePress(int button, int x, int y); void cb_mouseRelease(int button, int x, int y); + void cb_keyPress(int code); void cb_Open(); void animate() ; diff --git a/src/env_map.cpp b/src/env_map.cpp index 582291cf5a8cd4000c6fae62bbdc23a2703d8a5b..7e72ee846f225ec525ade731a31c51c3298bc283 100644 --- a/src/env_map.cpp +++ b/src/env_map.cpp @@ -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(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 { @@ -401,7 +384,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en int n1 = o->indexPart1; int n2 = o->indexPart2; #ifdef DEBUG_affichage - CGoGNout<<"First Registration arete "<index<p1; VEC3 p2 = o->p2; @@ -462,6 +445,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) #ifdef DEBUG_affichage CGoGNout<<"fin du push , etat du belong/neighbor : "<belonging_cells[n].size()<<"/"<neighbor_cells[n].size()<neighbor_cells[n].size()>26) +// { +// for(auto d : mo->neighbor_cells[n]) +// { +// CGoGNout<<" || "<& memo_c } #ifdef DEBUG_affichage CGoGNout<<"fin du push , etat du belong/neighbor : "<belonging_cells[n].size()<<"/"<neighbor_cells[n].size()<neighbor_cells[n].size()>26) +// { +// for(auto d : mo->neighbor_cells[n]) +// { +// CGoGNout<<" || "<neighbor_cells[n].clear(); } } -// -// -//void EnvMap::refine() -//{ -//// CGoGNout<<"refine"<::iterator it = refineCandidate.begin(); it != refineCandidate.end(); ++it) -// { -// Dart d = (*it) ; -// refineMark.unmark(d) ; -// -// //if the number of agents is big enough -// if (agentvect[d].size() > nbAgentsToSubdivide) -// { -// int fLevel = -1 ; -// Dart old = map.faceOldestDart(d) ; -// -// bool subdivisable = true ; -// -// //check if faces resulting from a subdivision are big enough -// std::pair& sf = subdivisableFace[old] ; -// if (sf.first == true) -// subdivisable = sf.second ; -// else -// { -//// float minSizeSq = minCellSize * minCellSize ; // diametre de vision de l'agent au carré -// float minSizeSq = Agent::neighborDistSq_; -// -// fLevel = map.faceLevel(old) ; -// map.setCurrentLevel(fLevel) ; -// PFP::VEC3 fCenter = Algo::Surface::Geometry::faceCentroid(map, old, position) ; -// Dart fd = old ; -// do -// { -// PFP::VEC3& p = position[fd] ; -// PFP::VEC3 edge = Algo::Surface::Geometry::vectorOutOfDart(map, fd, position) ; -// PFP::VEC3 proj = fCenter - (p + (edge * (fCenter - p) / edge.norm2()) * edge) ; -// if (proj.norm2() < minSizeSq) -// { -// subdivisable = false ; -// break ; -// } -// fd = map.phi1(fd) ; -// } while (fd != old) ; -// map.setCurrentLevel(map.getMaxLevel()) ; -// -// sf.first = true ; -// sf.second = subdivisable ; -// } -// -// if (subdivisable) -// { -// if (fLevel == -1) -// fLevel = map.faceLevel(old) ; -// -// sf.first = false ; -// -// PFP::AGENTS oldAgents(agentvect[old]) ; -// PFP::SegmentVECT oldObst(RegisteredEdges[old]) ; -// PFP::SegmentVECT oldNeighborObst(neighborRegisteredEdges[old]) ; -// -// for (PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait) -// { -// popAgentInCells(*ait, old) ; -// } -// for (PFP::SegmentVECT::iterator ait = oldObst.begin(); ait != oldObst.end(); ++ait) -// this->popSegment(*ait) ; -// for (PFP::SegmentVECT::iterator ait = oldNeighborObst.begin();ait != oldNeighborObst.end(); ++ait) -// this->popSegment(*ait) ; -// neighborAgentvect[old].clear() ; -// -// map.setCurrentLevel(fLevel) ; -// Algo::Surface::IHM::subdivideFace(map, old, position) ; -// CellMarkerStore newF(map) ; -// unsigned int degree = 0 ; -// Dart dd = old ; -// do -// { -// ++degree ; -// newF.mark(dd) ; -// dd = map.phi1(dd) ; -// } while (dd != old) ; -// map.setCurrentLevel(fLevel+1) ; -// if (degree == 3) -// { -// Dart centerFace = map.phi2(map.phi1(old)) ; -// newF.mark(centerFace) ; -// } -// -// map.setCurrentLevel(map.getMaxLevel()) ; -// //retrieve neighbors agents from onering cells -// dd = old ; -// do -// { -// Dart d3 = dd ; -// -// 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(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"<part_.d) ; -// } -// -// //same for Segments contained -// for (PFP::SegmentVECT::iterator ait = oldObst.begin(); ait != oldObst.end(); ++ait) -// { -//// CGoGNout<<"reseting Segments"<(map, dglobal, position); + + } + + map.setCurrentLevel(map.getMaxLevel()) ; + map.check(); + std::cout << "after level = "<< map.getMaxLevel() << std::endl; + + //same for adjacent obstacles // optimiser + for (Segment * s : oldNeighborObst) + { + FirstRegistrationSegment(s) ; + } + //same for obstacles contained + for (Segment * s : oldobst) + { +// CGoGNout<<"reseting Obstacles"<nid; + + if (mo != NULL) + { + + VEC3 pos = mo->parts_[o->indexPart1]->getPosition(); + VEC3 pos2 = mo->parts_[o->indexPart2]->getPosition(); + Dart d1 =mo->parts_[o->indexPart1]->d; + Dart d2 =mo->parts_[o->indexPart2]->d; + +#ifdef DEBUG_affichage + CGoGNout<<"Reset part subdiv (segment ,ind1, pos1, d1, ind2, pos2, d2) : "<index<<" || "<indexPart1<<" || "<indexPart2<<" || "<>(map,d1,position)<<" || "<>(map,d2,position)<parts_[o->indexPart1]->CGoGN::Algo::MovingObjects::ParticleBase::move(Algo::Surface::Geometry::volumeCentroid>(map,d1,position)) ; +#ifdef DEBUG_affichage + CGoGNout<<"part1 moved to centroid ,d : "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<parts_[o->indexPart1]->d<parts_[o->indexPart1]->setState(VOLUME) ; + mo->parts_[o->indexPart1]->move(pos) ; +#ifdef DEBUG_affichage + CGoGNout<<"part1 moved in the end (destination, arrivée,d) : "<parts_[o->indexPart1]->getPosition()<<" || "<parts_[o->indexPart1]->d<parts_[o->indexPart2]->CGoGN::Algo::MovingObjects::ParticleBase::move(Algo::Surface::Geometry::volumeCentroid>(map,d2,position)) ; +#ifdef DEBUG_affichage + CGoGNout<<"part2 moved to centroid ,d : "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<parts_[o->indexPart2]->d<parts_[o->indexPart2]->setState(VOLUME) ; + mo->parts_[o->indexPart2]->move(pos2) ; +#ifdef DEBUG_affichage + CGoGNout<<"part2 moved in the end (destination, arrivée,d) : "<parts_[o->indexPart2]->getPosition()<<" || "<parts_[o->indexPart2]->d< startingPoint ; Dart d=envMap_.map.indexDart(40); startingPoint.first=Algo::Surface::Geometry::volumeCentroid>(envMap_.map,d,envMap_.position); +// startingPoint.first=VEC3(-2.5f,-2.5f,2.5f); startingPoint.second=d; aiguille=new Needle(this,startingPoint); } diff --git a/src/viewer.cpp b/src/viewer.cpp index e1ae3e4a8575c137933a7398fdc5a20e52bbcbaf..43e9d24086bef8e699690c512b4b357b34a0df1c 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -148,6 +148,25 @@ void Volusion::slider_released() 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() { std::string filters("all (*.*)") ; @@ -209,7 +228,7 @@ void Volusion::cb_initGL() m_MovingObjectVBO = new Utils::VBO(); m_MovingObjectVBO->setDataSize(3); - m_MovingObjectVBO->allocate(simul.aiguille->nbVertices); + m_MovingObjectVBO->allocate(10000); //initialisation aiguille @@ -267,7 +286,11 @@ void Volusion::cb_redraw() m_ds->begin(GL_LINE_STRIP); 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_) { m_ds->color3f(s->r,s->g,s->b); @@ -275,8 +298,7 @@ void Volusion::cb_redraw() m_ds->vertex(p); } 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->endList(); @@ -285,12 +307,13 @@ void Volusion::cb_redraw() // float f; // VEC3 cylinder_axis =cylinder->getAxisScale(2,f); PFP::VEC3* data = static_cast(m_MovingObjectVBO->lockPtr()); - int n= simul.aiguille->nbVertices; - for(int i = 0; i< n; i ++) + int i=0; + for(auto particule : simul.aiguille->parts_) { - VEC3 p = simul.aiguille->parts_[i]->getPosition(); + VEC3 p = particule->getPosition(); data[i] = p; + i++; } @@ -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); + } } if(render_belonging) { + m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); if (dock.comboBoxEdge->count()nbEdges) { dock.comboBoxEdge->clear(); @@ -430,6 +459,7 @@ void Volusion::cb_redraw() if(render_neighbors) { + m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); if(val_comboEdge==0) { for(unsigned int i =0;inbEdges;i++) @@ -465,8 +495,10 @@ void Volusion::cb_redraw() } + if (render_topo) { + m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); m_topo_render->drawTopo(); } @@ -474,6 +506,7 @@ void Volusion::cb_redraw() if (render_edges) { glLineWidth(2.0f); + m_explode_render->updateData(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color); m_explode_render->drawEdges(); }