Commit 588e6cff authored by pitiot's avatar pitiot

update working needle

parent d9d97fb7
No preview for this file type
...@@ -118,9 +118,9 @@ ...@@ -118,9 +118,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_niddle"> <widget class="QCheckBox" name="checkBox_MovingObject">
<property name="text"> <property name="text">
<string>Niddle</string> <string>Needle</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
VEC3 mapMinZ; VEC3 mapMinZ;
VEC3 mapMaxZ; VEC3 mapMaxZ;
// Dart getBelongingCell(const PFP::VEC3& pos); Dart getBelongingCell(const PFP::VEC3& pos);
...@@ -210,16 +210,15 @@ inline void EnvMap::FindNeighborCellsOfSegment (const std::vector<Dart>& belongi ...@@ -210,16 +210,15 @@ inline void EnvMap::FindNeighborCellsOfSegment (const std::vector<Dart>& belongi
do do
{ {
dd = *it; dd = *it;
Traversor* tra = TraversorFactory<PFP::MAP>::createAdjacent(map,dd, 3, 4, 1); for (Vol d : volumesAdjacentByVertex3(map,(*it)))
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{ {
if (!map.isBoundaryMarked<3>(d) && !memo_mark.isMarked(d) && !OneRingMark.isMarked(d) ) if (!map.isBoundaryMarked<3>(d) && !memo_mark.isMarked(d) && !OneRingMark.isMarked(d) )
{ {
OneRingMark.mark(d); OneRingMark.mark(d);
(*neighbor_cells).push_back(d); (*neighbor_cells).push_back(d);
} }
} }
tra->~Traversor();
++it; ++it;
}while(it!=belonging_cells.end()); }while(it!=belonging_cells.end());
......
#ifndef NIDDLE_H #ifndef Niddle_H
#define NIDDLE_H #define Niddle_H
#include <iostream> #include <iostream>
#include "glm/glm.hpp" #include "glm/glm.hpp"
#include "env_map.h" #include "env_map.h"
#include "MovingObject.h"
//particules //particules
using namespace CGoGN ; using namespace CGoGN ;
class Simulator; class Simulator;
class Niddle class Niddle : public MovingObject
{ {
public: public:
Niddle(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints) ; Niddle(Simulator* sim, std::pair<VEC3, Dart> startingPoint) ;
VEC3 getPositionSegment(int index) ;
void addGeneralCell ( Dart d);
bool removeGeneralCell (Dart d);
VEC3 getPosition(int index);
void updateRegistration();
void move(VEC3 diff); void move(VEC3 diff);
void transfo (Geom::Matrix44f matrix); void createEdge(int index);
void color_close();
void unColor_close(Dart oldCell);
float edgeSize;
unsigned int nbVertices;
unsigned int nbEdges;
CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>* * parts_ ;
std::vector<Segment *> Segments_;
std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells;
std::vector<std::pair<Dart, int> > general_belonging;
double width;
Simulator* sim_;
}; };
void resetPart(Segment * o, Dart d1);
......
...@@ -2,24 +2,26 @@ ...@@ -2,24 +2,26 @@
#define _Segment_H_ #define _Segment_H_
#include "env_map.h" #include "env_map.h"
class Niddle; class MovingObject;
class Segment class Segment
{ {
public: public:
Segment(const VEC3 point1, const VEC3 point2, Segment(const VEC3 point1, const VEC3 point2,
Niddle * niddle =NULL, unsigned int ind=0) : MovingObject * niddle =NULL, unsigned int ind=0,float rouge=0,float green =0, float blue=1.0f) :
p1(point1), p2(point2), p1(point1), p2(point2),
nid(niddle), index(ind) nid(niddle), index(ind),r(rouge),g(green),b(blue)
{ {
} }
VEC3 p1 ; VEC3 p1 ;
VEC3 p2 ; VEC3 p2 ;
// colors
MovingObject * nid ;
Niddle * nid ;
unsigned int index ; unsigned int index ;
float r;
float g;
float b;
} ; } ;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "env_map.h" #include "env_map.h"
#include "niddle.h" #include "niddle.h"
#include "knife.h"
#include "segment.h" #include "segment.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -15,10 +16,11 @@ public: ...@@ -15,10 +16,11 @@ public:
void init(int argc, char **argv); void init(int argc, char **argv);
void doStep(); void doStep();
void initNiddle(); void initMovingObject();
EnvMap envMap_; EnvMap envMap_;
double nbSteps_; double nbSteps_;
Niddle * aiguille; MovingObject * aiguille;
bool needle_or_knife;
}; };
......
...@@ -74,7 +74,7 @@ class Volusion: public Utils::QT::SimpleQT ...@@ -74,7 +74,7 @@ class Volusion: public Utils::QT::SimpleQT
bool render_volumes; bool render_volumes;
bool render_edges; bool render_edges;
bool render_topo; bool render_topo;
bool render_niddle; bool render_MovingObject;
bool render_topoTemp; bool render_topoTemp;
bool clip_volume; bool clip_volume;
bool hide_clipping; bool hide_clipping;
...@@ -91,12 +91,12 @@ class Volusion: public Utils::QT::SimpleQT ...@@ -91,12 +91,12 @@ class Volusion: public Utils::QT::SimpleQT
unsigned int dartSlider; unsigned int dartSlider;
//niddle //MovingObject
Utils::VBO* m_niddleVBO; Utils::VBO* m_MovingObjectVBO;
Utils::PointSprite* m_sprite; Utils::PointSprite* m_sprite;
Utils::Drawer* m_ds; Utils::Drawer* m_ds;
// Utils::Pickable* cylinder; // Utils::Pickable* cylinder;
Utils::FrameManipulator* m_frame_niddle; Utils::FrameManipulator* m_frame_MovingObject;
unsigned int m_picked_part; unsigned int m_picked_part;
int startX; int startX;
int startY; int startY;
...@@ -120,13 +120,14 @@ public: ...@@ -120,13 +120,14 @@ public:
float m_WidthObj; float m_WidthObj;
Geom::Vec3f m_PosObj; Geom::Vec3f m_PosObj;
Simulator simul; Simulator simul;
Utils::QT::uiDockInterface dock;
public: public:
Volusion(): Volusion():
render_volumes(true), render_volumes(true),
render_edges(true), render_edges(true),
render_topo(false), render_topo(false),
render_niddle(true), render_MovingObject(true),
render_topoTemp(false), render_topoTemp(false),
clip_volume(false), clip_volume(false),
hide_clipping(true), hide_clipping(true),
...@@ -156,7 +157,7 @@ public slots: ...@@ -156,7 +157,7 @@ public slots:
void volumes_onoff(bool x); void volumes_onoff(bool x);
void edges_onoff(bool x); void edges_onoff(bool x);
void topo_onoff(bool x); void topo_onoff(bool x);
void niddle_onoff(bool x); void MovingObject_onoff(bool x);
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);
......
#include "env_map.h" #include "env_map.h"
#include "niddle.h" #include "MovingObject.h"
#include "segment.h" #include "segment.h"
using namespace CGoGN ; using namespace CGoGN ;
EnvMap::EnvMap() EnvMap::EnvMap()
{ {
...@@ -24,19 +23,16 @@ EnvMap::EnvMap() ...@@ -24,19 +23,16 @@ EnvMap::EnvMap()
void EnvMap::init(int argc, char **argv) void EnvMap::init(int argc, char **argv)
{ {
std::cout << "Init EnvMap" << std::endl ; std::cout << "Init EnvMap" << std::endl ;
if (argc>1) if (argc>2)
{ {
std::string filename(argv[1]); std::string filename(argv[2]);
open_file(filename); open_file(filename);
} }
else else
{ {
//Intialisation map MR //Intialisation map
// map.initImplicitProperties();
int nb = 5;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb);
// map.initImplicitProperties(); // Si map MR
///// initialisation attributs ///// initialisation attributs
position = map.addAttribute<VEC3, VERTEX, MAP>("position"); position = map.addAttribute<VEC3, VERTEX, MAP>("position");
...@@ -44,7 +40,50 @@ void EnvMap::init(int argc, char **argv) ...@@ -44,7 +40,50 @@ void EnvMap::init(int argc, char **argv)
color = map.addAttribute<VEC3, VOLUME, MAP>("color"); color = map.addAttribute<VEC3, VOLUME, MAP>("color");
RegisteredEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredEdges"); RegisteredEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredEdges");
RegisteredNeighborEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredNeighborEdges"); RegisteredNeighborEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredNeighborEdges");
int nb = 5;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
// 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;
TraversorV<MAP> tv(map); TraversorV<MAP> tv(map);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next()) for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{ {
...@@ -64,6 +103,9 @@ void EnvMap::init(int argc, char **argv) ...@@ -64,6 +103,9 @@ void EnvMap::init(int argc, char **argv)
color[d] = position[d]/10 + VEC3(0.5,0.5,0.5); color[d] = position[d]/10 + VEC3(0.5,0.5,0.5);
} }
// //// affichage positions // //// affichage positions
// CellMarkerStore<MAP, VOLUME> m(map) ; // CellMarkerStore<MAP, VOLUME> m(map) ;
// for (Dart d = map.begin(); d != map.end(); map.next(d)) // for (Dart d = map.begin(); d != map.end(); map.next(d))
...@@ -87,13 +129,12 @@ void EnvMap::init(int argc, char **argv) ...@@ -87,13 +129,12 @@ void EnvMap::init(int argc, char **argv)
} }
} }
VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face) 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 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 norm = Algo::Surface::Geometry::faceNormal<PFP, VertexAttribute<VEC3, MAP>>(map,face,position);
...@@ -102,12 +143,12 @@ VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face) ...@@ -102,12 +143,12 @@ VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face)
return norm; return norm;
} }
bool EnvMap::checkPointInMap(VEC3 pos,Dart neighborhood) bool EnvMap::checkPointInMap(VEC3 pos,Dart neighborhood) // definit si le point pos est dans le voisinage interne a la carte du volume "neighborhood"
{ {
if(insideVolume(pos, neighborhood)) if(insideVolume(pos, neighborhood))
return true; return true;
Traversor* tra = TraversorFactory<PFP::MAP>::createAdjacent(map,neighborhood, 3, 4, 1);
for (Dart d = tra->begin(); d != tra->end(); d = tra->next()) for (Vol d : volumesAdjacentByVertex3(map,neighborhood))
{ {
if (!map.isBoundaryMarked<3>(d) ) if (!map.isBoundaryMarked<3>(d) )
{ {
...@@ -115,15 +156,16 @@ bool EnvMap::checkPointInMap(VEC3 pos,Dart neighborhood) ...@@ -115,15 +156,16 @@ bool EnvMap::checkPointInMap(VEC3 pos,Dart neighborhood)
return true; return true;
} }
} }
tra->~Traversor();
return false; return false;
} }
bool EnvMap::insideVolume(VEC3 pos, Dart volume) bool EnvMap::insideVolume(VEC3 pos, Dart volume) // définit si le point pos est dans le volume convexe
{ {
Traversor* trav = TraversorFactory<PFP::MAP>::createIncident(map,volume, 3, 4, 3);
for (Dart d = trav->begin(); d != trav->end(); d = trav->next()) for(Face d : facesIncidentToVolume3(map,volume))
{ {
VEC3 normal = normaleFromVolume(volume,d); VEC3 normal = normaleFromVolume(volume,d);
VEC3 center = facecenter[d]; VEC3 center = facecenter[d];
...@@ -131,36 +173,41 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume) ...@@ -131,36 +173,41 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume)
if(normal*dirPoint>0) if(normal*dirPoint>0)
return false; return false;
} }
trav->~Traversor();
return true; return true;
} }
///// a coder ///// a coder
//Dart EnvMap::getBelongingCell(const PFP::VEC3& pos) Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
//{ {
//// assert(map.getCurrentLevel() == map.getMaxLevel()) ; assert(map.getCurrentLevel() == map.getMaxLevel()) ;
//// CellMarkerStore<MAP, VOLUME> m(map) ; CellMarkerStore<MAP, VOLUME> m(map) ;
//// for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
//// { {
//// if (!m.isMarked(d)) if (!m.isMarked(d))
//// { {
//// m.mark(d) ; m.mark(d) ;
//// if (Testinside(d)) if (insideVolume(pos, d))
//// return d ; return d ;
//// } }
//// } }
//// std::cout << "ERROR : pos not in map for getBelongingCell " << pos << std::endl ; std::cout << "ERROR : pos not in map for getBelongingCell " << pos << std::endl ;
// return map.begin() ; return map.begin() ;
//} }
...@@ -328,7 +375,7 @@ void EnvMap::open_file(std::string filename) ...@@ -328,7 +375,7 @@ void EnvMap::open_file(std::string filename)
void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en question void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en question
{ {
Niddle * mo = o->nid; MovingObject * mo = o->nid;
if (mo != NULL) if (mo != NULL)
{ {
int n = o->index; int n = o->index;
...@@ -343,6 +390,8 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en ...@@ -343,6 +390,8 @@ void EnvMap::FirstRegistrationSegment(Segment * o)// réenregistre l'Segment en
std::vector<Dart> memo; std::vector<Dart> memo;
d1=mo->parts_[n]->d; d1=mo->parts_[n]->d;
d2=mo->parts_[n+1]->d; d2=mo->parts_[n+1]->d;
memo = getMemoCross(p1,p2,d1); memo = getMemoCross(p1,p2,d1);
if(map.sameVolume(d1,d2)) if(map.sameVolume(d1,d2))
...@@ -371,7 +420,7 @@ Dart EnvMap::popAndPushSegment(Segment* o)// maj de l'enregistrement ...@@ -371,7 +420,7 @@ Dart EnvMap::popAndPushSegment(Segment* o)// maj de l'enregistrement
void EnvMap::pushAOneCellSegment(Segment * o, Dart d) void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
{ {
int n = o->index; int n = o->index;
Niddle * mo = o->nid; MovingObject * mo = o->nid;
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
CGoGNout<<"Push in one cell segment arete "<<n<<CGoGNendl; CGoGNout<<"Push in one cell segment arete "<<n<<CGoGNendl;
#endif #endif
...@@ -381,17 +430,18 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) ...@@ -381,17 +430,18 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
mo->belonging_cells[n].push_back(d); mo->belonging_cells[n].push_back(d);
mo->addGeneralCell (d); mo->addGeneralCell (d);
Traversor* tra = TraversorFactory<PFP::MAP>::createAdjacent(map,d, 3, 4, 1); for (Vol volume : volumesAdjacentByVertex3(map,d))
for (Dart d = tra->begin(); d != tra->end(); d = tra->next())
{ {
if (!map.isBoundaryMarked<3>(d)) if (!map.isBoundaryMarked<3>(volume))
{ {
pushSegmentInCellAsNeighbor(o, d); pushSegmentInCellAsNeighbor(o, volume);
mo->neighbor_cells[n].push_back(d); mo->neighbor_cells[n].push_back(volume);
} }
} }
tra->~Traversor();
#ifdef DEBUG_affichage
CGoGNout<<"fin du push , etat du belong/neighbor : "<<mo->belonging_cells[n].size()<<"/"<<mo->neighbor_cells[n].size()<<CGoGNendl;
#endif
} }
void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_cross) void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_cross)
...@@ -401,7 +451,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c ...@@ -401,7 +451,7 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
CGoGNout<<"Push in set of cells segment arete "<<n<<CGoGNendl; CGoGNout<<"Push in set of cells segment arete "<<n<<CGoGNendl;
#endif #endif
assert(!memo_cross.empty()); assert(!memo_cross.empty());
Niddle * mo = o->nid; MovingObject * mo = o->nid;
mo->belonging_cells[n] = memo_cross; mo->belonging_cells[n] = memo_cross;
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)
...@@ -409,6 +459,9 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c ...@@ -409,6 +459,9 @@ void EnvMap::pushSegmentInSetOfCells(Segment* o, const std::vector<Dart>& memo_c
addElementToVector<Segment*>(RegisteredEdges[*it],o); addElementToVector<Segment*>(RegisteredEdges[*it],o);
mo->addGeneralCell (*it); mo->addGeneralCell (*it);
#ifdef DEBUG_affichage
CGoGNout<<"cellule du belong :"<<(*it)<<CGoGNendl;