Commit 588e6cff authored by pitiot's avatar pitiot

update working needle

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