Commit b81d34da authored by Thomas Pitiot 's avatar Thomas Pitiot

up2

parent 4ab1c999
......@@ -15,8 +15,10 @@ class ArticulatedObject
{
public :
VEC3 getPositionSegment(int index) ;
void addGeneralCell (std::vector< std::pair<Dart,int> > general_belonging, Dart d);
bool removeGeneralCell (std::vector< std::pair<Dart,int> > 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<Dart> * belonging_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;
double width;
Simulator* sim_;
......
......@@ -83,23 +83,6 @@
</property>
</widget>
</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>
<widget class="QSlider" name="slider_explode">
<property name="value">
......@@ -117,6 +100,9 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxEdge"/>
</item>
<item>
<widget class="QCheckBox" name="checkBox_MovingObject">
<property name="text">
......@@ -125,32 +111,37 @@
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QCheckBox" name="checkBox_belonging">
<property name="text">
<string>Belonging Cells</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_plane">
<widget class="QCheckBox" name="checkBox_neighbors">
<property name="text">
<string>clipping</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>Neighbor Cells</string>
</property>
<property name="checked">
<bool>true</bool>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_displayobjects">
<property name="text">
<string>Objects</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_hide">
<property name="enabled">
<bool>true</bool>
<widget class="QCheckBox" name="checkBox_ObjBelong">
<property name="text">
<string>Objects belonging</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ObjNeighbors">
<property name="text">
<string>hide clipping plane</string>
<string>Objects neighbors</string>
</property>
</widget>
</item>
......@@ -190,22 +181,5 @@
</widget>
</widget>
<resources/>
<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>
<connections/>
</ui>
......@@ -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<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME> *OneRingMark, Dart d); // enregistrer une dart dans une cellule
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 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 popTriangle(Triangle* o);
void pushTriangleInCell(Triangle* o, Dart d);
......
......@@ -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<Dart,int> > general_belonging, Dart d);
bool removeGeneralCell (std::vector< std::pair<Dart,int> > general_belonging,Dart d);
void addGeneralCell ( Dart d);
bool removeGeneralCell (Dart d);
void addGeneralNeighbor ( Dart d);
bool removeGeneralNeighbor (Dart d);
std::vector<Dart> * belonging_cells;
......
......@@ -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();
......
......@@ -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;
std::vector< std::pair<Dart,int> >::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<Dart,int> 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<Dart,int> > general_belonging,Dart d)
bool ArticulatedObject::removeGeneralCell (Dart d)
{
std::vector< std::pair<Dart,int> >::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<Dart,int> 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<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)
{
......
......@@ -321,14 +321,14 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
addElementToVector<Segment*>(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<Dart>& memo_c
{
addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell (mo->general_belonging, (*it));
mo->addGeneralCell ( (*it));
#ifdef DEBUG_affichage
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;
#endif
......@@ -372,7 +372,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
if (!map.isBoundaryMarked<3>(*it))
{
addElementToVector<Segment*>(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<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{
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)
{
if (!map.isBoundaryMarked<3>(*it))
{
removeElementFromVector<Segment*>(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<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);
// 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<MAP,VOLUME> * memo_mark, CellMarkerMemo<MAP,VOLUME>* 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<MAP,VOLUME>* memo_mark, CellMarkerMemo<MAP,VOLUME>* OneRingMark, const std::vector<Dart>& memo_cross) // enregistrer une dart dans un ensemble de cellules
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
{
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
......@@ -498,10 +481,7 @@ void EnvMap::markMultipleVolumes(CellMarkerMemo<MAP,VOLUME>* 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<Dart>::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<Dart>::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 : "<<nv<< std::endl;
#endif
int currentLevel = map.getCurrentLevel();
subdivideVolume(nv);
map.setCurrentLevel(currentLevel);
}
else if()
}
}
......@@ -604,19 +579,10 @@ bool EnvMap::subdivideVolume(Dart dglobal)
// map.check();
map.setCurrentLevel(map.getMaxLevel()) ;
#ifdef DEBUG_affichage
CGoGNout<<"debut refine"<<CGoGNendl;
std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << " nombre de faces verifiées : "<<count<< std::endl;
#endif
ARETES oldobst(RegisteredEdges[dglobal]) ;
for (Segment * o : oldobst)
{
#ifdef DEBUG_affichage
ArticulatedObject * mo = o->nid;
CGoGNout<<"pop obst inside (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
this->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 ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
this->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<PFP>(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 ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
FirstRegistrationSegment(o) ;
}
//same for obstacles contained
for (Segment * o : oldobst)
{
#ifdef DEBUG_affichage
ArticulatedObject * mo = o->nid;
CGoGNout<<"reenregistrement obst inside (index articul , segment ) : "<<mo->index_articulated<<" || "<<o->index<<CGoGNendl;
#endif
resetPartSubdiv(o);
FirstRegistrationSegment(o);
......@@ -688,10 +657,6 @@ bool EnvMap::subdivideVolume(Dart dglobal)
#ifdef DEBUG_affichage
CGoGNout<<"fin refine principal"<<CGoGNendl;
#endif
#endif
return res;
......@@ -773,7 +738,7 @@ void EnvMap::resetPartSubdiv(Triangle * o)
#endif
p->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(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()<<" || "<<p->d<<CGoGNendl;
......