diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp index 956189b91e9f8cb6853500caccad835094907d66..c12748259304f8a32fb117c0ac95e4a05ab601d0 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp @@ -81,23 +81,17 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler trav3EW(map, old); // for(Dart dit = trav3EW.begin() ; dit != trav3EW.end() ; dit = trav3EW.next()) // { // Dart oldit = map.volumeOldestDart(dit); -// if(((vLevel+1) - map.volumeLevel(oldit)) > 1) -// Algo::IHM::subdivideVolumeClassic(map, oldit, position); // -//// Dart oldNeighbor = map.volumeOldestDart(map.phi3(old)); -//// unsigned int vLevel = map.volumeLevel(oldNeighbor); -//// -//// std::cout << "vLevel courant = " << map.volumeLevel(old) << std::endl; -//// std::cout << "vLevel voisin = " << vLevel << std::endl; -//// -//// if((map.volumeLevel(old)+1) - (vLevel) > 1) -//// Algo::IHM::subdivideVolumeClassic(map, oldNeighbor, position); +// //std::cout << "vLevel courant = " << map.volumeLevel(oldit) << std::endl; +// +// if(((vLevel+1) - map.volumeLevel(oldit)) > 1) +// Algo::IHM::subdivideVolumeClassic(map, oldit, position); // } unsigned int degree = 0 ; diff --git a/include/Algo/Modelisation/tetrahedralization.hpp b/include/Algo/Modelisation/tetrahedralization.hpp index fabd4dfccfb25a21910e06a848d90d9c276638e0..bac853d766b604b97fdb6614dd44fb8b7259f1eb 100644 --- a/include/Algo/Modelisation/tetrahedralization.hpp +++ b/include/Algo/Modelisation/tetrahedralization.hpp @@ -569,88 +569,92 @@ void swap5To4(typename PFP::MAP& map, Dart d, VertexAttribute void flip1To4(typename PFP::MAP& map, Dart d, VertexAttribute& position) { -// typedef typename PFP::TVEC3 TVEC3; -// typedef typename PFP::VEC3 VEC3; -// -// -// //parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid -// VEC3 volCenter; -// unsigned count = 0 ; -// -// DartMarkerStore mf(map); // Lock a face marker to save one dart per face -// DartMarkerStore mv(map); // Lock a vertex marker to compute volume center -// -// std::vector visitedFaces; -// visitedFaces.reserve(4); -// visitedFaces.push_back(d); -// -// mf.markOrbit(d) ; -// -// //TODO diminuer complexite avec boucle specifique aux tetras -// for(unsigned int i = 0; i < visitedFaces.size(); ++i) -// { -// Dart e = visitedFaces[i] ; -// do -// { -// //compute volume centroid -// if(!mv.isMarked(e)) -// { -// volCenter += position[e]; -// ++count; -// mv.markOrbit(e); -// } -// -// // add all face neighbours to the table -// Dart ee = map.phi2(e) ; -// if(!mf.isMarked(ee)) // not already marked -// { -// visitedFaces.push_back(ee) ; -// mf.markOrbit(ee) ; -// } -// -// e = map.phi1(e) ; -// } while(e != visitedFaces[i]) ; -// } -// -// volCenter /= typename PFP::REAL(count) ; -// -// //store the new faces to 3-sew -// std::vector > nFaces; -// nFaces.reserve(6); -// -// //triangule chaque face avec plongement au centroid -// for (std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) -// { -// // on decoud et on ferme le trou -// Dart temp = *face; -// do -// { -// nFaces.push_back(std::pair(temp, map.phi2(temp))); -// map.unsewFaces(temp); -// temp = map.phi1(temp); -// } -// while(temp != *face); -// -// map.closeHole(*face); -// -// Dart fi = map.phi2(*face); -// -// Dart cd = Algo::Modelisation::trianguleFace(map, fi); -// position[cd] = volCenter; -// } -// -// //coudre les nouveaux brins entre eux par phi3 -// for (std::vector >::iterator face =nFaces.begin(); face != nFaces.end(); ++face) -// { -// -// if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first)) -// map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second)); -// } + typedef typename PFP::VEC3 VEC3; + + + //parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid + VEC3 volCenter; + unsigned count = 0 ; + + DartMarkerStore mf(map); // Lock a face marker to save one dart per face + DartMarkerStore mv(map); // Lock a vertex marker to compute volume center + + std::vector visitedFaces; + visitedFaces.reserve(4); + visitedFaces.push_back(d); + + mf.markOrbit(d) ; + + //TODO diminuer complexite avec boucle specifique aux tetras + for(unsigned int i = 0; i < visitedFaces.size(); ++i) + { + Dart e = visitedFaces[i] ; + do + { + //compute volume centroid + if(!mv.isMarked(e)) + { + volCenter += position[e]; + ++count; + mv.markOrbit(e); + } + + // add all face neighbours to the table + Dart ee = map.phi2(e) ; + if(!mf.isMarked(ee)) // not already marked + { + visitedFaces.push_back(ee) ; + mf.markOrbit(ee) ; + } + + e = map.phi1(e) ; + } while(e != visitedFaces[i]) ; + } + + volCenter /= typename PFP::REAL(count) ; + + //store the new faces to 3-sew + std::vector > nFaces; + nFaces.reserve(6); + + //triangule chaque face avec plongement au centroid + for (std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) + { + // on decoud et on ferme le trou + Dart temp = *face; + do + { + nFaces.push_back(std::pair(temp, map.phi2(temp))); + map.unsewFaces(temp); + temp = map.phi1(temp); + } + while(temp != *face); + + map.PFP::MAP::ParentMap::closeHole(*face); + + Dart fi = map.phi2(*face); + + Dart cd = Algo::Modelisation::trianguleFace(map, fi); + position[cd] = volCenter; + } + + //coudre les nouveaux brins entre eux par phi3 + for (std::vector >::iterator face =nFaces.begin(); face != nFaces.end(); ++face) + { + + if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first)) + map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second)); + } + } + + /************************************************************************************************ * Bisection Functions * ************************************************************************************************/ diff --git a/include/Algo/Multiresolution/map2MR/map2MR_PM.h b/include/Algo/Multiresolution/map2MR/map2MR_PM.h index 8cdb734c8cb3caafc40091f7cf8cb2d22a169883..e3a1d046b1fce1d8049dc177fe63d6995765a6d9 100644 --- a/include/Algo/Multiresolution/map2MR/map2MR_PM.h +++ b/include/Algo/Multiresolution/map2MR/map2MR_PM.h @@ -57,14 +57,9 @@ public: private: MAP& m_map ; VertexAttribute& m_position; - bool shareVertexEmbeddings ; - - //SelectorUnmarked dartSelect ; bool m_initOk ; - DartMarker& inactiveMarker; - Algo::Decimation::EdgeSelector* m_selector ; std::vector*> m_approximators ; std::vector*> m_predictors ; @@ -72,13 +67,14 @@ private: Algo::Decimation::Approximator* m_positionApproximator ; public: - Map2MR_PM(MAP& map, VertexAttribute& position, DartMarker& inactive, - Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a) ; + Map2MR_PM(MAP& map, VertexAttribute& position); ~Map2MR_PM(); //create a progressive mesh (a coarser level) - void createPM(unsigned int percentWantedVertices); + void createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a, const FunctorSelect& select = allDarts) ; + + void addNewLevel(unsigned int percentWantedVertices); //coarsen the mesh -> analysis void coarsen() ; diff --git a/include/Algo/Multiresolution/map2MR/map2MR_PM.hpp b/include/Algo/Multiresolution/map2MR/map2MR_PM.hpp index 0c248cd69dfa0531372aeeabc07c721a10f40d02..8155011215c4f3f06bc6aa553f7f7e9a639accda 100644 --- a/include/Algo/Multiresolution/map2MR/map2MR_PM.hpp +++ b/include/Algo/Multiresolution/map2MR/map2MR_PM.hpp @@ -33,10 +33,28 @@ namespace Multiresolution { template -Map2MR_PM::Map2MR_PM(MAP& map, VertexAttribute& position, DartMarker& inactive, - Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a - ) : - m_map(map), m_position(position), inactiveMarker(inactive) +Map2MR_PM::Map2MR_PM(typename PFP::MAP& map, VertexAttribute& position) : m_map(map), m_position(position) +{ + //TODO + //map.enableMR(); +} + +template +Map2MR_PM::~Map2MR_PM() +{ + if(m_selector) + delete m_selector ; + for(typename std::vector*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it) + delete (*it) ; + for(typename std::vector*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it) + delete (*it) ; + + //TODO + //map.disableMR() +} + +template +void Map2MR_PM::createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a, const FunctorSelect& select = allDarts) { CGoGNout << " creating approximator and predictor.." << CGoGNflush ; @@ -75,22 +93,22 @@ Map2MR_PM::Map2MR_PM(MAP& map, VertexAttribute& position, DartMarker& switch(s) { case Algo::Decimation::S_MapOrder : { - m_selector = new Algo::Decimation::EdgeSelector_MapOrder(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_MapOrder(m_map, m_position, m_approximators, select) ; break ; } case Algo::Decimation::S_Random : { - m_selector = new Algo::Decimation::EdgeSelector_Random(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_Random(m_map, m_position, m_approximators, select) ; break ; } case Algo::Decimation::S_EdgeLength : { - m_selector = new Algo::Decimation::EdgeSelector_Length(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_Length(m_map, m_position, m_approximators, select) ; break ; } case Algo::Decimation::S_QEM : { - m_selector = new Algo::Decimation::EdgeSelector_QEM(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_QEM(m_map, m_position, m_approximators, select) ; break ; } case Algo::Decimation::S_MinDetail : { - m_selector = new Algo::Decimation::EdgeSelector_MinDetail(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_MinDetail(m_map, m_position, m_approximators, select) ; break ; } case Algo::Decimation::S_Curvature : { - m_selector = new Algo::Decimation::EdgeSelector_Curvature(m_map, m_position, m_approximators, allDarts) ; + m_selector = new Algo::Decimation::EdgeSelector_Curvature(m_map, m_position, m_approximators, select) ; break ; } } CGoGNout << "..done" << CGoGNendl ; @@ -112,32 +130,22 @@ Map2MR_PM::Map2MR_PM(MAP& map, VertexAttribute& position, DartMarker& if(! (*it)->init()) m_initOk = false ; CGoGNout << "..done" << CGoGNendl ; -} -template -Map2MR_PM::~Map2MR_PM() -{ - if(m_selector) - delete m_selector ; - for(typename std::vector*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it) - delete (*it) ; - for(typename std::vector*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it) - delete (*it) ; + CGoGNout << " initializing selector.." << CGoGNflush ; + m_initOk = m_selector->init() ; + CGoGNout << "..done" << CGoGNendl ; } + + template -void Map2MR_PM::createPM(unsigned int percentWantedVertices) +void Map2MR_PM::addNewLevel(unsigned int percentWantedVertices) { // level handling m_map.pushLevel() ; m_map.addLevel(); m_map.setCurrentLevel(m_map.getMaxLevel()) ; - // PM creation - CGoGNout << " initializing selector.." << CGoGNflush ; - m_initOk = m_selector->init() ; - CGoGNout << "..done" << CGoGNendl ; - unsigned int nbVertices = m_map.template getNbOrbits() ; unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ; CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ; @@ -153,6 +161,8 @@ void Map2MR_PM::createPM(unsigned int percentWantedVertices) Dart d2 = m_map.phi2(m_map.phi_1(d)) ; Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ; + + for(typename std::vector*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it) { (*it)->approximate(d) ; // compute approximated attributes with its associated detail diff --git a/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.h b/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.h index 1e937911f8cd032f6ec1ee0c71aef14151841b09..f6c8d108651d277701059d7ac24c86a2f80d3d04 100644 --- a/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.h +++ b/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.h @@ -77,6 +77,12 @@ public: * *************************************************************************/ //@{ + //! + /* + * + */ + void addNewLevelSqrt3(bool embedNewVertices); + //! /* */ diff --git a/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.hpp b/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.hpp index 0474acba5f7b86c822cb8640352dda698496e877..a2a4a65d0be3f32aa08ee44b3498f4bbf7f386b7 100644 --- a/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/map3MR/map3MR_PrimalRegular.hpp @@ -103,6 +103,69 @@ void Map3MR_PrimalRegular::splitSurfaceInVolume(std::vector& vd, bool /************************************************************************ * Level creation * ************************************************************************/ +template +void Map3MR_PrimalRegular::addNewLevelSqrt3(bool embedNewVertices) +{ + m_map.pushLevel(); + + m_map.addLevel(); + //m_map.setCurrentLevel(m_map.getMaxLevel()); + unsigned int cur = m_map.getCurrentLevel(); + + // + TraversorW travW(m_map); + for(Dart dit = travW.begin() ; dit != travW.end() ; dit = travW.next()) + { + m_map.setCurrentLevel(cur+1); + + //store the new faces to 3-sew + std::vector > nFaces; + nFaces.reserve(6); + + Traversor3WF travWF(m_map, dit); + for(Dart ditWF = travWF.begin() ; ditWF != travWF.end() ; ditWF = travWF.next()) + { + + + +// Dart temp = ditWF; +// do +// { +// nFaces.push_back(std::pair(temp, m_map.phi2(temp))); +// m_map.unsewFaces(temp); +// temp = m_map.phi1(temp); +// } +// while(temp != ditWF); +// +// m_map.PFP::MAP::ParentMap::closeHole(ditWF, false); + + //Dart fi = map.phi2(*face); + + +// std::vector split; +// split.push_back(ditWF); +// split.push_back(m_map.phi1(ditWF)); +// split.push_back(m_map.phi_1(ditWF)); +// +// splitSurfaceInVolume(split,true,false); + } + + //Dart fi = map.phi2(*face); + +// //coudre les nouveaux brins entre eux par phi3 +// for (std::vector >::iterator face =nFaces.begin(); face != nFaces.end(); ++face) +// { +// +// if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first)) +// map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second)); +// } +// + m_map.setCurrentLevel(cur); + } + + m_map.setCurrentLevel(m_map.getMaxLevel()); +} + template void Map3MR_PrimalRegular::addNewLevelTetraOcta(bool embedNewVertices) { diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp index 8de8917c1f392114e2de3bc9358bdb3d35619efd..6223ef40aecffbe15f1c155c6f65026ccd945164 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp @@ -728,10 +728,13 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersMoreThanOne(Dart d) unsigned int vLevel = volumeLevel(d); bool isMoreThanOne = false; +// std::cout << "niveau du courant : " << vLevel << std::endl; Traversor3WWaV trav3WWaV(*this, d); for(Dart dit = trav3WWaV.begin() ; !isMoreThanOne && dit != trav3WWaV.end() ; dit = trav3WWaV.next()) { //Dart oldit = volumeOldestDart(dit); +// std::cout << "niveau du voisin : " << volumeLevel(dit) << std::endl; +// std::cout << "difference de niveau avec voisin : " << abs((volumeLevel(dit) - vLevel)) << std::endl; if(abs((volumeLevel(dit) - vLevel)) > 1) isMoreThanOne = true; } @@ -751,18 +754,21 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersMoreThanOne(Dart d) bool ImplicitHierarchicalMap3::coarsenNeighborhoodLevelDiffersMoreThanOne(Dart d) { assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; - //assert(m_curLevel > 0 || !"Coarsen a volume at level 0"); +// assert(m_curLevel > 0 || !"Coarsen a volume at level 0"); - Dart old = volumeOldestDart(d); + unsigned int vLevel = volumeLevel(d)-1; bool isMoreThanOne = false; -// if(m_curLevel > 0) -// --m_curLevel; - - isMoreThanOne = neighborhoodLevelDiffersMoreThanOne(old); - -// if(m_curLevel > 0) -// ++m_curLevel; +// std::cout << "niveau du courant : " << vLevel << std::endl; + Traversor3WWaV trav3WWaV(*this, d); + for(Dart dit = trav3WWaV.begin() ; !isMoreThanOne && dit != trav3WWaV.end() ; dit = trav3WWaV.next()) + { + //Dart oldit = volumeOldestDart(dit); +// std::cout << "niveau du voisin : " << volumeLevel(dit) << std::endl; +// std::cout << "difference de niveau avec voisin : " << abs((volumeLevel(dit) - vLevel)) << std::endl; + if(abs((volumeLevel(dit) - vLevel)) > 1) + isMoreThanOne = true; + } return isMoreThanOne;