Commit 1538d00e authored by untereiner's avatar untereiner
Browse files

pas mal de modifications sur les IHM3 et l'import pour l'InESS

parent 39c7eaff
...@@ -84,6 +84,13 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, ...@@ -84,6 +84,13 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
template <typename PFP> template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good = SelectorTrue()) ; bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good = SelectorTrue()) ;
/**
* export pout l'InESS
*/
template <typename PFP>
bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position);
} // namespace Export } // namespace Export
} // namespace Algo } // namespace Algo
......
...@@ -515,6 +515,23 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P ...@@ -515,6 +515,23 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
return true ; return true ;
}*/ }*/
template <typename PFP>
bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ;
if (!out.good())
{
CGoGNerr << "Unable to open file " << CGoGNendl ;
return false ;
}
}
} // namespace Export } // namespace Export
} // namespace Algo } // namespace Algo
......
...@@ -106,17 +106,17 @@ public: ...@@ -106,17 +106,17 @@ public:
virtual void next(Dart& d) ; virtual void next(Dart& d) ;
virtual bool foreach_dart_of_vertex(Dart d, FunctorType& f) ; virtual bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) ;
virtual bool foreach_dart_of_edge(Dart d, FunctorType& f) ; virtual bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) ;
bool foreach_dart_of_oriented_face(Dart d, FunctorType& f); bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0);
virtual bool foreach_dart_of_face(Dart d, FunctorType& f) ; virtual bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0) ;
bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f); bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread = 0);
virtual bool foreach_dart_of_volume(Dart d, FunctorType& f) ; virtual bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0) ;
virtual bool foreach_dart_of_cc(Dart d, FunctorType& f) ; virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ;
/**************************************************** /****************************************************
......
...@@ -238,7 +238,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d) ...@@ -238,7 +238,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d)
} while(d != Map3::end() && m_dartLevel[d] > m_curLevel) ; } while(d != Map3::end() && m_dartLevel[d] > m_curLevel) ;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
{ {
DartMarkerStore mv(*this); // Lock a marker DartMarkerStore mv(*this); // Lock a marker
bool found = false; // Last functor return value bool found = false; // Last functor return value
...@@ -276,7 +276,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType ...@@ -276,7 +276,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType
return found; return found;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
{ {
Dart dNext = d; Dart dNext = d;
...@@ -296,7 +296,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType& ...@@ -296,7 +296,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType&
return false; return false;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread)
{ {
Dart dNext = d ; Dart dNext = d ;
do do
...@@ -308,7 +308,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, Func ...@@ -308,7 +308,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, Func
return false ; return false ;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
{ {
if (foreach_dart_of_oriented_face(d,f)) return true; if (foreach_dart_of_oriented_face(d,f)) return true;
...@@ -317,7 +317,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType& ...@@ -317,7 +317,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType&
return false; return false;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread)
{ {
DartMarkerStore mark(*this); // Lock a marker DartMarkerStore mark(*this); // Lock a marker
bool found = false; // Last functor return value bool found = false; // Last functor return value
...@@ -353,12 +353,12 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, Fu ...@@ -353,12 +353,12 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, Fu
return found; return found;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{ {
return foreach_dart_of_oriented_volume(d, f) ; return foreach_dart_of_oriented_volume(d, f) ;
} }
inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f) inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
{ {
return foreach_dart_of_oriented_volume(d, f) ; return foreach_dart_of_oriented_volume(d, f) ;
} }
......
...@@ -286,7 +286,7 @@ void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -286,7 +286,7 @@ void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.unsewFaces(map.phi1(map.phi1(e))); map.unsewFaces(map.phi1(map.phi1(e)));
//TODO utile ? //TODO utile ?
if(map.phi2(map.phi1(e)) != map.phi1(e)) //if(map.phi2(map.phi1(e)) != map.phi1(e))
map.unsewFaces(map.phi1(e)); map.unsewFaces(map.phi1(e));
e = map.phi2(map.phi_1(e)); e = map.phi2(map.phi_1(e));
......
...@@ -72,7 +72,7 @@ template <typename PFP> ...@@ -72,7 +72,7 @@ template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f); bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP> template <typename PFP>
bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames); bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, std::vector<std::pair<typename PFP::VEC3, typename PFP::VEC3> >& influences);
template <typename PFP> template <typename PFP>
bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames); bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*******************************************************************************/ *******************************************************************************/
#include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/primitives3d.h"
#include <vector> #include <vector>
#include "Geometry/bounding_box.h" #include "Geometry/bounding_box.h"
#include <set> #include <set>
...@@ -51,7 +52,7 @@ typename PFP::VEC3 stringToEmb(std::string s) ...@@ -51,7 +52,7 @@ typename PFP::VEC3 stringToEmb(std::string s)
typename PFP::VEC3 coord(x,y,z); typename PFP::VEC3 coord(x,y,z);
CGoGNout << coord << CGoGNendl; //CGoGNout << coord << CGoGNendl;
return coord; return coord;
} }
...@@ -72,7 +73,7 @@ inline unsigned int gcd(unsigned int a, unsigned int b) ...@@ -72,7 +73,7 @@ inline unsigned int gcd(unsigned int a, unsigned int b)
} }
template <typename PFP> template <typename PFP>
bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames) bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, std::vector<std::pair<typename PFP::VEC3, typename PFP::VEC3> > &influences)
{ {
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
...@@ -134,6 +135,11 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -134,6 +135,11 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
sy.insert(c1[1]); sy.insert(c1[1]);
sy.insert(c2[1]); sy.insert(c2[1]);
// Second Column (nil)
bg = line.substr(posData);
//std::cout << bg << std::endl;
size++; size++;
while ( std::getline( fp, line ) ) while ( std::getline( fp, line ) )
...@@ -147,11 +153,9 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -147,11 +153,9 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
VEC3 c1 = stringToEmb<PFP>(bg.substr(0, posCoord)); VEC3 c1 = stringToEmb<PFP>(bg.substr(0, posCoord));
VEC3 c2 = stringToEmb<PFP>(bg.substr(posCoord+3)); VEC3 c2 = stringToEmb<PFP>(bg.substr(posCoord+3));
std::cout << std::endl; //std::cout << std::endl;
coordonnees.push_back(std::pair<VEC3,VEC3>(c1,c2)); coordonnees.push_back(std::pair<VEC3,VEC3>(c1,c2));
// coordonneesX.insert(std::pair<int, unsigned int >(c1[0],size));
// coordonneesY.insert(std::pair<int, unsigned int >(c1[1],size));
sx.insert(c1[0]); sx.insert(c1[0]);
sx.insert(c2[0]); sx.insert(c2[0]);
...@@ -159,22 +163,25 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -159,22 +163,25 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
sy.insert(c1[1]); sy.insert(c1[1]);
sy.insert(c2[1]); sy.insert(c2[1]);
//Second Column
bg = line.substr(posData);
posCoord = bg.find(") (");
//std::cout << bg << std::endl;
c1 = stringToEmb<PFP>(bg.substr(1, posCoord+1));
//CGoGNout << c1 << CGoGNendl;
c2 = stringToEmb<PFP>(bg.substr(posCoord+3));
//CGoGNout << c2 << CGoGNendl;
influences.push_back(std::pair<VEC3,VEC3>(c1,c2));
size++; size++;
} }
fp.close(); fp.close();
// std::cout << "setx" << std::endl;
// for (std::set<int>::iterator it = sx.begin() ; it != sx.end(); ++it)
// std::cout << " " << *it;
// std::cout << std::endl;
//
// std::cout << "sety" << std::endl;
// for (std::set<int>::iterator it = sy.begin() ; it != sy.end(); ++it)
// std::cout << " " << *it;
// std::cout << std::endl;
// //
// Creation de la grille // Creation de la grille
// //
...@@ -186,11 +193,10 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -186,11 +193,10 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
int cy = sy.size(); int cy = sy.size();
prim.grid_topo(cx-1,cy-1); prim.grid_topo(cx-1,cy-1);
//tableau des brins (un par sommet)
std::vector<Dart> tableVertDarts = prim.getVertexDarts(); std::vector<Dart> tableVertDarts = prim.getVertexDarts();
std::pair<std::multimap<int, unsigned int>::iterator,std::multimap<int, unsigned int>::iterator > retX;
for(int i=0; i<cy; ++i) for(int i=0; i<cy; ++i)
{ {
//std::cout << "cood y =" << *sity << std::endl; //std::cout << "cood y =" << *sity << std::endl;
...@@ -201,7 +207,7 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -201,7 +207,7 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
Dart d = tableVertDarts[i*(cx)+j]; Dart d = tableVertDarts[i*(cx)+j];
position[d] = VEC3(*sitx, *sity, 0); position[d] = VEC3(*sitx, *sity, 0);
objects[d] = -1; objects[d] = 0;
++sitx; ++sitx;
} }
...@@ -213,7 +219,6 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -213,7 +219,6 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
// //
// Coloriage // Coloriage
// //
for(int i=0; i<cy; ++i) for(int i=0; i<cy; ++i)
{ {
//std::cout << "cood y =" << *sity << std::endl; //std::cout << "cood y =" << *sity << std::endl;
...@@ -223,232 +228,36 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, ...@@ -223,232 +228,36 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename,
{ {
Dart d = tableVertDarts[i*(cx)+j]; Dart d = tableVertDarts[i*(cx)+j];
if(objects[d] == 0)
{
//Calcul du centre de ce quad //Calcul du centre de ce quad
VEC3 c = Algo::Geometry::faceCentroid<PFP>(map, d, position); VEC3 c = Algo::Geometry::faceCentroid<PFP>(map, d, position);
//std::cout << "center=" << c << std::endl; //std::cout << "center=" << c << std::endl;
int place = 0;
int i = 1;
//Comparaison avec toutes les coordonnees si le point se trouve dedans //Comparaison avec toutes les coordonnees si le point se trouve dedans
for(typename std::vector<std::pair<VEC3,VEC3> >::iterator it = coordonnees.begin(); it != coordonnees.end() ; ++it) for(typename std::vector<std::pair<VEC3,VEC3> >::iterator it = coordonnees.begin(); it != coordonnees.end() ; ++it)
{ {
//comparaison si la coord du centre se situe dans l'intervalle de la boite anglobante //comparaison si la coord du centre se situe dans l'intervalle de la boite anglobante
//std::cout << "c1=" << (*it).first << " c2=" << (*it).second << std::endl; //std::cout << "c1=" << (*it).first << " c2=" << (*it).second << std::endl;
if((*it).first[0] < c[0] && c[0] < (*it).second[0] && (*it).first[1] < c[1] && c[1] < (*it).second[1]) if((*it).first[0] <= c[0] && c[0] < (*it).second[0] &&
(*it).first[1] <= c[1] && c[1] < (*it).second[1])
{ {
objects[d] = place; objects[d] = i ;
//std::cout << "i=" << place << std::endl;
std::cout << "place=" << place << std::endl;
} }
++place; ++i;
} }
}
++sitx; ++sitx;
} }
++sity; ++sity;
} }
std::cout << "coord size : " << coordonnees.size() << std::endl;
// for(int i=0; i<cy; ++i)
// {
// std::cout << "cood y =" << *sity << std::endl;
// std::set<int>::iterator sitx = sx.begin();
//
// for(int j=0; j<cx;++j)
// {
// Dart d = tableVertDarts[i*(cx)+j];
//
// //Amelioration : tester si le brin est marque d'abord
// if(!fm.isMarked(d))
// {
// //chercher dans la multimap X le début des sommets dont la cle vaut *sitx
//// retX = coordonneesX.lower_bound(*sitx);
// bool end = false;
//
// std::cout << "sitx=" << *sitx << std::endl;
// std::cout << "sity=" << *sity << std::endl;
// //chercher dans ce sous ensemble avec une indirection vers les coordonnnes le couple de coordonnees dans le first a une valeur Y qui vaut *sitY
// for(std::multimap<int, unsigned int>::iterator retX = coordonneesX.lower_bound(*sitx) ; !end && retX != coordonneesX.end() ; ++retX)
// {
// std::cout << (*retX).second << std::endl;
// std::cout << coordonnees[(*retX).second].first << std::endl;
//
// //si ce plongement est le debut d'une boite englobante
// if(coordonnees[(*retX).second].first[1] == *sity)
// {
// std::cout << "plop" << std::endl;
// //on plonge un brin de cette face
// //objects[d] = (*retX).second;
//
// //on marque les brins de la face
// //fm.markOrbit(FACE_ORBIT, d);
//
//
//// Dart e = d;
//// do
//// {
//// //se balader dans la carte vers l'autre extremite de la boite englobante tout en marquant les faces
////
//// //Tout en incrementant les y
////
//// Dart f = e;
//// do
//// {
//// //on plonge un brin de cette face
//// objects[f] = (*retX).second;
////
//// //on marque les brins de la face
//// fm.markOrbit(FACE_ORBIT, f);
////
//// //d'abord sur les x tant que le x de la fin de la boite englobante n'a pas ete atteint
////
//// f = map.phi1(map.phi2(map.phi1(f)));
//// }
//// while(position[f][1] <= coordonnees[(*retX).second].second[1]);
////
//// e = map.phi2(map.phi_1(map.phi_1(e)));
//// }
//// while(position[e][0] <= coordonnees[(*retX).second].second[0]);
//
// }
// }
//
// std::cout << std::endl << std::endl;
// }
//
// ++sitx;
// }
// ++sity;
// }
// std::pair<std::multimap<int, unsigned int>::iterator,std::multimap<int, unsigned int>::iterator > retX;
// std::pair<std::multimap<int, unsigned int>::iterator,std::multimap<int, unsigned int>::iterator > retY;
//
// for(int i=0; i<cy; ++i)
// {
// std::cout << "cood y =" << *sity << std::endl;
// std::set<int>::iterator sitx = sx.begin();
//
// for(int j=0; j<cx;++j)
// {
// Dart d = tableVertDarts[i*(cx)+j];
//
// std::cout << "sitx=" << *sitx << std::endl;
// std::cout << "sity=" << *sity << std::endl;
//
// //chercher dans la multimap X le sous ensemble de sommets dont la cle vaut *sitx
// retX = coordonneesX.equal_range(*sitx);
//
// //chercher dans ce sous ensemble avec une indirection vers les coordonnnes le couple de coordonnees dans le first a une valeur Y qui vaut *sitY
// typename std::multimap<int, unsigned int>::iterator it;
// for (it=retX.first; it!=retX.second; ++it)
// {
// std::cout << (*it).second << std::endl;
// std::cout << coordonnees[(*it).second].first << std::endl << std::endl;
//
// //plonger le brin de cette face avec la valeur de l'indirection
// if(coordonnees[(*it).second].first[1] == *sity)
// objects[d] = (*it).second;
// }
// std::cout << std::endl;
// ++sitx;
// }
// ++sity;
// }
// Dart e = d;
// do
// {
// //se balader dans la carte vers l'autre extremite de la boite englobante tout en marquant les faces
//
// //Tout en incrementant les y
//
// Dart f = e;
// do
// {
// //on plonge un brin de cette face
// objects[f] = (*retX).second;
//
// //on marque les brins de la face
// fm.mark(FACE_ORBIT, f);
//
// //d'abord sur les x tant que le x de la fin de la boite englobante n'a pas ete atteint
//
// f = map.phi1(map.phi2(map.phi1(f)));
// }
// while(position[f][1] < coordonnees[(*retX).second].second[1]);
//
// e = map.phi2(map.phi_1(map.phi_1(e)));
//
// }
// while(position[e][0] < coordonnees[(*retX).second].second[0]);
// unsigned int em;
// AttributeContainer& container = map.getAttributeContainer(VERTEX_CELL) ;
// typename std::vector<std::pair<VEC3,VEC3> >::iterator it = coordonnees.begin();
// // ++it;
//
// while( it != coordonnees.end())
// {
// std::cout << "x=" << (*it).first << "y=" << (*it).second << std::endl;
//
//
// Dart d = map.newFace(4);
//
// std::pair<VEC3,VEC3> c = *it;
// VEC3 c1 = c.first;
// VEC3 c2 = c.second;
//
// em = container.insertLine();
// position[em] = c1;
// map.setDartEmbedding(VERTEX_ORBIT, d, em);
// d = map.phi1(d);
//
// em = container.insertLine();
// position[em] = VEC3(c2[0],c1[1],c2[2]);
// map.setDartEmbedding(VERTEX_ORBIT, d, em);
// d = map.phi1(d);
//
// em = container.insertLine();
// position[em] = c2;
// map.setDartEmbedding(VERTEX_ORBIT, d, em);
// d = map.phi1(d);
//
// em = container.insertLine();
// position[em] = VEC3(c1[0],c2[1],c1[2]);
// map.setDartEmbedding(VERTEX_ORBIT, d, em);
// d = map.phi1(d);
//
// ++it;
// }
//
// Coloriage des cases de la grille en fonction des boites englobantes
//
// Dart d = map.begin();
// Dart e = d;