From 324560fb22a6b641ff9096e69564faff818a4d37 Mon Sep 17 00:00:00 2001 From: untereiner Date: Tue, 22 Nov 2011 14:20:57 +0100 Subject: [PATCH] modifs dans map3 et ihm3 --- include/Algo/ImplicitHierarchicalMesh/ihm3.h | 93 ++- .../Algo/ImplicitHierarchicalMesh/ihm3.hpp | 244 +++----- .../ImplicitHierarchicalMesh/subdivision3.hpp | 530 +++++++++--------- include/Algo/Modelisation/primitives3d.hpp | 6 +- src/Algo/ImplicitHierarchicalMesh/ihm3.cpp | 1 + src/Topology/map/embeddedMap3.cpp | 34 +- src/Topology/map/map3.cpp | 2 + 7 files changed, 392 insertions(+), 518 deletions(-) diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.h b/include/Algo/ImplicitHierarchicalMesh/ihm3.h index 5b1dfb48..71666f18 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.h +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.h @@ -36,11 +36,11 @@ namespace Algo namespace IHM { -template class AttributeHandler_IHM ; +//template class AttributeHandler_IHM ; class ImplicitHierarchicalMap3 : public EmbeddedMap3 { - template friend class AttributeHandler_IHM ; + //template friend class AttributeHandler_IHM ; public: unsigned int m_curLevel ; @@ -65,11 +65,11 @@ public: * ATTRIBUTES MANAGEMENT * ***************************************************/ - template - AttributeHandler_IHM addAttribute(unsigned int orbit, const std::string& nameAttr) ; + //template + //AttributeHandler_IHM addAttribute(unsigned int orbit, const std::string& nameAttr) ; - template - AttributeHandler_IHM getAttribute(unsigned int orbit, const std::string& nameAttr) ; + //template + //AttributeHandler_IHM getAttribute(unsigned int orbit, const std::string& nameAttr) ; /*************************************************** @@ -117,15 +117,6 @@ public: virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ; - /**************************************************** - * EMBEDDED FUNCTIONS * - ****************************************************/ -// virtual void cutEdge(Dart d); - -// virtual void splitFace(Dart d, Dart e); - -// virtual void sewVolumes(Dart d, Dart e); - /*************************************************** * LEVELS MANAGEMENT * ***************************************************/ @@ -278,42 +269,42 @@ public: bool coarsenNeighborhoodLevelDiffersByOne(Dart d); } ; -template -class AttributeHandler_IHM : public AttributeHandler -{ -public: - typedef T DATA_TYPE ; - - AttributeHandler_IHM() : AttributeHandler() - {} - - AttributeHandler_IHM(GenericMap* m, AttributeMultiVector* amv) : AttributeHandler(m, amv) - {} - - AttributeMultiVector* getDataVector() const - { - return AttributeHandler::getDataVector() ; - } - - bool isValid() const - { - return AttributeHandler::isValid() ; - } - - T& operator[](Dart d) ; - - const T& operator[](Dart d) const ; - - T& operator[](unsigned int a) - { - return AttributeHandler::operator[](a) ; - } - - const T& operator[](unsigned int a) const - { - return AttributeHandler::operator[](a) ; - } -} ; +//template +//class AttributeHandler_IHM : public AttributeHandler +//{ +//public: +// typedef T DATA_TYPE ; +// +// AttributeHandler_IHM() : AttributeHandler() +// {} +// +// AttributeHandler_IHM(GenericMap* m, AttributeMultiVector* amv) : AttributeHandler(m, amv) +// {} +// +// AttributeMultiVector* getDataVector() const +// { +// return AttributeHandler::getDataVector() ; +// } +// +// bool isValid() const +// { +// return AttributeHandler::isValid() ; +// } +// +// T& operator[](Dart d) ; +// +// const T& operator[](Dart d) const ; +// +// T& operator[](unsigned int a) +// { +// return AttributeHandler::operator[](a) ; +// } +// +// const T& operator[](unsigned int a) const +// { +// return AttributeHandler::operator[](a) ; +// } +//} ; } //namespace IHM diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp index 2024e67d..b271df89 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp @@ -31,37 +31,37 @@ namespace Algo namespace IHM { -/*************************************************** - * ATTRIBUTES MANAGEMENT * - ***************************************************/ - -template -AttributeHandler_IHM ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr) -{ - bool addNextLevelCell = false ; - if(!isOrbitEmbedded(orbit)) - addNextLevelCell = true ; - - AttributeHandler h = Map3::addAttribute(orbit, nameAttr) ; - - if(addNextLevelCell) - { - AttributeContainer& cellCont = m_attribs[orbit] ; - AttributeMultiVector* amv = cellCont.addAttribute("nextLevelCell") ; - m_nextLevelCell[orbit] = amv ; - for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i)) - amv->operator[](i) = EMBNULL ; - } - - return AttributeHandler_IHM(this, h.getDataVector()) ; -} - -template -AttributeHandler_IHM ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr) -{ - AttributeHandler h = Map2::getAttribute(orbit, nameAttr) ; - return AttributeHandler_IHM(this, h.getDataVector()) ; -} +///*************************************************** +// * ATTRIBUTES MANAGEMENT * +// ***************************************************/ +// +//template +//AttributeHandler_IHM ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr) +//{ +// bool addNextLevelCell = false ; +// if(!isOrbitEmbedded(orbit)) +// addNextLevelCell = true ; +// +// AttributeHandler h = Map3::addAttribute(orbit, nameAttr) ; +// +// if(addNextLevelCell) +// { +// AttributeContainer& cellCont = m_attribs[orbit] ; +// AttributeMultiVector* amv = cellCont.addAttribute("nextLevelCell") ; +// m_nextLevelCell[orbit] = amv ; +// for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i)) +// amv->operator[](i) = EMBNULL ; +// } +// +// return AttributeHandler_IHM(this, h.getDataVector()) ; +//} +// +//template +//AttributeHandler_IHM ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr) +//{ +// AttributeHandler h = Map2::getAttribute(orbit, nameAttr) ; +// return AttributeHandler_IHM(this, h.getDataVector()) ; +//} /*************************************************** * MAP TRAVERSAL * @@ -363,66 +363,6 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f, return foreach_dart_of_oriented_volume(d, f) ; } -/************************************************** - * EMBEDDED FUNCTIONS * - **************************************************/ -//void ImplicitHierarchicalMap3::cutEdge(Dart d) -//{ -// Dart dd = phi2(d) ; -// EmbeddedMap3::cutEdge(d); -// -// // -// //mise a jour de l'id d'arrete sur chaque moitie d'arete -// // -// -// // -// //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete -// // -// -//} -// -//void ImplicitHierarchicalMap3::splitFace(Dart d, Dart e) -//{ -// // -// //Verification que les brins precedents ceux que l'on split n'ont pas le meme id -// // -// if(m_edgeId[d] == m_edgeId[Map3::phi_1(d)]) -// { -// unsigned int eId = getNewEdgeId() ; -// -// Dart e = d; -// do -// { -// m_edgeId[e] = eId; //cas ou l'arete n'est pas du tout plonge -// m_edgeId[Map3::phi2(e)] = eId; -// -// e = Map3::alpha2(e); -// } while(e != d); -// } -// -// EmbeddedMap3::splitFace(d,e); -// -// // -// //creation d'un id d'arete sur la nouvelle arete -// // -// -// unsigned int eId = getNewEdgeId() ; -// Dart a =Map3:: phi_1(d); -// -// do -// { -// m_edgeId[a] = eId; -// m_edgeId[Map3::phi2(a)] = eId; -// -// a = Map3::alpha2(a); -// } while(a != Map3::phi_1(d)); -// -//} -// -//void ImplicitHierarchicalMap3::sewVolumes(Dart d, Dart e) -//{ -// -//} /*************************************************** * LEVELS MANAGEMENT * @@ -583,67 +523,67 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d) return r; } -/*************************************************** - * ATTRIBUTE HANDLER * - ***************************************************/ - -template -T& AttributeHandler_IHM::operator[](Dart d) -{ - ImplicitHierarchicalMap3* m = reinterpret_cast(this->m_map) ; - assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; - assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; - - unsigned int orbit = this->getOrbit() ; - unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; - unsigned int index = m->getEmbedding(orbit, d) ; - - if(index == EMBNULL) - { - index = m->embedNewCell(orbit, d) ; - m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ; - } - - AttributeContainer& cont = m->getAttributeContainer(orbit) ; - unsigned int step = 0 ; - while(step < nbSteps) - { - step++ ; - unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ; - if (nextIdx == EMBNULL) - { - nextIdx = m->newCell(orbit) ; - m->copyCell(orbit, nextIdx, index) ; - m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ; - m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ; - cont.refLine(index) ; - } - index = nextIdx ; - } - return this->m_attrib->operator[](index); -} - -template -const T& AttributeHandler_IHM::operator[](Dart d) const -{ - ImplicitHierarchicalMap3* m = reinterpret_cast(this->m_map) ; - assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; - assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; - - unsigned int orbit = this->getOrbit() ; - unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; - unsigned int index = m->getEmbedding(orbit, d) ; - - unsigned int step = 0 ; - while(step < nbSteps) - { - step++ ; - unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ; - if(next != EMBNULL) index = next ; - else break ; - } - return this->m_attrib->operator[](index); -} +///*************************************************** +// * ATTRIBUTE HANDLER * +// ***************************************************/ +// +//template +//T& AttributeHandler_IHM::operator[](Dart d) +//{ +// ImplicitHierarchicalMap3* m = reinterpret_cast(this->m_map) ; +// assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; +// assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; +// +// unsigned int orbit = this->getOrbit() ; +// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; +// unsigned int index = m->getEmbedding(orbit, d) ; +// +// if(index == EMBNULL) +// { +// index = m->embedNewCell(orbit, d) ; +// m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ; +// } +// +// AttributeContainer& cont = m->getAttributeContainer(orbit) ; +// unsigned int step = 0 ; +// while(step < nbSteps) +// { +// step++ ; +// unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ; +// if (nextIdx == EMBNULL) +// { +// nextIdx = m->newCell(orbit) ; +// m->copyCell(orbit, nextIdx, index) ; +// m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ; +// m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ; +// cont.refLine(index) ; +// } +// index = nextIdx ; +// } +// return this->m_attrib->operator[](index); +//} +// +//template +//const T& AttributeHandler_IHM::operator[](Dart d) const +//{ +// ImplicitHierarchicalMap3* m = reinterpret_cast(this->m_map) ; +// assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ; +// assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ; +// +// unsigned int orbit = this->getOrbit() ; +// unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ; +// unsigned int index = m->getEmbedding(orbit, d) ; +// +// unsigned int step = 0 ; +// while(step < nbSteps) +// { +// step++ ; +// unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ; +// if(next != EMBNULL) index = next ; +// else break ; +// } +// return this->m_attrib->operator[](index); +//} } //namespace IHM diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp index f9f75d7a..fa8cebd0 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp @@ -141,7 +141,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position id = map.getNewEdgeId() ; map.setEdgeId(ne2, id, EDGE) ; - position[map.phi2(ne)] = p ; + position[map.phi1(ne)] = p ; dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ; while(dd != ne) @@ -170,6 +170,202 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position map.setCurrentLevel(cur) ; } +template +Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; + assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ; + + unsigned int vLevel = map.volumeLevel(d); + Dart old = map.volumeOldestDart(d); + + unsigned int cur = map.getCurrentLevel(); + map.setCurrentLevel(vLevel); + + + /* + * au niveau du volume courant i + * stockage d'un brin de chaque face de celui-ci + * avec calcul du centroid + */ + + DartMarkerStore mf(map); // Lock a face marker to save one dart per face + DartMarkerStore mv(map); + + typename PFP::VEC3 volCenter; + unsigned count = 0 ; + + //Store faces that are traversed and start with the face of d + std::vector visitedFaces; + visitedFaces.reserve(200); + visitedFaces.push_back(old); + + //Store the edges before the cutEdge + std::vector oldEdges; + oldEdges.reserve(20); + + mf.markOrbit(FACE, old) ; + + for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) + { + Dart e = *face ; + do + { + //add one old edge per vertex to the old edge list + //compute volume centroid + if(!mv.isMarked(e)) + { + mv.markOrbit(VERTEX, e); + volCenter += position[e]; + ++count; + oldEdges.push_back(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(FACE, ee) ; + } + + e = map.phi1(e) ; + } while(e != *face) ; + } + + volCenter /= typename PFP::REAL(count) ; + + /* + * Subdivision + */ + + //Store the darts from quadrangulated faces + std::vector > subdividedfaces; + subdividedfaces.reserve(25); + + //First step : subdivide edges and faces + //creates a i+1 edge level and i+1 face level + for (std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) + { + Dart d = *face; + + //if needed subdivide face + if(!map.faceIsSubdivided(d)) + Algo::IHM::subdivideFace(map, d, position, Algo::IHM::S_QUAD); + + //save a dart from the subdivided face + unsigned int cur = map.getCurrentLevel() ; + + unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee + map.setCurrentLevel(fLevel) ; + + + //le brin est forcement du niveau cur + Dart cf = map.phi1(d); + Dart e = cf; + do + { + subdividedfaces.push_back(std::pair(e,map.phi2(e))); + e = map.phi2(map.phi1(e)); + }while (e != cf); + + map.setCurrentLevel(cur); + } + + map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision + + std::vector newEdges; //save darts from inner edges + newEdges.reserve(50); + + //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; + + Dart f1 = map.phi1(*edge); + + do + { + map.unsewFaces(map.phi1(map.phi1(e))); + + map.unsewFaces(map.phi1(e)); + + e = map.phi2(map.phi_1(e)); + } + while(e != *edge); + + map.closeHole(f1); + + Dart old = map.phi2(map.phi1(e)); + Dart dd = map.phi1(map.phi1(old)) ; + map.splitFace(old,dd) ; + + Dart ne = map.phi1(map.phi1(old)) ; + + map.cutEdge(ne); + position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ???? + newEdges.push_back(ne); + newEdges.push_back(map.phi1(ne)); + + + Dart stop = map.phi2(map.phi1(ne)); + ne = map.phi2(ne); + do + { + dd = map.phi1(map.phi1(map.phi1(ne))); + + //A Verifier !! + map.splitFace(ne, dd) ; + + newEdges.push_back(map.phi1(dd)); + + ne = map.phi2(map.phi_1(ne)); + dd = map.phi1(map.phi1(dd)); + } + while(dd != stop); + } + + //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.phi3(map.phi2(f1)) == map.phi2(f1) && map.phi3(map.phi2(f2)) == 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(std::vector::iterator it = newEdges.begin() ; it != newEdges.end() ; ++it) + { + if(!mne.isMarked(*it)) + { + unsigned int idedge = map.getNewEdgeId(); + map.setEdgeId(*it, idedge, EDGE); + mne.markOrbit(EDGE,*it); + } + } + + map.setCurrentLevel(cur) ; + + return subdividedfaces.begin()->first; +} + template Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) { @@ -643,7 +839,6 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos } - map.setCurrentLevel(cur) ; return subdividedfacesQ.begin()->first; @@ -985,201 +1180,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi } -template -Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) -{ - assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ; - assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ; - - unsigned int vLevel = map.volumeLevel(d); - Dart old = map.volumeOldestDart(d); - - unsigned int cur = map.getCurrentLevel(); - map.setCurrentLevel(vLevel); - - - /* - * au niveau du volume courant i - * stockage d'un brin de chaque face de celui-ci - * avec calcul du centroid - */ - - DartMarkerStore mf(map); // Lock a face marker to save one dart per face - CellMarker mv(map, VERTEX); - - typename PFP::VEC3 volCenter; - unsigned count = 0 ; - - //Store faces that are traversed and start with the face of d - std::vector visitedFaces; - visitedFaces.reserve(20); - visitedFaces.push_back(old); - - //Store the edges before the cutEdge - std::vector oldEdges; - oldEdges.reserve(20); - - mf.markOrbit(FACE, old) ; - - for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) - { - Dart e = *face ; - do - { - //add one old edge per vertex to the old edge list - //compute volume centroid - if(!mv.isMarked(e)) - { - mv.mark(e); - volCenter += position[e]; - ++count; - oldEdges.push_back(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(FACE, ee) ; - } - - e = map.phi1(e) ; - } while(e != *face) ; - } - - volCenter /= typename PFP::REAL(count) ; - - /* - * Subdivision - */ - - //Store the darts from quadrangulated faces - std::vector > subdividedfaces; - subdividedfaces.reserve(25); - - //First step : subdivide edges and faces - //creates a i+1 edge level and i+1 face level - for (std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) - { - Dart d = *face; - - //if needed subdivide face - if(!map.faceIsSubdivided(d)) - Algo::IHM::subdivideFace(map, d, position, Algo::IHM::S_QUAD); - - //save a dart from the subdivided face - unsigned int cur = map.getCurrentLevel() ; - - unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee - map.setCurrentLevel(fLevel) ; - - - //le brin est forcement du niveau cur - Dart cf = map.phi1(d); - Dart e = cf; - do - { - subdividedfaces.push_back(std::pair(e,map.phi2(e))); - e = map.phi2(map.phi1(e)); - }while (e != cf); - - map.setCurrentLevel(cur); - } - - map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision - - std::vector newEdges; //save darts from inner edges - newEdges.reserve(50); - - //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; - - Dart f1 = map.phi1(*edge); - - do - { - map.unsewFaces(map.phi1(map.phi1(e))); - - map.unsewFaces(map.phi1(e)); - - e = map.phi2(map.phi_1(e)); - } - while(e != *edge); - - map.closeHole(f1); - - Dart old = map.phi2(map.phi1(e)); - Dart dd = map.phi1(map.phi1(old)) ; - map.splitFace(old,dd) ; - - Dart ne = map.phi1(map.phi1(old)) ; - - map.cutEdge(ne); - position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ???? - newEdges.push_back(ne); - newEdges.push_back(map.phi1(ne)); - - - Dart stop = map.phi2(map.phi1(ne)); - ne = map.phi2(ne); - do - { - dd = map.phi1(map.phi1(map.phi1(ne))); - - //A Verifier !! - map.splitFace(ne, dd) ; - - newEdges.push_back(map.phi1(dd)); - - ne = map.phi2(map.phi_1(ne)); - dd = map.phi1(map.phi1(dd)); - } - while(dd != stop); - } - - //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.phi3(map.phi2(f1)) == map.phi2(f1) && map.phi3(map.phi2(f2)) == 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(std::vector::iterator it = newEdges.begin() ; it != newEdges.end() ; ++it) - { - if(!mne.isMarked(*it)) - { - unsigned int idedge = map.getNewEdgeId(); - map.setEdgeId(*it, idedge, EDGE); - mne.markOrbit(EDGE,*it); - } - } - - map.setCurrentLevel(cur) ; - - return subdividedfaces.begin()->first; -} /************************************************************************************************ * Simplification * @@ -1214,77 +1215,43 @@ void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, fit = map.phi1(fit) ; } while(fit != d) ; + // boucler sur d avec phi2(phi_1()) et faire des unsewvolumes + // delete le vertex sur d + // si le volume d'a cote n'est pas subdiv + // alors delete le vertex aussi + // recouture du tout - if(degree == 3 && sType == Algo::IHM::S_TRI) - { - - } - else - { - // boucler sur d avec phi2(phi_1()) et faire des unsewvolumes - // delete le vertex sur d - // si le volume d'a cote n'est pas subdiv - // alors delete le vertex aussi - // recouture du tout + Dart d3 = map.phi3(d); - Dart d3 = map.phi3(d); + map.setCurrentLevel(cur + 1) ; - map.setCurrentLevel(cur + 1) ; + Dart centralV = map.phi1(map.phi1(d)); + //Tester si il y a un volume voisin + if(d != d3) + { + //on decoud + Dart it = centralV; - Dart centralV = map.phi1(map.phi1(d)); - //Tester si il y a un volume voisin - if(d != d3) + do { - //on decoud - Dart it = centralV; + map.unsewVolumes(it); + it = map.phi2(map.phi_1(it)); + }while(it != centralV); - do - { - map.unsewVolumes(it); - it = map.phi2(map.phi_1(it)); - }while(it != centralV); - - //Si ce volume voisin n'est pas subdivise - if(!map.volumeIsSubdivided(d3)) - //alors on supprime le sommet en face - map.deleteVertex(map.phi1(map.phi1(d3))); - - } + //Si ce volume voisin n'est pas subdivise + if(!map.volumeIsSubdivided(d3)) + //alors on supprime le sommet en face + map.Map2::deleteVertex(map.phi1(map.phi1(d3))); - //On supprime le sommet sur la face du volume courant - map.deleteVertex(centralV); - - if(d != d3) - map.sewVolumes(d,map.phi1(d3)); - - map.setCurrentLevel(cur) ; } + //On supprime le sommet sur la face du volume courant + map.Map2::deleteVertex(centralV); -// if(degree == 3 && sType == Algo::IHM::S_TRI) -// { -// fit = d ; -// do -// { -// map.setCurrentLevel(cur + 1) ; -// Dart innerEdge = map.phi1(fit) ; -// map.setCurrentLevel(map.getMaxLevel()) ; -// map.mergeFaces(innerEdge) ; -// map.setCurrentLevel(cur) ; -// fit = map.phi1(fit) ; -// } while(fit != d) ; -// } - + if(d != d3) + map.sewVolumes(d,map.phi1(d3)); -// A faire dans coarsenVolume -// fit = d ; -// do -// { -// if(map.edgeCanBeCoarsened(fit)) -// coarsenEdge(map, fit, position) ; -// -// fit = map.phi1(fit) ; -// } while(fit != d) ; + map.setCurrentLevel(cur) ; } template @@ -1331,30 +1298,35 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position /* * Deconnecter toutes les faces interieurs */ - for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) - { - Dart fit = *face; - - do - { - map.setCurrentLevel(cur + 1) ; - - Dart nf = map.phi2(map.phi1(fit)); - if(map.getDartLevel(map.faceOldestDart(nf)) != cur) - map.mergeVolumes(nf); + map.setCurrentLevel(cur + 1) ; + Dart nf = map.phi_1(map.phi2(map.phi1(d))); + map.deleteVertex(nf); + map.setCurrentLevel(cur) ; - map.setCurrentLevel(cur) ; - fit = map.phi1(fit); - }while(fit != *face); - } +// for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) +// { +// Dart fit = *face; +// +// do +// { +// map.setCurrentLevel(cur + 1) ; +// +// Dart nf = map.phi2(map.phi1(fit)); +// if(map.getDartLevel(map.faceOldestDart(nf)) != cur) +// map.mergeVolumes(nf); +// +// map.setCurrentLevel(cur) ; +// fit = map.phi1(fit); +// }while(fit != *face); +// } /* * simplifier les faces */ + //std::vector::iterator face = visitedFaces.begin(); for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) { Dart fit = *face; - if(map.faceCanBeCoarsened(fit)) { Algo::IHM::coarsenFace(map, fit, position, Algo::IHM::S_QUAD); @@ -1366,14 +1338,14 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position */ for(std::vector::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) { - Dart fit = *face ; - do - { - if(map.edgeCanBeCoarsened(fit)) - Algo::IHM::coarsenEdge(map, fit, position) ; + Dart fit = *face ; + do + { + if(map.edgeCanBeCoarsened(fit)) + Algo::IHM::coarsenEdge(map, fit, position) ; - fit = map.phi1(fit) ; - } while(fit != *face) ; + fit = map.phi1(fit) ; + } while(fit != *face) ; } map.setCurrentLevel(cur) ; diff --git a/include/Algo/Modelisation/primitives3d.hpp b/include/Algo/Modelisation/primitives3d.hpp index bf617617..91d4c5bf 100644 --- a/include/Algo/Modelisation/primitives3d.hpp +++ b/include/Algo/Modelisation/primitives3d.hpp @@ -67,8 +67,8 @@ template Dart Primitive3D::HexaGrid1Topo(int nx) { // first cube - Dart d0 = createOrientedHexa(); - m_tableVertDarts.push_back(d0); + Dart d0 = createOrientedHexa(); //return a dart from the base of the cube + m_tableVertDarts.push_back(d0); //push_back darts frome the base of cubes Dart d1 = m_map.template phi<2112>(d0); for (int i=1; i< nx; ++i) @@ -80,7 +80,7 @@ Dart Primitive3D::HexaGrid1Topo(int nx) } // add last vertex (x=nx) - d1 = m_map.phi2(d1); + d1 = m_map.phi2(d1); //TODO can take phi1 instead > same vertex ?? m_tableVertDarts.push_back(d1); return d0; diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp index 0fbd4570..4873e53d 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp @@ -507,6 +507,7 @@ bool ImplicitHierarchicalMap3::faceCanBeCoarsened(Dart d) } std::cout << "subdNeighborhood = " << subdNeighborhood << std::endl; + std::cout << "faceCanBeCoarsened ? " << (subd && !subdNeighborhood && subdOnce) << std::endl; return subd && !subdNeighborhood && subdOnce; } diff --git a/src/Topology/map/embeddedMap3.cpp b/src/Topology/map/embeddedMap3.cpp index 22eaec7c..ce884a68 100644 --- a/src/Topology/map/embeddedMap3.cpp +++ b/src/Topology/map/embeddedMap3.cpp @@ -143,6 +143,7 @@ void EmbeddedMap3::splitFace(Dart d, Dart e) copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3); } } + } void EmbeddedMap3::sewVolumes(Dart d, Dart e) @@ -301,39 +302,6 @@ bool EmbeddedMap3::check() } } -// if (phi2(phi_1(d)) != phi_1(d) && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi2(phi_1(d)))) -// { -// std::cout << "Check: different embeddings on vertex" << std::endl ; -// return false ; -// } -// -// if(phi3(d) != d && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi1(phi3(d)))) -// { -// std::cout << "Check: different embeddings on vertex in the 2 oriented faces" << std::endl ; -// std::cout << "Dart #" << d << std::endl; -// std::cout << "Emb(d) = " << getEmbedding(VERTEX, d) << std::endl; -// std::cout << "Emb(phi32(d)) = " << getEmbedding(VERTEX, phi3(phi2(d))) << std::endl; -// return false ; -// } - - -// if (isOrbitEmbedded(EDGE)) -// { -// if (getEmbedding(EDGE, d) != getEmbedding(EDGE, phi2(d))) -// { -// std::cout << "Check: different embeddings on edge" << std::endl ; -// return false ; -// } -// } -// -// if (isOrbitEmbedded(FACE)) -// { -// if (getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d))) -// { -// std::cout << "Check: different embeddings on face" << std::endl ; -// return false ; -// } -// } } std::cout << "Check: embedding ok" << std::endl ; return true ; diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index af2c8a44..90baa034 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -91,12 +91,14 @@ bool Map3::deleteVertex(Dart d) } } + for(std::vector::iterator it = fstore.begin() ; it != fstore.end() ; ++it) { if(!mergeVolumes(*it)) return false; } + return true; } -- GitLab