From b81d34da7883df8525dedc3c2f094d2769cc2c7e Mon Sep 17 00:00:00 2001 From: Thomas PITIOT Date: Wed, 18 Mar 2015 15:02:34 +0100 Subject: [PATCH] up2 --- include/ArticulatedObject.h | 8 +- include/Volusion.ui | 72 ++---- include/env_map.h | 3 +- include/surface.h | 7 +- include/viewer.h | 15 +- src/ArticulatedObject.cpp | 109 ++++++--- src/env_map.cpp | 139 ++++------- src/surface.cpp | 81 ++++-- src/viewer.cpp | 475 +++++++++++++++++++++--------------- 9 files changed, 504 insertions(+), 405 deletions(-) diff --git a/include/ArticulatedObject.h b/include/ArticulatedObject.h index d080224..5858d86 100644 --- a/include/ArticulatedObject.h +++ b/include/ArticulatedObject.h @@ -15,8 +15,10 @@ class ArticulatedObject { public : VEC3 getPositionSegment(int index) ; - void addGeneralCell (std::vector< std::pair > general_belonging, Dart d); - bool removeGeneralCell (std::vector< std::pair > general_belonging,Dart d); + void addGeneralCell ( Dart d); + bool removeGeneralCell (Dart d); + void addGeneralNeighbor ( Dart d); + bool removeGeneralNeighbor (Dart d); VEC3 getPosition(int index); unsigned int nbVertices; @@ -27,7 +29,7 @@ public : std::vector * belonging_cells; std::vector * neighbor_cells; - std::vector > general_belonging; + std::vector > general_belonging; std::vector > general_neighbors; double width; Simulator* sim_; diff --git a/include/Volusion.ui b/include/Volusion.ui index b562833..6ee2738 100644 --- a/include/Volusion.ui +++ b/include/Volusion.ui @@ -83,23 +83,6 @@ - - - - Belonging Cells - - - - - - - Neighbor Cells - - - - - - @@ -117,6 +100,9 @@ + + + @@ -125,32 +111,37 @@ - - - Qt::Horizontal + + + Belonging Cells - + - clipping - - - true + Neighbor Cells - - true + + + + + + Objects - - - true + + + Objects belonging + + + + - hide clipping plane + Objects neighbors @@ -190,22 +181,5 @@ - - - checkBox_plane - clicked(bool) - checkBox_hide - setVisible(bool) - - - 74 - 174 - - - 74 - 200 - - - - + diff --git a/include/env_map.h b/include/env_map.h index 34a2fce..9af97ae 100644 --- a/include/env_map.h +++ b/include/env_map.h @@ -98,8 +98,7 @@ public: //Enregistrement Surfaces void popAndPushTriangle(Triangle* o); // pop et push d'une Triangle void FirstRegistrationTriangle (Triangle* o); // premier enregistrement d'une Triangle - void markSameVolume(CellMarkerMemo * memo_mark, CellMarkerMemo *OneRingMark, Dart d); // enregistrer une dart dans une cellule - void markMultipleVolumes(CellMarkerMemo * memo_mark, CellMarkerMemo * OneRingMark, const std::vector& memo_cross); // enregistrer une dart dans un ensemble de cellules + void markNeighbors(CellMarkerMemo * memo_mark, CellMarkerMemo * OneRingMark, const std::vector& memo_cross); // marker les cellules voisines d'un ensemble de cellules retenu dans memo_cross void popTriangle(Triangle* o); void pushTriangleInCell(Triangle* o, Dart d); diff --git a/include/surface.h b/include/surface.h index 6f06c51..7b2826b 100644 --- a/include/surface.h +++ b/include/surface.h @@ -51,9 +51,10 @@ public: void initOperators(SubdivisionType st); // fonction de sélection du type de subdivision pour l'ihm2 - void addGeneralCell (std::vector< std::pair > general_belonging, Dart d); - bool removeGeneralCell (std::vector< std::pair > general_belonging,Dart d); - + void addGeneralCell ( Dart d); + bool removeGeneralCell (Dart d); + void addGeneralNeighbor ( Dart d); + bool removeGeneralNeighbor (Dart d); std::vector * belonging_cells; diff --git a/include/viewer.h b/include/viewer.h index 6d62388..3d78ca3 100644 --- a/include/viewer.h +++ b/include/viewer.h @@ -80,6 +80,9 @@ class Volusion: public Utils::QT::SimpleQGLV bool render_topo; bool render_MovingObject; bool render_topoTemp; + bool display_obj; + bool obj_belong; + bool obj_neighbors; // bool clip_volume; // bool hide_clipping; bool draw_dart; @@ -136,6 +139,9 @@ public: render_topo(false), render_MovingObject(true), render_topoTemp(false), + display_obj(true), + obj_belong(false), + obj_neighbors(false), // clip_volume(false), // hide_clipping(true), draw_dart(false), @@ -149,6 +155,8 @@ public: {} + void displayMO(); + void displayObj(); protected: void cb_redraw(); @@ -169,8 +177,11 @@ public slots: void belonging_onoff(bool x); void neighbors_onoff(bool x); void comboEdge(int x); - void clipping_onoff(bool x); - void hide_onoff(bool x); + void obj_onoff(bool x); + void objBelong_onoff(bool x); + void objNeighbors_onoff(bool x); +// void clipping_onoff(bool x); +// void hide_onoff(bool x); void slider_explode(int x); void slider_pressed(); void slider_released(); diff --git a/src/ArticulatedObject.cpp b/src/ArticulatedObject.cpp index 37a7611..585a280 100644 --- a/src/ArticulatedObject.cpp +++ b/src/ArticulatedObject.cpp @@ -6,50 +6,87 @@ */ -void ArticulatedObject::addGeneralCell (std::vector< std::pair > general_belonging, Dart d) +void ArticulatedObject::addGeneralCell ( Dart d) { - bool added = false; - std::vector< std::pair >::iterator it =general_belonging.begin(); - while (it != general_belonging.end() ) - { - if(sim_->envMap_.map.sameVolume((*it).first,d)) - { - (*it).second ++; - added= true; - break; - } - else ++it; - - }; - - if (!added) - { - general_belonging.push_back(std::make_pair(d,1)); - } + bool added = false; + for(std::pair pere : general_belonging) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second ++; + added= true; + break; + } + + } + if (!added) + { + general_belonging.push_back(std::make_pair(d,1)); + } } /*removeGeneralCell * removes cell d to general belonging decreases the number of instance of the cell, if the number is 0 the celle is removed *forever* */ -bool ArticulatedObject::removeGeneralCell (std::vector< std::pair > general_belonging,Dart d) +bool ArticulatedObject::removeGeneralCell (Dart d) { - std::vector< std::pair >::iterator it =general_belonging.begin(); - while (it != general_belonging.end() ) - { - if(sim_->envMap_.map.sameVolume((*it).first,d)) - { - if(--((*it).second)==0) - { - *it = general_belonging.back() ; - general_belonging.pop_back() ; - } - return true; - } - else ++it; - - }; - return false; + for(std::pair pere : general_belonging) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second--; + if(pere.second==0) + { + pere=general_belonging.back() ; + general_belonging.pop_back() ; + } + return true; + } + + + }; + return false; } +void ArticulatedObject::addGeneralNeighbor ( Dart d) +{ + bool added = false; + for(std::pair pere : general_neighbors) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second ++; + added= true; + break; + } + + } + if (!added) + { + general_neighbors.push_back(std::make_pair(d,1)); + } +} +/*removeGeneralCell + * removes cell d to general belonging decreases the number of instance of the cell, if the number is 0 the celle is removed *forever* + */ +bool ArticulatedObject::removeGeneralNeighbor (Dart d) +{ + for(std::pair pere : general_neighbors) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second--; + if(pere.second==0) + { + pere=general_neighbors.back() ; + general_neighbors.pop_back() ; + } + return true; + } + + + }; + return false; +} VEC3 ArticulatedObject::getPosition(int index) { diff --git a/src/env_map.cpp b/src/env_map.cpp index 59780e5..b4997b3 100644 --- a/src/env_map.cpp +++ b/src/env_map.cpp @@ -321,14 +321,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) addElementToVector(RegisteredEdges[d],o); mo->belonging_cells[n].push_back(d); - mo->addGeneralCell (mo->general_belonging, d); + mo->addGeneralCell (d); for (Vol volume : volumesAdjacentByVertex3(map,d)) { if (!map.isBoundaryMarked<3>(volume)) { pushSegmentInCellAsNeighbor(o, volume); mo->neighbor_cells[n].push_back(volume); - mo->addGeneralCell (mo->general_neighbors, d); + mo->addGeneralNeighbor ( d); } } @@ -359,7 +359,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector& memo_c { addElementToVector(RegisteredEdges[*it],o); - mo->addGeneralCell (mo->general_belonging, (*it)); + mo->addGeneralCell ( (*it)); #ifdef DEBUG_affichage CGoGNout<<"cellule du belong :"<<(*it)<& memo_c if (!map.isBoundaryMarked<3>(*it)) { addElementToVector(RegisteredNeighborEdges[*it],o); - mo->addGeneralCell (mo->general_neighbors, (*it)); + mo->addGeneralNeighbor ( (*it)); } } #ifdef DEBUG_affichage @@ -401,14 +401,14 @@ void EnvMap::popSegment(Segment* o) for (std::vector::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it) { removeElementFromVector(RegisteredEdges[*it], o) ; - mo->removeGeneralCell (mo->general_belonging,*it); + mo->removeGeneralCell (*it); } for (std::vector::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it) { if (!map.isBoundaryMarked<3>(*it)) { removeElementFromVector(RegisteredNeighborEdges[*it], o) ; - mo->removeGeneralCell (mo->general_neighbors,*it); + mo->removeGeneralNeighbor (*it); } } mo->belonging_cells[n].clear(); @@ -436,61 +436,44 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle Dart cell =o->cell; std::vector memo; - for(Edge e : edgesIncidentToFace2(mo->surfaceMap,cell)) + for(Edge e : edgesIncidentToFace2(mo->surfaceMap,cell)) // first mark inside { Dart cell2=mo->surfaceMap.phi1(e); // on récupère les aprticules correspondant a chaque edge du triangle a enregistrer PARTICULE * p1 = mo->parts_[mo->indexParticule[cell]]; - PARTICULE * p2 = mo->parts_[mo->indexParticule[cell2]]; + Dart d1=p1->d; // darts de la carte 3D contenant les particules - Dart d2=p2->d; - memo = getMemoCross(p1->getPosition(),p2->getPosition(),d1); + memo = getMemoCross(p1->getPosition(),mo->positionSurface[cell2],d1); - if(map.sameVolume(d1,d2)) - { - markSameVolume(&inside, &neighbor, d1); - } - else - { + for (Dart d : memo) + inside.mark(d); - markMultipleVolumes(&inside, &neighbor, memo); - } } - for(Dart d : inside.get_markedCells()) + + + for(Dart d : inside.get_markedCells()) // and register them { pushTriangleInCell(o,d); - (mo->belonging_cells[mo->indexTriangle[cell]]).push_back(d); - mo->addGeneralCell (mo->general_belonging, d); + (mo->belonging_cells[o->indexTri]).push_back(d); + mo->addGeneralCell ( d); } - for(Dart d : neighbor.get_markedCells()) + markNeighbors(&inside,&neighbor,(mo->belonging_cells[o->indexTri])); // then mark neighbors + for(Dart d : neighbor.get_markedCells()) // and register them { pushTriangleInCellAsNeighbor(o,d); - (mo->neighbor_cells[mo->indexTriangle[cell]]).push_back(d); - mo->addGeneralCell (mo->general_neighbors, d); + (mo->neighbor_cells[o->indexTri]).push_back(d); + mo->addGeneralNeighbor ( d); } } } -void EnvMap::markSameVolume(CellMarkerMemo * memo_mark, CellMarkerMemo* OneRingMark, Dart d) -{ - memo_mark->mark(d); - for (Vol volume : volumesAdjacentByVertex3(map,d)) - { - if (!map.isBoundaryMarked<3>(volume)) - { - - OneRingMark->mark(volume); - } - } -} - -void EnvMap::markMultipleVolumes(CellMarkerMemo* memo_mark, CellMarkerMemo* OneRingMark, const std::vector& memo_cross) // enregistrer une dart dans un ensemble de cellules +void EnvMap::markNeighbors(CellMarkerMemo * memo_mark, CellMarkerMemo* OneRingMark, const std::vector& memo_cross) // enregistrer une dart dans un ensemble de cellules { #ifdef IHMap assert(map.getCurrentLevel() == map.getMaxLevel()); @@ -498,10 +481,7 @@ void EnvMap::markMultipleVolumes(CellMarkerMemo* memo_mark, CellMark assert(!memo_cross.empty()); - for (Dart d : memo_cross) - memo_mark->mark(d); - - for(Dart e : memo_cross) + for(Dart e : memo_cross) { for (Vol d : volumesAdjacentByVertex3(map,e)) @@ -546,14 +526,14 @@ void EnvMap::popTriangle(Triangle* o) for (std::vector::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it) { popTriangleInCell(o,*it); - mo->removeGeneralCell (mo->general_belonging,*it); + mo->removeGeneralCell (*it); } for (std::vector::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it) { if (!map.isBoundaryMarked<3>(*it)) { popTriangleInCellAsNeighbor(o,*it); - mo->removeGeneralCell (mo->general_neighbors,*it); + mo->removeGeneralNeighbor (*it); } } mo->belonging_cells[n].clear(); @@ -580,21 +560,16 @@ bool EnvMap::subdivideVolume(Dart dglobal) // { for ( Face dit : facesIncidentToVolume3(map,old)) { -#ifdef DEBUG_affichage - count++; -#endif Dart nv = map.phi3(dit); if(!map.isBoundaryMarked(3, nv)) { if(map.volumeLevel(nv) == vLevel - 1) { -#ifdef DEBUG_affichage - std::cout << "OK pour cascade en : "<nid; - CGoGNout<<"pop obst inside (index articul , segment ) : "<index_articulated<<" || "<index<popSegment(o) ; } @@ -624,20 +590,25 @@ bool EnvMap::subdivideVolume(Dart dglobal) for (Segment * o : oldNeighborObst) { -#ifdef DEBUG_affichage - ArticulatedObject * mo = o->nid; - CGoGNout<<"pop obst voisin (index articul , segment ) : "<index_articulated<<" || "<index<popSegment(o) ; } -#ifdef DEBUG_affichage - CGoGNout<<"tests pour subdivision"<< CGoGNendl; -#endif + + TRIANGLES oldTrian(RegisteredTriangles[dglobal]) ; + + for (Triangle * o : oldTrian) + { + this->popTriangle(o) ; + } + + TRIANGLES oldTrianNeighbor(RegisteredNeighborTriangles[dglobal]) ; + + for (Triangle * o : oldTrianNeighbor) + { + this->popTriangle(o) ; + } + if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= map.getMaxLevel() && !map.volumeIsSubdivided(dglobal) ) { -#ifdef DEBUG_affichage - CGoGNout<<"debut subdivision"<< CGoGNendl; -#endif Algo::Volume::IHM::subdivideVolumeClassic(map, dglobal, position,false); res=true; } @@ -657,30 +628,28 @@ bool EnvMap::subdivideVolume(Dart dglobal) } + //same for adjacent triangles // optimiser + for (Triangle * o : oldTrianNeighbor) + { + this->FirstRegistrationTriangle(o) ; + } + //same for triangles // optimiser + for (Triangle * o : oldTrian) + { + resetPartSubdiv(o); + this->FirstRegistrationTriangle(o) ; + } -#ifdef DEBUG_affichage - std::cout << "after level = "<< map.getMaxLevel() << std::endl; -#endif //same for adjacent obstacles // optimiser for (Segment * o : oldNeighborObst) { -#ifdef DEBUG_affichage - ArticulatedObject * mo = o->nid; - CGoGNout<<"reenregistrement obst voisin (index articul , segment ) : "<index_articulated<<" || "<index<nid; - CGoGNout<<"reenregistrement obst inside (index articul , segment ) : "<index_articulated<<" || "<index<CGoGN::Algo::MovingObjects::ParticleBase::move(Algo::Surface::Geometry::volumeCentroid>(map,d1,position)) ; - p->reset_positionFace(); + p->reset_positionFace(); // attention avec les particules 3D on doit mettre a jour la position_face !!! #ifdef DEBUG_affichage CGoGNout<<"part1 moved to centroid ,d : "<< p->getPosition()<<" || "<d< prim(surfaceMap, 1,1) ; + prim.embedIntoGrid(positionSurface,1.0f,1.0f, 0.0f) ; @@ -156,12 +157,12 @@ void Surface::initPlane() } - bool test = false; - while (!test) - { - test = subdiveMap(); -// CGoGNout<<"subdiv effectuée ? " < > general_belonging, Dart d) +void Surface::addGeneralCell ( Dart d) { bool added = false; - std::vector< std::pair >::iterator it =general_belonging.begin(); - while (it != general_belonging.end() ) + for(std::pair pere : general_belonging) { - if(sim_->envMap_.map.sameVolume((*it).first,d)) + if(sim_->envMap_.map.sameVolume(pere.first,d)) { - (*it).second ++; + pere.second ++; added= true; break; } - else ++it; - - }; + } if (!added) { general_belonging.push_back(std::make_pair(d,1)); @@ -305,21 +303,62 @@ void Surface::addGeneralCell (std::vector< std::pair > general_belong /*removeGeneralCell * removes cell d to general belonging decreases the number of instance of the cell, if the number is 0 the celle is removed *forever* */ -bool Surface::removeGeneralCell (std::vector< std::pair > general_belonging,Dart d) +bool Surface::removeGeneralCell (Dart d) { - std::vector< std::pair >::iterator it =general_belonging.begin(); - while (it != general_belonging.end() ) + for(std::pair pere : general_belonging) { - if(sim_->envMap_.map.sameVolume((*it).first,d)) + if(sim_->envMap_.map.sameVolume(pere.first,d)) { - if(--((*it).second)==0) + pere.second--; + if(pere.second==0) { - *it = general_belonging.back() ; + pere=general_belonging.back() ; general_belonging.pop_back() ; } return true; } - else ++it; + + + }; + return false; +} + +void Surface::addGeneralNeighbor ( Dart d) +{ + bool added = false; + for(std::pair pere : general_neighbors) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second ++; + added= true; + break; + } + + } + if (!added) + { + general_neighbors.push_back(std::make_pair(d,1)); + } +} +/*removeGeneralCell + * removes cell d to general belonging decreases the number of instance of the cell, if the number is 0 the celle is removed *forever* + */ +bool Surface::removeGeneralNeighbor (Dart d) +{ + for(std::pair pere : general_neighbors) + { + if(sim_->envMap_.map.sameVolume(pere.first,d)) + { + pere.second--; + if(pere.second==0) + { + pere=general_neighbors.back() ; + general_neighbors.pop_back() ; + } + return true; + } + }; return false; diff --git a/src/viewer.cpp b/src/viewer.cpp index f13603c..bef0ce2 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -64,6 +64,22 @@ void Volusion::neighbors_onoff(bool x) render_neighbors= x; updateGL(); } + +void Volusion::obj_onoff(bool x) +{ + display_obj= x; + updateGL(); +} +void Volusion::objBelong_onoff(bool x) +{ + obj_belong= x; + updateGL(); +} +void Volusion::objNeighbors_onoff(bool x) +{ + obj_neighbors= x; + updateGL(); +} void Volusion::comboEdge(int x) { val_comboEdge = x; @@ -84,8 +100,8 @@ void Volusion::topo_onoff(bool x) updateGL(); } -void Volusion::clipping_onoff(bool x) -{ +//void Volusion::clipping_onoff(bool x) +//{ // clip_volume = x; // if (clip_volume) @@ -106,14 +122,14 @@ void Volusion::clipping_onoff(bool x) // m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f); // m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f); // } - updateGL(); -} +// updateGL(); +//} -void Volusion::hide_onoff(bool x) -{ +//void Volusion::hide_onoff(bool x) +//{ // hide_clipping = x; - updateGL(); -} +// updateGL(); +//} void Volusion::slider_explode(int x) { @@ -214,7 +230,7 @@ void Volusion::cb_initGL() m_explode_render->setAmbiant(Geom::Vec4f(0.2f,0.2f,0.2f,1.0f)); m_explode_render->setBackColor(Geom::Vec4f(0.9f,0.9f,0.9f,1.0f)); m_explode_render->setColorLine(Geom::Vec4f(0.8f,0.2f,0.2f,1.0f)); - + m_explode_render->setNoClippingPlane(); // m_sh1 = static_cast(m_topo_render->shader1()); // m_sh2 = static_cast(m_topo_render->shader2()); @@ -234,7 +250,7 @@ void Volusion::cb_initGL() // m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj); // m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj); - m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1))); +// m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1))); // m_closestVBO = new Utils::VBO(); // m_closestVBO->setDataSize(3); @@ -294,61 +310,47 @@ void Volusion::cb_initGL() -void Volusion::cb_redraw() +void Volusion::displayMO() { + m_ds->newList(GL_COMPILE_AND_EXECUTE); + m_ds->begin(GL_LINE_STRIP); - - - - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glEnable(GL_LIGHTING); - - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1.0f, 1.0f); - - if(render_MovingObject) + 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); + VEC3 p = s->p2; + m_ds->vertex(p); + } + m_ds->color3f(0,0.5f,1.0f); - - m_ds->newList(GL_COMPILE_AND_EXECUTE); - 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); - VEC3 p = s->p2; - m_ds->vertex(p); - } - m_ds->color3f(0,0.5f,1.0f); - - m_ds->end(); - m_ds->endList(); + m_ds->end(); + m_ds->endList(); // VEC3 pos1 = simul.aiguille->parts_[0]->getPosition(); // VEC3 pos2 = simul.aiguille->parts_[1]->getPosition(); // float f; // VEC3 cylinder_axis =cylinder->getAxisScale(2,f); - PFP::VEC3* data = static_cast(m_MovingObjectVBO->lockPtr()); - int i=0; - for(auto particule : simul.aiguille->parts_) - { - VEC3 p = particule->getPosition(); + PFP::VEC3* data = static_cast(m_MovingObjectVBO->lockPtr()); + int i=0; + for(auto particule : simul.aiguille->parts_) + { + VEC3 p = particule->getPosition(); // if(i==0) // { // 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); // } - data[i] = p; - i++; - } + data[i] = p; + i++; + } // data[simul.aiguille->nbVertices]=simul.aiguille->closest_point; - m_MovingObjectVBO->releasePtr(); + m_MovingObjectVBO->releasePtr(); // m_frame_MovingObject->draw(); // CGoGNout<rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1)); @@ -357,130 +359,193 @@ void Volusion::cb_redraw() // cylinder->draw(); - m_sprite->enableVertexAttribs(); - glDrawArrays(GL_POINTS, 0, simul.aiguille->nbVertices/*+1*/); - m_sprite->disableVertexAttribs(); + m_sprite->enableVertexAttribs(); + glDrawArrays(GL_POINTS, 0, simul.aiguille->nbVertices/*+1*/); + m_sprite->disableVertexAttribs(); + if(render_belonging) // affichage des cellules qui contiennent l'aiguille + { + m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); - } - if(true) // affichage objets fixes - { -// PFP::VEC3* data2 = static_cast(m_closestVBO->lockPtr()); + if ((unsigned int)dock.comboBoxEdge->count()nbEdges) + { + dock.comboBoxEdge->clear(); + dock.comboBoxEdge->addItem("Aiguille entiere",2); + for(unsigned int i = 0; i< simul.aiguille->nbEdges;i++) + { + std::ostringstream oss ; + oss<<"arete "<addItem(s,2); + } + } + -// int j =0; - for(Surface * surf : simul.surfaces) + if(val_comboEdge==0) { - surf->draw(); -// for(Triangle * t : surf->triangles_) -// { -// data2[j]=t->closest_point; -//// data2[j+1]=t->p1; -// j++; -// } + for(unsigned int i =0;inbEdges;i++) + { +// 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 (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + { - } + m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); + } -// m_closestVBO->releasePtr(); -// m_spriteClosest->enableVertexAttribs(); -// glDrawArrays(GL_POINTS, 0, j+1); -// m_spriteClosest->disableVertexAttribs(); - for (ArticulatedObject * art : simul.objects) + } + } +// m_topo_render->overdrawDart(simul.aiguille->parts_[simul.aiguille->nbEdges]->d,10.0f,1.0f,0,0); + } + else { +// 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 (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + { + m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); + } - m_ds->newList(GL_COMPILE_AND_EXECUTE); - m_ds->begin(GL_LINE_STRIP); - m_ds->lineWidth(10.0f); - if(art->nbEdges>0) - { - VEC3 origin = art->Segments_[0]->p1; - Segment * s=art->Segments_[0]; - m_ds->color3f(s->r,s->g,s->b); - m_ds->vertex(origin); - } - for(Segment * s : art->Segments_) - { - m_ds->color3f(s->r,s->g,s->b); - VEC3 p = s->p2; - m_ds->vertex(p); } + } + } - m_ds->end(); - m_ds->endList(); - // VEC3 pos1 = art->parts_[0]->getPosition(); - // VEC3 pos2 = art->parts_[1]->getPosition(); - // float f; - // VEC3 cylinder_axis =cylinder->getAxisScale(2,f); - PFP::VEC3* data = static_cast(m_MovingObjectVBO->lockPtr()); - int i=0; - for(auto particule : art->parts_) + if(render_neighbors) // affichage des cellules voisines de l'aiguille + { + 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++) { - VEC3 p = particule->getPosition(); - // if(i==0) - // { - // 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); - // } - data[i] = p; - i++; - } + for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) + { + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + { - m_MovingObjectVBO->releasePtr(); - // m_frame_MovingObject->draw(); - // CGoGNout<rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1)); + m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); + } - // cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2); - // cylinder->draw(); + } + + } + } + else + { + int i = val_comboEdge-1; + for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) + { + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + { + m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); + } - m_sprite->enableVertexAttribs(); - glDrawArrays(GL_POINTS, 0, art->nbVertices); - m_sprite->disableVertexAttribs(); + } } + } +} +void Volusion::displayObj() +{ - } - if(false) //affichage des normales + // PFP::VEC3* data2 = static_cast(m_closestVBO->lockPtr()); + + // int j =0; + for(Surface * surf : simul.surfaces) { - Dart volume=simul.envMap_.map.indexDart(1500); - for (Face d : facesIncidentToVolume3(simul.envMap_.map,volume)) - { + surf->draw(); +// for(Triangle * t : surf->triangles_) +// { +// data2[j]=t->closest_point; +//// data2[j+1]=t->p1; +// j++; - m_ds->newList(GL_COMPILE_AND_EXECUTE); - m_ds->begin(GL_LINE_STRIP); - m_ds->color3f(0,1.0f,0); - m_ds->lineWidth(10.0f); - m_ds->vertex(simul.envMap_.facecenter[d]); - m_ds->vertex(simul.envMap_.facecenter[d]+simul.envMap_.normaleFromVolume(volume,d)); - m_ds->end(); - m_ds->endList(); - } +// } } - if (draw_dart) +// m_closestVBO->releasePtr(); +// m_spriteClosest->enableVertexAttribs(); +// glDrawArrays(GL_POINTS, 0, j+1); +// m_spriteClosest->disableVertexAttribs(); + + for (ArticulatedObject * art : simul.objects) { - 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_ds->newList(GL_COMPILE_AND_EXECUTE); + m_ds->begin(GL_LINE_STRIP); + + m_ds->lineWidth(10.0f); + if(art->nbEdges>0) { - m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f); + VEC3 origin = art->Segments_[0]->p1; + Segment * s=art->Segments_[0]; + m_ds->color3f(s->r,s->g,s->b); + m_ds->vertex(origin); + } + for(Segment * s : art->Segments_) + { + m_ds->color3f(s->r,s->g,s->b); + VEC3 p = s->p2; + m_ds->vertex(p); + } + + m_ds->end(); + m_ds->endList(); +// VEC3 pos1 = art->parts_[0]->getPosition(); +// VEC3 pos2 = art->parts_[1]->getPosition(); +// float f; +// VEC3 cylinder_axis =cylinder->getAxisScale(2,f); + PFP::VEC3* data = static_cast(m_MovingObjectVBO->lockPtr()); + int i=0; + for(auto particule : art->parts_) + { + VEC3 p = particule->getPosition(); +// if(i==0) +// { +// 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); +// } + data[i] = p; + i++; } - } - if(render_belonging) + + m_MovingObjectVBO->releasePtr(); +// m_frame_MovingObject->draw(); +// CGoGNout<rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1)); + +// cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2); +// cylinder->draw(); + + + m_sprite->enableVertexAttribs(); + glDrawArrays(GL_POINTS, 0, art->nbVertices); + m_sprite->disableVertexAttribs(); + + + } + if(obj_belong) { m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); for (ArticulatedObject * o : simul.objects) @@ -492,7 +557,7 @@ void Volusion::cb_redraw() { for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) { - m_topo_render->overdrawDart(d,5.0f,0.5f,0,0.4f); + m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f); } @@ -510,108 +575,109 @@ void Volusion::cb_redraw() { for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) { - m_topo_render->overdrawDart(d,5.0f,0.5f,0,0.4f); + m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f); } } } } - - - if ((unsigned int)dock.comboBoxEdge->count()nbEdges) + } + if(obj_neighbors) + { + m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); + for (ArticulatedObject * o : simul.objects) { - dock.comboBoxEdge->clear(); - dock.comboBoxEdge->addItem("Aiguille entiere",2); - for(unsigned int i = 0; i< simul.aiguille->nbEdges;i++) + for(unsigned int i =0;inbEdges;i++) { - std::ostringstream oss ; - oss<<"arete "<addItem(s,2); + // 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) + { + for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) + { + m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); + } + + + } } } - - if(val_comboEdge==0) + 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;inbEdges;i++) + 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 = simul.aiguille->belonging_cells[i].begin(); it !=simul.aiguille->belonging_cells[i].end();++it) + // 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) { for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) { - - m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); + m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); } } } -// m_topo_render->overdrawDart(simul.aiguille->parts_[simul.aiguille->nbEdges]->d,10.0f,1.0f,0,0); } - else - { + } +} -// 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) - { +void Volusion::cb_redraw() +{ - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) - { - m_topo_render->overdrawDart(d,5.0f,0,1.0f,0); - } - } - } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_LIGHTING); - } + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1.0f, 1.0f); - if(render_neighbors) + if(render_MovingObject) + { + displayMO(); + } + if(display_obj) // affichage objets fixes { - 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 it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) - { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) - { - - m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); - } + displayObj(); - } + } + if(false) //affichage des normales + { + Dart volume=simul.envMap_.map.indexDart(1500); + for (Face d : facesIncidentToVolume3(simul.envMap_.map,volume)) + { - } + m_ds->newList(GL_COMPILE_AND_EXECUTE); + m_ds->begin(GL_LINE_STRIP); + m_ds->color3f(0,1.0f,0); + m_ds->lineWidth(10.0f); + m_ds->vertex(simul.envMap_.facecenter[d]); + m_ds->vertex(simul.envMap_.facecenter[d]+simul.envMap_.normaleFromVolume(volume,d)); + m_ds->end(); + m_ds->endList(); } - else - { - int i = val_comboEdge-1; - for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it) - { - for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it))) - { - m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f); - } + } - } + 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_topo) { m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); @@ -804,9 +870,11 @@ int main(int argc, char **argv) sqt.setCallBack( sqt.dock.checkBox_MovingObject, SIGNAL(toggled(bool)), SLOT(MovingObject_onoff(bool)) ); sqt.setCallBack( sqt.dock.checkBox_belonging, SIGNAL(toggled(bool)), SLOT(belonging_onoff(bool)) ); sqt.setCallBack( sqt.dock.checkBox_neighbors, SIGNAL(toggled(bool)), SLOT(neighbors_onoff(bool)) ); - sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) ); - sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) ); - sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(valueChanged(int)), SLOT(slider_explode(int)) ); + sqt.setCallBack( sqt.dock.checkBox_displayobjects, SIGNAL(toggled(bool)), SLOT(obj_onoff(bool)) ); + sqt.setCallBack( sqt.dock.checkBox_ObjBelong, SIGNAL(toggled(bool)), SLOT(objBelong_onoff(bool)) ); + sqt.setCallBack( sqt.dock.checkBox_ObjNeighbors, SIGNAL(toggled(bool)), SLOT(objNeighbors_onoff(bool)) ); +// sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) ); +// sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) ); sqt.setCallBack( sqt.dock.comboBoxEdge, SIGNAL( activated(int)), SLOT(comboEdge(int)) ); sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderPressed()), SLOT(slider_pressed()) ); sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderReleased()), SLOT(slider_released()) ); @@ -820,15 +888,18 @@ int main(int argc, char **argv) sqt.show(); sqt.dock.slider_explode->setValue(100); sqt.dock.slider_explode_face->setValue(100); - sqt.clipping_onoff(false); +// sqt.clipping_onoff(false); sqt.topo_onoff(false); sqt.edges_onoff(true); sqt.dock.checkBox_MovingObject->setChecked(true); + sqt.dock.checkBox_displayobjects->setChecked(true); + sqt.dock.checkBox_ObjBelong->setChecked(false); + sqt.dock.checkBox_ObjNeighbors->setChecked(false); sqt.dock.checkBox_topo->setChecked(false); sqt.dock.checkBox_belonging->setChecked(false); sqt.dock.checkBox_neighbors->setChecked(false); - sqt.dock.checkBox_plane->setChecked(false); - sqt.dock.checkBox_hide->setChecked(true); +// sqt.dock.checkBox_plane->setChecked(false); +// sqt.dock.checkBox_hide->setChecked(true); sqt.dock.checkBox_volumes->setChecked(false); sqt.dock.spinBox_dart->setRange(0, sqt.simul.envMap_.map.end().index) ; -- GitLab