Commit 2a8274e6 authored by Thomas Pitiot 's avatar Thomas Pitiot

ajouts optim pour particules

parent d69e3ee7
......@@ -2,7 +2,7 @@
#define ENV_MAP_H
#define DEBUG_affichage
//#define DEBUG_affichage
//#define DEBUG
#include <iostream>
......@@ -73,13 +73,14 @@ public:
VertexAttribute<VEC3, MAP> position ;
FaceAttribute<VEC3, MAP> facecenter;
VolumeAttribute<VEC3, MAP> color ;
VolumeAttribute<VEC3, MAP> volumecenter;
VolumeAttribute<ARETES, MAP> RegisteredEdges ;
VolumeAttribute<ARETES, MAP> RegisteredNeighborEdges ;
VolumeAttribute<TRIANGLES, MAP> RegisteredTriangles ;
VolumeAttribute<TRIANGLES, MAP> RegisteredNeighborTriangles ;
Geom::BoundingBox<PFP::VEC3> bb;
std::vector<Dart> getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1);
std::vector<Dart> getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1, unsigned int state);
void FindNeighborCells (const std::vector<Dart>& belonging_cells, std::vector<Dart> * nieghbor_cells);
......@@ -94,7 +95,7 @@ public:
void pushSegmentInCellAsNeighbor(Segment* o, Dart d);
void popSegmentInCellAsNeighbor(Segment* o, Dart d);
void resetPartSubdiv(Segment* o);
void resetPartSubdiv(Segment* o, int vLevelOld);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Enregistrement Surfaces
......@@ -107,7 +108,7 @@ public:
void popTriangleInCell(Triangle* o, Dart d);
void pushTriangleInCellAsNeighbor(Triangle* cell, Dart d);
void popTriangleInCellAsNeighbor(Triangle* cell, Dart d);
void resetPartSubdiv(Triangle* cell);
void resetPartSubdiv(Triangle* cell, int vLevelOld);
} ;
......@@ -152,10 +153,12 @@ inline bool removeElementFromVector(std::vector<T>& a, T ag)
/////////////////////////////////////////////////////////////////////REGISTRATIONS
inline std::vector<Dart> EnvMap::getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1)
inline std::vector<Dart> EnvMap::getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1 , unsigned int state)
{
typedef CGoGN::Algo::Volume::MovingObjects::ParticleCell3DMemo<PFP> ParticleCell3DMemo;
return ParticleCell3DMemo(map, d1, pos,position).move(dest);
ParticleCell3DMemo part(map, d1, pos,position,&facecenter,&volumecenter);
part.setState(state);
return part.move(dest);
}
......
......@@ -37,12 +37,22 @@ public:
{
return parts_[index];
}
inline Particule* getParticule(int index)
{
return parts_[index];
}
inline const int& getNeedForSubd(int index) const
{
return partNeedReset[index];
}
inline const int& getNeedForSubd(int index)
{
return partNeedReset[index];
}
inline void setNeedForSubd(int index, int b)
{
partNeedReset[index]=b;
}
inline int getIndexOfParticuleAtVertex(Dart d) const
{
return indexParticule[d];
......@@ -86,7 +96,7 @@ public:
REAL faceMaxdistance(Face face); //calcul du rayon max d'une face
bool subdiveMap(); //subdivision de la map
void initOperators(SubdivisionType st); // fonction de sélection du type de subdivision pour l'ihm2
void needResetTriangle(Triangle * o);
void addGeneralCell ( Dart d);
bool removeGeneralCell (Dart d);
......@@ -120,6 +130,7 @@ private:
unsigned int nbTriangles;
std::vector<Particule*> parts_ ;
std::vector<int>partNeedReset;
std::vector<Triangle *> triangles_;
Algo::Render::GL2::MapRender* m_render_map; // render de l'objet
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ Knife::Knife(Simulator* sim,std::vector<std::pair<VEC3, Dart>> startingPoints)
for (auto it =startingPoints.begin();it!=startingPoints.end();++it)
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position));
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
}
......
......@@ -22,7 +22,7 @@ Needle::Needle(Simulator* sim,std::pair<VEC3, Dart> startingPoint)
index_articulated=sim->objects.size();
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, startingPoint.second, startingPoint.first , sim_->envMap_.position));
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, startingPoint.second, startingPoint.first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
this->color_close();
......@@ -110,7 +110,7 @@ void Needle::unColor_close(Dart volume)
void Needle::createEdge(int index)
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, this->getParticule(0)->getCell(), getParticule(0)->getPosition() , sim_->envMap_.position));
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, this->getParticule(0)->getCell(), getParticule(0)->getPosition() , sim_->envMap_.position,&(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
Segment* o = new Segment(getParticule(index+1)->getPosition(),
getParticule(0)->getPosition(),
......@@ -141,6 +141,7 @@ void Needle::move(VEC3 diff)
{
if(!sim_->envMap_.checkPointInMap(pos,this->getParticule(0)->getCell()))
{
CGoGNout<<"pos not in map :"<<pos<< " || d: "<<this->getParticule(0)->getCell()<<CGoGNendl;
pos=pos-diff;
}
}
......@@ -205,7 +206,7 @@ void Needle::refine()
{
if(sim_->envMap_.subdivideVolume(volume))
{
// refine();
refine();
}
}
......
......@@ -42,7 +42,7 @@ void Simulator::doStep()
void Simulator::initSurfaces()
{
Surface * obj = new Surface(this,VEC3(-1.0f,-1.5f,0.0f));
Surface * obj = new Surface(this,VEC3(-2.0f,0.0f,0.0f));
CGoGNout<<"surface initialisée : "<<obj->index_surface<<CGoGNendl;
}
......
......@@ -35,8 +35,9 @@ Surface::Surface(Simulator* sim,VEC3 offset):
{
positionSurface[d]+=offset;
indexParticule[d]=nbVertices;
parts_.push_back(new Particule(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,&(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
nbVertices ++;
partNeedReset.push_back(0);
}
// initialisation tableaux de vecteurs qui vont stocker les belonging cells
TraversorE<SurfaceMap> tF2(surfaceMap);
......@@ -375,5 +376,13 @@ bool Surface::removeGeneralNeighbor (Dart d)
return false;
}
void Surface::needResetTriangle(Triangle * o)
{
Dart d =o->cell;
for(int i=0;i<3;i++)
{
partNeedReset[indexParticule[d]]=1;
d=surfaceMap.phi1(d);
}
}
......@@ -20,7 +20,7 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st
for (auto it =startingPoints.begin();it!=startingPoints.end();++it)
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position));
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
}
......
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