From bb14948f18768aeb2f2aeec0fbb31e0c5576710d Mon Sep 17 00:00:00 2001 From: Thomas PITIOT Date: Thu, 19 Mar 2015 14:45:48 +0100 Subject: [PATCH] some change --- include/surface.h | 4 ++-- src/ArticulatedObject.cpp | 4 ++-- src/env_map.cpp | 1 - src/simulator.cpp | 34 +++++++++++++++++----------------- src/surface.cpp | 2 -- src/viewer.cpp | 32 ++++++++++++++++---------------- 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/include/surface.h b/include/surface.h index 7b2826b..fbc5d58 100644 --- a/include/surface.h +++ b/include/surface.h @@ -57,8 +57,8 @@ public: bool removeGeneralNeighbor (Dart d); - std::vector * belonging_cells; - std::vector * neighbor_cells; + std::vector< std::vector > belonging_cells; + std::vector< std::vector > neighbor_cells; std::vector > general_belonging; std::vector > general_neighbors; diff --git a/src/ArticulatedObject.cpp b/src/ArticulatedObject.cpp index 96e0561..e866194 100644 --- a/src/ArticulatedObject.cpp +++ b/src/ArticulatedObject.cpp @@ -11,8 +11,8 @@ ArticulatedObject::ArticulatedObject() : ,nbEdges(0u) ,parts_(std::vector()) ,Segments_(std::vector()) - ,belonging_cells(NULL) - ,neighbor_cells(NULL) + ,belonging_cells(std::vector>()) + ,neighbor_cells(std::vector>()) , width(0.) , sim_(NULL) ,index_articulated(0u) diff --git a/src/env_map.cpp b/src/env_map.cpp index 4a23f64..5bbe29c 100644 --- a/src/env_map.cpp +++ b/src/env_map.cpp @@ -286,7 +286,6 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en if(memo.size() == 1u) { - std::cout << "COUCOU !! " << std::endl; pushAOneCellSegment(o , d1); } else diff --git a/src/simulator.cpp b/src/simulator.cpp index 40cbbe5..b10f198 100644 --- a/src/simulator.cpp +++ b/src/simulator.cpp @@ -26,8 +26,8 @@ void Simulator::init(int argc, char **argv) else Needle_or_knife=true; -// initFixedObjects(); - initSurfaces(); + initFixedObjects(); +// initSurfaces(); initMovingObject(); // initEmptyMovingObject(); @@ -60,20 +60,20 @@ void Simulator::initFixedObjects() p.second=envMap_.getBelongingCell(pos); startingPoints.push_back(p); - pos=VEC3(-4.68,1.36,2.15); + pos=VEC3(1.23,1.36,2.15); p.first=pos; p.second=envMap_.getBelongingCell(pos); startingPoints.push_back(p); - pos=VEC3(4,-2,3); - p.first=pos; - p.second=envMap_.getBelongingCell(pos); - startingPoints.push_back(p); +// pos=VEC3(4,-2,3); +// p.first=pos; +// p.second=envMap_.getBelongingCell(pos); +// startingPoints.push_back(p); - pos=VEC3(1,-1,1); - p.first=pos; - p.second=envMap_.getBelongingCell(pos); - startingPoints.push_back(p); +// pos=VEC3(1,-1,1); +// p.first=pos; +// p.second=envMap_.getBelongingCell(pos); +// startingPoints.push_back(p); // pos=VEC3(2,-2.5f,0.5f); // p.first=pos; @@ -84,13 +84,13 @@ void Simulator::initFixedObjects() ind.second=1; segmentParts.push_back(ind); - ind.first=2; - ind.second=3; - segmentParts.push_back(ind); +// ind.first=2; +// ind.second=3; +// segmentParts.push_back(ind); - ind.first=0; - ind.second=2; - segmentParts.push_back(ind); +// ind.first=0; +// ind.second=2; +// segmentParts.push_back(ind); // ind.first=0; // ind.second=4; // segmentParts.push_back(ind); diff --git a/src/surface.cpp b/src/surface.cpp index 6cfdb3e..2e0ea6e 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -44,8 +44,6 @@ Surface::Surface(Simulator* sim,VEC3 offset): { nbTriangles ++; } - belonging_cells = new std::vector[nbTriangles]; - neighbor_cells = new std::vector[nbTriangles]; diff --git a/src/viewer.cpp b/src/viewer.cpp index 112e6c0..6bae5ab 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -386,12 +386,12 @@ void Volusion::displayMO() if(val_comboEdge==0) { - for(unsigned int i =0;inbEdges;i++) + for(auto vect : simul.aiguille->belonging_cells) { // m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0); - for(auto it = simul.aiguille->belonging_cells[i].begin(); it !=simul.aiguille->belonging_cells[i].end();++it) + for(Dart it : vect) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,it)) { m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); @@ -408,10 +408,10 @@ void Volusion::displayMO() // m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge-1]->d,10.0f,1.0f,0,0); // m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge]->d,10.0f,1.0f,0,0); int i = val_comboEdge-1; - for(auto it = simul.aiguille->belonging_cells[i].begin(); it !=simul.aiguille->belonging_cells[i].end();++it) + for(Dart it : simul.aiguille->belonging_cells[i]) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it))) { m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); @@ -428,12 +428,12 @@ void Volusion::displayMO() 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++) + for(auto vect : simul.aiguille->neighbor_cells) { - - for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) +// m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0); + for(Dart it : vect) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it))) { m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); @@ -447,9 +447,9 @@ void Volusion::displayMO() else { int i = val_comboEdge-1; - for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) + for(Dart it : simul.aiguille->neighbor_cells[i]) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it))) { m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); } @@ -551,12 +551,12 @@ void Volusion::displayObj() m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); for (ArticulatedObject * o : simul.objects) { - for(unsigned int i =0;inbEdges;i++) + for(auto vect : o->belonging_cells) { // 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) + for(Dart it : vect) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it))) { m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f); } @@ -573,9 +573,9 @@ void Volusion::displayObj() // for(unsigned int i =0;inbTriangles;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) + for(Dart it : o->belonging_cells[i]) { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it))) { m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f); } -- GitLab