From 1538d00ef07c252e44c1761d0b37052ac98da9d7 Mon Sep 17 00:00:00 2001 From: untereiner Date: Wed, 18 May 2011 14:32:54 +0200 Subject: [PATCH] pas mal de modifications sur les IHM3 et l'import pour l'InESS --- include/Algo/Export/export.h | 7 + include/Algo/Export/export.hpp | 17 + include/Algo/ImplicitHierarchicalMesh/ihm3.h | 14 +- .../Algo/ImplicitHierarchicalMesh/ihm3.hpp | 14 +- .../ImplicitHierarchicalMesh/subdivision3.hpp | 2 +- include/Algo/Import/import.h | 2 +- include/Algo/Import/importInESS.hpp | 402 +++++++---------- include/Algo/Modelisation/polyhedron.hpp | 2 +- include/Algo/Modelisation/tetrahedron.h | 23 +- include/Algo/Modelisation/tetrahedron.hpp | 425 ++++++++++-------- include/Geometry/bounding_box.hpp | 2 +- include/Topology/generic/embeddedMap3.h | 13 - include/Topology/generic/embeddedMap3.hpp | 27 -- 13 files changed, 466 insertions(+), 484 deletions(-) diff --git a/include/Algo/Export/export.h b/include/Algo/Export/export.h index f86a2409d..5de946a53 100644 --- a/include/Algo/Export/export.h +++ b/include/Algo/Export/export.h @@ -84,6 +84,13 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, template 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 +bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position); + } // namespace Export } // namespace Algo diff --git a/include/Algo/Export/export.hpp b/include/Algo/Export/export.hpp index 4ec2dede4..3307937f5 100644 --- a/include/Algo/Export/export.hpp +++ b/include/Algo/Export/export.hpp @@ -515,6 +515,23 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P return true ; }*/ + +template +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 Algo diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.h b/include/Algo/ImplicitHierarchicalMesh/ihm3.h index e82efae60..77a1f9cd6 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.h +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.h @@ -106,17 +106,17 @@ public: 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); - virtual bool foreach_dart_of_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, unsigned int thread = 0) ; - bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f); - virtual bool foreach_dart_of_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, 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) ; /**************************************************** diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp index b56192997..0696b4bc6 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp @@ -238,7 +238,7 @@ inline void ImplicitHierarchicalMap3::next(Dart& d) } 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 bool found = false; // Last functor return value @@ -276,7 +276,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType 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; @@ -296,7 +296,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType& 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 ; do @@ -308,7 +308,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, Func 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; @@ -317,7 +317,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType& 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 bool found = false; // Last functor return value @@ -353,12 +353,12 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, Fu 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) ; } -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) ; } diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp index 66a934cd9..008fecfa6 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp @@ -286,7 +286,7 @@ void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi map.unsewFaces(map.phi1(map.phi1(e))); //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)); e = map.phi2(map.phi_1(e)); diff --git a/include/Algo/Import/import.h b/include/Algo/Import/import.h index 4fc2c7fa7..fc3f260bf 100644 --- a/include/Algo/Import/import.h +++ b/include/Algo/Import/import.h @@ -72,7 +72,7 @@ template bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector& attrNames, float scaleFactor = 1.0f); template -bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector& attrNames); +bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector& attrNames, std::vector >& influences); template bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector& attrNames); diff --git a/include/Algo/Import/importInESS.hpp b/include/Algo/Import/importInESS.hpp index 8536fe267..763aa7d16 100644 --- a/include/Algo/Import/importInESS.hpp +++ b/include/Algo/Import/importInESS.hpp @@ -23,6 +23,7 @@ *******************************************************************************/ #include "Algo/Modelisation/polyhedron.h" +#include "Algo/Modelisation/primitives3d.h" #include #include "Geometry/bounding_box.h" #include @@ -51,7 +52,7 @@ typename PFP::VEC3 stringToEmb(std::string s) typename PFP::VEC3 coord(x,y,z); - CGoGNout << coord << CGoGNendl; + //CGoGNout << coord << CGoGNendl; return coord; } @@ -72,7 +73,7 @@ inline unsigned int gcd(unsigned int a, unsigned int b) } template -bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames) +bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, std::vector > &influences) { typedef typename PFP::VEC3 VEC3; @@ -134,6 +135,11 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, sy.insert(c1[1]); sy.insert(c2[1]); + + // Second Column (nil) + bg = line.substr(posData); + //std::cout << bg << std::endl; + size++; while ( std::getline( fp, line ) ) @@ -147,11 +153,9 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, VEC3 c1 = stringToEmb(bg.substr(0, posCoord)); VEC3 c2 = stringToEmb(bg.substr(posCoord+3)); - std::cout << std::endl; + //std::cout << std::endl; coordonnees.push_back(std::pair(c1,c2)); -// coordonneesX.insert(std::pair(c1[0],size)); -// coordonneesY.insert(std::pair(c1[1],size)); sx.insert(c1[0]); sx.insert(c2[0]); @@ -159,22 +163,25 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, sy.insert(c1[1]); sy.insert(c2[1]); + + //Second Column + bg = line.substr(posData); + posCoord = bg.find(") ("); + //std::cout << bg << std::endl; + c1 = stringToEmb(bg.substr(1, posCoord+1)); + //CGoGNout << c1 << CGoGNendl; + c2 = stringToEmb(bg.substr(posCoord+3)); + //CGoGNout << c2 << CGoGNendl; + influences.push_back(std::pair(c1,c2)); + + + size++; } fp.close(); -// std::cout << "setx" << std::endl; -// for (std::set::iterator it = sx.begin() ; it != sx.end(); ++it) -// std::cout << " " << *it; -// std::cout << std::endl; -// -// std::cout << "sety" << std::endl; -// for (std::set::iterator it = sy.begin() ; it != sy.end(); ++it) -// std::cout << " " << *it; -// std::cout << std::endl; - // // Creation de la grille // @@ -186,11 +193,10 @@ bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, int cy = sy.size(); prim.grid_topo(cx-1,cy-1); + //tableau des brins (un par sommet) std::vector tableVertDarts = prim.getVertexDarts(); - std::pair::iterator,std::multimap::iterator > retX; - for(int i=0; i::iterator,std::multimap::iterator > retX; -// std::pair::iterator,std::multimap::iterator > retY; -// -// for(int i=0; i(bg.substr(posCoord+3)); std::cout << std::endl; + float x = c1[0]; + float y = c1[1]; + float z = c1[2]; + //coordonnees.push_back(std::pair(c1,c2)); // coordonneesX.insert(std::pair(c1[0],size)); // coordonneesY.insert(std::pair(c1[1],size)); @@ -546,6 +360,124 @@ bool importInESSVolumique(typename PFP::MAP& map, const std::string& filename, s fp.close(); + +// std::cout << "setx" << std::endl; +// for (std::set::iterator it = sx.begin() ; it != sx.end(); ++it) +// std::cout << " " << *it; +// std::cout << std::endl; +// +// std::cout << "sety" << std::endl; +// for (std::set::iterator it = sy.begin() ; it != sy.end(); ++it) +// std::cout << " " << *it; +// std::cout << std::endl; + + // + // Creation de la grille + // + Algo::Modelisation::Primitive3D prim(map, position); + + std::set::iterator sity = sy.begin(); + + int cx = sx.size(); + int cy = sy.size(); + prim.hexaGrid_topo(cx-1,cy-1, cx); + + std::vector tableVertDarts = prim.getVertexDarts(); + + + prim.embedHexaGrid(x,y,z); + +// std::pair::iterator,std::multimap::iterator > retX; +// int nbs = (cx+1)*(cy+1); +// +// for(int i=0; i<= 1; ++i) //z +// { +// for(int j=0; j<= cy; ++j) //y +// { +// std::set::iterator sitx = sx.begin(); +// +// for(int k=0; k<=cx;++k) //x +// { +// Dart d = tableVertDarts[ i*nbs+j*(cx+1)+k ]; +// +// map.embedNewCell(VERTEX_ORBIT,d); +// +// position[d] = VEC3(float(k), float(j), float(i)); +// +//// if(i == 0) +//// position[d] = VEC3(*sitx, *sity, 0); +//// else +//// position[d] = VEC3(*sitx,*sity, 0); +// +// ++sitx; +// } +// +// ++sity; +// } +// } + +// for(int i=0; i