Commit 34034512 authored by untereiner's avatar untereiner
Browse files

few changes in Multiresolution managing

parent dde45350
......@@ -27,10 +27,14 @@
#include <cmath>
#include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/tetrahedralization.h"
namespace CGoGN
{
namespace Algo
{
namespace Multiresolution
{
......@@ -47,7 +51,7 @@ public:
* LOOP BASIC FUNCTIONS
*********************************************************************************/
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 d3 = map.phi_1(d1) ;
......@@ -67,7 +71,7 @@ typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const typename PFP::TVE
}
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() ;
......@@ -93,11 +97,11 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const typename PFP::TV
* SHW04 BASIC FUNCTIONS : tetrahedral/octahedral meshes
*********************************************************************************/
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);
if(map.isTetrahedron(d))
if(Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(map, d))
{
Dart d1 = map.phi1(d) ;
Dart d2 = map.phi_1(d);
......@@ -162,10 +166,10 @@ class LoopEvenAnalysisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -188,10 +192,10 @@ class LoopNormalisationAnalysisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -218,10 +222,10 @@ class LoopOddAnalysisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -267,17 +271,28 @@ class LerpEdgeSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
{
std::cout << "lerp edges" << std::endl;
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())
{
std::cout << "edges" << std::endl;
typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
......@@ -295,14 +310,15 @@ class LerpFaceSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
{
std::cout << "lerp faces" << std::endl;
TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
......@@ -325,14 +341,15 @@ class LerpVolumeSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
{
std::cout << "lerp volumes" << std::endl;
TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
......@@ -340,7 +357,7 @@ public:
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)));
......@@ -361,10 +378,10 @@ class Ber02OddSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -450,10 +467,10 @@ class Ber02EvenSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -639,10 +656,10 @@ class Ber02ScaleSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -705,10 +722,10 @@ class LoopOddSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -748,10 +765,10 @@ class LoopNormalisationSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -778,10 +795,10 @@ class LoopEvenSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -804,10 +821,10 @@ class LoopVolumeSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -815,7 +832,7 @@ public:
TraversorW<typename PFP::MAP> trav(m_map) ;
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);
......@@ -835,10 +852,10 @@ class SHW04VolumeNormalisationSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
VertexAttribute<typename PFP::VEC3>& m_position ;
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() ()
......@@ -871,6 +888,8 @@ public:
} // namespace Multiresolution
} // namespace Algo
} // namespace CGoGN
......
......@@ -29,29 +29,40 @@
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h"
#include "Topology/map/map3MR/filters_Primal.h"
#include "Topology/map/map3MR/schemes_Primal.h"
#include "Algo/Multiresolution/map3MR/filters_Primal.h"
#include "Algo/Modelisation/tetrahedralization.h"
namespace CGoGN
{
namespace Algo
{
namespace Multiresolution
{
/*! \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:
MAP& m_map;
bool shareVertexEmbeddings;
std::vector<Multiresolution::MRFilter*> synthesisFilters ;
std::vector<Multiresolution::MRFilter*> analysisFilters ;
std::vector<Multiresolution::MRScheme*> subdivisionSchemes;
std::vector<Algo::Multiresolution::MRFilter*> synthesisFilters ;
std::vector<Algo::Multiresolution::MRFilter*> analysisFilters ;
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
*
......@@ -59,113 +70,78 @@ public:
//@{
void swapEdges(Dart d, Dart e);
bool isTetrahedron(Dart d);
void splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = false);
//@}
void setSharingVertexEmbeddings(bool b) { shareVertexEmbeddings = b; }
/*! @name Level creation
*
*************************************************************************/
//@{
//!
/*
*
*/
void addNewLevelTetraOcta(bool embedNewVertices);
//!
/*
*
*/
void addNewLevelHexa(bool embedNewVertices);
//void addNewLevelHexa(bool embedNewVertices);
//!
/*
*
*/
void addNewLevel(bool embedNewVertices);
//void addNewLevel(bool embedNewVertices);
//@}
/*! @name Geometry modification
* 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() ;
//@}
/*! @name Geometry modification
* Subdivision Schemes
*************************************************************************/
//@{
//!
/*!
*
*/
void addSubdivisionScheme(Multiresolution::MRScheme* f) { assert(!shareVertexEmbeddings); subdivisionSchemes.push_back(f); }
void clearAnalysisFilters() { analysisFilters.clear() ; }
//!
/*
*
*/
void clearSubdivisionSchemes() { subdivisionSchemes.clear() ; }
void analysis() ;
//!
/*
*
*/
void subdivision() ;
void synthesis() ;
//@}
};
} //end namespace CGoGN
} // namespace Multiresolution
#endif /* __MAP3MR_PRIMAL__ */
} // namespace Algo
//void splitFaceInSurface(Dart d, Dart e);
} // namespace CGoGN
//Dart cutEdgeInSurface(Dart d);
//void saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd);
#include "Algo/Multiresolution/map3MR/map3MR_PrimalRegular.hpp"
//void unsewAroundVertex(std::vector<std::pair<Dart, Dart> >& vd);
//Dart quadranguleFace(Dart d);
#endif /* __MAP3MR_PRIMAL__ */
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace CGoGN
{
namespace Algo
{
namespace Multiresolution
{
template <typename PFP>
Map3MR_PrimalRegular<PFP>::Map3MR_PrimalRegular(typename PFP::MAP& map) : m_map(map), shareVertexEmbeddings(true)
{
// m_map.initMR();
}
/************************************************************************
* Topological helping functions *
************************************************************************/
template <typename PFP>
void Map3MR_PrimalRegular<PFP>::swapEdges(Dart d, Dart e)
{
if(!m_map.PFP::MAP::ParentMap::isBoundaryEdge(d) && !m_map.PFP::MAP::ParentMap::isBoundaryEdge(e))
{
Dart d2 = m_map.phi2(d);
Dart e2 = m_map.phi2(e);
m_map.PFP::MAP::ParentMap::swapEdges(d,e);
if(m_map.template isOrbitEmbedded<VERTEX>())
{
m_map.template copyDartEmbedding<VERTEX>(d, m_map.phi2(m_map.phi_1(d)));
m_map.template copyDartEmbedding<VERTEX>(e, m_map.phi2(m_map.phi_1(e)));
m_map.template copyDartEmbedding<VERTEX>(d2, m_map.phi2(m_map.phi_1(d2)));
m_map.template copyDartEmbedding<VERTEX>(e2, m_map.phi2(m_map.phi_1(e2)));
}
if(m_map.template isOrbitEmbedded<EDGE>())
{
}
if(m_map.template isOrbitEmbedded<VOLUME>())
m_map.template embedNewCell<VOLUME>(d);
}
}
template <typename PFP>
void Map3MR_PrimalRegular<PFP>::splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed, bool secondSideClosed)
{
std::vector<Dart> vd2 ;
vd2.reserve(vd.size());
// save the edge neighbors darts
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{
vd2.push_back(m_map.phi2(*it));
}
assert(vd2.size() == vd.size());
m_map.PFP::MAP::ParentMap::splitSurface(vd, firstSideClosed, secondSideClosed);
// follow the edge path a second time to embed the vertex, edge and volume orbits
for(unsigned int i = 0; i < vd.size(); ++i)
{
Dart dit = vd[i];
Dart dit2 = vd2[i];
// embed the vertex embedded from the origin volume to the new darts
if(m_map.template isOrbitEmbedded<VERTEX>())
{
m_map.copyDartEmbedding<VERTEX>(m_map.phi2(dit), m_map.phi1(dit));
m_map.copyDartEmbedding<VERTEX>(m_map.phi2(dit2), m_map.phi1(dit2));
}
}
}
//Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map, d);
/************************************************************************
* Level creation *
************************************************************************/
template <typename PFP>
void Map3MR_PrimalRegular<PFP>::addNewLevelTetraOcta(bool embedNewVertices)
{
m_map.pushLevel();
m_map.addLevel();
m_map.setCurrentLevel(m_map.getMaxLevel());
// if(!shareVertexEmbeddings)
// {
// //create the new level with the old one
// for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
// {
// unsigned int index = (*m_mrDarts[m_mrCurrentLevel])[i] ;
// (*m_embeddings[VERTEX])[index] = EMBNULL ; // set vertex embedding to EMBNULL if no sharing
// }
// }
//subdivision
//1. cut edges
TraversorE<typename PFP::MAP> travE(m_map);
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
// if(!shareVertexEmbeddings)
// {
// if(getEmbedding<VERTEX>(d) == EMBNULL)
// embedNewCell<VERTEX>(d) ;
// if(getEmbedding<VERTEX>(phi1(d)) == EMBNULL)
// embedNewCell<VERTEX>(d) ;
// }
std::cout << "cut edge" << std::endl;
m_map.cutEdge(d) ;
travE.