Commit c849c0ae authored by Etienne Schmitt's avatar Etienne Schmitt

some cleaning

Signed-off-by: Etienne Schmitt's avatarÉtienne Schmitt <etienne.schmitt@inria.fr>
parent 9d618d97
......@@ -28,7 +28,7 @@ public :
return parts_[(Segments_[index])->indexPart1]->getPosition();
}
const PARTICULE* getParticule(int index) const
const Particule* getParticule(int index) const
{
return parts_[index];
}
......@@ -55,7 +55,7 @@ public :
unsigned int nbVertices;
unsigned int nbEdges;
std::vector<PARTICULE*> parts_ ;
std::vector<Particule*> parts_ ;
std::vector<Segment *> Segments_;
std::vector< std::vector<Dart> > belonging_cells;
......
......@@ -38,8 +38,8 @@ using namespace CGoGN ;
#include "triangle.h"
typedef CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP> PARTICULE;
typedef CGoGN::Algo::Volume::MovingObjects::ParticleCell3DMemo<PFP> PARTICULEMEMO;
typedef CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP> Particule;
typedef CGoGN::Algo::Volume::MovingObjects::ParticleCell3DMemo<PFP> ParticuleMemo;
class EnvMap
{
......
......@@ -25,24 +25,12 @@ class Surface
{
public:
Surface(Simulator* sim, VEC3 offset) ;
~Surface();
VEC3 getPosition(int index);
unsigned int nbVertices;
unsigned int nbTriangles;
std::vector<PARTICULE*> parts_ ;
std::vector<Triangle *> triangles_;
SURFACE surfaceMap; // map
CGoGN::Algo::MR::Primal::Adaptive::IHM2<PFPSurface> mapOperator;
VertexAttribute<VEC3, SURFACE> positionSurface ; //position
VertexAttribute<int, SURFACE> indexParticule; // index des particules de chaque sommet
FaceAttribute<int, SURFACE> indexTriangle;
FaceAttribute<VEC3,SURFACE> faceColor;
const VEC3& getPosition(int index) const
{
return parts_[index]->getPosition();
}
void initPlane(); //initialisation d'une grille
......@@ -57,8 +45,8 @@ public:
bool removeGeneralNeighbor (Dart d);
std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells;
std::vector< std::vector<Dart> > belonging_cells;
std::vector< std::vector<Dart> > neighbor_cells;
std::vector<std::pair<Dart, int> > general_belonging;
std::vector<std::pair<Dart, int> > general_neighbors;
......@@ -75,6 +63,19 @@ public:
unsigned int nbVertices;
unsigned int nbTriangles;
std::vector<Particule*> parts_ ;
std::vector<Triangle *> triangles_;
SURFACE surfaceMap; // map
CGoGN::Algo::MR::Primal::Adaptive::IHM2<PFPSurface> mapOperator;
VertexAttribute<VEC3, SURFACE> positionSurface ; //position
VertexAttribute<int, SURFACE> indexParticule; // index des particules de chaque sommet
FaceAttribute<int, SURFACE> indexTriangle;
FaceAttribute<VEC3,SURFACE> faceColor;
// visualisation
void initGL(); // initialisation GL
void draw(); // redessiner l'objet
......
......@@ -9,7 +9,7 @@
ArticulatedObject::ArticulatedObject() :
nbVertices(0u)
,nbEdges(0u)
,parts_(std::vector<PARTICULE*>())
,parts_(std::vector<Particule*>())
,Segments_(std::vector<Segment *>())
,belonging_cells(NULL)
,neighbor_cells(NULL)
......
......@@ -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
......@@ -439,7 +438,7 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle
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 * p1 = mo->parts_[mo->indexParticule[cell]];
Dart d1=p1->d; // darts de la carte 3D contenant les particules
......@@ -596,40 +595,41 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
// map.check();
map.setCurrentLevel(map.getMaxLevel()) ;
ARETES oldobst(RegisteredEdges[dglobal]) ;
const ARETES& oldobst(RegisteredEdges[dglobal]) ;
for (Segment * o : oldobst)
{
this->popSegment(o) ;
}
ARETES oldNeighborObst(RegisteredNeighborEdges[old]) ;
ARETES& oldNeighborObst(RegisteredNeighborEdges[old]) ;
for (Segment * o : oldNeighborObst)
{
// this->popSegment(o) ; // old version
removeElementFromVector(RegisteredNeighborEdges[old], o) ;
// removeElementFromVector(RegisteredNeighborEdges[old], o) ;
removeElementFromVector(o->nid->neighbor_cells[o->index],old);
o->nid->removeGeneralNeighbor (old);
}
oldNeighborObst.clear();
TRIANGLES oldTrian(RegisteredTriangles[dglobal]) ;
const TRIANGLES& oldTrian(RegisteredTriangles[dglobal]) ;
for (Triangle * o : oldTrian)
{
this->popTriangle(o) ;
}
TRIANGLES oldTrianNeighbor(RegisteredNeighborTriangles[old]) ;
TRIANGLES& oldTrianNeighbor(RegisteredNeighborTriangles[old]) ;
for (Triangle * o : oldTrianNeighbor)
{
// this->popTriangle(o) ; // old version
removeElementFromVector(RegisteredNeighborTriangles[old], o) ;
// removeElementFromVector(RegisteredNeighborTriangles[old], o) ;
removeElementFromVector(o->surf->neighbor_cells[o->indexTri],old);
o->surf->removeGeneralNeighbor (old);
}
oldTrianNeighbor.clear();
const std::chrono::time_point<std::chrono::system_clock> endPop = std::chrono::system_clock::now();
duration_pop = endPop - startPop;
......@@ -804,9 +804,9 @@ void EnvMap::resetPartSubdiv(Triangle * o)
Dart cell =o->cell;
Dart cell2 = mo->surfaceMap.phi1(cell);
Dart cell3 = mo->surfaceMap.phi1(cell2);
PARTICULE * p = mo->parts_[mo->indexParticule[cell]];
PARTICULE * p2 = mo->parts_[mo->indexParticule[cell2]];
PARTICULE * p3 = mo->parts_[mo->indexParticule[cell3]];
Particule * p = mo->parts_[mo->indexParticule[cell]];
Particule * p2 = mo->parts_[mo->indexParticule[cell2]];
Particule * p3 = mo->parts_[mo->indexParticule[cell3]];
if (mo != NULL)
{
......
......@@ -35,23 +35,22 @@ Surface::Surface(Simulator* sim,VEC3 offset):
{
positionSurface[d]+=offset;
indexParticule[d]=nbVertices;
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, sim_->envMap_.getBelongingCell(positionSurface[d]), positionSurface[d] , sim_->envMap_.position));
parts_.push_back(new Particule(sim_->envMap_.map, sim_->envMap_.getBelongingCell(positionSurface[d]), positionSurface[d] , sim_->envMap_.position));
nbVertices ++;
}
// initialisation tableaux de vecteurs qui vont stocker les belonging cells
TraversorE<SURFACE> tF2(surfaceMap);
for(Dart d = tF2.begin() ; d != tF2.end() ; d = tF2.next())
for(Dart d = tF2.begin(), end = tF2.end() ; d != end ; d = tF2.next())
{
nbTriangles ++;
}
belonging_cells = new std::vector<Dart>[nbTriangles];
neighbor_cells = new std::vector<Dart>[nbTriangles];
belonging_cells.resize(nbTriangles);
neighbor_cells.resize(nbTriangles);
// initialisation des segments et des attributs d'edge
TraversorF<SURFACE> tE(surfaceMap);
for(Dart d = tE.begin() ; d != tE.end() ; d = tE.next())
for(Dart d = tE.begin() , end = tE.end(); d != end ; d = tE.next())
{
faceColor[d]=VEC3(r,g,b);
#ifdef DEBUG_affichage
......@@ -65,7 +64,6 @@ Surface::Surface(Simulator* sim,VEC3 offset):
triangles_.push_back(o);
sim_->envMap_.FirstRegistrationTriangle(o);
}
......@@ -80,7 +78,16 @@ Surface::Surface(Simulator* sim,VEC3 offset):
// for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
// {
// CGoGNout<<" position dart :"<<d<<" || : "<<positionSurface[d]<<CGoGNendl ;
// }
// }
}
Surface::~Surface()
{
for (auto p : parts_)
delete p;
for (auto t : triangles_)
delete t;
}
void Surface::initGL()
......@@ -369,9 +376,4 @@ bool Surface::removeGeneralNeighbor (Dart d)
}
VEC3 Surface::getPosition(int index)
{
return parts_[index]->getPosition();
}
......@@ -847,27 +847,21 @@ void Volusion::cb_mouseMove(int buttons, int x, int y)
int main(int argc, char **argv)
void setupQtWidgets(char **argv, int argc,Volusion& sqt)
{
sqt.simul.init(argc,argv);
// un peu d'interface
QApplication app(argc, argv);
Volusion sqt;
sqt.simul.init(argc,argv);
// interface de tuto5.ui
// interface de tuto5.ui
sqt.setDock(&(sqt.dock));
// bounding box
// bounding box
Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(sqt.simul.envMap_.map, sqt.simul.envMap_.position);
sqt.m_WidthObj = std::max<REAL>(std::max<REAL>(bb.size(0), bb.size(1)), bb.size(2));
sqt.m_PosObj = (bb.min() + bb.max()) / REAL(2);
sqt.m_WidthObj = std::max<REAL>(std::max<REAL>(bb.size(0), bb.size(1)), bb.size(2));
sqt.m_PosObj = (bb.min() + bb.max()) / REAL(2);
// envoit info BB a l'interface
sqt.setParamObject(sqt.m_WidthObj, sqt.m_PosObj.data());
sqt.setParamObject(sqt.m_WidthObj, sqt.m_PosObj.data());
sqt.setCallBack( sqt.dock.checkBox_volumes, SIGNAL(toggled(bool)), SLOT(volumes_onoff(bool)) );
sqt.setCallBack( sqt.dock.checkBox_edges, SIGNAL(toggled(bool)), SLOT(edges_onoff(bool)) );
......@@ -878,9 +872,9 @@ int main(int argc, char **argv)
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.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()) );
sqt.setCallBack(sqt.dock.spinBox_dart, SIGNAL(valueChanged(int)), SLOT(slot_slide(int))) ;
......@@ -890,12 +884,12 @@ int main(int argc, char **argv)
sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderReleased()), SLOT(slider_released()) );
sqt.show();
sqt.show();
sqt.dock.slider_explode->setValue(100);
sqt.dock.slider_explode_face->setValue(100);
// sqt.clipping_onoff(false);
sqt.topo_onoff(false);
sqt.edges_onoff(true);
// 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);
......@@ -903,8 +897,8 @@ int main(int argc, char **argv)
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) ;
......@@ -916,6 +910,14 @@ int main(int argc, char **argv)
const QString& s=oss.str().c_str();
sqt.dock.comboBoxEdge->addItem(s,2);
}
}
int main(int argc, char **argv)
{
// un peu d'interface
QApplication app(argc, argv);
Volusion sqt;
setupQtWidgets(argv, argc, sqt);
// et on attend la fin.
return app.exec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment