From 010b59778230b20d0e48a95655d1a499d94b18be Mon Sep 17 00:00:00 2001 From: untereiner Date: Thu, 22 Dec 2011 17:31:38 +0100 Subject: [PATCH] Xmas modifications --- CMakeLists.txt | 2 + include/Algo/ImplicitHierarchicalMesh/ihm3.h | 24 +++- .../Algo/ImplicitHierarchicalMesh/ihm3.hpp | 1 - .../ImplicitHierarchicalMesh/subdivision3.hpp | 109 ++++++++++-------- src/Algo/ImplicitHierarchicalMesh/ihm3.cpp | 87 ++++++++++++++ 5 files changed, 169 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a494ad1b..fb86f9a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8) project(CGoGN) +#SET( CMAKE_VERBOSE_MAKEFILE 1 ) + SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}) # for GLEW diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.h b/include/Algo/ImplicitHierarchicalMesh/ihm3.h index a50a4afc..1e69fa60 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.h +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.h @@ -113,11 +113,23 @@ public: Dart alpha_2(Dart d); //@} -// /*! @name Topological Operators with Cells id management -// * Topological operations on Hierarchical Implicit 3-maps -// *************************************************************************/ -// -// //@{ + /*! @name Topological Operators with Cells id management + * Topological operations on Hierarchical Implicit 3-maps + *************************************************************************/ + + //@{ + //! + /*! + * + */ + Dart beginSplittingPath(Dart d, DartMarker& m); + + //! + /*! + * + */ + void constructSplittingPath(Dart d, std::vector& v, DartMarker& m); + // //! // /*! // * @@ -147,7 +159,7 @@ public: // * // */ // virtual void splitVolume(std::vector& vd); -// //@} + //@} /*! @name Levels Management * Operations to manage the levels of an Implicit Hierarchical 3-map diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp index a488d6e1..2967ffe0 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp @@ -123,7 +123,6 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d) return it ; } -//TODO A verifier si besoin d'assertion inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d) { unsigned int faceId = m_faceId[d]; diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp index fd60935a..178ff0e3 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp @@ -279,25 +279,40 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& std::vector newEdges; //save darts from inner edges newEdges.reserve(50); + DartMarker mSplitted(map); + + int i = 0; + //Second step : deconnect each corner, close each hole, subdivide each new face into 3 for (std::vector::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge) { - Dart e = *edge; - std::vector v ; + Dart e = map.beginSplittingPath(*edge, mSplitted); - do - { - v.push_back(map.phi1(map.phi1(e))); - v.push_back(map.phi1(e)); + std::cout << "e = " << e << "plop" << std::endl; - e = map.phi2(map.phi_1(e)); + //Tous les brins ont deja ete decousus, il n'y a pas de chemin d'arete a construire + if(e == NIL) + { + return NIL; } - while(e != *edge); + else + { + map.constructSplittingPath(e, v, mSplitted); + } + + std::cout << std::endl; + for(std::vector::iterator it = v.begin() ; it != v.end() ; ++it) + std::cout << *it << std::endl; + std::cout << std::endl; + + i++; + if(i == 2) + return NIL; map.splitVolume(v) ; - Dart old = map.phi2(map.phi1(e)); + Dart old = map.phi2(map.phi1(*edge)); Dart dd = map.phi1(map.phi1(old)) ; map.splitFace(old,dd) ; @@ -330,46 +345,46 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& dd = map.phi1(map.phi1(dd)); } while(dd != stop); - } - - map.deleteVolume(map.phi3(map.phi2(map.phi1(oldEdges.front())))); - - - //Third step : 3-sew internal faces - for (std::vector >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it) - { - Dart f1 = (*it).first; - Dart f2 = (*it).second; - if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2))) - { - //id pour toutes les faces interieures - map.sewVolumes(map.phi2(f1), map.phi2(f2)); - - //Fais a la couture !!!!! - unsigned int idface = map.getNewFaceId(); - map.setFaceId(map.phi2(f1),idface, FACE); - } - - //FAIS a la couture !!!!!!! - //id pour toutes les aretes exterieurs des faces quadrangulees - unsigned int idedge = map.getEdgeId(f1); - map.setEdgeId(map.phi2(f1), idedge, DART); - map.setEdgeId( map.phi2(f2), idedge, DART); } - //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!! - //id pour les aretes interieurs : (i.e. 6 pour un hexa) - DartMarker mne(map); - for(unsigned int i = 0; i < newEdges.size(); ++i) - { - if(!mne.isMarked(newEdges[i])) - { - unsigned int idedge = map.getNewEdgeId(); - map.setEdgeId(newEdges[i], idedge, EDGE); - mne.markOrbit(EDGE, newEdges[i]); - } - } + //map.deleteVolume(map.phi3(map.phi2(map.phi1(oldEdges.front())))); + +// //Third step : 3-sew internal faces +// for (std::vector >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it) +// { +// Dart f1 = (*it).first; +// Dart f2 = (*it).second; +// +// if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2))) +// { +// //id pour toutes les faces interieures +// map.sewVolumes(map.phi2(f1), map.phi2(f2)); +// +// //Fais a la couture !!!!! +// unsigned int idface = map.getNewFaceId(); +// map.setFaceId(map.phi2(f1),idface, FACE); +// } +// +// //FAIS a la couture !!!!!!! +// //id pour toutes les aretes exterieurs des faces quadrangulees +// unsigned int idedge = map.getEdgeId(f1); +// map.setEdgeId(map.phi2(f1), idedge, DART); +// map.setEdgeId( map.phi2(f2), idedge, DART); +// } +// +// //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!! +// //id pour les aretes interieurs : (i.e. 6 pour un hexa) +// DartMarker mne(map); +// for(unsigned int i = 0; i < newEdges.size(); ++i) +// { +// if(!mne.isMarked(newEdges[i])) +// { +// unsigned int idedge = map.getNewEdgeId(); +// map.setEdgeId(newEdges[i], idedge, EDGE); +// mne.markOrbit(EDGE, newEdges[i]); +// } +// } map.setCurrentLevel(cur) ; @@ -644,7 +659,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos //Etape 2 for (std::vector >::iterator edges = subdividedfacesT.begin(); edges != subdividedfacesT.end(); ++edges) { - Dart f1 = (*edges).first; +// Dart f1 = (*edges).first; Dart f2 = (*edges).second; //si ce n'est pas un tetrahedre diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp index d6ab8b2d..c38f58e2 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp @@ -68,6 +68,93 @@ void ImplicitHierarchicalMap3::init() } } + +Dart ImplicitHierarchicalMap3::beginSplittingPath(Dart d, DartMarker& m) +{ + Dart dres = NIL; + Dart dit = d; + bool found = false; + + // Recherche d'un brin de depart du chemin d'arete + do + { + Dart eit = phi1(dit); + + if(!m.isMarked(eit) && getDartLevel(eit) == getCurrentLevel()) + { + found = true; + dres = eit; + } + + dit = phi2(phi_1(dit)); + } + while(!found && dit != d); + + return dres; +} + +void ImplicitHierarchicalMap3::constructSplittingPath(Dart d, std::vector& v, DartMarker& m) +{ + + //Construction du chemin d'arete + Dart cit = d; + + v.push_back(cit); + m.markOrbit(EDGE, cit); + + do + { + + if(std::min(getDartLevel(phi1(cit)),getDartLevel(phi2(phi1(cit)))) == getDartLevel(d)) + { + if(m.isMarked(phi1(cit))) + { + cit = phi1(phi2(phi1(cit))); + std::cout << "1_1" << std::endl; + } + } + else if(std::min(getDartLevel(phi1(cit)),getDartLevel(phi2(phi1(cit)))) < getDartLevel(d)) + { + cit = phi1(phi2(phi1(cit))); + std::cout << "2" << std::endl; + } + else + cit = phi1(cit); + + v.push_back(cit); + m.markOrbit(EDGE, cit); + + + } + while(cit != d); + +// do +// { +// v.push_back(cit); +// m.markOrbit(EDGE, cit); +// +// cit = phi1(cit); +// +// //std::cout << "cit = " << cit << std::endl; +// +// if(std::min(getDartLevel(cit), getDartLevel(phi2(cit))) == getDartLevel(d)) +// { +// if(m.isMarked(cit)) +// { +// cit = phi1(phi2(cit)); +// //std::cout << "1_1" << std::endl; +// } +// } +// else if(std::min(getDartLevel(cit),getDartLevel(phi2(cit))) < getDartLevel(d)) +// { +// cit = phi1(phi2(cit)); +// //std::cout << "2" << std::endl; +// } +// +// }while(cit != d); + +} + //Dart ImplicitHierarchicalMap3::cutEdge(Dart d) //{ // Dart resV = EmbeddedMap3::cutEdge(d); -- GitLab