diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp index 2f36b67e94accd7beec67d65e0f11f0d04d4bb88..4405f1c7454a7047920538134bbf8a67a2e72a03 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision3.hpp @@ -461,49 +461,49 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 } } - //position[centralDart] = volCenter; + position[centralDart] = volCenter; -// //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; + //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))) + { + std::cout << "boundary" << std::endl; + //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); + } // -// if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2))) -// { -// std::cout << "boundary" << std::endl; -// //id pour toutes les faces interieures -// map.sewVolumes(map.phi2(f1), map.phi2(f2)); -// break; -//// -//// //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); -// } +// //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]); -// } -// } + //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]); + } + } //plonger a la fin de la boucle ???? diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 0c11525fce21df570a19c3c10d7041b4ca4da4da..93ff73cb872097cdcb706c62ddc54ac6bb35575f 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -1154,7 +1154,7 @@ bool MeshTablesSurface::mergeCloseVertices() } d /= double(nbf); - typename PFP::REAL EPSILON = d/10000.0; + typename PFP::REAL epsilon = d/10000.0; // traverse vertices @@ -1176,7 +1176,7 @@ bool MeshTablesSurface::mergeCloseVertices() typename PFP::VEC3 Q = positions[*v]; Q -= P; typename PFP::REAL d2 = Q*Q; - if (d2 < EPSILON*EPSILON) + if (d2 < epsilon*epsilon) { newIndices[*v] = i; *v = 0xffffffff; diff --git a/include/Algo/Modelisation/tetrahedralization.hpp b/include/Algo/Modelisation/tetrahedralization.hpp index e8b81076f1f9681f6418c815c44c2ae61e39a01c..7cb1ab889dd06cb8d7fdc463b3b18990aee321d7 100644 --- a/include/Algo/Modelisation/tetrahedralization.hpp +++ b/include/Algo/Modelisation/tetrahedralization.hpp @@ -22,6 +22,8 @@ * * *******************************************************************************/ +#include "Topology/generic/traversor3.h" + namespace CGoGN { @@ -59,44 +61,20 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d) template bool isTetrahedron(typename PFP::MAP& the_map, Dart d) { - DartMarkerStore mark(the_map); // Lock a marker - - std::vector visitedFaces; // Faces that are traversed - visitedFaces.reserve(64) ; - visitedFaces.push_back(d); - - unsigned int nbFaces = 0; // Count the faces + unsigned int nbFaces = 0; //Test the number of faces end its valency - for(unsigned int i = 0; i < visitedFaces.size(); ++i) + Traversor3WF travWF(the_map, d); + for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next()) { - Dart dc = visitedFaces[i]; - - //if this dart is not marked - if(!mark.isMarked(dc)) - { - //increase the number of faces - nbFaces++; - if(nbFaces > 4) //too much faces - return false; - - //test the valency of this face - if(dc != the_map.phi1(the_map.phi1(the_map.phi1(dc)))) - return false; - - //mark the face and push adjacent faces - Dart d1 = dc; - for(unsigned int i = 0; i <3 ; ++i) - { - mark.mark(d1); - //if phi2 not marked - Dart d2 = the_map.phi2(d1); - if(!mark.isMarked(d2)) - visitedFaces.push_back(d2); - - d1 = the_map.phi1(dc); - } - } + //increase the number of faces + nbFaces++; + if(nbFaces > 4) //too much faces + return false; + + //test the valency of this face + if(the_map.faceDegree(dit) != 3) + return false; } return true; @@ -408,83 +386,83 @@ void swap5To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions) template void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& 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(FACE, 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(VERTEX, 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 != 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::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(FACE, 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(VERTEX, 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 != 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)); +// } } /************************************************************************************************ diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 95b335cd339b8c478a3a8c5ec66911bdc2d29049..89ac687ac4542b1783fa3546111a82be17546a0a 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -115,6 +115,7 @@ inline void GenericMap::deleteDart(Dart d) for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) { unsigned int index = (*m_mrDarts[i])[d.index] ; + std::cout << "deleteDart index = " << index << std::endl << std::endl; if(isDartValid(index)) deleteDartLine(index) ; } diff --git a/include/Topology/map/embeddedMap2.h b/include/Topology/map/embeddedMap2.h index ec3426bee99f42cf177f29506e3b8e9393e630db..ab0948153d87beedd7da7142097e4c3819de46b5 100644 --- a/include/Topology/map/embeddedMap2.h +++ b/include/Topology/map/embeddedMap2.h @@ -85,6 +85,10 @@ public: */ virtual bool flipBackEdge(Dart d) ; + /* + * + */ + virtual void swapEdges(Dart d, Dart e); // /** // * The attributes attached to the vertex of dart d are kept on the resulting vertex // * The attributes attached to the face of dart d are overwritten on the face of dart e diff --git a/include/Topology/map/map2.h b/include/Topology/map/map2.h index dbee21996fc63b9c722b8e8eb95cdaa2e4e88c06..ceba3d713bbdec97c2a065b4440045cd9f2826d5 100644 --- a/include/Topology/map/map2.h +++ b/include/Topology/map/map2.h @@ -208,6 +208,12 @@ public: */ virtual bool flipBackEdge(Dart d); + //! + /*! + * + */ + void swapEdges(Dart d, Dart e); + // //! Insert an edge after a dart in the vertex orbit // /*! \pre Dart d and e MUST be different and belong to distinct face // * \pre Dart e must be phi2-linked with its phi_1 dart diff --git a/include/Topology/map/map3.h b/include/Topology/map/map3.h index e1cd7af8f4a541eda8debc9b37c791b2174193c3..da825e0aac630e0d2e4749d5637d19d6eebe9a05 100644 --- a/include/Topology/map/map3.h +++ b/include/Topology/map/map3.h @@ -238,6 +238,12 @@ public: */ bool isBoundaryVertex(Dart d) ; + //! Find the dart of vertex that belong to the boundary + /*! return NIL if the vertex is not on the boundary + * @param d a dart + */ + Dart findBoundaryFaceOfVertex(Dart d) ; + //! Test if dart d and e belong to the same oriented edge /*! @param d a dart * @param e a dart @@ -255,14 +261,14 @@ public: */ unsigned int edgeDegree(Dart d) ; - /** - * tell if the edge of d is on the boundary of the map + //! Tell if the edge of d is on the boundary of the map + /*! @param d a dart */ bool isBoundaryEdge(Dart d) ; - /** - * find the dart of edge that belong to the boundary - * return NIL if the edge is not on the boundary + //! Find the dart of edge that belong to the boundary + /*! return NIL if the edge is not on the boundary + * @param d a dart */ Dart findBoundaryFaceOfEdge(Dart d) ; diff --git a/include/Utils/text3d.h b/include/Utils/text3d.h index a59abbedd4a03671c5c98a4e58dc28394a4919b4..210a2786d071c126f4409aa7db9a319f50d027d1 100644 --- a/include/Utils/text3d.h +++ b/include/Utils/text3d.h @@ -103,7 +103,7 @@ public: void clear(); /** - * once all string are stored, we must send it to the gracphic card + * once all string are stored, we must send it to the graphic card */ void sendToVBO(); diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp index d4a28e16ca66b32ad393ee053d3e43739daa22df..257408ec498fdb5dadb8ff87e59c15cbb3f89883 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm3.cpp @@ -570,7 +570,6 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d) if(m_dartLevel[old] < m_dartLevel[oldest]) oldest = old ; - // // add all face neighbours to the table // diff --git a/src/Topology/map/embeddedMap2.cpp b/src/Topology/map/embeddedMap2.cpp index b11e6958fe77d9ebbc0772ee144d5c4027ca07db..b46b7ac55fa1bc00f42a4d8ca30e75cf26f11852 100644 --- a/src/Topology/map/embeddedMap2.cpp +++ b/src/Topology/map/embeddedMap2.cpp @@ -208,6 +208,29 @@ bool EmbeddedMap2::flipBackEdge(Dart d) return false ; } +void EmbeddedMap2::swapEdges(Dart d, Dart e) +{ + Dart d2 = phi2(d); + Dart e2 = phi2(e); + Map2::swapEdges(d,e); + + if(isOrbitEmbedded(VERTEX)) + { + copyDartEmbedding(VERTEX, d, phi2(phi_1(d))); + copyDartEmbedding(VERTEX, e, phi2(phi_1(e))); + copyDartEmbedding(VERTEX, d2, phi2(phi_1(d2))); + copyDartEmbedding(VERTEX, e2, phi2(phi_1(e2))); + } + + if(isOrbitEmbedded(EDGE)) + { + + } + + if(isOrbitEmbedded(VOLUME)) + embedNewCell(VOLUME, d); +} + //void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) //{ // Map2::insertEdgeInVertex(d, e); diff --git a/src/Topology/map/map2.cpp b/src/Topology/map/map2.cpp index 84794e44327fb951ef9efe09c19517dbe8516a4b..07dc57d4f86076cbf16298459d6b3fb2a19ac01a 100644 --- a/src/Topology/map/map2.cpp +++ b/src/Topology/map/map2.cpp @@ -325,6 +325,20 @@ bool Map2::flipBackEdge(Dart d) return false ; // cannot flip a border edge } +void Map2::swapEdges(Dart d, Dart e) +{ + assert(!Map2::isBoundaryEdge(d) && !Map2::isBoundaryEdge(e)); + + Dart d2 = phi2(d); + Dart e2 = phi2(e); + + phi2unsew(d); + phi2unsew(e) ; + + phi2sew(d, e); + //phi2sew(d2, e2); +} + //void Map2::insertEdgeInVertex(Dart d, Dart e) //{ // assert(!sameVertex(d,e) && phi2(e) == phi_1(e)); @@ -538,10 +552,10 @@ void Map2::splitSurface(std::vector& vd, bool firstSideClosed, bool second unsewFaces(*it) ; if(firstSideClosed) - fillHole(e) ; + Map2::fillHole(e) ; if(secondSideClosed) - fillHole(e2) ; + Map2::fillHole(e2) ; } /*! @name Topological Queries diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index efeab657aa0d4d96b04b14f298e1e319a2026103..cd7f71fb1d52bd51f268c7477bcc4b80f7e518df 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -636,6 +636,39 @@ bool Map3::isBoundaryVertex(Dart d) return false ; } +Dart Map3::findBoundaryFaceOfVertex(Dart d) +{ + DartMarkerStore mv(*this); // Lock a marker + + std::vector darts; // Darts that are traversed + darts.reserve(256); + darts.push_back(d); // Start with the dart d + mv.mark(d); + + for(unsigned int i = 0; i < darts.size(); ++i) + { + if(isBoundaryMarked(darts[i])) + return darts[i]; + + //add phi21 and phi23 successor if they are not marked yet + Dart d2 = phi2(darts[i]); + Dart d21 = phi1(d2); // turn in volume + Dart d23 = phi3(d2); // change volume + + if(!mv.isMarked(d21)) + { + darts.push_back(d21); + mv.mark(d21); + } + if(!mv.isMarked(d23)) + { + darts.push_back(d23); + mv.mark(d23); + } + } + return NIL ; +} + bool Map3::sameOrientedEdge(Dart d, Dart e) { Dart it = d;