Commit ab0782c2 authored by Thomas Pitiot 's avatar Thomas Pitiot

ajout chargement maillages + check

parent 1b4debb2
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
void init(int argc, char **argv) ; void init(int argc, char **argv) ;
bool checkPointInMap(VEC3 pos,Dart neighborhood); bool checkPointInMap(VEC3 pos,Dart neighborhood);
bool checkPointInCube(VEC3 pos); bool checkPointInCube(VEC3 pos);
bool checkFaces(); // vérifie que tous les points des faces sont bien coplanaires si ce n'eest pas le cas renvoie true
bool insideVolume(VEC3 pos, Dart d); bool insideVolume(VEC3 pos, Dart d);
REAL volumeMaxdistance(Vol volume); REAL volumeMaxdistance(Vol volume);
VEC3 normaleFromVolume(Dart volume,Dart face); VEC3 normaleFromVolume(Dart volume,Dart face);
......
...@@ -32,66 +32,82 @@ void EnvMap::init(int argc, char **argv) ...@@ -32,66 +32,82 @@ void EnvMap::init(int argc, char **argv)
mapMaxZ=0; mapMaxZ=0;
std::cout << "Init EnvMap" << std::endl ; std::cout << "Init EnvMap" << std::endl ;
if (argc>2)
#ifdef IHMap
map.initImplicitProperties(); // Si map MR
#endif
if (argc>1)
{ {
std::string filename(argv[2]); std::string filename(argv[1]);
open_file(filename); open_file(filename);
TraversorV<MAP> tv(map);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
position[d] /= 10;
}
} }
else else
{ {
//Intialisation map //Intialisation map
#ifdef IHMap
map.initImplicitProperties(); // Si map MR
#endif
///// initialisation attributs
position = map.addAttribute<VEC3, VERTEX, MAP>("position"); position = map.addAttribute<VEC3, VERTEX, MAP>("position");
facecenter = map.addAttribute<VEC3, FACE, MAP>("facecenter");
volumecenter=map.addAttribute<VEC3, VOLUME, MAP>("volumecenter");
color = map.addAttribute<VEC3, VOLUME, MAP>("color");
RegisteredEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredEdges");
RegisteredNeighborEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredNeighborEdges");
RegisteredTriangles=map.addAttribute<TRIANGLES,VOLUME, MAP>("RegisteredTriangles");
RegisteredNeighborTriangles=map.addAttribute<TRIANGLES,VOLUME, MAP>("RegisteredNeighborTriangles");
int nb = 1; int nb = 1;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(map, nb, nb, nb); 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);
// map.check();
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())
{ {
position[d] *= 10; position[d] *= 10;
if(position[d][0]<mapMinX) mapMinX=position[d][0];
if(position[d][0]>mapMaxX) mapMaxX=position[d][0];
if(position[d][1]<mapMinY) mapMinY=position[d][1];
if(position[d][1]>mapMaxY) mapMaxY=position[d][1];
if(position[d][2]<mapMinZ) mapMinZ=position[d][2];
if(position[d][2]>mapMaxZ) mapMaxZ=position[d][2];
} }
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); // map.check();
}
if(checkFaces())
exit(0);
///// initialisation attributs
} facecenter = map.addAttribute<VEC3, FACE, MAP>("facecenter");
volumecenter=map.addAttribute<VEC3, VOLUME, MAP>("volumecenter");
color = map.addAttribute<VEC3, VOLUME, MAP>("color");
RegisteredEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredEdges");
RegisteredNeighborEdges=map.addAttribute<ARETES,VOLUME, MAP>("RegisteredNeighborEdges");
RegisteredTriangles=map.addAttribute<TRIANGLES,VOLUME, MAP>("RegisteredTriangles");
RegisteredNeighborTriangles=map.addAttribute<TRIANGLES,VOLUME, MAP>("RegisteredNeighborTriangles");
TraversorW<MAP> tra(map);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
color[d] = position[d]/10 + VEC3(0.5,0.5,0.5);
volumecenter[d]=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3, MAP>>(map,d,position);
}
TraversorV<MAP> tv(map);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
if(position[d][0]<mapMinX) mapMinX=position[d][0];
if(position[d][0]>mapMaxX) mapMaxX=position[d][0];
if(position[d][1]<mapMinY) mapMinY=position[d][1];
if(position[d][1]>mapMaxY) mapMaxY=position[d][1];
if(position[d][2]<mapMinZ) mapMinZ=position[d][2];
if(position[d][2]>mapMaxZ) mapMaxZ=position[d][2];
}
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())
{
VEC3 pos =position[d];
color[d] = VEC3((pos[0]-mapMinX)/(mapMaxX-mapMinX),(pos[1]-mapMinY)/(mapMaxY-mapMinY),(pos[2]-mapMinZ)/(mapMaxZ-mapMinZ));
volumecenter[d]=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3, MAP>>(map,d,position);
}
map.check();
} }
REAL EnvMap::volumeMaxdistance(Vol volume) REAL EnvMap::volumeMaxdistance(Vol volume)
...@@ -179,9 +195,6 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume) // définit si le point pos est ...@@ -179,9 +195,6 @@ bool EnvMap::insideVolume(VEC3 pos, Dart volume) // définit si le point pos est
///// a coder
Dart EnvMap::getBelongingCell(const PFP::VEC3& pos) Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
{ {
#ifdef IHMap #ifdef IHMap
...@@ -204,7 +217,30 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos) ...@@ -204,7 +217,30 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
} }
bool EnvMap::checkFaces()
{
CGoGNout<<"check faces"<<CGoGNendl;
TraversorF<MAP> tf(map);
for(Dart d = tf.begin() ; d != tf.end() ; d = tf.next())
{
Dart d2 = map.phi1(d);
Dart d3 = map.phi1(d2);
Geom::Plane3D<typename PFP::REAL> plan(position[d],position[d2],position[d3]);
do
{
d3=map.phi1(d3);
if(plan.orient(position[d3])!=Geom::ON)
{
CGoGNout << " face non coplanaire !" <<d3<<CGoGNendl;
return true;
}
}while(d3!=d);
}
return false;
}
...@@ -244,37 +280,15 @@ void EnvMap::open_file(std::string filename) ...@@ -244,37 +280,15 @@ void EnvMap::open_file(std::string filename)
} }
else else
{ {
// if(!Algo::Volume::Import::importMesh<PFP>(map, filename, attrNames)) if(!Algo::Volume::Import::importMesh<PFP>(map, filename, attrNames))
// { {
// std::cerr << "could not import " << filename << std::endl ; std::cerr << "could not import " << filename << std::endl ;
// return ; return ;
// } }
// else else
// position = map.getAttribute<VEC3, VERTEX>(attrNames[0]) ; position = map.getAttribute<VEC3, VERTEX, MAP>(attrNames[0]) ;
}
color = map.addAttribute<VEC3, VOLUME, MAP>("colorVol");
TraversorCell<MAP, VOLUME> tra(map);
float maxV = 0.0f;
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
float v = Algo::Geometry::tetrahedronVolume<PFP>(map, d, position);
color[d] = VEC3(v,0,0);
if (v>maxV)
maxV=v;
// if(envMap.map.isVolumeIncidentToBoundary(d))
// color[d] = VEC3(0,0,0);
// else
color[d] = VEC3(v,0,0);
} }
for (unsigned int i = color.begin(); i != color.end(); color.next(i))
{
color[i][0] /= maxV;
color[i][2] = 1.0f - color[i][0];
}
} }
} }
//////////////////////////////////enregistrement des segments //////////////////////////////////enregistrement des segments
......
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