diff --git a/include/Algo/Modelisation/subdivision3.hpp b/include/Algo/Modelisation/subdivision3.hpp index 15bd91fb9af97b4a29283364103c833c1d57ba49..c5a5426c9800276f1ce2b2874f7886174b420a00 100644 --- a/include/Algo/Modelisation/subdivision3.hpp +++ b/include/Algo/Modelisation/subdivision3.hpp @@ -730,6 +730,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit } } +/* TraversorV tVg(map); for(Dart dit = tVg.begin() ; dit != tVg.end() ; dit = tVg.next()) { @@ -743,7 +744,8 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit Dart vit = db ; do { - newP += position[map.phi_1(map.phi2(map.phi1(vit)))] ; + //newP += position[map.phi_1(map.phi2(map.phi1(vit)))] ; + newP += position[map.phi2(vit)]; ++val ; vit = map.phi2(map.phi_1(vit)) ; } while(vit != db) ; @@ -755,7 +757,9 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit position[db] = newP ; } } +*/ +/* // // edge-removal on all old boundary edges // @@ -767,10 +771,13 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit m.unmarkOrbit(dit); Dart d = map.phi2(map.phi3(map.findBoundaryFaceOfEdge(dit))); Volume::Modelisation::Tetrahedralization::swapGen3To2(map, d); - } } +*/ + + + // TraversorV tVg(map,selected); // for(Dart dit = tVg.begin() ; dit != tVg.end() ; dit = tVg.next()) // { diff --git a/include/Algo/Multiresolution/Map3MR/Filters/lerp.h b/include/Algo/Multiresolution/Map3MR/Filters/lerp.h index c863d68d1054cc94db5f1b61e54b7c4ec1623716..de8a156d208dd5f418718cd0af21b1b02b5e8f1c 100644 --- a/include/Algo/Multiresolution/Map3MR/Filters/lerp.h +++ b/include/Algo/Multiresolution/Map3MR/Filters/lerp.h @@ -564,6 +564,36 @@ public: } } ; + +//template +//bool isDartOfFaceAtLevel(typename PFP::MAP map, Dart d, unsigned int level) +//{ +// unsigned int cur = map.getCurrentLevel(); +// map.setCurrentLevel(level); +//// TraversorDartsOfOrbit to(map,d); +//// for (Dart dit = to.begin(); dit != to.end(); dit = to.next()) +//// { +//// if(d == dit) +//// { +//// map.setCurrentLevel(cur); +//// return true; +//// } +//// } +// Dart dit = d; +// do +// { +// if(d == dit) +// { +// map.setCurrentLevel(cur); +// return true; +// } +// dit = map.phi1(dit); +// }while(dit != d); + +// map.setCurrentLevel(cur); +// return false; +//} + template class LerpSqrt3VolumeSynthesisFilter : public Algo::MR::Filter { @@ -575,21 +605,115 @@ public: LerpSqrt3VolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) {} + Dart findDartOfCentralVertex(Dart d) + { + Dart olddart = NIL; + TraversorDartsOfOrbit to(m_map,d); + for(Dart dit = to.begin() ; (olddart == NIL) && (dit != to.end()) ; dit = to.next()) + { + m_map.incCurrentLevel(); + unsigned int emb = m_map.template getEmbedding(dit); + m_map.decCurrentLevel(); + if(!m_map.isBoundaryMarked3(m_map.phi3(dit))) + { + if(emb == EMBNULL) + olddart = dit; + } + } + + std::cout << "findDartOfCentralVertex = " << olddart << std::endl; + return olddart; + } + void operator() () { +// m_map.incCurrentLevel() ; + +// unsigned int cur = m_map.getCurrentLevel(); + +// TraversorV trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { +// if(!m_map.isBoundaryVertex(d)) +// { +// std::cout << "sommet" << std::endl; + +// //search an old dart +// Dart olddart = NIL; +// TraversorDartsOfOrbit to(m_map,d); +// for(Dart dit = to.begin() ; (olddart == NIL) && (dit != to.end()) ; dit = to.next()) +// { +// if(m_map.getDartLevel(dit) == (cur - 1)) && isDartOfFaceAtLevel(m_map,dit, cur-1)) +// { +// olddart = dit; +// } +// } + +// if(olddart != NIL) +// { +// std::cout << "olddart = " << olddart << std::endl; + +// m_map.decCurrentLevel(); +// typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, olddart, m_position); +// m_map.incCurrentLevel() ; +// m_position[d] = p; +// } +// } +// } +// m_map.decCurrentLevel() ; + + + + + +// TraversorW trav(m_map) ; +// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) +// { + +// typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d , m_position); + +// m_map.incCurrentLevel() ; + +// Dart midV = m_map.phi_1(m_map.phi2(d)); +// m_position[midV] = p; +// //m_position[d] = p; + +// m_map.decCurrentLevel() ; +// } + + TraversorW trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) { - typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + Dart dit = d; - m_map.incCurrentLevel() ; + if(m_map.isBoundaryVolume(d)) + { + dit = findDartOfCentralVertex(d); + } + + typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); - Dart midV = m_map.phi_1(m_map.phi2(d)); - //Dart midV = m_map.phi_1(d); - m_position[midV] = p; + //Dart midV = m_map.phi1(dit); + m_map.incCurrentLevel() ; + m_position[dit] = p; m_map.decCurrentLevel() ; } + + TraversorF tf(m_map); + for(Dart dit = tf.begin() ; dit != tf.end() ; dit = tf.next()) + { + if(m_map.isBoundaryFace(dit)) + { + typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid(m_map, dit, m_position); + m_map.incCurrentLevel(); + Dart midF = m_map.phi_1(dit); + m_position[midF] = p; + m_map.decCurrentLevel(); + } + } + } } ; diff --git a/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.h b/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.h index 5ac948f42b6c73a69ce59a28231ebd4b6a3d2596..6e09541837749ee2c372c5172f0dbf84633fade8 100644 --- a/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.h +++ b/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.h @@ -89,6 +89,10 @@ public: void swapEdges(Dart d, Dart e); + + Dart swap2To3(Dart d); + void swapGen3To2(Dart d); + /*! @name Level creation * *************************************************************************/ @@ -110,6 +114,8 @@ public: void addNewLevelSqrt3(bool embedNewVertices = false); + void addNewLevelSqrt3(bool embedNewVertices, VertexAttribute position); + //! /* */ diff --git a/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.hpp b/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.hpp index cc28bb87d1021874b178e7a3ec948e9b80142f2a..f6cc24f6697266e300679efc5f29fd9908fd8e17 100644 --- a/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/Map3MR/map3MR_PrimalRegular.hpp @@ -130,12 +130,241 @@ void Map3MR::splitSurfaceInVolume(std::vector& vd, bool firstSideClos } } +template +Dart Map3MR::swap2To3(Dart d) +{ + std::vector edges; + + Dart d2_1 = m_map.phi_1(m_map.phi2(d)); + m_map.mergeVolumes(d,false); + + // + // Cut the 1st tetrahedron + // + Dart stop = d2_1; + Dart dit = stop; + do + { + edges.push_back(dit); + dit = m_map.phi1(m_map.phi2(m_map.phi1(dit))); + } + while(dit != stop); + + m_map.splitVolume(edges); + m_map.splitFace(m_map.alpha2(edges[0]), m_map.alpha2(edges[2])); + + // + // Cut the 2nd tetrahedron + // + edges.clear(); + stop = m_map.phi1(m_map.phi2(d2_1)); + dit = stop; + do + { + edges.push_back(dit); + dit = m_map.phi1(m_map.phi2(m_map.phi1(dit))); + } + while(dit != stop); + m_map.splitVolumeWithFace(edges,m_map.phi_1(m_map.phi3(d))); + //m_map.splitVolume(edges); + + return m_map.phi1(d2_1); +} + + +template +void Map3MR::swapGen3To2(Dart d) +{ + unsigned int n = m_map.edgeDegree(d); + + if(n >= 4) + { + Dart dit = d; + if(m_map.isBoundaryEdge(dit)) + { + for(unsigned int i = 0 ; i < n - 2 ; ++i) + { + dit = m_map.phi2(swap2To3(dit)); + } + + //Volume::Modelisation::Tetrahedralization::swap2To2(m_map, dit); + } + else + { + for(unsigned int i = 0 ; i < n - 4 ; ++i) + { + dit = m_map.phi2(swap2To3(dit)); + } + //Volume::Modelisation::Tetrahedralization::swap4To4(m_map, m_map.alpha2(dit)); + } + } + else if (n == 3) + { + Dart dres = swap2To3(d); + //Volume::Modelisation::Tetrahedralization::swap2To2(m_map, m_map.phi2(dres)); + } + else // si (n == 2) + { + //Volume::Modelisation::Tetrahedralization::swap2To2(m_map, d); + } +} + /************************************************************************ * Level creation * ************************************************************************/ +inline double sqrt3_K(unsigned int n) +{ + switch(n) + { + case 1: return 0.333333 ; + case 2: return 0.555556 ; + case 3: return 0.5 ; + case 4: return 0.444444 ; + case 5: return 0.410109 ; + case 6: return 0.388889 ; + case 7: return 0.375168 ; + case 8: return 0.365877 ; + case 9: return 0.359328 ; + case 10: return 0.354554 ; + case 11: return 0.350972 ; + case 12: return 0.348219 ; + default: + double t = cos((2.0*M_PI)/double(n)) ; + return (4.0 - t) / 9.0 ; + } +} + +template +void Map3MR::addNewLevelSqrt3(bool embedNewVertices, VertexAttribute position) +{ + m_map.pushLevel(); + + m_map.addLevelBack(); + m_map.duplicateDarts(m_map.getMaxLevel()); + m_map.setCurrentLevel(m_map.getMaxLevel()); + + DartMarkerStore m(m_map); + + DartMarkerStore newBoundaryV(m_map); + + // + // 1-4 flip of all tetrahedra + // + TraversorW tW(m_map); + for(Dart dit = tW.begin() ; dit != tW.end() ; dit = tW.next()) + { + Traversor3WF tWF(m_map, dit); + for(Dart ditWF = tWF.begin() ; ditWF != tWF.end() ; ditWF = tWF.next()) + { + if(!m_map.isBoundaryFace(ditWF) && !m.isMarked(ditWF)) + m.markOrbit(ditWF); + } + + typename PFP::VEC3 volCenter(0.0); + volCenter += position[dit]; + volCenter += position[m_map.phi1(dit)]; + volCenter += position[m_map.phi_1(dit)]; + volCenter += position[m_map.phi_1(m_map.phi2(dit))]; + volCenter /= 4; + + Dart dres = Volume::Modelisation::Tetrahedralization::flip1To4(m_map, dit); + position[dres] = volCenter; + } + + + // + // 2-3 swap of all old interior faces + // + //TraversorF tF(m_map); + for(Dart dit = m_map.begin() ; dit != m_map.end() ; m_map.next(dit)) + { + if(m.isMarked(dit)) + { + m.unmarkOrbit(dit); + swap2To3(dit); + } + } + + // + // 1-3 flip of all boundary tetrahedra + // + TraversorW tWb(m_map); + for(Dart dit = tWb.begin() ; dit != tWb.end() ; dit = tWb.next()) + { + if(m_map.isBoundaryVolume(dit)) + { + Traversor3WE tWE(m_map, dit); + for(Dart ditWE = tWE.begin() ; ditWE != tWE.end() ; ditWE = tWE.next()) + { + if(m_map.isBoundaryEdge(ditWE) && !m.isMarked(ditWE)) + m.markOrbit(ditWE); + } + + typename PFP::VEC3 faceCenter(0.0); + faceCenter += position[dit]; + faceCenter += position[m_map.phi1(dit)]; + faceCenter += position[m_map.phi_1(dit)]; + faceCenter /= 3; + + Dart dres = Volume::Modelisation::Tetrahedralization::flip1To3(m_map, dit); + position[dres] = faceCenter; + + newBoundaryV.markOrbit(dres); + } + } + +/* + TraversorV tVg(m_map); + for(Dart dit = tVg.begin() ; dit != tVg.end() ; dit = tVg.next()) + { + if(m_map.isBoundaryVertex(dit) && !newBoundaryV.isMarked(dit)) + { + Dart db = m_map.findBoundaryFaceOfVertex(dit); + + typename PFP::VEC3 P = position[db] ; + typename PFP::VEC3 newP(0) ; + unsigned int val = 0 ; + Dart vit = db ; + do + { + newP += position[m_map.phi_1(m_map.phi2(m_map.phi1(vit)))] ; + ++val ; + vit = m_map.phi2(m_map.phi_1(vit)) ; + } while(vit != db) ; + typename PFP::REAL K = sqrt3_K(val) ; + newP *= typename PFP::REAL(3) ; + newP -= typename PFP::REAL(val) * P ; + newP *= K / typename PFP::REAL(2 * val) ; + newP += (typename PFP::REAL(1) - K) * P ; + position[db] = newP ; + } + } +*/ + + // + // edge-removal on all old boundary edges + // + TraversorE tE(m_map); + for(Dart dit = tE.begin() ; dit != tE.end() ; dit = tE.next()) + { + if(m.isMarked(dit)) + { + m.unmarkOrbit(dit); + Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit))); + swapGen3To2(d); + + } + } + + m_map.setCurrentLevel(m_map.getMaxLevel()); + m_map.popLevel() ; +} + + template void Map3MR::addNewLevelSqrt3(bool embedNewVertices) { + /* m_map.pushLevel(); m_map.addLevelBack(); @@ -153,27 +382,27 @@ void Map3MR::addNewLevelSqrt3(bool embedNewVertices) Traversor3WF tWF(m_map, dit); for(Dart ditWF = tWF.begin() ; ditWF != tWF.end() ; ditWF = tWF.next()) { - if(!m_map.isBoundaryFace(ditWF)) + if(!m_map.isBoundaryFace(ditWF) && !m.isMarked(ditWF)) m.markOrbit(ditWF); } Algo::Volume::Modelisation::Tetrahedralization::flip1To4(m_map, dit); } - // - // 2-3 swap of all old interior faces - // - TraversorF tF(m_map); - for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next()) - { - if(m.isMarked(dit)) - { - m.unmarkOrbit(dit); - Algo::Volume::Modelisation::Tetrahedralization::swap2To3(m_map, dit); - } - } + // + // 2-3 swap of all old interior faces + // + //TraversorF tF(m_map); + for(Dart dit = m_map.begin() ; dit != m_map.end() ; m_map.next(dit)) + { + if(m.isMarked(dit)) + { + m.unmarkOrbit(dit); + std::cout << "dit = " << dit << std::endl; + swap2To3(dit); + } + } -/* // // 1-3 flip of all boundary tetrahedra // @@ -193,6 +422,7 @@ void Map3MR::addNewLevelSqrt3(bool embedNewVertices) } } + // // edge-removal on all old boundary edges // @@ -203,14 +433,15 @@ void Map3MR::addNewLevelSqrt3(bool embedNewVertices) { m.unmarkOrbit(dit); Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit))); - Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2(m_map, d); - + //Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2(m_map, d); + swapGen3To2(d); } } -*/ + m_map.setCurrentLevel(m_map.getMaxLevel()); m_map.popLevel() ; + */ } template @@ -356,7 +587,7 @@ void Map3MR::addNewLevelTetraOcta() } m_map.setCurrentLevel(m_map.getMaxLevel() - 1) ; } - } + } m_map.popLevel() ; } diff --git a/include/Topology/map/embeddedMap2.h b/include/Topology/map/embeddedMap2.h index 250be3c587f8c386694b2e971fc470b0138a7aa0..1643c6e8d69811c1f4df345dffb307a9f042110a 100644 --- a/include/Topology/map/embeddedMap2.h +++ b/include/Topology/map/embeddedMap2.h @@ -141,7 +141,7 @@ public: * The attributes attached to the vertices of the face of d are kept on the resulting vertices * The attributes attached to the edges of the face of d are kept on the resulting edges */ - virtual bool mergeVolumes(Dart d, Dart e) ; + virtual bool mergeVolumes(Dart d, Dart e, bool deleteFace = true) ; /** * diff --git a/include/Topology/map/embeddedMap3.h b/include/Topology/map/embeddedMap3.h index 1de11aa07783329ab12db55465ea720a6e5f92ab..31dbd442306e639747f21d0ebb23490f9d7b900b 100644 --- a/include/Topology/map/embeddedMap3.h +++ b/include/Topology/map/embeddedMap3.h @@ -112,13 +112,17 @@ public: //! /*! */ - virtual bool mergeVolumes(Dart d); + virtual bool mergeVolumes(Dart d, bool deleteFace = true); //! /*! */ virtual void splitVolume(std::vector& vd); + //! + virtual void splitVolumeWithFace(std::vector& vd, Dart d); + + //! /*! */ diff --git a/include/Topology/map/map2.h b/include/Topology/map/map2.h index 166e9ac8de2915669c11abf3e325a30afc9ac9bb..d3cd88b8a85799f978389a7e3987a4013503ad5a 100644 --- a/include/Topology/map/map2.h +++ b/include/Topology/map/map2.h @@ -301,7 +301,7 @@ public: * @param e a dart of the second face * @return true if the merge has been executed, false otherwise */ - virtual bool mergeVolumes(Dart d, Dart e); + virtual bool mergeVolumes(Dart d, Dart e, bool deleteFace = true); //! Split a surface into two disconnected surfaces along a edge path /*! @param vd a vector of darts diff --git a/include/Topology/map/map3.h b/include/Topology/map/map3.h index bbca4f766772adef0f0308df16fb8e2f7a20810d..40ae1c808bd31beff4f45c21eb2981759f84b2c2 100644 --- a/include/Topology/map/map3.h +++ b/include/Topology/map/map3.h @@ -267,7 +267,7 @@ public: //! Merge two volumes along their common oriented face /*! @param d a dart of common face */ - virtual bool mergeVolumes(Dart d); + virtual bool mergeVolumes(Dart d, bool deleteFace = true); virtual bool mergeVolumes(Dart /*d*/, Dart /*e*/) { assert("use mergeVolumes(d,e) only in dimension 2");return false;} @@ -277,6 +277,11 @@ public: */ virtual void splitVolume(std::vector& vd); + + //! Split a volume into two volumes along a edge path and add the given face between + virtual void splitVolumeWithFace(std::vector& vd, Dart d); + + //! Collapse a volume (that is deleted) possibly merging its vertices /*! \warning * @param d a dart in the deleted volume diff --git a/include/Utils/textures.h b/include/Utils/textures.h index a9c4655490485308f1953ae5cecfce448f2a1ff6..1330f5ce587f8b1a53cbf426d41860097298f2e9 100644 --- a/include/Utils/textures.h +++ b/include/Utils/textures.h @@ -236,13 +236,11 @@ public: */ bool load(const unsigned char *ptr, unsigned int w, unsigned int h, unsigned int bpp); -#ifdef WITH_QT /// load from file bool load(const std::string& filename); /// load from file void save(const std::string& filename); -#endif /** * crop image diff --git a/include/Utils/textures.hpp b/include/Utils/textures.hpp index e286b184e3bf5b60c048b77e7ad06727b62dfca9..0b975ae74a42ba4bc1c468419a59eece7105468e 100644 --- a/include/Utils/textures.hpp +++ b/include/Utils/textures.hpp @@ -347,13 +347,13 @@ bool Image::load(const std::string& filename) this->m_size[1] = ilGetInteger(IL_IMAGE_HEIGHT); this->computeSub(); - this->m_data_ptr = new TYPE[ptr->width()*ptr->height()]; + this->m_data_ptr = new TYPE[this->m_size[0]*this->m_size[1]]; unsigned char* ptr = reinterpret_cast(this->m_data_ptr); for (int i=this->m_size[1]-1; i>=0; --i) { ilCopyPixels(0, i, 0, this->m_size[0],1, 1, IL_RGB, IL_UNSIGNED_BYTE, ptr); - ptr += 3*w; + ptr += 3*this->m_size[0]; } ilDeleteImage(imgName); diff --git a/src/Topology/map/embeddedMap2.cpp b/src/Topology/map/embeddedMap2.cpp index b0b6a568f0e9fe0641293c8c807efd12f6b945bc..37e7e1977251ca8a5fcee342a48075975fd674cc 100644 --- a/src/Topology/map/embeddedMap2.cpp +++ b/src/Topology/map/embeddedMap2.cpp @@ -518,7 +518,7 @@ bool EmbeddedMap2::mergeFaces(Dart d) return false ; } -bool EmbeddedMap2::mergeVolumes(Dart d, Dart e) +bool EmbeddedMap2::mergeVolumes(Dart d, Dart e, bool deleteFace) { std::vector darts ; std::vector vEmb ; @@ -543,7 +543,7 @@ bool EmbeddedMap2::mergeVolumes(Dart d, Dart e) fit = phi1(fit) ; } while (fit != d) ; - if(Map2::mergeVolumes(d, e)) + if(Map2::mergeVolumes(d, e, deleteFace)) { for(unsigned int i = 0; i < darts.size(); ++i) { diff --git a/src/Topology/map/embeddedMap3.cpp b/src/Topology/map/embeddedMap3.cpp index beba5be3afca3899e35d09482d9e68036135486b..f932ba8494dd3f1cdca7868dcfbf52e634bbe9bd 100644 --- a/src/Topology/map/embeddedMap3.cpp +++ b/src/Topology/map/embeddedMap3.cpp @@ -426,11 +426,11 @@ void EmbeddedMap3::unsewVolumes(Dart d, bool withBoundary) } } -bool EmbeddedMap3::mergeVolumes(Dart d) +bool EmbeddedMap3::mergeVolumes(Dart d, bool deleteFace) { Dart d2 = phi2(d); - if(Map3::mergeVolumes(d)) + if(Map3::mergeVolumes(d, deleteFace)) { if (isOrbitEmbedded()) { @@ -491,6 +491,57 @@ void EmbeddedMap3::splitVolume(std::vector& vd) } } +//! Split a volume into two volumes along a edge path and add the given face between +void EmbeddedMap3::splitVolumeWithFace(std::vector& vd, Dart d) +{ + Map3::splitVolumeWithFace(vd,d); + + // follow the edge path a second time to embed the vertex, edge and volume orbits + for(std::vector::iterator it = vd.begin() ; it != vd.end() ; ++it) + { + Dart dit = *it; + Dart dit23 = phi3(phi2(dit)); + + // embed the vertex embedded from the origin volume to the new darts + if(isOrbitEmbedded()) + { + copyDartEmbedding(dit23, dit); + copyDartEmbedding(phi2(dit), phi1(dit)); + } + + // embed the edge embedded from the origin volume to the new darts + if(isOrbitEmbedded()) + { + setOrbitEmbeddingOnNewCell(dit23) ; + copyCell(dit23, dit) ; + + copyDartEmbedding(phi2(dit), dit); + } + + // embed the edge embedded from the origin volume to the new darts + if(isOrbitEmbedded()) + { + unsigned int eEmb = getEmbedding(dit) ; + setDartEmbedding(dit23, eEmb); + setDartEmbedding(phi2(dit), eEmb); + } + + // embed the volume embedded from the origin volume to the new darts + if(isOrbitEmbedded()) + { + copyDartEmbedding(phi2(dit), dit); + } + } + + if(isOrbitEmbedded()) + { + Dart v = vd.front() ; + Dart v23 = phi3(phi2(v)); + setOrbitEmbeddingOnNewCell(v23) ; + copyCell(v23, v) ; + } +} + Dart EmbeddedMap3::collapseVolume(Dart d, bool delDegenerateVolumes) { unsigned int vEmb = getEmbedding(d) ; diff --git a/src/Topology/map/map2.cpp b/src/Topology/map/map2.cpp index b5a7a6e4c6592aa423301007a2a89ac917d04acc..b80f8e923491397c3c55a244b3d382ea320194bd 100644 --- a/src/Topology/map/map2.cpp +++ b/src/Topology/map/map2.cpp @@ -521,7 +521,7 @@ void Map2::insertTrianglePair(Dart d, Dart v1, Dart v2) phi2sew(phi1(e), vv2) ; } -bool Map2::mergeVolumes(Dart d, Dart e) +bool Map2::mergeVolumes(Dart d, Dart e, bool deleteFace) { assert(!isBoundaryMarked2(d) && !isBoundaryMarked2(e)) ; @@ -564,8 +564,12 @@ bool Map2::mergeVolumes(Dart d, Dart e) phi2unsew(e2); phi2sew(d2, e2); // Link the two adjacent faces together } - Map1::deleteCycle(d); // Delete the two alone faces - Map1::deleteCycle(e); + + if(deleteFace) + { + Map1::deleteCycle(d); // Delete the two alone faces + Map1::deleteCycle(e); + } return true ; } diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index b1ae47b99ae010638ecd0c6c20bfd6833bec8f23..7b1887a4ee03ccfb0237259f225a1cc2e5ddfd35 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -755,11 +755,11 @@ void Map3::unsewVolumes(Dart d, bool withBoundary) } while(fitB1 != b1) ; } -bool Map3::mergeVolumes(Dart d) +bool Map3::mergeVolumes(Dart d, bool deleteFace) { if(!Map3::isBoundaryFace(d)) { - Map2::mergeVolumes(d, phi3(d)); // merge the two volumes along common face + Map2::mergeVolumes(d, phi3(d), deleteFace); // merge the two volumes along common face return true ; } return false ; @@ -778,6 +778,26 @@ void Map3::splitVolume(std::vector& vd) Map3::sewVolumes(phi2(e), phi2(e2), false); } +void Map3::splitVolumeWithFace(std::vector& vd, Dart d) +{ + assert(vd.size() == faceDegree(d)); + + // deconnect edges around the path + // sew the given face into the paths + Dart dit = d; + for(std::vector::iterator it = vd.begin() ; it != vd.end() ; ++it) + { + Dart it2 = phi2(*it); + unsewFaces(*it, false) ; + + sewFaces(*it,dit,false); + sewFaces(it2, phi3(dit),false); + + dit = phi_1(dit); + + } +} + Dart Map3::collapseVolume(Dart d, bool delDegenerateVolumes) { Dart resV = NIL; diff --git a/src/Utils/Shaders/shaderTextureMask.cpp b/src/Utils/Shaders/shaderTextureMask.cpp index 8b9583ae93386950479e843e4a7a200b6c3f38e6..2c20cd898725118e3516dbfc47be83b1092cf048 100644 --- a/src/Utils/Shaders/shaderTextureMask.cpp +++ b/src/Utils/Shaders/shaderTextureMask.cpp @@ -21,7 +21,7 @@ * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ -#ifdef WITH_QT +//#ifdef WITH_QT #include "Utils/Shaders/shaderTextureMask.h" @@ -35,32 +35,6 @@ namespace Utils #include "shaderTextureMask.vert" #include "shaderTextureMask.frag" -//std::string ShaderTextureMask::vertexShaderText = -// "ATTRIBUTE vec3 VertexPosition;\n" -// "ATTRIBUTE vec2 VertexTexCoord;\n" -// "uniform mat4 ModelViewProjectionMatrix;\n" -// "VARYING_VERT vec2 texCoord;\n" -// "INVARIANT_POS;\n" -// "void main ()\n" -// "{\n" -// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n" -// " texCoord = VertexTexCoord;\n" -// "}"; -// -// -//std::string ShaderTextureMask::fragmentShaderText = -// "PRECISON;\n" -// "VARYING_FRAG vec2 texCoord;\n" -// "uniform sampler2D textureUnit;\n" -// "uniform sampler2D textureUnitMask;\n" -// "FRAG_OUT_DEF;\n" -// "void main()\n" -// "{\n" -// " float m = texture2D(textureUnitMask,texCoord).r;\n" -// " if (m < 0.5)" -// " discard;" -// " gl_FragColor=texture2D(textureUnit,texCoord)*m;\n" -// "}"; ShaderTextureMask::ShaderTextureMask() @@ -137,6 +111,6 @@ void ShaderTextureMask::restoreUniformsAttribs() } // namespace CGoGN -#else -#pragma message(__FILE__ " not compiled because of mising Qt") -#endif +//#else +//#pragma message(__FILE__ " not compiled because of mising Qt") +//#endif