Commit 9daeca4c authored by pitiot's avatar pitiot

up

parent 8f6a48f5
......@@ -2,7 +2,7 @@
#define ENV_MAP_H
//#define DEBUG_affichage
#define DEBUG_affichage
//#define DEBUG
#include <iostream>
......@@ -47,6 +47,7 @@ public:
void init(int argc, char **argv) ;
bool checkPointInMap(VEC3 pos,Dart neighborhood);
bool insideVolume(VEC3 pos, Dart d);
REAL volumeMaxdistance(Vol volume);
VEC3 normaleFromVolume(Dart volume,Dart face);
void open_file(std::string filename);
VEC3 mapMinX;
......
......@@ -129,14 +129,28 @@ void EnvMap::init(int argc, char **argv)
// std::cout << "level :"<<map.getCurrentLevel() << std::endl ;
}
}
}
REAL EnvMap::volumeMaxdistance(Vol volume)
{
Dart d = volume;
VEC3 center = Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(map,volume,position);
REAL res = (position[d]-center).norm2();
for ( Vertex vert : verticesIncidentToVolume3(map,volume))
{
REAL size=(position[vert]-center).norm2();
if(size>res)
{
res=size;
}
}
return res;
}
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);
......@@ -537,14 +551,19 @@ bool EnvMap::subdivideVolume(Dart dglobal)
map.setCurrentLevel(map.getMaxLevel()) ;
unsigned int vLevel = map.volumeLevel(dglobal);
Dart old = map.volumeOldestDart(dglobal);
#ifdef DEBUG_affichage
int count = 0;
#endif
// 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, true);
// for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
// {
for ( Face dit : facesIncidentToVolume3(map,old))
{
#ifdef DEBUG_affichage
count++;
#endif
Dart nv = map.phi3(dit);
if(!map.isBoundaryMarked(3, nv))
{
......@@ -553,18 +572,22 @@ bool EnvMap::subdivideVolume(Dart dglobal)
#ifdef DEBUG_affichage
std::cout << "OK pour cascade en : "<<nv<< std::endl;
#endif
int currentLevel = map.getCurrentLevel();
subdivideVolume(nv);
map.setCurrentLevel(currentLevel);
}
}
}
// on commence ensuite a subdiviser
// map.check();
map.setCurrentLevel(map.getMaxLevel()) ;
#ifdef DEBUG_affichage
CGoGNout<<"debut refine"<<CGoGNendl;
std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << std::endl;
std::cout << "dglobal = " << dglobal << "level = "<< map.getDartLevel(dglobal) << " nombre de faces verifiées : "<<count<< std::endl;
#endif
ARETES oldobst(RegisteredEdges[dglobal]) ;
......
......@@ -41,7 +41,7 @@ Needle::Needle(Simulator* sim,std::pair<VEC3, Dart> startingPoint)
createEdge(0);
#ifdef IHMap
refine();
// refine();
#endif
}
......@@ -253,13 +253,12 @@ 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) ;
if(edge.norm2() > 2.0f )
REAL rayon = sim_->envMap_.volumeMaxdistance(volume) ;
if(rayon > 2.0f )
{
if(sim_->envMap_.subdivideVolume(volume))
{
refine();
// refine();
}
}
......
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