Commit 34034512 authored by untereiner's avatar untereiner
Browse files

few changes in Multiresolution managing

parent dde45350
...@@ -27,10 +27,14 @@ ...@@ -27,10 +27,14 @@
#include <cmath> #include <cmath>
#include "Algo/Geometry/centroid.h" #include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/tetrahedralization.h"
namespace CGoGN namespace CGoGN
{ {
namespace Algo
{
namespace Multiresolution namespace Multiresolution
{ {
...@@ -47,7 +51,7 @@ public: ...@@ -47,7 +51,7 @@ public:
* LOOP BASIC FUNCTIONS * LOOP BASIC FUNCTIONS
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const typename PFP::TVEC3& position, Dart d1) typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, Dart d1)
{ {
Dart d2 = map.phi2(d1) ; Dart d2 = map.phi2(d1) ;
Dart d3 = map.phi_1(d1) ; Dart d3 = map.phi_1(d1) ;
...@@ -67,7 +71,7 @@ typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const typename PFP::TVE ...@@ -67,7 +71,7 @@ typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const typename PFP::TVE
} }
template <typename PFP> template <typename PFP>
typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const typename PFP::TVEC3& position, Dart d) typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, Dart d)
{ {
map.incCurrentLevel() ; map.incCurrentLevel() ;
...@@ -93,11 +97,11 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const typename PFP::TV ...@@ -93,11 +97,11 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const typename PFP::TV
* SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes * SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const typename PFP::TVEC3& position, Dart d) typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, Dart d)
{ {
typename PFP::VEC3 res(0); typename PFP::VEC3 res(0);
if(map.isTetrahedron(d)) if(Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(map, d))
{ {
Dart d1 = map.phi1(d) ; Dart d1 = map.phi1(d) ;
Dart d2 = map.phi_1(d); Dart d2 = map.phi_1(d);
...@@ -162,10 +166,10 @@ class LoopEvenAnalysisFilter : public MRFilter ...@@ -162,10 +166,10 @@ class LoopEvenAnalysisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopEvenAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopEvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -188,10 +192,10 @@ class LoopNormalisationAnalysisFilter : public MRFilter ...@@ -188,10 +192,10 @@ class LoopNormalisationAnalysisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopNormalisationAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopNormalisationAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -218,10 +222,10 @@ class LoopOddAnalysisFilter : public MRFilter ...@@ -218,10 +222,10 @@ class LoopOddAnalysisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopOddAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -267,17 +271,28 @@ class LerpEdgeSynthesisFilter : public MRFilter ...@@ -267,17 +271,28 @@ class LerpEdgeSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LerpEdgeSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LerpEdgeSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
std::cout << "lerp edges" << std::endl;
TraversorE<typename PFP::MAP> trav(m_map) ; TraversorE<typename PFP::MAP> trav(m_map) ;
std::cout << "begin = " << m_map.begin() << std::endl;
std::cout << "end = " << m_map.end() << std::endl;
std::cout << "begin = " << trav.begin() << std::endl;
std::cout << "end = " << trav.end() << std::endl;
std::cout << "next = " << trav.next() << std::endl;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
std::cout << "edges" << std::endl;
typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5); typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
...@@ -295,14 +310,15 @@ class LerpFaceSynthesisFilter : public MRFilter ...@@ -295,14 +310,15 @@ class LerpFaceSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LerpFaceSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LerpFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
std::cout << "lerp faces" << std::endl;
TraversorF<typename PFP::MAP> trav(m_map) ; TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
...@@ -325,14 +341,15 @@ class LerpVolumeSynthesisFilter : public MRFilter ...@@ -325,14 +341,15 @@ class LerpVolumeSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LerpVolumeSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LerpVolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
std::cout << "lerp volumes" << std::endl;
TraversorW<typename PFP::MAP> trav(m_map) ; TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
...@@ -340,7 +357,7 @@ public: ...@@ -340,7 +357,7 @@ public:
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
if(!m_map.isTetrahedron(d)) if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
{ {
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
...@@ -361,10 +378,10 @@ class Ber02OddSynthesisFilter : public MRFilter ...@@ -361,10 +378,10 @@ class Ber02OddSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
Ber02OddSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -450,10 +467,10 @@ class Ber02EvenSynthesisFilter : public MRFilter ...@@ -450,10 +467,10 @@ class Ber02EvenSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
Ber02EvenSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -639,10 +656,10 @@ class Ber02ScaleSynthesisFilter : public MRFilter ...@@ -639,10 +656,10 @@ class Ber02ScaleSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
Ber02ScaleSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -705,10 +722,10 @@ class LoopOddSynthesisFilter : public MRFilter ...@@ -705,10 +722,10 @@ class LoopOddSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopOddSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -748,10 +765,10 @@ class LoopNormalisationSynthesisFilter : public MRFilter ...@@ -748,10 +765,10 @@ class LoopNormalisationSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopNormalisationSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -778,10 +795,10 @@ class LoopEvenSynthesisFilter : public MRFilter ...@@ -778,10 +795,10 @@ class LoopEvenSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopEvenSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -804,10 +821,10 @@ class LoopVolumeSynthesisFilter : public MRFilter ...@@ -804,10 +821,10 @@ class LoopVolumeSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
LoopVolumeSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) LoopVolumeSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -815,7 +832,7 @@ public: ...@@ -815,7 +832,7 @@ public:
TraversorW<typename PFP::MAP> trav(m_map) ; TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
if(!m_map.isTetrahedron(d)) if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
{ {
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position); typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
...@@ -835,10 +852,10 @@ class SHW04VolumeNormalisationSynthesisFilter : public MRFilter ...@@ -835,10 +852,10 @@ class SHW04VolumeNormalisationSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; VertexAttribute<typename PFP::VEC3>& m_position ;
public: public:
SHW04VolumeNormalisationSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) SHW04VolumeNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
...@@ -871,6 +888,8 @@ public: ...@@ -871,6 +888,8 @@ public:
} // namespace Multiresolution } // namespace Multiresolution
} // namespace Algo
} // namespace CGoGN } // namespace CGoGN
......
...@@ -29,29 +29,40 @@ ...@@ -29,29 +29,40 @@
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h" #include "Topology/generic/traversor3.h"
#include "Topology/map/map3MR/filters_Primal.h" #include "Algo/Multiresolution/map3MR/filters_Primal.h"
#include "Topology/map/map3MR/schemes_Primal.h" #include "Algo/Modelisation/tetrahedralization.h"
namespace CGoGN namespace CGoGN
{ {
namespace Algo
{
namespace Multiresolution
{
/*! \brief The class of regular 3-map MR /*! \brief The class of regular 3-map MR
*/ */
class Map3MR_PrimalRegular : public EmbeddedMap3 template <typename PFP>
class Map3MR_PrimalRegular
{ {
public:
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
protected: protected:
MAP& m_map;
bool shareVertexEmbeddings; bool shareVertexEmbeddings;
std::vector<Multiresolution::MRFilter*> synthesisFilters ; std::vector<Algo::Multiresolution::MRFilter*> synthesisFilters ;
std::vector<Multiresolution::MRFilter*> analysisFilters ; std::vector<Algo::Multiresolution::MRFilter*> analysisFilters ;
std::vector<Multiresolution::MRScheme*> subdivisionSchemes;
public: public:
Map3MR_PrimalRegular(); Map3MR_PrimalRegular(MAP& map);
virtual std::string mapTypeName() const { return "Map3MR_PrimalRegular"; } std::string mapTypeName() const { return "Map3MR_PrimalRegular"; }
/*! @name Topological helping functions /*! @name Topological helping functions
* *
...@@ -59,113 +70,78 @@ public: ...@@ -59,113 +70,78 @@ public:
//@{ //@{
void swapEdges(Dart d, Dart e); void swapEdges(Dart d, Dart e);
bool isTetrahedron(Dart d);
void splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = false); void splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = false);
//@} //@}
void setSharingVertexEmbeddings(bool b) { shareVertexEmbeddings = b; }
/*! @name Level creation /*! @name Level creation
* *
*************************************************************************/ *************************************************************************/
//@{ //@{
//! //!
/* /*
*
*/ */
void addNewLevelTetraOcta(bool embedNewVertices); void addNewLevelTetraOcta(bool embedNewVertices);
//! //!
/* /*
*
*/ */
void addNewLevelHexa(bool embedNewVertices); //void addNewLevelHexa(bool embedNewVertices);
//! //!
/* /*
*
*/ */
void addNewLevel(bool embedNewVertices); //void addNewLevel(bool embedNewVertices);
//@} //@}
/*! @name Geometry modification /*! @name Geometry modification
* Analysis / Synthesis * Analysis / Synthesis
*************************************************************************/ *************************************************************************/
//@{ //@{
//!
/*
*
*/
void addSynthesisFilter(Multiresolution::MRFilter* f) { assert(shareVertexEmbeddings); synthesisFilters.push_back(f) ; }
//! //!
/* /*
*
*/ */
void addAnalysisFilter(Multiresolution::MRFilter* f) { assert(shareVertexEmbeddings); analysisFilters.push_back(f) ; } void setSharingVertexEmbeddings(bool b) { shareVertexEmbeddings = b; }
//! //!
/* /*
*
*/ */
void clearSynthesisFilters() { synthesisFilters.clear() ; } void addSynthesisFilter(Algo::Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; }
//! //!
/* /*
*
*/ */
void clearAnalysisFilters() { analysisFilters.clear() ; } void addAnalysisFilter(Algo::Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; }
//! //!
/* /*
*
*/ */
void analysis() ; void clearSynthesisFilters() { synthesisFilters.clear() ; }
//! //!
/* /*
*
*/ */
void synthesis() ; void clearAnalysisFilters() { analysisFilters.clear() ; }
//@}
/*! @name Geometry modification
* Subdivision Schemes