Commit d9d97fb7 authored by pitiot's avatar pitiot

up

parent 6e256b2e
......@@ -45,7 +45,17 @@ public:
EnvMap() ;
void init(int argc, char **argv) ;
bool checkPointInMap(VEC3 pos,Dart neighborhood);
bool insideVolume(VEC3 pos, Dart d);
VEC3 normaleFromVolume(Dart volume,Dart face);
void open_file(std::string filename);
VEC3 mapMinX;
VEC3 mapMaxX;
VEC3 mapMinY;
VEC3 mapMaxY;
VEC3 mapMinZ;
VEC3 mapMaxZ;
// Dart getBelongingCell(const PFP::VEC3& pos);
......@@ -56,6 +66,7 @@ public:
PFP::MAP map ;
VertexAttribute<VEC3, MAP> position ;
FaceAttribute<VEC3, MAP> facecenter;
VolumeAttribute<VEC3, MAP> color ;
VolumeAttribute<ARETES, MAP> RegisteredEdges ;
VolumeAttribute<ARETES, MAP> RegisteredNeighborEdges ;
......
......@@ -40,6 +40,7 @@ void EnvMap::init(int argc, char **argv)
///// initialisation attributs
position = map.addAttribute<VEC3, VERTEX, MAP>("position");
facecenter = map.addAttribute<VEC3, FACE, MAP>("facecenter");
color = map.addAttribute<VEC3, VOLUME, MAP>("color");
RegisteredEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredEdges");
RegisteredNeighborEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredNeighborEdges");
......@@ -49,6 +50,13 @@ void EnvMap::init(int argc, char **argv)
{
position[d] *= 10;
}
TraversorF<MAP> tf(map);
for(Dart d = tf.begin() ; d != tf.end() ; d = tf.next())
{
facecenter[d]=Algo::Surface::Geometry::faceCentroid<PFP, VertexAttribute<VEC3, MAP>>(map,d,position);
}
TraversorW<MAP> tra(map);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
......@@ -85,6 +93,54 @@ void EnvMap::init(int argc, char **argv)
}
VEC3 EnvMap::normaleFromVolume(Dart volume,Dart face)
{
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)
{
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())
{
if (!map.isBoundaryMarked<3>(d) )
{
if(insideVolume(pos, d))
return true;
}
}
tra->~Traversor();
return false;
}
bool EnvMap::insideVolume(VEC3 pos, Dart volume)
{
Traversor* trav = TraversorFactory<PFP::MAP>::createIncident(map,volume, 3, 4, 3);
for (Dart d = trav->begin(); d != trav->end(); d = trav->next())
{
VEC3 normal = normaleFromVolume(volume,d);
VEC3 center = facecenter[d];
VEC3 dirPoint = pos-center;
if(normal*dirPoint>0)
return false;
}
trav->~Traversor();
return true;
}
///// a coder
//Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
......
......@@ -112,14 +112,23 @@ void Niddle::transfo (Geom::Matrix44f matrix)
void Niddle::move(VEC3 diff)
{
VEC3 pos = getPosition(0)+diff;
parts_[0]->move(pos);
// for (unsigned int i = 1; i < nbVertices; ++i)
// {
// VEC3 pos = getPosition(i)+diff;
// parts_[i]->move(pos);
// }
// VEC3 pos = getPosition(0)+diff;
// parts_[0]->move(pos);
for (unsigned int i = 0; i < nbVertices; ++i)
{
VEC3 pos = getPosition(i)+diff;
if(sim_->envMap_.map.isVolumeIncidentToBoundary(parts_[i]->d))
{
if(sim_->envMap_.checkPointInMap(pos,parts_[i]->d))
{
parts_[i]->move(pos);
}
}
else
parts_[i]->move(pos);
}
updateRegistration();
}
......
......@@ -296,9 +296,30 @@ void Volusion::cb_redraw()
}
if(false) //affichage des normales
{
Dart volume=simul.envMap_.map.indexDart(1500);
Traversor* trav = TraversorFactory<PFP::MAP>::createIncident(simul.envMap_.map,volume, 3, 4, 3);
for (Dart d = trav->begin(); d != trav->end(); d = trav->next())
{
m_ds->newList(GL_COMPILE_AND_EXECUTE);
m_ds->begin(GL_LINE_STRIP);
m_ds->color3f(0,1.0f,0);
m_ds->lineWidth(10.0f);
m_ds->vertex(simul.envMap_.facecenter[d]);
m_ds->vertex(simul.envMap_.facecenter[d]+simul.envMap_.normaleFromVolume(volume,d));
m_ds->end();
m_ds->endList();
}
trav->~Traversor();
}
if (draw_dart && dartSlider < (simul.envMap_.map.end().index))
{
m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f);
}
if(render_belonging)
{
if(val_comboEdge==0)
......
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