diff --git a/Apps/Examples/volumeExplorer.cpp b/Apps/Examples/volumeExplorer.cpp index 7f40e623ea1383eceaa978838399850a1da87f70..77c62ff43ea974dccf5467f66f093049e4b5f91b 100644 --- a/Apps/Examples/volumeExplorer.cpp +++ b/Apps/Examples/volumeExplorer.cpp @@ -146,21 +146,21 @@ void MyQT::cb_Open() size_t pos = filename.rfind("."); // position of "." in filename std::string extension = filename.substr(pos); - if(extension == std::string(".off")) - { - if(!Algo::Volume::Import::importMeshToExtrude(myMap, filename, attrNames)) - { - std::cerr << "could not import " << filename << std::endl ; - return ; - } - else - { - position = myMap.getAttribute(attrNames[0]) ; - myMap.closeMap(); - } - } - else - { +// if(extension == std::string(".off")) +// { +// if(!Algo::Volume::Import::importMeshToExtrude(myMap, filename, attrNames)) +// { +// std::cerr << "could not import " << filename << std::endl ; +// return ; +// } +// else +// { +// position = myMap.getAttribute(attrNames[0]) ; +// myMap.closeMap(); +// } +// } +// else +// { if(!Algo::Volume::Import::importMesh(myMap, filename, attrNames)) { std::cerr << "could not import " << filename << std::endl ; @@ -168,7 +168,7 @@ void MyQT::cb_Open() } else position = myMap.getAttribute(attrNames[0]) ; - } +// } color = myMap.addAttribute("color"); diff --git a/Apps/Tuto/tuto_oper2.cpp b/Apps/Tuto/tuto_oper2.cpp index f63660947296bcb886a3dc17a66953bfd25f15f9..3b03e78c4d8ea6f2623c6529acd0d6dc88eb5afd 100644 --- a/Apps/Tuto/tuto_oper2.cpp +++ b/Apps/Tuto/tuto_oper2.cpp @@ -357,10 +357,9 @@ void MyQT::cb_Open() void MyQT::cb_Save() { - std::string filename = selectFileSave("Export Map file ",".","(*.map)"); - //Algo::Surface::Export::exportOFF(myMap,position,filename.c_str()); - if(!myMap.saveMapBin(filename)) - std::cout << "could not save file : " << filename << std::endl; + std::string filename = selectFileSave("Export Off file ",".","(*.off)"); + Algo::Surface::Export::exportOFF(myMap,position,filename.c_str()); + //std::cout << "could not save file : " << filename << std::endl; } void MyQT::importMesh(std::string& filename) diff --git a/include/Algo/DecimationVolumes/approximator.h b/include/Algo/DecimationVolumes/approximator.h index 1738fb698fc371c2ffe575b6fc906071290f1423..70f23a6aaab8f9b0db9536e2fdcca3e131ed849c 100644 --- a/include/Algo/DecimationVolumes/approximator.h +++ b/include/Algo/DecimationVolumes/approximator.h @@ -44,7 +44,10 @@ enum ApproximatorType { A_QEM, A_MidEdge, - A_hHalfCollapse + A_MidFace, + A_MidVolume, + A_hHalfEdgeCollapse, + A_QEM }; template @@ -63,7 +66,7 @@ public: {} virtual ~ApproximatorGen() {} - virtual const std::string& getApproximatedAttributeName() const = 0 ; + virtual const std::string& getApproximatedAttributeName(unsigned int index = 0) const = 0 ; virtual ApproximatorType getType() const = 0 ; virtual bool init() = 0 ; virtual void approximate(Dart d) = 0 ; @@ -73,67 +76,101 @@ public: } ; -template +template class Approximator : public ApproximatorGen { public: typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::REAL REAL; protected: Predictor* m_predictor ; - //Vertex attribute to be approximated - VertexAttribute& m_attrV; - //Attribute to store approximation result - EdgeAttribute m_approx; - // attribute to store detail information for reconstruction - EdgeAttribute m_detail ; - - T m_app; + std::vector* > m_attrV ; // vertex attributes to be approximated + std::vector > m_approx ; // attributes to store approximation result + std::vector > m_detail ; // attributes to store detail information for reconstruction + std::vector m_app ; public: - Approximator(MAP& m, VertexAttribute& a, Predictor* predictor) : - ApproximatorGen(m), m_predictor(predictor), m_attrV(a) + Approximator(MAP& m, std::vector* > va, Predictor * predictor) : + ApproximatorGen(m), m_predictor(predictor), m_attrV(va) { - std::stringstream aname ; - aname << "approx_" << m_attrV.name() ; - m_approx = this->m_map.template addAttribute(aname.str()) ; - - if(m_predictor) // if a predictor is associated to the approximator - { // create an attribute to store the detail needed for reconstruction - std::stringstream dname ; - dname << "detail_" << m_attrV.name() ; - m_detail = this->m_map.template addAttribute(dname.str()) ; + const unsigned int& size = m_attrV.size() ; + assert(size > 0 || !"Approximator: no attributes provided") ; + + m_approx.resize(size) ; + m_detail.resize(size) ; + m_app.resize(size) ; + + for (unsigned int i = 0 ; i < size ; ++i) + { + if (!m_attrV[i]->isValid()) + std::cerr << "Approximator Warning: attribute number " << i << " is not valid" << std::endl ; + + std::stringstream aname ; + aname << "approx_" << m_attrV[i]->name() ; + m_approx[i] = this->m_map.template addAttribute(aname.str()) ; + + if(m_predictor) // if predictors are associated to the approximator + { // create attributes to store the details needed for reconstruction + std::stringstream dname ; + dname << "detail_" << m_attrV[i]->name() ; + m_detail[i] = this->m_map.template addAttribute(dname.str()) ; + } } } virtual ~Approximator() { - this->m_map.template removeAttribute(m_approx) ; - - if(m_predictor) - this->m_map.template removeAttribute(m_detail) ; + for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) + { + this->m_map.template removeAttribute(m_approx[i]) ; + if(m_predictor) + this->m_map.template removeAttribute(m_detail[i]) ; + } } - const std::string& getApproximatedAttributeName() const + const std::string& getApproximatedAttributeName(unsigned int index = 0) const { - return m_attrV.name() ; + return m_attrV[index]->name() ; } - const T& getApprox(Dart d) const + unsigned int getNbApproximated() const { - return m_approx[d] ; + return m_attrV.size() ; } void saveApprox(Dart d) { - m_app = m_approx[d] ; + for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) + m_app[i] = m_approx[i][d] ; } void affectApprox(Dart d) { - m_attrV[d] = m_app ; + for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) + m_attrV[i]->operator[](d) = m_app[i] ; + } + + const T& getApprox(Dart d, unsigned int index = 0) const + { + return m_approx[index][d] ; + } + + const VertexAttribute& getAttr(unsigned int index = 0) const + { + return *(m_attrV[index]) ; + } + + std::vector getAllApprox(Dart d) const + { + std::vector res ; + res.resize(m_attrV.size()) ; + for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) + res[i] = m_approx[i][d] ; + + return res ; } const Predictor* getPredictor() const diff --git a/include/Algo/DecimationVolumes/geometryApproximator.h b/include/Algo/DecimationVolumes/geometryApproximator.h index c58e3ce4e4a392eeac4d40c12d2c5ff0db6dc06b..10fd7803cf261b04cf3444ce883d0ee539aa1ffa 100644 --- a/include/Algo/DecimationVolumes/geometryApproximator.h +++ b/include/Algo/DecimationVolumes/geometryApproximator.h @@ -40,16 +40,18 @@ namespace Decimation { template -class Approximator_MidEdge : public Approximator +class Approximator_MidEdge : public Approximator { public: typedef typename PFP::MAP MAP ; typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::REAL REAL ; - Approximator_MidEdge(MAP& m, VertexAttribute& pos, Predictor* pred = NULL) : - Approximator(m, pos, pred) - {} + Approximator_MidEdge(MAP& m, std::vector* > pos, Predictor* pred = NULL) : + Approximator(m, pos, pred) + { + assert(pos.size() > 0 || !"Approximator_MidEdge: attribute vector is empty") ; + } ~Approximator_MidEdge() {} ApproximatorType getType() const { return A_MidEdge ; } @@ -58,25 +60,90 @@ public: } ; template -class Approximator_HalfCollapse : public Approximator +class Approximator_MidFace : public Approximator +{ +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + + Approximator_MidFace(MAP& m, std::vector* > pos, Predictor* pred = NULL) : + Approximator(m, pos, pred) + { + assert(pos.size() > 0 || !"Approximator_MidFace: attribute vector is empty") ; + } + ~Approximator_MidFace() + {} + ApproximatorType getType() const { return A_MidFace ; } + bool init() ; + void approximate(Dart d) ; +} ; + +template +class Approximator_MidVolume : public Approximator { public: typedef typename PFP::MAP MAP ; typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::REAL REAL ; - Approximator_HalfCollapse(MAP& m, VertexAttribute& pos, Predictor* pred = NULL) : - Approximator(m, pos, pred) + Approximator_MidVolume(MAP& m, std::vector* > pos, Predictor* pred = NULL) : + Approximator(m, pos, pred) { - assert(pos.size() > 0 || !"Approximator_HalfCollapse: attribute vector is empty") ; + assert(pos.size() > 0 || !"Approximator_MidVolume: attribute vector is empty") ; } - ~Approximator_HalfCollapse() + ~Approximator_MidVolume() {} - ApproximatorType getType() const { return A_hHalfCollapse ; } + ApproximatorType getType() const { return A_MidVolume ; } bool init() ; void approximate(Dart d) ; } ; +template +class Approximator_HalfEdgeCollapse : public Approximator +{ +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + + Approximator_HalfEdgeCollapse(MAP& m, std::vector* > pos, Predictor* pred = NULL) : + Approximator(m, pos, pred) + { + assert(pos.size() > 0 || !"Approximator_HalfEdgeCollapse: attribute vector is empty") ; + } + ~Approximator_HalfEdgeCollapse() + {} + ApproximatorType getType() const { return A_hHalfEdgeCollapse ; } + bool init() ; + void approximate(Dart d) ; +} ; + +//template +//class Approximator_QEM : public Approximator +//{ +//public: +// typedef typename PFP::MAP MAP ; +// typedef typename PFP::VEC3 VEC3 ; +// typedef typename PFP::REAL REAL ; +// +//protected: +// VertexAttribute > m_quadric ; +// +//public: +// Approximator_QEM(MAP& m, std::vector* > pos, Predictor* pred = NULL) : +// Approximator(m, pos, pred) +// { +// assert(pos.size() > 0 || !"Approximator_QEM: attribute vector is empty") ; +// } +// ~Approximator_QEM() +// {} +// ApproximatorType getType() const { return A_QEM ; } +// bool init() ; +// void approximate(Dart d) ; +//} ; + + } //namespace Decimation diff --git a/include/Algo/DecimationVolumes/geometryApproximator.hpp b/include/Algo/DecimationVolumes/geometryApproximator.hpp index 2c7fcb1b20ad770f4728ce021b87038c8b6e3cbf..eed66afb3ea2778ebf9be642a936125757ddec10 100644 --- a/include/Algo/DecimationVolumes/geometryApproximator.hpp +++ b/include/Algo/DecimationVolumes/geometryApproximator.hpp @@ -53,19 +53,78 @@ void Approximator_MidEdge::approximate(Dart d) MAP& m = this->m_map ; // get some darts - Dart dd = m.phi2(d) ; + Dart d1 = m.phi1(d) ; // get the contracted edge vertices positions - VEC3 v1 = this->m_attrV[d] ; - VEC3 v2 = this->m_attrV[dd] ; + VEC3 v1 = this->m_attrV[0]->operator[](d) ; + VEC3 v2 = this->m_attrV[0]->operator[](d1) ; // Compute the approximated position - this->m_approx[d] = (v1 + v2) / REAL(2) ; + this->m_approx[0][d] = (v1 + v2) / REAL(2) ; -// if(this->m_predictor) -// { -// -// } + //TODO predictor part +} + +/************************************************************************************ + * MID FACE * + ************************************************************************************/ + +template +bool Approximator_MidFace::init() +{ + return true ; +} + +template +void Approximator_MidFace::approximate(Dart d) +{ + MAP& m = this->m_map ; + + // get some darts + Dart d1 = m.phi1(d) ; + Dart d_1 = m.phi_1(d) ; + + // get the contracted edge vertices positions + VEC3 v1 = this->m_attrV[0]->operator[](d) ; + VEC3 v2 = this->m_attrV[0]->operator[](d1) ; + VEC3 v3 = this->m_attrV[0]->operator[](d_1) ; + + // Compute the approximated position + this->m_approx[0][d] = (v1 + v2 + v3) / REAL(3) ; + + //TODO predictor part +} + +/************************************************************************************ + * MID VOLUME * + ************************************************************************************/ + +template +bool Approximator_MidVolume::init() +{ + return true ; +} + +template +void Approximator_MidVolume::approximate(Dart d) +{ + MAP& m = this->m_map ; + + // get some darts + Dart d1 = m.phi1(d) ; + Dart d_1 = m.phi_1(d) ; + Dart d2_1 = m.phi_1(m.phi2(d)) ; + + // get the contracted edge vertices positions + VEC3 v1 = this->m_attrV[0]->operator[](d) ; + VEC3 v2 = this->m_attrV[0]->operator[](d1) ; + VEC3 v3 = this->m_attrV[0]->operator[](d_1) ; + VEC3 v4 = this->m_attrV[0]->operator[](d2_1) ; + + // Compute the approximated position + this->m_approx[0][d] = (v1 + v2 + v3 + v4) / REAL(4) ; + + //TODO predictor part } /************************************************************************************ @@ -73,54 +132,37 @@ void Approximator_MidEdge::approximate(Dart d) ************************************************************************************/ template -bool Approximator_HalfCollapse::init() +bool Approximator_HalfEdgeCollapse::init() { -// if(this->m_predictor) -// { -// if(! ( this->m_predictor->getType() == P_HalfCollapse ) ) -// { -// return false ; -// } -// } return true ; } template -void Approximator_HalfCollapse::approximate(Dart d) +void Approximator_HalfEdgeCollapse::approximate(Dart d) { MAP& m = this->m_map ; - this->m_approx[d] = this->m_attrV[d]; + for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i) + this->m_approx[i][d] = this->m_attrV[i]->operator[](d) ; + + //TODO predictor part +} +///************************************************************************************ +// * QUADRIC ERROR METRIC * +// ************************************************************************************/ +//template +//bool Approximator_QEM::init() +//{ +// m_quadric = this->m_map.template getAttribute, VERTEX>("QEMquadric") ; +// // Does not require to be valid (if it is not, altenatives will be used). +// // if(this->m_predictor) // { -// Dart dd = m.phi2(d) ; -// Dart d2 = m.phi2(m.phi_1(d)) ; -// Dart dd2 = m.phi2(m.phi_1(dd)) ; -// -// VEC3 v2 = this->m_attrV[0]->operator[](dd) ; -// -// // temporary edge collapse -// m.extractTrianglePair(d) ; -// unsigned int newV = m.template embedNewCell(d2) ; -// for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i) -// { -// this->m_attrV[i]->operator[](newV) = this->m_approx[i][d] ; -// } -// -// // compute the detail vector -// this->m_predictor->predict(d2, dd2) ; -// for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i) -// { -// this->m_detail[i][d] = v2 - this->m_predictor->getPredict(1) ; -// } -// -// // vertex split to reset the initial connectivity and embeddings -// m.insertTrianglePair(d, d2, dd2) ; -// m.template embedOrbit(d, m.template getEmbedding(d)) ; -// m.template embedOrbit(dd, m.template getEmbedding(dd)) ; +// return false ; // } -} +// return true ; +//} } //end namespace Decimation diff --git a/include/Algo/DecimationVolumes/selector.h b/include/Algo/DecimationVolumes/selector.h index 3fb5b8dd9924382b4157d56c615644066cf9b9dc..2a92202e6b04972a44c2c9dcafe7f64a7326aea5 100644 --- a/include/Algo/DecimationVolumes/selector.h +++ b/include/Algo/DecimationVolumes/selector.h @@ -26,7 +26,7 @@ enum SelectorType } ; template class ApproximatorGen ; -template class Approximator ; +template class Approximator ; /******************************************************************************** * Parent Selector * @@ -62,13 +62,13 @@ public: virtual void updateWithoutCollapse() = 0; }; -} //end namespace Decimation +} // namespace Decimation -} //namespace Volume +} // namespace Volume -} //end namespace Algo +} // namespace Algo -} //end namespace CGoGN +} // namespace CGoGN #endif diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm.h b/include/Algo/ImplicitHierarchicalMesh/ihm.h index 9fd92a6d8e810f984a0167057ef3a0e9fa25541f..7d7974bdcdd834f319778a5f98d5d09ae8ad30dc 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm.h +++ b/include/Algo/ImplicitHierarchicalMesh/ihm.h @@ -142,6 +142,7 @@ public: void setDartLevel(Dart d, unsigned int i) ; + /*************************************************** * EDGE ID MANAGEMENT * ***************************************************/ @@ -160,6 +161,8 @@ public: void setEdgeId(Dart d, unsigned int i) ; + unsigned int getMaxEdgeId(); + /*************************************************** * CELLS INFORMATION * ***************************************************/ diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm.hpp index 477f15d9a0ff5b72098d33fc84ed1d0b8619fe96..eb468c156295055f51baa2e6c477b28e576a2855 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm.hpp @@ -326,6 +326,11 @@ inline void ImplicitHierarchicalMap::setEdgeId(Dart d, unsigned int i) m_edgeId[d] = i ; } +inline unsigned int ImplicitHierarchicalMap::getMaxEdgeId() +{ + return m_idCount; +} + /*************************************************** * CELLS INFORMATION * ***************************************************/ diff --git a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp index 64339aaa7e73a25c35cbbdf6dc9756b2d34e229e..74f80fcc95f56a07b705ba3782d66ea8a41d8866 100644 --- a/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/ihm3.hpp @@ -146,6 +146,7 @@ inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d) it = Map3::phi2(it) ; + /* du cote des volumes non subdivise (subdiv adapt) */ if(m_faceId[it] == faceId) return it; else diff --git a/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp b/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp index c0b35f0158e6d918559343dc00b2dc5955ef5cba..77a26d99384bb1a912b6b4c421b8b687d3061a00 100644 --- a/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp +++ b/include/Algo/ImplicitHierarchicalMesh/subdivision.hpp @@ -72,6 +72,8 @@ void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute(map, old, position); + typename PFP::VEC3 volCenter = Algo::Surface::Geometry::volumeCentroid(map, old, position); Traversor3WV traV(map, old); @@ -672,7 +672,7 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler(map, old, position); + typename PFP::VEC3 volCenter = Algo::Surface::Geometry::volumeCentroid(map, old, position); /* * Subdivide Faces diff --git a/include/Algo/Import/importObjEle.hpp b/include/Algo/Import/importObjEle.hpp index eb64af7399046a44c51f364006663dda4f3a75c7..6f725edca2096dcf54eab437ba72307ea1d0171a 100644 --- a/include/Algo/Import/importObjEle.hpp +++ b/include/Algo/Import/importObjEle.hpp @@ -156,8 +156,14 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename oss >> pt[2]; oss >> pt[3]; +// oss >> pt[1]; +// oss >> pt[2]; +// oss >> pt[3]; +// oss >> pt[0]; + + //regions ? - oss >> nbe; + //oss >> nbe; // Embed three vertices for(unsigned int j = 0 ; j < 3 ; ++j) @@ -198,44 +204,44 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename foff.close(); fele.close(); - //Association des phi3 - unsigned int nbBoundaryFaces = 0 ; - for (Dart d = map.begin(); d != map.end(); map.next(d)) - { - if (m.isMarked(d)) - { - std::vector& vec = vecDartsPerVertex[map.phi1(d)]; - - Dart good_dart = NIL; - for(typename std::vector::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) - { - if(map.template getEmbedding(map.phi1(*it)) == map.template getEmbedding(d) && - map.template getEmbedding(map.phi_1(*it)) == map.template getEmbedding(map.phi_1(d)) /*&& - map.template getEmbedding(*it) == map.template getEmbedding(map.phi1(d)) */) - { - good_dart = *it ; - } - } - - if (good_dart != NIL) - { - map.sewVolumes(d, good_dart, false); - m.template unmarkOrbit(d); - } - else - { - m.template unmarkOrbit(d); - ++nbBoundaryFaces; - } - } - } - - if (nbBoundaryFaces > 0) - { - std::cout << "closing" << std::endl ; - map.closeMap(); - CGoGNout << "Map closed (" << nbBoundaryFaces << " boundary faces)" << CGoGNendl; - } +// //Association des phi3 +// unsigned int nbBoundaryFaces = 0 ; +// for (Dart d = map.begin(); d != map.end(); map.next(d)) +// { +// if (m.isMarked(d)) +// { +// std::vector& vec = vecDartsPerVertex[map.phi1(d)]; +// +// Dart good_dart = NIL; +// for(typename std::vector::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) +// { +// if(map.template getEmbedding(map.phi1(*it)) == map.template getEmbedding(d) && +// map.template getEmbedding(map.phi_1(*it)) == map.template getEmbedding(map.phi_1(d)) /*&& +// map.template getEmbedding(*it) == map.template getEmbedding(map.phi1(d)) */) +// { +// good_dart = *it ; +// } +// } +// +// if (good_dart != NIL) +// { +// map.sewVolumes(d, good_dart, false); +// m.template unmarkOrbit(d); +// } +// else +// { +// m.template unmarkOrbit(d); +// ++nbBoundaryFaces; +// } +// } +// } +// +// if (nbBoundaryFaces > 0) +// { +// std::cout << "closing" << std::endl ; +// map.closeMap(); +// CGoGNout << "Map closed (" << nbBoundaryFaces << " boundary faces)" << CGoGNendl; +// } return true; } diff --git a/include/Algo/Modelisation/subdivision3.h b/include/Algo/Modelisation/subdivision3.h index 05d7a5a7ef70b85a2d13900bd0692a78308a3f22..2ac20c64dc3f4e24d0e73694687d655bcb915fd9 100644 --- a/include/Algo/Modelisation/subdivision3.h +++ b/include/Algo/Modelisation/subdivision3.h @@ -100,6 +100,9 @@ void catmullClarkVol(typename PFP::MAP& map, VertexAttribute template void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& position); +template +void relaxation(typename PFP::MAP& map, VertexAttribute& position); + template void computeDual(typename PFP::MAP& map, VertexAttribute& position); diff --git a/include/Algo/Modelisation/subdivision3.hpp b/include/Algo/Modelisation/subdivision3.hpp index a8319b71a7ebc62576f5e032a0d9f3f6231de466..2fa39fc30b66b576a8fe4ffada0f3d63b980254e 100644 --- a/include/Algo/Modelisation/subdivision3.hpp +++ b/include/Algo/Modelisation/subdivision3.hpp @@ -853,6 +853,96 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit // nlDeleteContext(nlContext); } + +// solving Ax = b + +template +void relaxation(typename PFP::MAP& map, VertexAttribute& position) +{ + VertexAttribute indexV = map.template getAttribute("indexV"); + if(!indexV.isValid()) + indexV = map.template addAttribute("indexV"); + + unsigned int nb_vertices = map.template computeIndexCells(indexV); + + //uniform weight + float weight = 1.0; + + NLContext nlContext = nlNewContext(); + nlSolverParameteri(NL_NB_VARIABLES, nb_vertices); + nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); + nlSolverParameteri(NL_SOLVER, NL_CHOLMOD_EXT); + +// nlMakeCurrent(nlContext); + if(nlGetCurrentState() == NL_STATE_INITIAL) + nlBegin(NL_SYSTEM) ; + + for(unsigned int coord = 0; coord < 3; ++coord) + { + std::cout << "coord " << coord << std::flush; + //setup variables + TraversorV tv(map); + for(Dart dit = tv.begin() ; dit != tv.end() ; dit = tv.next()) + { + nlSetVariable(indexV[dit], (position[dit])[coord]); + + if(map.isBoundaryVertex(dit)) + nlLockVariable(indexV[dit]); + } + + std::cout << "... variables set... " << std::flush; + + nlBegin(NL_MATRIX) ; + + nlEnable(NL_NORMALIZE_ROWS) ; + + TraversorV tv2(map); + for(Dart dit = tv2.begin() ; dit != tv2.end() ; dit = tv2.next()) + { + if(!map.isBoundaryVertex(dit)) + { + nlRowParameterd(NL_RIGHT_HAND_SIDE, 0) ; //b[i] + //nlRowParameterd(NL_ROW_SCALING, weight) ; + + nlBegin(NL_ROW) ; + + float sum = 0; + Traversor3VVaE tvvae(map, dit); + for(Dart ditvvae = tvvae.begin() ; ditvvae != tvvae.end() ; ditvvae = tvvae.next()) + { + nlCoefficient(indexV[ditvvae], weight); + sum += weight; + } + + nlCoefficient(indexV[dit], -sum) ; + nlEnd(NL_ROW) ; + } + } + + nlDisable(NL_NORMALIZE_ROWS) ; + + nlEnd(NL_MATRIX) ; + + nlEnd(NL_SYSTEM) ; + std::cout << "... system built... " << std::flush; + + nlSolve(); + std::cout << "... system solved... " << std::flush; + + //results + TraversorV tv3(map); + for(Dart dit = tv3.begin() ; dit != tv3.end() ; dit = tv3.next()) + { + position[dit][coord] = nlGetVariable(indexV[dit]); + } + + nlReset(NL_TRUE) ; + std::cout << "... done" << std::endl; + } + + nlDeleteContext(nlContext); +} + template void computeDual(typename PFP::MAP& map, VertexAttribute& position) { diff --git a/include/Algo/Multiresolution/Map2MR/lerpAttributes.h b/include/Algo/Multiresolution/Map2MR/lerpAttributes.h index b53fbdfb4804684941d1d7d8755f9a49378feb29..7f5251081c83719075a7c2dec4b24bf77a85d40e 100644 --- a/include/Algo/Multiresolution/Map2MR/lerpAttributes.h +++ b/include/Algo/Multiresolution/Map2MR/lerpAttributes.h @@ -46,7 +46,7 @@ namespace MR *********************************************************************************/ template -class vertexFilter : public Filter +class vertexFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -76,7 +76,7 @@ public: }while(!found && dit!=d); - m_map.template embedOrbit(dres, m_map.template getEmbedding(dres)); + m_map.template setOrbitEmbedding(dres, m_map.template getEmbedding(dres)); } // SelectorEdgeLevel ml(m_map, m_map.getCurrentLevel()); @@ -90,7 +90,7 @@ public: }; template -class LerpVertexSynthesisFilter : public Filter +class LerpVertexSynthesisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; @@ -140,7 +140,7 @@ public: template -class LerpVertexAnalysisFilter : public Filter +class LerpVertexAnalysisFilter : public Algo::MR::Filter { protected: typename PFP::MAP& m_map ; diff --git a/include/Algo/Multiresolution/Map2MR/map2MR_PM.hpp b/include/Algo/Multiresolution/Map2MR/map2MR_PM.hpp index 7b45e52d421a356bb71dc8a3ccd08ff328c9a711..732ee49fa2ad9c4436ae58a1e69c0b8570682445 100644 --- a/include/Algo/Multiresolution/Map2MR/map2MR_PM.hpp +++ b/include/Algo/Multiresolution/Map2MR/map2MR_PM.hpp @@ -88,6 +88,12 @@ void Map2MR_PM::createPM(Algo::Surface::Decimation::SelectorType s, Algo::S m_predictors.push_back(pred) ; m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge(m_map, pos_v, pred)) ; break ; } + case Algo::Surface::Decimation::A_NormalArea : + case Algo::Surface::Decimation::A_ColorQEMext : + case Algo::Surface::Decimation::A_hQEM : + case Algo::Surface::Decimation::A_hLightfieldHalf : + case Algo::Surface::Decimation::A_Lightfield : + default: break; } CGoGNout << "..done" << CGoGNendl ; @@ -109,9 +115,25 @@ void Map2MR_PM::createPM(Algo::Surface::Decimation::SelectorType s, Algo::S case Algo::Surface::Decimation::S_MinDetail : { m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail(m_map, m_position, m_approximators) ; break ; } - case Algo::Surface::Decimation::S_Curvature : { + case Algo::Surface::Decimation::S_CurvatureTensor : { m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature(m_map, m_position, m_approximators) ; break ; } + case Algo::Surface::Decimation::S_QEMml : + case Algo::Surface::Decimation::S_Curvature : + case Algo::Surface::Decimation::S_NormalArea : + case Algo::Surface::Decimation::S_ColorNaive : + case Algo::Surface::Decimation::S_QEMextColor : + case Algo::Surface::Decimation::S_hQEMextColor : + case Algo::Surface::Decimation::S_hQEMml : + case Algo::Surface::Decimation::S_Lightfield : + case Algo::Surface::Decimation::S_hLightfield : + case Algo::Surface::Decimation::S_hLightfieldExp : + case Algo::Surface::Decimation::S_hLightfieldKCL : + case Algo::Surface::Decimation::S_hColorExperimental : + case Algo::Surface::Decimation::S_hLFexperimental : + case Algo::Surface::Decimation::S_hColorPerFace : + case Algo::Surface::Decimation::S_hLFperFace : + default: break; } CGoGNout << "..done" << CGoGNendl ; @@ -291,6 +313,8 @@ Dart Map2MR_PM::vertexOrigin(Dart d) // dit = m_map.phi2(m_map.phi_1(dit)); // } // while(dit != d); + + return NIL; } //template diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm.cpp index e757d9f714e08377f597f73517d33c242084d54b..b67f157a624b580f8973a5cb09bcfd20c5658414 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm.cpp @@ -66,7 +66,14 @@ void ImplicitHierarchicalMap::clear(bool removeAttrib) void ImplicitHierarchicalMap::initImplicitProperties() { - initEdgeId() ; + //initEdgeId() ; + + //init each edge Id at 0 + TraversorE te(*this); + for(Dart dit = te.begin() ; dit != te.next() ; dit = te.next()) + { + m_edgeId[dit] = 0; + } for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) { @@ -161,20 +168,21 @@ unsigned int ImplicitHierarchicalMap::faceLevel(Dart d) unsigned int cur = m_curLevel ; m_curLevel = fLevel ; - unsigned int nbSubd = 0 ; - it = old ; - unsigned int eId = m_edgeId[old] ; // the particular case of a face - do // with all neighboring faces regularly subdivided - { // but not the face itself - ++nbSubd ; // is treated here - it = phi1(it) ; - } while(m_edgeId[it] == eId) ; - - while(nbSubd > 1) - { - nbSubd /= 2 ; - --fLevel ; - } +// unsigned int nbSubd = 0 ; +// it = old ; +// unsigned int eId = m_edgeId[old] ; // the particular case of a face +// do // with all neighboring faces regularly subdivided +// { // but not the face itself +// ++nbSubd ; // is treated here +// std::cout << "plop" << std::endl; +// it = phi1(it) ; +// } while(m_edgeId[it] == eId) ; + +// while(nbSubd > 1) +// { +// nbSubd /= 2 ; +// --fLevel ; +// } m_curLevel = cur ;