diff --git a/include/Algo/Filtering/tools.h b/include/Algo/Filtering/tools.h index 713b505b899f4cfdc65908c3223bb6941c6394a2..f93c9981f77f9c7be7a3791ac5b6b2508c8a7a20 100644 --- a/include/Algo/Filtering/tools.h +++ b/include/Algo/Filtering/tools.h @@ -132,10 +132,205 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute +void computeUnfirmAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2) +{ + typedef typename PFP::VEC3 VEC3 ; + + // Compute mesh center + unsigned int count = 0; + VEC3 centroid(0.0); + + TraversorV tv(map) ; + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + centroid += position[dit]; + ++count; + } + centroid /= count; + + double distanceCentroid = 0.0; + + // Compute the average distance from vertices to mesh center + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + VEC3 dist = position[dit]; + dist -= centroid; + distanceCentroid += float(dist.norm()); + } + distanceCentroid /= count; + + // add random uniform-distributed (between [-noiseLevel, +noiseLevel]) + srand((unsigned)time(NULL)); + float noisex, noisey, noisez; + float noiseLevel = distanceCentroid * noiseIntensity; + + + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + noisex = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; + noisey = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; + noisez = noiseLevel * (1.0*rand()/RAND_MAX-0.5)*2; + + position2[dit] = position[dit] + VEC3(noisex,noisey,noisez); + } +} + + +//Gaussian-distributed additive noise +//TODO do not touch to boundary vertices +template +void computeGaussianAdditiveNoise(typename PFP::MAP& map, float noiseIntensity, const VertexAttribute& position, VertexAttribute& position2) +{ + typedef typename PFP::VEC3 VEC3 ; + + // Compute mesh center + unsigned int count = 0; + VEC3 centroid(0.0); + + TraversorV tv(map) ; + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + centroid += position[dit]; + ++count; + } + centroid /= count; + + double distanceCentroid = 0.0; + + // Compute the average distance from vertices to mesh center + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + VEC3 dist = position[dit]; + dist -= centroid; + distanceCentroid += float(dist.norm()); + } + distanceCentroid /= count; + + // add random gaussian-distributed + srand((unsigned)time(NULL)); + float noisex, noisey, noisez; + float gaussNumbers[3]; + float noiseLevel = distanceCentroid * noiseIntensity; + + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + + // pseudo-random Gaussian-distributed numbers generation from uniformly-distributed pseudo-random numbers + float x, y, r2; + for (int i=0; i<3; i++) + { + do + { + x = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + y = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + r2 = x * x + y * y; + } while ((r2>1.0)||(r2==0.0)); + gaussNumbers[i] = y * sqrt(-2.0 * log(r2) / r2); + } + + noisex = noiseLevel * gaussNumbers[0]; + noisey = noiseLevel * gaussNumbers[1]; + noisez = noiseLevel * gaussNumbers[2]; + + position2[dit] = position[dit] + VEC3(noisex,noisey,noisez); + } + +} + } //namespace Filtering } //namespace Surface + +namespace Volume +{ + +namespace Filtering +{ + +template +void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute& position, VertexAttribute& position2) +{ + typedef typename PFP::VEC3 VEC3 ; + + // add random gaussian-distributed + srand((unsigned)time(NULL)); + float noisex, noisey, noisez; + float gaussNumbers[3]; + float noiseLevel = 0.1f; + + TraversorV tv(map) ; + for(Dart dit = tv.begin(); dit != tv.end(); dit = tv.next()) + { + + // pseudo-random Gaussian-distributed numbers generation from uniformly-distributed pseudo-random numbers + float x, y, r2; + for (int i=0; i<3; i++) + { + do + { + x = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + y = -1.0 + 2.0 * 1.0*rand()/RAND_MAX; + r2 = x * x + y * y; + } while ((r2>1.0)||(r2==0.0)); + gaussNumbers[i] = y * sqrt(-2.0 * log(r2) / r2); + } + + noisex = noiseLevel * gaussNumbers[0]; + noisey = noiseLevel * gaussNumbers[1]; + noisez = noiseLevel * gaussNumbers[2]; + + position2[dit] = position[dit] + VEC3(noisex,noisey,noisez); + } + + +// // init the seed for random +// srand(time(NULL)) ; +// +// // apply noise on each vertex +// TraversorV t(map) ; +// for(Dart d = t.begin(); d != t.end(); d = t.next()) +// { +// const VEC3& pos = position[d] ; +// VEC3 norm = position[d] ; +// +// float r1 = float(rand() % amount) / 100.0f ; +// float r2 = 0 ; +// if (amount >= 5) +// r2 = float(rand() % (amount/5)) / 100.0f ; +// +// long sign = rand() % 2 ; +// if (sign == 1) norm *= -1.0f ; +// float avEL = 0.0f ; +// VEC3 td(0) ; +// +// long nbE = 0 ; +// Traversor3VVaE tav(map, d) ; +// for(Dart it = tav.begin(); it != tav.end(); it = tav.next()) +// { +// const VEC3& p = position[it] ; +// VEC3 vec = p - pos ; +// float el = vec.norm() ; +// vec *= r2 ; +// td += vec ; +// avEL += el ; +// nbE++ ; +// } +// +// avEL /= float(nbE) ; +// norm *= avEL * r1 ; +// norm += td ; +// position2[d] = pos + norm ; +// } +} + +} //namespace Filtering + +} //namespace Volume + } //namespace Algo } //namespace CGoGN diff --git a/include/Algo/Multiresolution/Map2MR/Filters/bertram.h b/include/Algo/Multiresolution/Map2MR/Filters/bertram.h index 964eaed0dade5e50d988abf557cdb133b951f440..4e0fd0eff272b342290b6530fedb6125f5b48a9d 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/bertram.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/bertram.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __3MR_BERTRAM_FILTER__ -#define __3MR_BERTRAM_FILTER__ +#ifndef __2MR_BERTRAM_FILTER__ +#define __2MR_BERTRAM_FILTER__ #include #include "Algo/Geometry/centroid.h" @@ -66,11 +66,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorE travE(m_map) ; for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) @@ -128,11 +123,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorE travE(m_map); for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) @@ -171,9 +161,11 @@ public: { Dart db = m_map.findBoundaryEdgeOfVertex(d); m_map.incCurrentLevel() ; - ev = (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]); + ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5); + //ev = (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]); m_map.decCurrentLevel() ; - ev *= m_a; + ev *= 2 * m_a; + //ev *= m_a; m_position[d] -= ev; } @@ -220,20 +212,6 @@ public: void operator() () { - - } - - void operator() (bool filtering) - { - TraversorV travV(m_map) ; - for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) - { - if(m_map.isBoundaryVertex(d)) - m_position[d] /= m_a; - else - m_position[d] /= m_a * m_a; - } - TraversorE travE(m_map) ; for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) { @@ -243,6 +221,15 @@ public: m_position[midE] /= m_a ; m_map.decCurrentLevel() ; } + + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + { + if(m_map.isBoundaryVertex(d)) + m_position[d] /= m_a; + else + m_position[d] /= m_a * m_a; + } } }; @@ -267,11 +254,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorF travF(m_map) ; for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) @@ -297,14 +279,7 @@ public: m_map.incCurrentLevel() ; Dart midF = m_map.phi1(m_map.phi1(d)); - if(filtering) - { - m_position[midF] = vf + ef ; - } - else - { - m_position[midF] += vf + ef ; - } + m_position[midF] += vf + ef ; m_map.decCurrentLevel() ; } @@ -316,15 +291,8 @@ public: ve *= 2.0 * m_a; m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(d) ; - if(filtering) - { - m_position[midV] = ve; - } - else - { - m_position[midV] += ve; - } + Dart midE = m_map.phi1(d) ; + m_position[midE] += ve; m_map.decCurrentLevel() ; } } @@ -344,11 +312,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorV travV(m_map); for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) @@ -363,14 +326,7 @@ public: m_map.decCurrentLevel() ; ev *= 2 * m_a; - if(filtering) - { - m_position[db] = ev; - } - else - { - m_position[db] += ev; - } + m_position[db] += ev; } else { @@ -392,14 +348,7 @@ public: ev /= count; ev *= 4 * m_a; - if(filtering) - { - m_position[d] = fv + ev; - } - else - { - m_position[d] += fv + ev; - } + m_position[d] += fv + ev; } } @@ -426,17 +375,11 @@ public: m_map.incCurrentLevel() ; Dart midF = m_map.phi1(d); - if(filtering) - { - m_position[midF] = fe; - } - else - { - m_position[midF] += fe; - } + m_position[midF] += fe; m_map.decCurrentLevel() ; } } + } } ; @@ -454,11 +397,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorV travV(m_map) ; for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) @@ -496,4 +434,4 @@ public: } // namespace CGoGN -#endif /* __3MR_FILTERS_PRIMAL__ */ +#endif /* __2MR_FILTERS_PRIMAL__ */ diff --git a/include/Algo/Multiresolution/Map2MR/Filters/catmullClark.h b/include/Algo/Multiresolution/Map2MR/Filters/catmullClark.h index 929713355e81a91466c5b572293ca11d9d683f88..dd2c9450d4080c9efbd50cd25d3c54095caa9c42 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/catmullClark.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/catmullClark.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __MR_CC_FILTER__ -#define __MR_CC_FILTER__ +#ifndef __2MR_CC_FILTER__ +#define __2MR_CC_FILTER__ #include #include "Algo/Multiresolution/filter.h" @@ -93,11 +93,6 @@ public: first = false; } } - - void operator() (bool filtering) - { - - } } ; template @@ -126,11 +121,6 @@ public: first = false; } } - - void operator() (bool filtering) - { - - } } ; template @@ -157,11 +147,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -210,11 +195,6 @@ public: } } - - void operator() (bool filtering) - { - - } } ; template @@ -267,11 +247,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -305,11 +280,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -343,11 +313,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -402,11 +367,6 @@ public: } } - - void operator() (bool filtering) - { - - } } ; template @@ -455,11 +415,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -486,11 +441,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; } // namespace Filters diff --git a/include/Algo/Multiresolution/Map2MR/Filters/lerp.h b/include/Algo/Multiresolution/Map2MR/Filters/lerp.h index d7f5f999347a6807adefab3e330670b2c307e458..eaa2dad8273c7a406c8e8812223d1348c30b5078 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/lerp.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/lerp.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __MR_LERP_FILTER__ -#define __MR_LERP_FILTER__ +#ifndef __2MR_LERP_FILTER__ +#define __2MR_LERP_FILTER__ #include #include "Algo/Multiresolution/filter.h" diff --git a/include/Algo/Multiresolution/Map2MR/Filters/loop.h b/include/Algo/Multiresolution/Map2MR/Filters/loop.h index 9cfbbf3ceb1831ba8b32d827ab4f547a1da9e05d..70078ffaac7c3769fb14d36851ff5ec54e9452c7 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/loop.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/loop.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __MR_LOOP_FILTER__ -#define __MR_LOOP_FILTER__ +#ifndef __2MR_LOOP_FILTER__ +#define __2MR_LOOP_FILTER__ #include #include "Algo/Multiresolution/filter.h" @@ -124,11 +124,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -151,11 +146,6 @@ public: m_position[d] -= p ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -181,11 +171,6 @@ public: m_position[d] /= n ; } } - - void operator() (bool filtering) - { - - } } ; /********************************************************************************* @@ -218,11 +203,6 @@ public: m_map.decCurrentLevel() ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -245,11 +225,6 @@ public: m_position[d] += p ; } } - - void operator() (bool filtering) - { - - } } ; template @@ -275,11 +250,6 @@ public: m_position[d] *= n ; } } - - void operator() (bool filtering) - { - - } } ; } // namespace Filters diff --git a/include/Algo/Multiresolution/Map2MR/Filters/sqrt2.h b/include/Algo/Multiresolution/Map2MR/Filters/sqrt2.h index 77577c81106f3b06fdc8e9fd6293154cc74a8ed6..401d30344ac357f4226fd7a69262f25ace202e00 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/sqrt2.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/sqrt2.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __MR_SQRT2_FILTER__ -#define __MR_SQRT2_FILTER__ +#ifndef __2MR_SQRT2_FILTER__ +#define __2MR_SQRT2_FILTER__ #include #include "Algo/Multiresolution/filter.h" @@ -83,11 +83,6 @@ public: } } - - void operator() (bool filtering) - { - - } } ; diff --git a/include/Algo/Multiresolution/Map2MR/Filters/sqrt3.h b/include/Algo/Multiresolution/Map2MR/Filters/sqrt3.h index b79d9254eb1e7b64b40c9402453bc6d5b3b41df3..46128089d17e197e999d3f95abd87047075f693e 100644 --- a/include/Algo/Multiresolution/Map2MR/Filters/sqrt3.h +++ b/include/Algo/Multiresolution/Map2MR/Filters/sqrt3.h @@ -22,8 +22,8 @@ * * *******************************************************************************/ -#ifndef __MR_SQRT3_FILTER__ -#define __MR_SQRT3_FILTER__ +#ifndef __2MR_SQRT3_FILTER__ +#define __2MR_SQRT3_FILTER__ #include #include "Algo/Multiresolution/filter.h" @@ -114,11 +114,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorF trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -149,7 +144,6 @@ public: m_map.decCurrentLevel() ; } } - } ; template @@ -164,11 +158,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorV trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -239,7 +228,6 @@ public: } } } - } ; template @@ -254,11 +242,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorV trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -295,7 +278,6 @@ public: } } - } ; template @@ -310,11 +292,6 @@ public: {} void operator() () - { - - } - - void operator() (bool filtering) { TraversorF trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -338,7 +315,6 @@ public: } } - } ; /********************************************************************************* diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h index 3c299474dd6108090bf550927e7a287b5b436e5e..e78258f09957470b9560132d1aab8ec53db8be61 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.h @@ -49,14 +49,6 @@ namespace Primal namespace Regular { -enum FilteringType -{ - F_HighPass = 0, - F_LowPass, - F_BandPass, - F_None -} ; - template class Map2MR { @@ -70,10 +62,6 @@ protected: std::vector synthesisFilters ; std::vector analysisFilters ; - FilteringType filter; - unsigned int thresholdLow; - unsigned int thresholdHigh; - public: Map2MR(MAP& map); @@ -94,12 +82,6 @@ public: void analysis() ; void synthesis() ; - - void lowPassFiltering(unsigned int cutoff) { thresholdHigh = cutoff; filter = F_LowPass; } - void highPassFiltering(unsigned int cutoff) { thresholdLow = cutoff; filter = F_HighPass; } - void bandPassFiltering(unsigned int cutoffLow, unsigned int cutoffHigh) { thresholdLow = cutoffLow; thresholdHigh = cutoffHigh; filter = F_BandPass; } - void resetFiltering() { thresholdLow = 0; thresholdHigh = 0; filter = F_None; } - } ; } // namespace Regular diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp index 63a3a0abb18ef7419c7c881921b265b1546bed69..c1368d053fcd2ac6c3f4a69922806ab231ecd851 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PrimalRegular.hpp @@ -43,10 +43,9 @@ namespace Regular template Map2MR::Map2MR(typename PFP::MAP& map) : m_map(map), - shareVertexEmbeddings(true), - filter(F_None) + shareVertexEmbeddings(true) { - std::cout << "filter = " << filter << std::endl; + } template @@ -252,14 +251,8 @@ void Map2MR::analysis() m_map.decCurrentLevel() ; -// for(unsigned int i = 0; i < analysisFilters.size(); ++i) -// (*analysisFilters[i])() ; - for(unsigned int i = 0; i < analysisFilters.size(); ++i) - { - std::cout << "filter false" << std::endl; - (*analysisFilters[i])(false) ; - } + (*analysisFilters[i])() ; } @@ -268,26 +261,8 @@ void Map2MR::synthesis() { assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ; -// for(unsigned int i = 0; i < synthesisFilters.size(); ++i) -// (*synthesisFilters[i])() ; - for(unsigned int i = 0; i < synthesisFilters.size(); ++i) - { - std::cout << "filter = " << filter << std::endl; - - if((filter == F_LowPass && m_map.getCurrentLevel() <= thresholdHigh))// || - //(filter == F_HighPass && m_map.getCurrentLevel() >= thresholdLow) || - //(filter == F_BandPass && (thresholdLow >= m_map.getCurrentLevel() && m_map.getCurrentLevel() <= thresholdHigh))) - { - std::cout << "filter true , currentLevel = " << m_map.getCurrentLevel() << ", level = " << thresholdHigh << std::endl; - (*synthesisFilters[i])(true) ; - } - else - { - std::cout << "filter false" << std::endl; - (*synthesisFilters[i])(false) ; - } - } + (*synthesisFilters[i])() ; m_map.incCurrentLevel() ; } diff --git a/include/Algo/Multiresolution/Map3MR/Filters/bertram.h b/include/Algo/Multiresolution/Map3MR/Filters/bertram.h index 8a8df1a7d9f1f879c9c99feb91de86c2ea8c48c2..f29303fefe773b2886a2fb918eab49a81cfa70e9 100644 --- a/include/Algo/Multiresolution/Map3MR/Filters/bertram.h +++ b/include/Algo/Multiresolution/Map3MR/Filters/bertram.h @@ -54,12 +54,12 @@ namespace Filters *******************************************************************************/ // -// Synthesis +// Analysis // //w-lift(a) template -class Ber02OddSynthesisFilter : public Algo::MR::Filter +class Ber02OddAnalysisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -67,46 +67,20 @@ protected: typename PFP::VEC3::DATA_TYPE m_a; public: - Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) {} void operator() () { - TraversorW travW(m_map) ; - for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) { - typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); - vc *= 8 * m_a * m_a * m_a; - - unsigned int count = 0; - typename PFP::VEC3 ec(0.0); - Traversor3WE travWE(m_map, d); - for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) - { - m_map.incCurrentLevel(); - ec += m_position[m_map.phi1(dit)]; - m_map.decCurrentLevel(); - ++count; - } - ec /= count; - ec *= 12 * m_a * m_a; - - count = 0; - typename PFP::VEC3 fc(0.0); - Traversor3WF travWF(m_map, d); - for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) - { - m_map.incCurrentLevel(); - fc += m_position[m_map.phi1(m_map.phi1(dit))]; - m_map.decCurrentLevel(); - ++count; - } - fc /= count; - fc *= 6 * m_a; + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; m_map.incCurrentLevel() ; - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); - m_position[midV] += vc + ec + fc; + Dart midV = m_map.phi1(d) ; + m_position[midV] -= ve; m_map.decCurrentLevel() ; } @@ -134,19 +108,45 @@ public: m_map.incCurrentLevel() ; Dart midF = m_map.phi1(m_map.phi1(d)); - m_position[midF] += vf + ef ; + m_position[midF] -= vf + ef ; m_map.decCurrentLevel() ; } - TraversorE travE(m_map) ; - for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) { - typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); - ve *= 2.0 * m_a; + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(d) ; - m_position[midV] += ve; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] -= vc + ec + fc; m_map.decCurrentLevel() ; } } @@ -154,7 +154,7 @@ public: // s-lift(a) template -class Ber02EvenSynthesisFilter : public Algo::MR::Filter +class Ber02EvenAnalysisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -162,11 +162,112 @@ protected: typename PFP::VEC3::DATA_TYPE m_a; public: - Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) {} void operator() () { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(!m_map.isBoundaryFace(d)) + { + unsigned int count = 0; + + typename PFP::VEC3 cf(0.0); + Traversor3FW travFW(m_map, d); + for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) + { + m_map.incCurrentLevel(); + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cf += m_position[midV]; + m_map.decCurrentLevel(); + ++count; + } + cf /= count; + cf *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] -= cf; + m_map.decCurrentLevel() ; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + +// unsigned int count = 2; +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(db)); +// fe += m_position[midV]; +// midV = m_map.phi_1(m_map.phi2(db)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] -= fe; + m_map.decCurrentLevel() ; + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 ce(0.0); + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + ce += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ce /= count; + ce *= 4 * m_a * m_a; + + typename PFP::VEC3 fe(0.0); + count = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fe /= count; + fe *= 4 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + m_position[midE] -= ce + fe; + m_map.decCurrentLevel() ; + } + } + TraversorV travV(m_map); for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) { @@ -194,7 +295,6 @@ public: // // }while(dit != db); - //TODO Replace do--while with a Traversor2 on Boundary Traversor2VF travVF(m_map,db); for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) { @@ -214,7 +314,7 @@ public: ev /= count; ev *= 4 * m_a; - m_position[d] += fv + ev; + m_position[d] -= fv + ev; } else @@ -262,135 +362,36 @@ public: ev /= count; ev *= 6 * m_a; - m_position[d] += cv + fv + ev; + m_position[d] -= cv + fv + ev; } } + } +} ; - TraversorE travE(m_map); - for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) - { - if(m_map.isBoundaryEdge(d)) - { - Dart db = m_map.findBoundaryFaceOfEdge(d); - typename PFP::VEC3 fe(0.0); - -// unsigned int count = 2; -// m_map.incCurrentLevel() ; -// Dart midV = m_map.phi1(m_map.phi1(db)); -// fe += m_position[midV]; -// midV = m_map.phi_1(m_map.phi2(db)); -// fe += m_position[midV]; -// m_map.decCurrentLevel() ; - - //TODO Replace do--while with a Traversor2 on Boundary - unsigned int count = 0; - Traversor2EF travEF(m_map, db); - for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(m_map.phi1(dit)); - fe += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } +// s-scale(a) +template +class Ber02ScaleAnalysisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + typename PFP::VEC3::DATA_TYPE m_a; - fe /= count; - fe *= 2 * m_a; +public: + Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + {} + void operator() () + { + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { m_map.incCurrentLevel() ; - Dart midE = m_map.phi1(db); - m_position[midE] += fe; + Dart midF = m_map.phi1(m_map.phi1(d)); + if(!m_map.isBoundaryVertex(midF)) + m_position[midF] /= m_a ; m_map.decCurrentLevel() ; - } - else - { - unsigned int count = 0; - typename PFP::VEC3 ce(0.0); - Traversor3EW travEW(m_map, d); - for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); - ce += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } - ce /= count; - ce *= 4 * m_a * m_a; - - typename PFP::VEC3 fe(0.0); - count = 0; - Traversor3EF travEF(m_map, d); - for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(m_map.phi1(dit)); - fe += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } - fe /= count; - fe *= 4 * m_a; - - m_map.incCurrentLevel() ; - Dart midE = m_map.phi1(d); - m_position[midE] += ce + fe; - m_map.decCurrentLevel() ; - } - } - - TraversorF travF(m_map) ; - for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) - { - if(!m_map.isBoundaryFace(d)) - { - unsigned int count = 0; - - typename PFP::VEC3 cf(0.0); - Traversor3FW travFW(m_map, d); - for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) - { - m_map.incCurrentLevel(); - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); - cf += m_position[midV]; - m_map.decCurrentLevel(); - ++count; - } - cf /= count; - cf *= 2 * m_a; - - m_map.incCurrentLevel() ; - Dart midF = m_map.phi1(m_map.phi1(d)); - m_position[midF] += cf; - m_map.decCurrentLevel() ; - } - } - } -} ; - -// s-scale(a) -template -class Ber02ScaleSynthesisFilter : public Algo::MR::Filter -{ -protected: - typename PFP::MAP& m_map ; - VertexAttribute& m_position ; - typename PFP::VEC3::DATA_TYPE m_a; - -public: - Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) - {} - - void operator() () - { - TraversorV travV(m_map) ; - for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) - { - if(m_map.isBoundaryVertex(d)) - m_position[d] *= m_a * m_a; - else - m_position[d] *= m_a *m_a * m_a; } TraversorE travE(m_map) ; @@ -400,33 +401,32 @@ public: m_map.incCurrentLevel() ; Dart midE = m_map.phi1(d); if(m_map.isBoundaryVertex(midE)) - m_position[midE] *= m_a; + m_position[midE] /= m_a; else - m_position[midE] *= m_a * m_a; + m_position[midE] /= m_a * m_a; m_map.decCurrentLevel() ; } - TraversorF travF(m_map) ; - for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) { - m_map.incCurrentLevel() ; - Dart midF = m_map.phi1(m_map.phi1(d)); - if(!m_map.isBoundaryVertex(midF)) - m_position[midF] *= m_a ; - m_map.decCurrentLevel() ; - + if(m_map.isBoundaryVertex(d)) + m_position[d] /= m_a * m_a; + else + m_position[d] /= m_a *m_a * m_a; } } } ; + // -// Analysis +// Synthesis // //w-lift(a) template -class Ber02OddAnalysisFilter : public Algo::MR::Filter +class Ber02OddSynthesisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -434,20 +434,46 @@ protected: typename PFP::VEC3::DATA_TYPE m_a; public: - Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) {} void operator() () { - TraversorE travE(m_map) ; - for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) + TraversorW travW(m_map) ; + for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) { - typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); - ve *= 2.0 * m_a; + typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); + vc *= 8 * m_a * m_a * m_a; + + unsigned int count = 0; + typename PFP::VEC3 ec(0.0); + Traversor3WE travWE(m_map, d); + for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) + { + m_map.incCurrentLevel(); + ec += m_position[m_map.phi1(dit)]; + m_map.decCurrentLevel(); + ++count; + } + ec /= count; + ec *= 12 * m_a * m_a; + + count = 0; + typename PFP::VEC3 fc(0.0); + Traversor3WF travWF(m_map, d); + for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) + { + m_map.incCurrentLevel(); + fc += m_position[m_map.phi1(m_map.phi1(dit))]; + m_map.decCurrentLevel(); + ++count; + } + fc /= count; + fc *= 6 * m_a; m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(d) ; - m_position[midV] -= ve; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); + m_position[midV] += vc + ec + fc; m_map.decCurrentLevel() ; } @@ -475,45 +501,19 @@ public: m_map.incCurrentLevel() ; Dart midF = m_map.phi1(m_map.phi1(d)); - m_position[midF] -= vf + ef ; + m_position[midF] += vf + ef ; m_map.decCurrentLevel() ; } - TraversorW travW(m_map) ; - for (Dart d = travW.begin(); d != travW.end(); d = travW.next()) + TraversorE travE(m_map) ; + for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) { - typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); - vc *= 8 * m_a * m_a * m_a; - - unsigned int count = 0; - typename PFP::VEC3 ec(0.0); - Traversor3WE travWE(m_map, d); - for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next()) - { - m_map.incCurrentLevel(); - ec += m_position[m_map.phi1(dit)]; - m_map.decCurrentLevel(); - ++count; - } - ec /= count; - ec *= 12 * m_a * m_a; - - count = 0; - typename PFP::VEC3 fc(0.0); - Traversor3WF travWF(m_map, d); - for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next()) - { - m_map.incCurrentLevel(); - fc += m_position[m_map.phi1(m_map.phi1(dit))]; - m_map.decCurrentLevel(); - ++count; - } - fc /= count; - fc *= 6 * m_a; + typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); + ve *= 2.0 * m_a; m_map.incCurrentLevel() ; - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); - m_position[midV] -= vc + ec + fc; + Dart midV = m_map.phi1(d) ; + m_position[midV] += ve; m_map.decCurrentLevel() ; } } @@ -521,7 +521,7 @@ public: // s-lift(a) template -class Ber02EvenAnalysisFilter : public Algo::MR::Filter +class Ber02EvenSynthesisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -529,112 +529,11 @@ protected: typename PFP::VEC3::DATA_TYPE m_a; public: - Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) {} void operator() () { - TraversorF travF(m_map) ; - for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) - { - if(!m_map.isBoundaryFace(d)) - { - unsigned int count = 0; - - typename PFP::VEC3 cf(0.0); - Traversor3FW travFW(m_map, d); - for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) - { - m_map.incCurrentLevel(); - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); - cf += m_position[midV]; - m_map.decCurrentLevel(); - ++count; - } - cf /= count; - cf *= 2 * m_a; - - m_map.incCurrentLevel() ; - Dart midF = m_map.phi1(m_map.phi1(d)); - m_position[midF] -= cf; - m_map.decCurrentLevel() ; - } - } - - TraversorE travE(m_map); - for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) - { - if(m_map.isBoundaryEdge(d)) - { - Dart db = m_map.findBoundaryFaceOfEdge(d); - typename PFP::VEC3 fe(0.0); - -// unsigned int count = 2; -// m_map.incCurrentLevel() ; -// Dart midV = m_map.phi1(m_map.phi1(db)); -// fe += m_position[midV]; -// midV = m_map.phi_1(m_map.phi2(db)); -// fe += m_position[midV]; -// m_map.decCurrentLevel() ; - - //TODO Replace do--while with a Traversor2 on Boundary - unsigned int count = 0; - Traversor2EF travEF(m_map, db); - for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(m_map.phi1(dit)); - fe += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } - - fe /= count; - fe *= 2 * m_a; - - m_map.incCurrentLevel() ; - Dart midE = m_map.phi1(db); - m_position[midE] -= fe; - m_map.decCurrentLevel() ; - } - else - { - unsigned int count = 0; - - typename PFP::VEC3 ce(0.0); - Traversor3EW travEW(m_map, d); - for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); - ce += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } - ce /= count; - ce *= 4 * m_a * m_a; - - typename PFP::VEC3 fe(0.0); - count = 0; - Traversor3EF travEF(m_map, d); - for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) - { - m_map.incCurrentLevel() ; - Dart midV = m_map.phi1(m_map.phi1(dit)); - fe += m_position[midV]; - m_map.decCurrentLevel() ; - ++count; - } - fe /= count; - fe *= 4 * m_a; - - m_map.incCurrentLevel() ; - Dart midE = m_map.phi1(d); - m_position[midE] -= ce + fe; - m_map.decCurrentLevel() ; - } - } - TraversorV travV(m_map); for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next()) { @@ -662,10 +561,10 @@ public: // // }while(dit != db); + //TODO Replace do--while with a Traversor2 on Boundary Traversor2VF travVF(m_map,db); for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next()) { - std::cout << "dit = " << dit << std::endl; m_map.incCurrentLevel() ; Dart midEdgeV = m_map.phi1(dit); @@ -682,7 +581,7 @@ public: ev /= count; ev *= 4 * m_a; - m_position[d] -= fv + ev; + m_position[d] += fv + ev; } else @@ -730,7 +629,108 @@ public: ev /= count; ev *= 6 * m_a; - m_position[d] -= cv + fv + ev; + m_position[d] += cv + fv + ev; + } + } + + TraversorE travE(m_map); + for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next()) + { + if(m_map.isBoundaryEdge(d)) + { + Dart db = m_map.findBoundaryFaceOfEdge(d); + typename PFP::VEC3 fe(0.0); + +// unsigned int count = 2; +// m_map.incCurrentLevel() ; +// Dart midV = m_map.phi1(m_map.phi1(db)); +// fe += m_position[midV]; +// midV = m_map.phi_1(m_map.phi2(db)); +// fe += m_position[midV]; +// m_map.decCurrentLevel() ; + + //TODO Replace do--while with a Traversor2 on Boundary + unsigned int count = 0; + Traversor2EF travEF(m_map, db); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + + fe /= count; + fe *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(db); + m_position[midE] += fe; + m_map.decCurrentLevel() ; + } + else + { + unsigned int count = 0; + + typename PFP::VEC3 ce(0.0); + Traversor3EW travEW(m_map, d); + for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + ce += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + ce /= count; + ce *= 4 * m_a * m_a; + + typename PFP::VEC3 fe(0.0); + count = 0; + Traversor3EF travEF(m_map, d); + for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next()) + { + m_map.incCurrentLevel() ; + Dart midV = m_map.phi1(m_map.phi1(dit)); + fe += m_position[midV]; + m_map.decCurrentLevel() ; + ++count; + } + fe /= count; + fe *= 4 * m_a; + + m_map.incCurrentLevel() ; + Dart midE = m_map.phi1(d); + m_position[midE] += ce + fe; + m_map.decCurrentLevel() ; + } + } + + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + { + if(!m_map.isBoundaryFace(d)) + { + unsigned int count = 0; + + typename PFP::VEC3 cf(0.0); + Traversor3FW travFW(m_map, d); + for(Dart dit = travFW.begin() ; dit != travFW.end() ; dit = travFW.next()) + { + m_map.incCurrentLevel(); + Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(dit))); + cf += m_position[midV]; + m_map.decCurrentLevel(); + ++count; + } + cf /= count; + cf *= 2 * m_a; + + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + m_position[midF] += cf; + m_map.decCurrentLevel() ; } } } @@ -738,7 +738,7 @@ public: // s-scale(a) template -class Ber02ScaleAnalysisFilter : public Algo::MR::Filter +class Ber02ScaleSynthesisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -746,20 +746,18 @@ protected: typename PFP::VEC3::DATA_TYPE m_a; public: - Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) + Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a) {} void operator() () { - TraversorF travF(m_map) ; - for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) + TraversorV travV(m_map) ; + for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) { - m_map.incCurrentLevel() ; - Dart midF = m_map.phi1(m_map.phi1(d)); - if(!m_map.isBoundaryVertex(midF)) - m_position[midF] /= m_a ; - m_map.decCurrentLevel() ; - + if(m_map.isBoundaryVertex(d)) + m_position[d] *= m_a * m_a; + else + m_position[d] *= m_a *m_a * m_a; } TraversorE travE(m_map) ; @@ -769,24 +767,28 @@ public: m_map.incCurrentLevel() ; Dart midE = m_map.phi1(d); if(m_map.isBoundaryVertex(midE)) - m_position[midE] /= m_a; + m_position[midE] *= m_a; else - m_position[midE] /= m_a * m_a; + m_position[midE] *= m_a * m_a; m_map.decCurrentLevel() ; } - TraversorV travV(m_map) ; - for (Dart d = travV.begin(); d != travV.end(); d = travV.next()) + TraversorF travF(m_map) ; + for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) { - if(m_map.isBoundaryVertex(d)) - m_position[d] /= m_a * m_a; - else - m_position[d] /= m_a *m_a * m_a; + m_map.incCurrentLevel() ; + Dart midF = m_map.phi1(m_map.phi1(d)); + if(!m_map.isBoundaryVertex(midF)) + m_position[midF] *= m_a ; + m_map.decCurrentLevel() ; + } } } ; + + } // namespace Filters } // namespace Primal diff --git a/include/Algo/Multiresolution/filter.h b/include/Algo/Multiresolution/filter.h index 3c04bbb7ddb0b9abac41343e2c05a285f1eaf654..cb5a7ec62d8f3b1717458a968730d466277be09b 100644 --- a/include/Algo/Multiresolution/filter.h +++ b/include/Algo/Multiresolution/filter.h @@ -43,9 +43,101 @@ public: Filter() {} virtual ~Filter() {} virtual void operator() () = 0 ; - virtual void operator() (bool filtering) { } } ; +template +unsigned int vertexLevel(typename PFP::MAP& map, Dart d) +{ + assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"edgeLevel : called with a dart inserted after current level") ; + + unsigned int level = map.getMaxLevel(); + Dart dit = d; + do + { + unsigned int ldit = map.getDartLevel(dit) ; + if(ldit < level) + level = ldit; + + dit = map.phi2(map.phi_1(dit)); + } + while(dit != d); + + return level; +} + + +template +void filterLowPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + if(vertexLevel(map,d) > cutoffLevel) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +void filterHighPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + if(vertexLevel(map,d) < cutoffLevel) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +void filterBandPass(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevelLow, unsigned int cutoffLevelHigh) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + unsigned int vLevel = vertexLevel(map,d); + if(cutoffLevelLow > vLevel && vLevel < cutoffLevelHigh) + attIn[d] = T(0.0); + } + + map.setCurrentLevel(cur); +} + +template +void frequencyDeformation(typename PFP::MAP& map, VertexAttribute& attIn, unsigned int cutoffLevel) +{ + unsigned int cur = map.getCurrentLevel(); + unsigned int max = map.getMaxLevel(); + + map.setCurrentLevel(max); + + TraversorV tv(map); + for (Dart d = tv.begin(); d != tv.end(); d = tv.next()) + { + if(vertexLevel(map,d) == cutoffLevel) + attIn[d] *= 2.0;//T(0.0,6.0,0.0); + } + + map.setCurrentLevel(cur); +} } // namespace MR diff --git a/src/Algo/Render/topo3Render.cpp b/src/Algo/Render/topo3Render.cpp index 4746743556b2bcee94701a12f53b3e0a0cf1346e..275f0cbb0b752946d61c77f69b0c592abe62f254 100644 --- a/src/Algo/Render/topo3Render.cpp +++ b/src/Algo/Render/topo3Render.cpp @@ -380,6 +380,7 @@ void Topo3Render::svgout2D(const std::string& filename, const glm::mat4& model, { Utils::SVG::SVGOut svg(filename,model,proj); toSVG(svg); + svg.write(); } void Topo3Render::toSVG(Utils::SVG::SVGOut& svg)