Commit 8f6a48f5 authored by Thomas Pitiot 's avatar Thomas Pitiot

tout reparé ? Oo

parent 005e0485
......@@ -2,8 +2,8 @@
#define ENV_MAP_H
#define DEBUG_affichage
#define DEBUG
//#define DEBUG_affichage
//#define DEBUG
#include <iostream>
#include <algorithm>
......@@ -191,8 +191,11 @@ inline std::vector<Dart> EnvMap::getMemoCross(const VEC3& pos, const VEC3& dest,
inline void EnvMap::FindNeighborCellsOfSegment (const std::vector<Dart>& belonging_cells, std::vector<Dart> *neighbor_cells)
{
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
assert(!belonging_cells.empty());
neighbor_cells->clear();
CellMarkerMemo<MAP,VOLUME> memo_mark(map); //marqueur des cellules "présentes"
CellMarkerMemo<MAP,VOLUME> OneRingMark(map); // marquer des cellules voisines
......@@ -227,7 +230,9 @@ inline void EnvMap::FindNeighborCellsOfSegment (const std::vector<Dart>& belongi
inline void EnvMap::pushSegmentInCellAsNeighbor(Segment* o, Dart d)
{
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
assert(std::find(RegisteredNeighborEdges[d].begin(), RegisteredNeighborEdges[d].end(), o) == RegisteredNeighborEdges[d].end());
addElementToVector<Segment*>(RegisteredNeighborEdges[d],o);
......@@ -236,7 +241,9 @@ inline void EnvMap::pushSegmentInCellAsNeighbor(Segment* o, Dart d)
inline void EnvMap::popSegmentInCellAsNeighbor(Segment* o, Dart d)
{
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
assert(std::find(RegisteredNeighborEdges[d].begin(), RegisteredNeighborEdges[d].end(), o) != RegisteredNeighborEdges[d].end());
removeElementFromVector<Segment*>(RegisteredNeighborEdges[d],o);
......
......@@ -124,7 +124,7 @@ public:
public:
Volusion():
render_volumes(true),
render_volumes(false),
render_edges(true),
render_topo(false),
render_MovingObject(true),
......
......@@ -11,26 +11,26 @@ EnvMap::EnvMap()
#ifndef SPATIAL_HASHING
// RegisteredEdges = map.addAttribute<PFP::SegmentVECT, FACE>("Segments") ;
// neighborRegisteredEdges = map.addAttribute<PFP::SegmentVECT, FACE>("neighborSegments") ;
// subdivisableFace = map.addAttribute<PFP::BOOLATTRIB, FACE>("subdivisableFace") ;
// RegisteredEdges = map.addAttribute<PFP::SegmentVECT, FACE>("Segments") ;
// neighborRegisteredEdges = map.addAttribute<PFP::SegmentVECT, FACE>("neighborSegments") ;
// subdivisableFace = map.addAttribute<PFP::BOOLATTRIB, FACE>("subdivisableFace") ;
// refineCandidate.reserve(100) ;
// coarsenCandidate.reserve(100) ;
// refineCandidate.reserve(100) ;
// coarsenCandidate.reserve(100) ;
#endif
}
void EnvMap::init(int argc, char **argv)
{
std::cout << "Init EnvMap" << std::endl ;
std::cout << "Init EnvMap" << std::endl ;
if (argc>2)
{
{
std::string filename(argv[2]);
open_file(filename);
}
else
{
//Intialisation map
}
else
{
//Intialisation map
#ifdef IHMap
map.initImplicitProperties(); // Si map MR
#endif
......@@ -49,40 +49,40 @@ void EnvMap::init(int argc, char **argv)
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
// subdivideVolume(map.begin());
// subdivideVolume(map.begin());
// Algo::Surface::Modelisation::createTetrahedron<PFP>(map,true);
// Algo::Surface::Modelisation::embedPyramid<PFP>(map,position,3,true,1.0f,1.0f);
// Algo::Volume::Modelisation::sqrt3Vol<PFP>(map,position);
// Algo::Surface::Modelisation::createTetrahedron<PFP>(map,true);
// Algo::Surface::Modelisation::embedPyramid<PFP>(map,position,3,true,1.0f,1.0f);
// Algo::Volume::Modelisation::sqrt3Vol<PFP>(map,position);
map.check();
// Dart d1=map.indexDart(0);
// Dart d2=map.indexDart(1);
// Dart d3=map.indexDart(8);
// Geom::Plane3D<PFP::REAL> pl (position[d1],position[d2],position[d3]);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,d2,pl);
// map.check();
// VEC3 center = Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,map.indexDart(0),position);
// VEC3 norm = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(0),position);
// VEC3 norm2 = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(4),position);
// VEC3 norm3 = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(16),position);
// Geom::Plane3D<PFP::REAL> pl (norm,center);
// Geom::Plane3D<PFP::REAL> pl2 (norm2,center);
// Geom::Plane3D<PFP::REAL> pl3 (norm3,center);
// Dart newd = Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl);
// map.check();
// Dart newd2 =Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl2);
// Dart newd3 =Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,newd,pl2);
// map.check();
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,newd,pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(3),pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(15),pl3);
// map.check();
// CGoGNout<<" darts : 0 , "<<newd<<" , "<<newd2<<" , "<<newd3<<CGoGNendl;
// Dart d1=map.indexDart(0);
// Dart d2=map.indexDart(1);
// Dart d3=map.indexDart(8);
// Geom::Plane3D<PFP::REAL> pl (position[d1],position[d2],position[d3]);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,d2,pl);
// map.check();
// VEC3 center = Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,map.indexDart(0),position);
// VEC3 norm = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(0),position);
// VEC3 norm2 = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(4),position);
// VEC3 norm3 = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,map.indexDart(16),position);
// Geom::Plane3D<PFP::REAL> pl (norm,center);
// Geom::Plane3D<PFP::REAL> pl2 (norm2,center);
// Geom::Plane3D<PFP::REAL> pl3 (norm3,center);
// Dart newd = Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl);
// map.check();
// Dart newd2 =Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl2);
// Dart newd3 =Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,newd,pl2);
// map.check();
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(0),pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,newd,pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(3),pl3);
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(map,position,map.indexDart(15),pl3);
// map.check();
// CGoGNout<<" darts : 0 , "<<newd<<" , "<<newd2<<" , "<<newd3<<CGoGNendl;
......@@ -108,30 +108,30 @@ void EnvMap::init(int argc, char **argv)
// //// affichage positions
// CellMarkerStore<MAP, VOLUME> m(map) ;
// for (Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if (!m.isMarked(d))
// {
// m.mark(d) ;
// CGoGNout<<"Dart "<<d.index<<" en : "<<position[d]<<CGoGNendl;
// }
// }
// //// affichage positions
// CellMarkerStore<MAP, VOLUME> m(map) ;
// for (Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if (!m.isMarked(d))
// {
// m.mark(d) ;
// CGoGNout<<"Dart "<<d.index<<" en : "<<position[d]<<CGoGNendl;
// }
// }
/////////////////////////// Subdivision
// std::cout << "level :"<<map.getCurrentLevel() << std::endl ;
// Dart d =Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map,map.phi2(map.begin()), position);
// std::cout << "centralDart : "<< d.index << std::endl ;
// map.setCurrentLevel(1);
// std::cout << "level :"<<map.getCurrentLevel() << std::endl ;
/////////////////////////// Subdivision
// std::cout << "level :"<<map.getCurrentLevel() << std::endl ;
// Dart d =Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map,map.phi2(map.begin()), position);
// std::cout << "centralDart : "<< d.index << std::endl ;
// map.setCurrentLevel(1);
// std::cout << "level :"<<map.getCurrentLevel() << std::endl ;
}
}
}
......@@ -139,11 +139,11 @@ void EnvMap::init(int argc, char **argv)
VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face) // renvoie la normale a la face pointant vers l'extérieur du volume
{
VEC3 center = Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,volume,position);
VEC3 norm = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,face,position);
VEC3 temp =center-facecenter[face];
if(norm*temp>0) norm*=-1;
return norm;
VEC3 center = Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,volume,position);
VEC3 norm = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,face,position);
VEC3 temp =center-facecenter[face];
if(norm*temp>0) norm*=-1;
return norm;
}
bool EnvMap::checkPointInMap(VEC3 pos,Dart neighborhood) // definit si le point pos est dans le voisinage interne a la carte du volume "neighborhood"
......@@ -195,7 +195,9 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume) // définit si le point pos est
Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
{
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
CellMarkerStore<MAP, VOLUME> m(map) ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -411,7 +413,7 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en
Dart EnvMap::popAndPushSegment(Segment* o)// maj de l'enregistrement
{
#ifdef DEBUG_affichage
CGoGNout<<"pop&push arete "<<o->index<<CGoGNendl;
CGoGNout<<"pop&push arete "<<o->index<<CGoGNendl;
#endif
popSegment(o);
FirstRegistrationSegment(o);
......@@ -426,7 +428,9 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
#ifdef DEBUG_affichage
CGoGNout<<"Push in one cell segment arete "<<n<<CGoGNendl;
#endif
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
addElementToVector<Segment*>(RegisteredEdges[d],o);
......@@ -437,19 +441,19 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
if (!map.isBoundaryMarked<3>(volume))
{
pushSegmentInCellAsNeighbor(o, volume);
mo->neighbor_cells[n].push_back(volume);
mo->neighbor_cells[n].push_back(volume);
}
}
#ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
#endif
}
......@@ -460,17 +464,17 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
#ifdef DEBUG_affichage
CGoGNout<<"Push in set of cells segment arete "<<n<<CGoGNendl;
#endif
assert(!memo_cross.empty() && memo_cross.size() > 1);
// assert( memo_cross.size() > 1);
ArticulatedObject * mo = o->nid;
mo->belonging_cells[n] = memo_cross;
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{
addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell (*it);
addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell (*it);
#ifdef DEBUG_affichage
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;
#endif
}
......@@ -485,13 +489,13 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
}
#ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
// if(mo->neighbor_cells[n].size()>26)
// {
// for(auto d : mo->neighbor_cells[n])
// {
// CGoGNout<<" || "<<d<<" || "<<CGoGNendl;
// }
// }
#endif
}
......@@ -500,7 +504,9 @@ void EnvMap::popSegment(Segment* o)
{
ArticulatedObject * mo = o->nid;
int n = o->index;
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
#ifdef IHMap
assert(map.getCurrentLevel() == map.getMaxLevel());
#endif
if (mo != NULL)
{
......@@ -534,16 +540,18 @@ bool EnvMap::subdivideVolume(Dart dglobal)
// la subdivision ne doit pas mettre plus d'un level de différence entre des cellules adjacentes
// on commence donc par subdiviser les voisins qui ont trop de différence
Traversor3WF<typename PFP::MAP> traF(map, old);
for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
for ( Face dit : facesIncidentToVolume3(map,old))
{
Dart nv = map.phi3(dit);
if(!map.isBoundaryMarked(3, nv))
{
if(map.volumeLevel(nv) == vLevel - 1)
{
#ifdef DEBUG_affichage
std::cout << "cascade en : "<<nv<< std::endl;
std::cout << "OK pour cascade en : "<<nv<< std::endl;
#endif
subdivideVolume(nv);
}
......@@ -551,14 +559,11 @@ bool EnvMap::subdivideVolume(Dart dglobal)
}
// on commence ensuite a subdiviser
CGoGNout<<"debut refine"<<CGoGNendl;
// map.check();
map.setCurrentLevel(map.getMaxLevel()) ;
#ifdef DEBUG_affichage
CGoGNout<<"debut refine"<<CGoGNendl;
std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << std::endl;
#endif
......@@ -586,17 +591,31 @@ bool EnvMap::subdivideVolume(Dart dglobal)
#ifdef DEBUG_affichage
CGoGNout<<"tests pour subdivision"<< CGoGNendl;
#endif
if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= max && !map.volumeIsSubdivided(dglobal) )
if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= map.getMaxLevel() && !map.volumeIsSubdivided(dglobal) )
{
#ifdef DEBUG_affichage
CGoGNout<<"debut subdivision"<< CGoGNendl;
CGoGNout<<"debut subdivision"<< CGoGNendl;
#endif
Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position,false);
res=true;
}
map.setCurrentLevel(map.getMaxLevel()) ;
// map.check();
// map.check();
for (Vol d : volumesAdjacentByVertex3(map,(dglobal))) // parcours des sous cellules crées par la subdivision pour mettr a jour l'attribut facecenter a remplacer par un traverseur de sous cellules IHM
{
for ( Face f : facesIncidentToVolume3(map,d))
{
facecenter[f]=Algo::Surface::Geometry::faceCentroid<PFP, VertexAttribute<VEC3, MAP>>(map,f,position);
}
}
#ifdef DEBUG_affichage
std::cout << "after level = "<< map.getMaxLevel() << std::endl;
#endif
......@@ -648,31 +667,33 @@ void EnvMap::resetPartSubdiv(Segment* o)
Dart d2 =mo->parts_[o->indexPart2]->d;
#ifdef DEBUG_affichage
CGoGNout<<"Reset part subdiv (index articul , segment ,ind1, pos1, d1, ind2, pos2, d2) : "<<mo->index_articulated<<" || "<<o->index<<" || "<<o->indexPart1<<" || "<<pos<<" || "<<d1<<" || "<<o->indexPart2<<" || "<<pos2<<" || "<<d2<<CGoGNendl;
CGoGNout<<"Faces centroids : "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d1,position)<<" || "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d2,position)<<CGoGNendl;
CGoGNout<<"Reset part subdiv (index articul , segment ,ind1, pos1, d1, ind2, pos2, d2) : "<<mo->index_articulated<<" || "<<o->index<<" || "<<o->indexPart1<<" || "<<pos<<" || "<<d1<<" || "<<o->indexPart2<<" || "<<pos2<<" || "<<d2<<CGoGNendl;
CGoGNout<<"Faces centroids : "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d1,position)<<" || "<<Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d2,position)<<CGoGNendl;
#endif
mo->parts_[o->indexPart1]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d1,position)) ;
mo->parts_[o->indexPart1]->reset_positionFace();
#ifdef DEBUG_affichage
CGoGNout<<"part1 moved to centroid ,d : "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
CGoGNout<<"part1 moved to centroid ,d : "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
#endif
mo->parts_[o->indexPart1]->setState(VOLUME) ;
mo->parts_[o->indexPart1]->move(pos) ;
#ifdef DEBUG_affichage
CGoGNout<<"part1 moved in the end (destination, arrivée,d) : "<<pos<<" || "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
CGoGNout<<"part1 moved in the end (destination, arrivée,d) : "<<pos<<" || "<< mo->parts_[o->indexPart1]->getPosition()<<" || "<<mo->parts_[o->indexPart1]->d<<CGoGNendl;
#endif
mo->parts_[o->indexPart2]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,d2,position)) ;
mo->parts_[o->indexPart2]->reset_positionFace();
#ifdef DEBUG_affichage
CGoGNout<<"part2 moved to centroid ,d : "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
CGoGNout<<"part2 moved to centroid ,d : "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
#endif
mo->parts_[o->indexPart2]->setState(VOLUME) ;
mo->parts_[o->indexPart2]->move(pos2) ;
#ifdef DEBUG_affichage
CGoGNout<<"part2 moved in the end (destination, arrivée,d) : "<<pos2<<" || "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
CGoGNout<<"part2 moved in the end (destination, arrivée,d) : "<<pos2<<" || "<< mo->parts_[o->indexPart2]->getPosition()<<" || "<<mo->parts_[o->indexPart2]->d<<CGoGNendl;
#endif
}
......
......@@ -41,7 +41,7 @@ Needle::Needle(Simulator* sim,std::pair<VEC3, Dart> startingPoint)
createEdge(0);
#ifdef IHMap
// refine();
refine();
#endif
}
......@@ -213,17 +213,11 @@ void Needle::move(VEC3 diff)
#endif
}
}
void Needle::updateRegistration()
{
Segment* o = Segments_[nbEdges-1];
o->p1 = parts_[o->indexPart1]->getPosition();
o->p2 = parts_[o->indexPart2]->getPosition();
......@@ -257,6 +251,7 @@ void Needle::updateRegistration()
void Needle::refine()
{
#ifdef IHMap
Dart volume = parts_[0]->d;
volume = sim_->envMap_.map.volumeOldestDart(volume);
PFP::VEC3 edge = Algo::Surface::Geometry::vectorOutOfDart<PFP>(sim_->envMap_.map, volume, sim_->envMap_.position) ;
......@@ -264,10 +259,10 @@ void Needle::refine()
{
if(sim_->envMap_.subdivideVolume(volume))
{
// refine();
refine();
}
}
#endif
}
......@@ -25,7 +25,7 @@ void Simulator::init(int argc, char **argv)
Needle_or_knife = atoi(argv[1]) ;
// Needle_or_knife=false;
initFixedObjects();
// initFixedObjects();
initMovingObject();
// initEmptyMovingObject();
......@@ -45,15 +45,15 @@ void Simulator::initFixedObjects()
std::pair<unsigned int,unsigned int> ind;
VEC3 pos;
// pos=VEC3(2.21,3.02,3.53);
// p.first=pos;
// p.second=envMap_.getBelongingCell(pos);
// startingPoints.push_back(p);
pos=VEC3(2.21,3.02,3.53);
p.first=pos;
p.second=envMap_.getBelongingCell(pos);
startingPoints.push_back(p);
// pos=VEC3(-4.68,1.36,2.15);
// p.first=pos;
// p.second=envMap_.getBelongingCell(pos);
// startingPoints.push_back(p);
pos=VEC3(-4.68,1.36,2.15);
p.first=pos;
p.second=envMap_.getBelongingCell(pos);
startingPoints.push_back(p);
pos=VEC3(4,-2,3);
p.first=pos;
......@@ -74,13 +74,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);
......
......@@ -154,11 +154,20 @@ void Volusion::cb_keyPress(int code)
{
case 'r' :
{
#ifndef IHMap
// simul.envMap_.popSegment(simul.objects[0]->Segments_[0]);
// simul.envMap_.resetPartSubdiv(simul.objects[0]->Segments_[0]);
// simul.envMap_.FirstRegistrationSegment(simul.objects[0]->Segments_[0]);
#else
simul.aiguille->refine();
m_MovingObjectVBO->updateData(simul.envMap_.position);
updateGL() ;
#endif
break;
}
......@@ -343,32 +352,57 @@ void Volusion::cb_redraw()
m_ds->lineWidth(10.0f);
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;
m_ds->vertex(origin);
}
for(Segment * s : art->Segments_)
{
m_ds->newList(GL_COMPILE_AND_EXECUTE);
m_ds->begin(GL_LINE_STRIP);
m_ds->color3f(s->r,s->g,s->b);
m_ds->vertex(s->p1);
m_ds->vertex(s->p2);
m_ds->end();
m_ds->endList();
VEC3 p = s->p2;
m_ds->vertex(p);
}
m_ds->color3f(0,0.5f,1.0f);
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<PFP::VEC3*>(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++;
}
// VEC3 pos1 = simul.aiguille->parts_[0]->getPosition();
// VEC3 pos2 = simul.aiguille->parts_[1]->getPosition();
// float f;
// VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
m_MovingObjectVBO->releasePtr();
// m_frame_MovingObject->draw();
// CGoGNout<<Geom::angle(pos2-pos1,cylinder_axis)<<CGoGNendl;
// cylinder->rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1));
// m_frame_MovingObject->draw();