Commit 1344b138 authored by untereiner's avatar untereiner

qq modifs

parent a8ccbe42
......@@ -81,23 +81,17 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
// unsigned int vLevel = map.volumeLevel(old);
// //one level of subdivision in the neighbordhood
unsigned int vLevel = map.volumeLevel(old);
//one level of subdivision in the neighbordhood
// Traversor3VW<typename PFP::MAP> trav3EW(map, old);
// for(Dart dit = trav3EW.begin() ; dit != trav3EW.end() ; dit = trav3EW.next())
// {
// Dart oldit = map.volumeOldestDart(dit);
//
// //std::cout << "vLevel courant = " << map.volumeLevel(oldit) << std::endl;
//
// if(((vLevel+1) - map.volumeLevel(oldit)) > 1)
// Algo::IHM::subdivideVolumeClassic<PFP>(map, oldit, position);
//
//// Dart oldNeighbor = map.volumeOldestDart(map.phi3(old));
//// unsigned int vLevel = map.volumeLevel(oldNeighbor);
////
//// std::cout << "vLevel courant = " << map.volumeLevel(old) << std::endl;
//// std::cout << "vLevel voisin = " << vLevel << std::endl;
////
//// if((map.volumeLevel(old)+1) - (vLevel) > 1)
//// Algo::IHM::subdivideVolumeClassic<PFP>(map, oldNeighbor, position);
// }
unsigned int degree = 0 ;
......
......@@ -569,88 +569,92 @@ void swap5To4(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3
* Flip Functions *
************************************************************************************************/
template <typename PFP>
void flip1To4(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3>& position)
{
// typedef typename PFP::TVEC3 TVEC3;
// typedef typename PFP::VEC3 VEC3;
//
//
// //parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid
// VEC3 volCenter;
// unsigned count = 0 ;
//
// DartMarkerStore mf(map); // Lock a face marker to save one dart per face
// DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
//
// std::vector<Dart> visitedFaces;
// visitedFaces.reserve(4);
// visitedFaces.push_back(d);
//
// mf.markOrbit<FACE>(d) ;
//
// //TODO diminuer complexite avec boucle specifique aux tetras
// for(unsigned int i = 0; i < visitedFaces.size(); ++i)
// {
// Dart e = visitedFaces[i] ;
// do
// {
// //compute volume centroid
// if(!mv.isMarked(e))
// {
// volCenter += position[e];
// ++count;
// mv.markOrbit<VERTEX>(e);
// }
//
// // add all face neighbours to the table
// Dart ee = map.phi2(e) ;
// if(!mf.isMarked(ee)) // not already marked
// {
// visitedFaces.push_back(ee) ;
// mf.markOrbit<FACE>(ee) ;
// }
//
// e = map.phi1(e) ;
// } while(e != visitedFaces[i]) ;
// }
//
// volCenter /= typename PFP::REAL(count) ;
//
// //store the new faces to 3-sew
// std::vector<std::pair<Dart,Dart> > nFaces;
// nFaces.reserve(6);
//
// //triangule chaque face avec plongement au centroid
// for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
// {
// // on decoud et on ferme le trou
// Dart temp = *face;
// do
// {
// nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp)));
// map.unsewFaces(temp);
// temp = map.phi1(temp);
// }
// while(temp != *face);
//
// map.closeHole(*face);
//
// Dart fi = map.phi2(*face);
//
// Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi);
// position[cd] = volCenter;
// }
//
// //coudre les nouveaux brins entre eux par phi3
// for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
// {
//
// if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
// map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
// }
typedef typename PFP::VEC3 VEC3;
//parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid
VEC3 volCenter;
unsigned count = 0 ;
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
std::vector<Dart> visitedFaces;
visitedFaces.reserve(4);
visitedFaces.push_back(d);
mf.markOrbit<FACE>(d) ;
//TODO diminuer complexite avec boucle specifique aux tetras
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
Dart e = visitedFaces[i] ;
do
{
//compute volume centroid
if(!mv.isMarked(e))
{
volCenter += position[e];
++count;
mv.markOrbit<VERTEX>(e);
}
// add all face neighbours to the table
Dart ee = map.phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit<FACE>(ee) ;
}
e = map.phi1(e) ;
} while(e != visitedFaces[i]) ;
}
volCenter /= typename PFP::REAL(count) ;
//store the new faces to 3-sew
std::vector<std::pair<Dart,Dart> > nFaces;
nFaces.reserve(6);
//triangule chaque face avec plongement au centroid
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
// on decoud et on ferme le trou
Dart temp = *face;
do
{
nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp)));
map.unsewFaces(temp);
temp = map.phi1(temp);
}
while(temp != *face);
map.PFP::MAP::ParentMap::closeHole(*face);
Dart fi = map.phi2(*face);
Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi);
position[cd] = volCenter;
}
//coudre les nouveaux brins entre eux par phi3
for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
{
if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
}
}
/************************************************************************************************
* Bisection Functions *
************************************************************************************************/
......
......@@ -57,14 +57,9 @@ public:
private:
MAP& m_map ;
VertexAttribute<VEC3>& m_position;
bool shareVertexEmbeddings ;
//SelectorUnmarked dartSelect ;
bool m_initOk ;
DartMarker& inactiveMarker;
Algo::Decimation::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Decimation::PredictorGen<PFP>*> m_predictors ;
......@@ -72,13 +67,14 @@ private:
Algo::Decimation::Approximator<PFP, VEC3>* m_positionApproximator ;
public:
Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position, DartMarker& inactive,
Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a) ;
Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position);
~Map2MR_PM();
//create a progressive mesh (a coarser level)
void createPM(unsigned int percentWantedVertices);
void createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a, const FunctorSelect& select = allDarts) ;
void addNewLevel(unsigned int percentWantedVertices);
//coarsen the mesh -> analysis
void coarsen() ;
......
......@@ -33,10 +33,28 @@ namespace Multiresolution
{
template <typename PFP>
Map2MR_PM<PFP>::Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position, DartMarker& inactive,
Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a
) :
m_map(map), m_position(position), inactiveMarker(inactive)
Map2MR_PM<PFP>::Map2MR_PM(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position) : m_map(map), m_position(position)
{
//TODO
//map.enableMR();
}
template <typename PFP>
Map2MR_PM<PFP>::~Map2MR_PM()
{
if(m_selector)
delete m_selector ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
delete (*it) ;
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
delete (*it) ;
//TODO
//map.disableMR()
}
template <typename PFP>
void Map2MR_PM<PFP>::createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a, const FunctorSelect& select = allDarts)
{
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
......@@ -75,22 +93,22 @@ Map2MR_PM<PFP>::Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position, DartMarker&
switch(s)
{
case Algo::Decimation::S_MapOrder : {
m_selector = new Algo::Decimation::EdgeSelector_MapOrder<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_MapOrder<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
case Algo::Decimation::S_Random : {
m_selector = new Algo::Decimation::EdgeSelector_Random<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_Random<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
case Algo::Decimation::S_EdgeLength : {
m_selector = new Algo::Decimation::EdgeSelector_Length<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_Length<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
case Algo::Decimation::S_QEM : {
m_selector = new Algo::Decimation::EdgeSelector_QEM<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_QEM<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
case Algo::Decimation::S_MinDetail : {
m_selector = new Algo::Decimation::EdgeSelector_MinDetail<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_MinDetail<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
case Algo::Decimation::S_Curvature : {
m_selector = new Algo::Decimation::EdgeSelector_Curvature<PFP>(m_map, m_position, m_approximators, allDarts) ;
m_selector = new Algo::Decimation::EdgeSelector_Curvature<PFP>(m_map, m_position, m_approximators, select) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
......@@ -112,32 +130,22 @@ Map2MR_PM<PFP>::Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position, DartMarker&
if(! (*it)->init())
m_initOk = false ;
CGoGNout << "..done" << CGoGNendl ;
}
template <typename PFP>
Map2MR_PM<PFP>::~Map2MR_PM()
{
if(m_selector)
delete m_selector ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
delete (*it) ;
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
delete (*it) ;
CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ;
CGoGNout << "..done" << CGoGNendl ;
}
template <typename PFP>
void Map2MR_PM<PFP>::createPM(unsigned int percentWantedVertices)
void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
{
// level handling
m_map.pushLevel() ;
m_map.addLevel();
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
// PM creation
CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ;
CGoGNout << "..done" << CGoGNendl ;
unsigned int nbVertices = m_map.template getNbOrbits<VERTEX>() ;
unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ;
......@@ -153,6 +161,8 @@ void Map2MR_PM<PFP>::createPM(unsigned int percentWantedVertices)
Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
{
(*it)->approximate(d) ; // compute approximated attributes with its associated detail
......
......@@ -77,6 +77,12 @@ public:
*
*************************************************************************/
//@{
//!
/*
*
*/
void addNewLevelSqrt3(bool embedNewVertices);
//!
/*
*/
......
......@@ -103,6 +103,69 @@ void Map3MR_PrimalRegular<PFP>::splitSurfaceInVolume(std::vector<Dart>& vd, bool
/************************************************************************
* Level creation *
************************************************************************/
template <typename PFP>
void Map3MR_PrimalRegular<PFP>::addNewLevelSqrt3(bool embedNewVertices)
{
m_map.pushLevel();
m_map.addLevel();
//m_map.setCurrentLevel(m_map.getMaxLevel());
unsigned int cur = m_map.getCurrentLevel();
//
TraversorW<typename PFP::MAP> travW(m_map);
for(Dart dit = travW.begin() ; dit != travW.end() ; dit = travW.next())
{
m_map.setCurrentLevel(cur+1);
//store the new faces to 3-sew
std::vector<std::pair<Dart,Dart> > nFaces;
nFaces.reserve(6);
Traversor3WF<typename PFP::MAP> travWF(m_map, dit);
for(Dart ditWF = travWF.begin() ; ditWF != travWF.end() ; ditWF = travWF.next())
{
// Dart temp = ditWF;
// do
// {
// nFaces.push_back(std::pair<Dart,Dart>(temp, m_map.phi2(temp)));
// m_map.unsewFaces(temp);
// temp = m_map.phi1(temp);
// }
// while(temp != ditWF);
//
// m_map.PFP::MAP::ParentMap::closeHole(ditWF, false);
//Dart fi = map.phi2(*face);
// std::vector<Dart> split;
// split.push_back(ditWF);
// split.push_back(m_map.phi1(ditWF));
// split.push_back(m_map.phi_1(ditWF));
//
// splitSurfaceInVolume(split,true,false);
}
//Dart fi = map.phi2(*face);
// //coudre les nouveaux brins entre eux par phi3
// for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
// {
//
// if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
// map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
// }
//
m_map.setCurrentLevel(cur);
}
m_map.setCurrentLevel(m_map.getMaxLevel());
}
template <typename PFP>
void Map3MR_PrimalRegular<PFP>::addNewLevelTetraOcta(bool embedNewVertices)
{
......
......@@ -728,10 +728,13 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersMoreThanOne(Dart d)
unsigned int vLevel = volumeLevel(d);
bool isMoreThanOne = false;
// std::cout << "niveau du courant : " << vLevel << std::endl;
Traversor3WWaV<ImplicitHierarchicalMap3> trav3WWaV(*this, d);
for(Dart dit = trav3WWaV.begin() ; !isMoreThanOne && dit != trav3WWaV.end() ; dit = trav3WWaV.next())
{
//Dart oldit = volumeOldestDart(dit);
// std::cout << "niveau du voisin : " << volumeLevel(dit) << std::endl;
// std::cout << "difference de niveau avec voisin : " << abs((volumeLevel(dit) - vLevel)) << std::endl;
if(abs((volumeLevel(dit) - vLevel)) > 1)
isMoreThanOne = true;
}
......@@ -751,18 +754,21 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersMoreThanOne(Dart d)
bool ImplicitHierarchicalMap3::coarsenNeighborhoodLevelDiffersMoreThanOne(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//assert(m_curLevel > 0 || !"Coarsen a volume at level 0");
// assert(m_curLevel > 0 || !"Coarsen a volume at level 0");
Dart old = volumeOldestDart(d);
unsigned int vLevel = volumeLevel(d)-1;
bool isMoreThanOne = false;
// if(m_curLevel > 0)
// --m_curLevel;
isMoreThanOne = neighborhoodLevelDiffersMoreThanOne(old);
// if(m_curLevel > 0)
// ++m_curLevel;
// std::cout << "niveau du courant : " << vLevel << std::endl;
Traversor3WWaV<ImplicitHierarchicalMap3> trav3WWaV(*this, d);
for(Dart dit = trav3WWaV.begin() ; !isMoreThanOne && dit != trav3WWaV.end() ; dit = trav3WWaV.next())
{
//Dart oldit = volumeOldestDart(dit);
// std::cout << "niveau du voisin : " << volumeLevel(dit) << std::endl;
// std::cout << "difference de niveau avec voisin : " << abs((volumeLevel(dit) - vLevel)) << std::endl;
if(abs((volumeLevel(dit) - vLevel)) > 1)
isMoreThanOne = true;
}
return isMoreThanOne;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment