Commit b81d34da authored by Thomas Pitiot 's avatar Thomas Pitiot

up2

parent 4ab1c999
...@@ -15,8 +15,10 @@ class ArticulatedObject ...@@ -15,8 +15,10 @@ class ArticulatedObject
{ {
public : public :
VEC3 getPositionSegment(int index) ; VEC3 getPositionSegment(int index) ;
void addGeneralCell (std::vector< std::pair<Dart,int> > general_belonging, Dart d); void addGeneralCell ( Dart d);
bool removeGeneralCell (std::vector< std::pair<Dart,int> > general_belonging,Dart d); bool removeGeneralCell (Dart d);
void addGeneralNeighbor ( Dart d);
bool removeGeneralNeighbor (Dart d);
VEC3 getPosition(int index); VEC3 getPosition(int index);
unsigned int nbVertices; unsigned int nbVertices;
...@@ -27,7 +29,7 @@ public : ...@@ -27,7 +29,7 @@ public :
std::vector<Dart> * belonging_cells; std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells; std::vector<Dart> * neighbor_cells;
std::vector<std::pair<Dart, int> > general_belonging; std::vector<std::pair<Dart, int> > general_belonging;
std::vector<std::pair<Dart, int> > general_neighbors; std::vector<std::pair<Dart, int> > general_neighbors;
double width; double width;
Simulator* sim_; Simulator* sim_;
......
...@@ -83,23 +83,6 @@ ...@@ -83,23 +83,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBox_belonging">
<property name="text">
<string>Belonging Cells</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_neighbors">
<property name="text">
<string>Neighbor Cells</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxEdge"/>
</item>
<item> <item>
<widget class="QSlider" name="slider_explode"> <widget class="QSlider" name="slider_explode">
<property name="value"> <property name="value">
...@@ -117,6 +100,9 @@ ...@@ -117,6 +100,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QComboBox" name="comboBoxEdge"/>
</item>
<item> <item>
<widget class="QCheckBox" name="checkBox_MovingObject"> <widget class="QCheckBox" name="checkBox_MovingObject">
<property name="text"> <property name="text">
...@@ -125,32 +111,37 @@ ...@@ -125,32 +111,37 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Line" name="line_3"> <widget class="QCheckBox" name="checkBox_belonging">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Belonging Cells</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_plane"> <widget class="QCheckBox" name="checkBox_neighbors">
<property name="text"> <property name="text">
<string>clipping</string> <string>Neighbor Cells</string>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
<property name="checked"> </widget>
<bool>true</bool> </item>
<item>
<widget class="QCheckBox" name="checkBox_displayobjects">
<property name="text">
<string>Objects</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_hide"> <widget class="QCheckBox" name="checkBox_ObjBelong">
<property name="enabled"> <property name="text">
<bool>true</bool> <string>Objects belonging</string>
</property> </property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ObjNeighbors">
<property name="text"> <property name="text">
<string>hide clipping plane</string> <string>Objects neighbors</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -190,22 +181,5 @@ ...@@ -190,22 +181,5 @@
</widget> </widget>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>checkBox_plane</sender>
<signal>clicked(bool)</signal>
<receiver>checkBox_hide</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>74</x>
<y>174</y>
</hint>
<hint type="destinationlabel">
<x>74</x>
<y>200</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
...@@ -98,8 +98,7 @@ public: ...@@ -98,8 +98,7 @@ public:
//Enregistrement Surfaces //Enregistrement Surfaces
void popAndPushTriangle(Triangle* o); // pop et push d'une Triangle void popAndPushTriangle(Triangle* o); // pop et push d'une Triangle
void FirstRegistrationTriangle (Triangle* o); // premier enregistrement d'une Triangle void FirstRegistrationTriangle (Triangle* o); // premier enregistrement d'une Triangle
void markSameVolume(CellMarkerMemo<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME> *OneRingMark, Dart d); // enregistrer une dart dans une cellule void markNeighbors(CellMarkerMemo<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME> * OneRingMark, const std::vector<Dart>& memo_cross); // marker les cellules voisines d'un ensemble de cellules retenu dans memo_cross
void markMultipleVolumes(CellMarkerMemo<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME> * OneRingMark, const std::vector<Dart>& memo_cross); // enregistrer une dart dans un ensemble de cellules
void popTriangle(Triangle* o); void popTriangle(Triangle* o);
void pushTriangleInCell(Triangle* o, Dart d); void pushTriangleInCell(Triangle* o, Dart d);
......
...@@ -51,9 +51,10 @@ public: ...@@ -51,9 +51,10 @@ public:
void initOperators(SubdivisionType st); // fonction de sélection du type de subdivision pour l'ihm2 void initOperators(SubdivisionType st); // fonction de sélection du type de subdivision pour l'ihm2
void addGeneralCell (std::vector< std::pair<Dart,int> > general_belonging, Dart d); void addGeneralCell ( Dart d);
bool removeGeneralCell (std::vector< std::pair<Dart,int> > general_belonging,Dart d); bool removeGeneralCell (Dart d);
void addGeneralNeighbor ( Dart d);
bool removeGeneralNeighbor (Dart d);
std::vector<Dart> * belonging_cells; std::vector<Dart> * belonging_cells;
......
...@@ -80,6 +80,9 @@ class Volusion: public Utils::QT::SimpleQGLV ...@@ -80,6 +80,9 @@ class Volusion: public Utils::QT::SimpleQGLV
bool render_topo; bool render_topo;
bool render_MovingObject; bool render_MovingObject;
bool render_topoTemp; bool render_topoTemp;
bool display_obj;
bool obj_belong;
bool obj_neighbors;
// bool clip_volume; // bool clip_volume;
// bool hide_clipping; // bool hide_clipping;
bool draw_dart; bool draw_dart;
...@@ -136,6 +139,9 @@ public: ...@@ -136,6 +139,9 @@ public:
render_topo(false), render_topo(false),
render_MovingObject(true), render_MovingObject(true),
render_topoTemp(false), render_topoTemp(false),
display_obj(true),
obj_belong(false),
obj_neighbors(false),
// clip_volume(false), // clip_volume(false),
// hide_clipping(true), // hide_clipping(true),
draw_dart(false), draw_dart(false),
...@@ -149,6 +155,8 @@ public: ...@@ -149,6 +155,8 @@ public:
{} {}
void displayMO();
void displayObj();
protected: protected:
void cb_redraw(); void cb_redraw();
...@@ -169,8 +177,11 @@ public slots: ...@@ -169,8 +177,11 @@ public slots:
void belonging_onoff(bool x); void belonging_onoff(bool x);
void neighbors_onoff(bool x); void neighbors_onoff(bool x);
void comboEdge(int x); void comboEdge(int x);
void clipping_onoff(bool x); void obj_onoff(bool x);
void hide_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_explode(int x);
void slider_pressed(); void slider_pressed();
void slider_released(); void slider_released();
......
...@@ -6,50 +6,87 @@ ...@@ -6,50 +6,87 @@
*/ */
void ArticulatedObject::addGeneralCell (std::vector< std::pair<Dart,int> > general_belonging, Dart d) void ArticulatedObject::addGeneralCell ( Dart d)
{ {
bool added = false; bool added = false;
std::vector< std::pair<Dart,int> >::iterator it =general_belonging.begin(); for(std::pair<Dart,int> pere : general_belonging)
while (it != general_belonging.end() ) {
{ if(sim_->envMap_.map.sameVolume(pere.first,d))
if(sim_->envMap_.map.sameVolume((*it).first,d)) {
{ pere.second ++;
(*it).second ++; added= true;
added= true; break;
break; }
}
else ++it; }
if (!added)
}; {
general_belonging.push_back(std::make_pair(d,1));
if (!added) }
{
general_belonging.push_back(std::make_pair(d,1));
}
} }
/*removeGeneralCell /*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* * 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<Dart,int> > general_belonging,Dart d) bool ArticulatedObject::removeGeneralCell (Dart d)
{ {
std::vector< std::pair<Dart,int> >::iterator it =general_belonging.begin(); for(std::pair<Dart,int> pere : general_belonging)
while (it != general_belonging.end() ) {
{ if(sim_->envMap_.map.sameVolume(pere.first,d))
if(sim_->envMap_.map.sameVolume((*it).first,d)) {
{ pere.second--;
if(--((*it).second)==0) if(pere.second==0)
{ {
*it = general_belonging.back() ; pere=general_belonging.back() ;
general_belonging.pop_back() ; general_belonging.pop_back() ;
} }
return true; return true;
} }
else ++it;
}; };
return false; return false;
} }
void ArticulatedObject::addGeneralNeighbor ( Dart d)
{
bool added = false;
for(std::pair<Dart,int> 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<Dart,int> 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) VEC3 ArticulatedObject::getPosition(int index)
{ {
......
...@@ -321,14 +321,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) ...@@ -321,14 +321,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
addElementToVector<Segment*>(RegisteredEdges[d],o); addElementToVector<Segment*>(RegisteredEdges[d],o);
mo->belonging_cells[n].push_back(d); mo->belonging_cells[n].push_back(d);
mo->addGeneralCell (mo->general_belonging, d); mo->addGeneralCell (d);
for (Vol volume : volumesAdjacentByVertex3(map,d)) for (Vol volume : volumesAdjacentByVertex3(map,d))
{ {
if (!map.isBoundaryMarked<3>(volume)) if (!map.isBoundaryMarked<3>(volume))
{ {
pushSegmentInCellAsNeighbor(o, volume); pushSegmentInCellAsNeighbor(o, volume);
mo->neighbor_cells[n].push_back(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<Dart>& memo_c ...@@ -359,7 +359,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
{ {
addElementToVector<Segment*>(RegisteredEdges[*it],o); addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell (mo->general_belonging, (*it)); mo->addGeneralCell ( (*it));
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl; CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;
#endif #endif
...@@ -372,7 +372,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c ...@@ -372,7 +372,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
if (!map.isBoundaryMarked<3>(*it)) if (!map.isBoundaryMarked<3>(*it))
{ {
addElementToVector<Segment*>(RegisteredNeighborEdges[*it],o); addElementToVector<Segment*>(RegisteredNeighborEdges[*it],o);
mo->addGeneralCell (mo->general_neighbors, (*it)); mo->addGeneralNeighbor ( (*it));
} }
} }
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
...@@ -401,14 +401,14 @@ void EnvMap::popSegment(Segment* o) ...@@ -401,14 +401,14 @@ void EnvMap::popSegment(Segment* o)
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it) for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{ {
removeElementFromVector<Segment*>(RegisteredEdges[*it], o) ; removeElementFromVector<Segment*>(RegisteredEdges[*it], o) ;
mo->removeGeneralCell (mo->general_belonging,*it); mo->removeGeneralCell (*it);
} }
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it) for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
{ {
if (!map.isBoundaryMarked<3>(*it)) if (!map.isBoundaryMarked<3>(*it))
{ {
removeElementFromVector<Segment*>(RegisteredNeighborEdges[*it], o) ; removeElementFromVector<Segment*>(RegisteredNeighborEdges[*it], o) ;
mo->removeGeneralCell (mo->general_neighbors,*it); mo->removeGeneralNeighbor (*it);
} }
} }
mo->belonging_cells[n].clear(); mo->belonging_cells[n].clear();
...@@ -436,61 +436,44 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle ...@@ -436,61 +436,44 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle
Dart cell =o->cell; Dart cell =o->cell;
std::vector<Dart> memo; std::vector<Dart> memo;
for(Edge e : edgesIncidentToFace2<SURFACE>(mo->surfaceMap,cell)) for(Edge e : edgesIncidentToFace2<SURFACE>(mo->surfaceMap,cell)) // first mark inside
{ {
Dart cell2=mo->surfaceMap.phi1(e); Dart cell2=mo->surfaceMap.phi1(e);
// on récupère les aprticules correspondant a chaque edge du triangle a enregistrer // on récupère les aprticules correspondant a chaque edge du triangle a enregistrer
PARTICULE * p1 = mo->parts_[mo->indexParticule[cell]]; 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 d1=p1->d; // darts de la carte 3D contenant les particules
Dart d2=p2->d; memo = getMemoCross(p1->getPosition(),mo->positionSurface[cell2],d1);
memo = getMemoCross(p1->getPosition(),p2->getPosition(),d1);
if(map.sameVolume(d1,d2)) for (Dart d : memo)
{ inside.mark(d);
markSameVolume(&inside, &neighbor, d1);
}
else
{
markMultipleVolumes(&inside, &neighbor, memo);
}
} }
for(Dart d : inside.get_markedCells())
for(Dart d : inside.get_markedCells()) // and register them
{ {
pushTriangleInCell(o,d); pushTriangleInCell(o,d);
(mo->belonging_cells[mo->indexTriangle[cell]]).push_back(d); (mo->belonging_cells[o->indexTri]).push_back(d);
mo->addGeneralCell (mo->general_belonging, 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); pushTriangleInCellAsNeighbor(o,d);
(mo->neighbor_cells[mo->indexTriangle[cell]]).push_back(d); (mo->neighbor_cells[o->indexTri]).push_back(d);
mo->addGeneralCell (mo->general_neighbors, d); mo->addGeneralNeighbor ( d);
} }
} }
} }
void EnvMap::markSameVolume(CellMarkerMemo<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME>* OneRingMark, Dart d)
{
memo_mark->mark(d);
for (Vol volume : volumesAdjacentByVertex3(map,d)) void EnvMap::markNeighbors(CellMarkerMemo<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME>* OneRingMark, const std::vector<Dart>& memo_cross) // enregistrer une dart dans un ensemble de cellules
{
if (!map.isBoundaryMarked<3>(volume))
{
OneRingMark->mark(volume);
}
}
}
void EnvMap::markMultipleVolumes(CellMarkerMemo<MAP,VOLUME>* memo_mark, CellMarkerMemo<MAP,VOLUME>* OneRingMark, const std::vector<Dart>& memo_cross) // enregistrer une dart dans un ensemble de cellules
{ {
#ifdef IHMap #ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel()); assert(map.getCurrentLevel() == map.getMaxLevel());
...@@ -498,10 +481,7 @@ void EnvMap::markMultipleVolumes(CellMarkerMemo<MAP,VOLUME>* memo_mark, CellMark ...@@ -498,10 +481,7 @@ void EnvMap::markMultipleVolumes(CellMarkerMemo<MAP,VOLUME>* memo_mark, CellMark
assert(!memo_cross.empty()); assert(!memo_cross.empty());
for (Dart d : memo_cross) for(Dart e : memo_cross)
memo_mark->mark(d);
for(Dart e : memo_cross)
{ {
for (Vol d : volumesAdjacentByVertex3(map,e)) for (Vol d : volumesAdjacentByVertex3(map,e))
...@@ -546,14 +526,14 @@ void EnvMap::popTriangle(Triangle* o) ...@@ -546,14 +526,14 @@ void EnvMap::popTriangle(Triangle* o)
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it) for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{ {
popTriangleInCell(o,*it); popTriangleInCell(o,*it);
mo->removeGeneralCell (mo->general_belonging,*it); mo->removeGeneralCell (*it);
} }
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it) for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
{ {
if (!map.isBoundaryMarked<3>(*it)) if (!map.isBoundaryMarked<3>(*it))
{ {
popTriangleInCellAsNeighbor(o,*it); popTriangleInCellAsNeighbor(o,*it);
mo->removeGeneralCell (mo->general_neighbors,*it); mo->removeGeneralNeighbor (*it);
} }
} }
mo->belonging_cells[n].clear(); mo->belonging_cells[n].clear();
...@@ -580,21 +560,16 @@ bool EnvMap::subdivideVolume(Dart dglobal) ...@@ -580,21 +560,16 @@ bool EnvMap::subdivideVolume(Dart dglobal)
// { // {
for ( Face dit : facesIncidentToVolume3(map,old)) for ( Face dit : facesIncidentToVolume3(map,old))
{ {
#ifdef DEBUG_affichage
count++;
#endif
Dart nv = map.phi3(dit); Dart nv = map.phi3(dit);
if(!map.isBoundaryMarked(3, nv)) if(!map.isBoundaryMarked(3, nv))
{ {
if(map.volumeLevel(nv) == vLevel - 1) if(map.volumeLevel(nv) == vLevel - 1)
{ {
#ifdef DEBUG_affichage
std::cout << "OK pour cascade en : "<<nv<< std::endl;
#endif
int currentLevel = map.getCurrentLevel(); int currentLevel = map.getCurrentLevel();
subdivideVolume(nv); subdivideVolume(nv);
map.setCurrentLevel(currentLevel); map.setCurrentLevel(currentLevel);
}