Commit 6a58a080 authored by untereiner's avatar untereiner

Dual Regular subdivision + removeFrontLevel() in an MR map

parent ea93f7ca
...@@ -330,6 +330,7 @@ void MyQT::cb_mousePress(int button, int x, int y) ...@@ -330,6 +330,7 @@ void MyQT::cb_mousePress(int button, int x, int y)
{ {
if (d != Dart::nil()) if (d != Dart::nil())
m_selected = d; m_selected = d;
std::cout << myMap.edgeCanCollapse(d) << std::endl;
} }
if (button == Qt::RightButton) if (button == Qt::RightButton)
{ {
......
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __MR_CC_MASK__
#define __MR_CC_MASK__
#include <cmath>
namespace CGoGN
{
namespace Algo
{
namespace MR
{
namespace Dual
{
namespace Filters
{
template <typename PFP>
class CCVertexSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
CCVertexSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorV<typename PFP::MAP> trav(m_map) ;
for (Dart dV = trav.begin(); dV != trav.end(); dV = trav.next())
{
m_map.incCurrentLevel() ;
Dart start = m_map.phi2(m_map.phi1(m_map.phi2(dV)));
Dart dit = start;
do
{
Dart d = m_map.phi1(m_map.phi2(m_map.phi1(m_map.phi2(dit))));
unsigned int degree = m_map.faceDegree(d);
typename PFP::VEC3 p(0.0);
typename PFP::REAL a0 = 1.0 / 2.0 + 1.0 / (4.0 * typename PFP::REAL(degree));
typename PFP::REAL a1 = 1.0 / 8.0 + 1.0 / (4.0 * typename PFP::REAL(degree));
typename PFP::REAL ak_1 = a1;
if(degree == 3)
{
p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)] + ak_1 * m_position[m_map.phi_1(d)];
m_map.incCurrentLevel();
m_position[d] = p;
m_map.decCurrentLevel();
}
else if(degree == 4)
{
typename PFP::REAL a2 = 1.0 / (4.0 * typename PFP::REAL(degree));
p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)] + a2 * m_position[m_map.phi1(m_map.phi1(d))] + ak_1 * m_position[m_map.phi_1(d)];
m_map.incCurrentLevel();
m_position[d] = p;
}
else
{
p += a0 * m_position[d] + a1 * m_position[m_map.phi1(d)];
Dart end = m_map.phi_1(m_map.phi_1(d));
Dart dit = m_map.phi1(m_map.phi1(d));
do
{
typename PFP::REAL ai = 1.0 / (4.0 * typename PFP::REAL(degree));
p += ai * m_position[dit];
dit = m_map.phi1(dit);
}
while(dit != end);
p += ak_1 * m_position[m_map.phi_1(d)];
m_map.incCurrentLevel();
m_position[d] = p;
}
dit = m_map.phi1(dit);
}
while(dit != start);
}
m_map.decCurrentLevel();
}
} ;
} // namespace Masks
} // namespace Primal
} // namespace MR
} // namespace Algo
} // namespace CGoGN
#endif
...@@ -408,7 +408,7 @@ public: ...@@ -408,7 +408,7 @@ public:
e *= u / degree; e *= u / degree;
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
m_position[m_map.phi2(m_map.phi1(d))] -= v - e ; m_position[m_map.phi2(m_map.phi1(d))] = m_position[m_map.phi2(m_map.phi1(d))] - v - e ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
......
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __MAP2MR_DUAL_REGULAR__
#define __MAP2MR_DUAL_REGULAR__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Algo/Multiresolution/filter.h"
namespace CGoGN
{
namespace Algo
{
namespace MR
{
namespace Dual
{
namespace Regular
{
template <typename PFP>
class Map2MR
{
public:
typedef typename PFP::MAP MAP ;
protected:
MAP& m_map;
bool shareVertexEmbeddings ;
std::vector<Filter*> synthesisFilters ;
std::vector<Filter*> analysisFilters ;
public:
Map2MR(MAP& map);
~Map2MR();
//if true : tri and quad else quad
void addNewLevel(bool embedNewVertices = true) ;
void addSynthesisFilter(Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
void analysis() ;
void synthesis() ;
} ;
} // namespace Regular
} // namespace Dual
} // namespace MR
} // namespace Algo
} // namespace CGoGN
#include "Algo/Multiresolution/Map2MR/map2MR_DualRegular.hpp"
#endif
/*******************************************************************************
* 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 MR
{
namespace Dual
{
namespace Regular
{
template <typename PFP>
Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(true)
{
}
template <typename PFP>
Map2MR<PFP>::~Map2MR()
{
unsigned int level = m_map.getCurrentLevel();
unsigned int maxL = m_map.getMaxLevel();
for(unsigned int i = maxL ; i > level ; --i)
m_map.removeLevelBack();
for(unsigned int i = 0 ; i < level ; ++i)
m_map.removeLevelFront();
}
template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
{
m_map.pushLevel() ;
m_map.addLevelBack() ;
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel()-1) ;
TraversorV<typename PFP::MAP> travV(m_map) ;
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
{
//create new faces in the previous edges
unsigned int count = 0;
Dart ditv = d;
do
{
Dart d2 = m_map.phi2(ditv);
m_map.incCurrentLevel();
if(m_map.phi2(d) == d2)
{
m_map.unsewFaces(d, false);
Dart nf = m_map.newFace(4,false);
m_map.sewFaces(nf,d,false);
m_map.sewFaces(m_map.phi1(m_map.phi1(nf)),d2,false);
}
m_map.decCurrentLevel();
++count;
ditv = m_map.phi2(m_map.phi_1(ditv));
}while(ditv != d);
// // create new faces in the previous vertices
// Dart nf = m_map.newFace(count,false);
// do
// {
// m_map.incCurrentLevel();
//
// Dart d21 = m_map.phi1(m_map.phi2(ditv));
// m_map.sewFaces(nf,d21,false);
//
// if(embedNewVertices)
// m_map.template embedNewCell<VERTEX>(nf) ;
//
// nf = m_map.phi1(nf);
//
// m_map.decCurrentLevel();
//
//
// ditv = m_map.phi2(m_map.phi_1(ditv));
// }while(ditv != d);
}
m_map.popLevel() ;
}
template <typename PFP>
void Map2MR<PFP>::analysis()
{
assert(m_map.getCurrentLevel() > 0 || !"analysis : called on level 0") ;
m_map.decCurrentLevel() ;
for(unsigned int i = 0; i < analysisFilters.size(); ++i)
(*analysisFilters[i])() ;
}
template <typename PFP>
void Map2MR<PFP>::synthesis()
{
assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ;
for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
(*synthesisFilters[i])() ;
m_map.incCurrentLevel() ;
}
} // namespace Regular
} // namespace Dual
} // namespace MR
} // namespace Algo
} // namespace CGoGN
...@@ -60,7 +60,9 @@ protected: ...@@ -60,7 +60,9 @@ protected:
std::vector<Filter*> analysisFilters ; std::vector<Filter*> analysisFilters ;
public: public:
Map2MR(MAP& map) ; Map2MR(MAP& map);
~Map2MR();
//if true : tri and quad else quad //if true : tri and quad else quad
void addNewLevel(bool triQuad = true, bool embedNewVertices = true) ; void addNewLevel(bool triQuad = true, bool embedNewVertices = true) ;
......
...@@ -45,6 +45,19 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) : ...@@ -45,6 +45,19 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
} }
template <typename PFP>
Map2MR<PFP>::~Map2MR()
{
unsigned int level = m_map.getCurrentLevel();
unsigned int maxL = m_map.getMaxLevel();
for(unsigned int i = maxL ; i > level ; --i)
m_map.removeLevelBack();
for(unsigned int i = 0 ; i < level ; ++i)
m_map.removeLevelFront();
}
template <typename PFP> template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool triQuad, bool embedNewVertices) void Map2MR<PFP>::addNewLevel(bool triQuad, bool embedNewVertices)
{ {
......
...@@ -89,17 +89,6 @@ public: ...@@ -89,17 +89,6 @@ public:
* *
*/ */
virtual void swapEdges(Dart d, Dart e); virtual void swapEdges(Dart d, Dart e);
// /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e
// */
// virtual void insertEdgeInVertex(Dart d, Dart e);
//
// /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e
// */
// virtual void removeEdgeFromVertex(Dart d);
/** /**
* The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge * The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge
...@@ -111,7 +100,7 @@ public: ...@@ -111,7 +100,7 @@ public:
* The attributes attached to the vertices of the old edge of d are duplicated on the vertices of both resulting edges * The attributes attached to the vertices of the old edge of d are duplicated on the vertices of both resulting edges
* The attributes attached to the old edge are duplicated on both resulting edges * The attributes attached to the old edge are duplicated on both resulting edges
*/ */
virtual void unsewFaces(Dart d) ; virtual void unsewFaces(Dart d, bool withBoundary = true) ;
/** /**
* The attributes attached to the edge of d are kept on the resulting edge * The attributes attached to the edge of d are kept on the resulting edge
......
...@@ -228,7 +228,7 @@ public: ...@@ -228,7 +228,7 @@ public:
/*! \pre Edge of dart d MUST NOT be a boundary edge /*! \pre Edge of dart d MUST NOT be a boundary edge
* @param d a dart of a face * @param d a dart of a face
*/ */
virtual void unsewFaces(Dart d); virtual void unsewFaces(Dart d, bool withBoundary = true);
//! Delete an oriented face if and only if it has one or two edges //! Delete an oriented face if and only if it has one or two edges
/*! If the face is sewed to two distinct adjacent faces, /*! If the face is sewed to two distinct adjacent faces,
......
...@@ -283,7 +283,33 @@ void GenericMap::removeLevelBack() ...@@ -283,7 +283,33 @@ void GenericMap::removeLevelBack()
void GenericMap::removeLevelFront() void GenericMap::removeLevelFront()
{ {
std::cout << "TO DO" << std::endl; unsigned int maxL = getMaxLevel() ;
if(maxL > 0) //must have at min 2 levels (0 and 1) to remove the front one
{
AttributeMultiVector<unsigned int>* minMR = m_mrDarts[0] ;
AttributeMultiVector<unsigned int>* firstMR = m_mrDarts[1] ;
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int idx = (*minMR)[i] ;
if((*m_mrLevels)[i] != 0) // if the MRdart was introduced after the level we're removing
{
--(*m_mrLevels)[i]; //decrement his level of insertion
}
else // if the dart was introduced on a this level and not used after
{
// if(idx != (*firstMR)[i]) // delete the pointed dart line only if
// deleteDartLine(idx) ; // it is not shared with next level
}
}
m_mrNbDarts[1] += m_mrNbDarts[0];
m_mrattribs.removeAttribute<unsigned int>(minMR->getIndex()) ;
m_mrDarts.erase(m_mrDarts.begin()) ;
m_mrNbDarts.erase(m_mrNbDarts.begin()) ;
--m_mrCurrentLevel ;
}
} }
void GenericMap::copyLevel(unsigned int level) void GenericMap::copyLevel(unsigned int level)
......
...@@ -231,55 +231,6 @@ void EmbeddedMap2::swapEdges(Dart d, Dart e) ...@@ -231,55 +231,6 @@ void EmbeddedMap2::swapEdges(Dart d, Dart e)
embedNewCell<VOLUME>(d); embedNewCell<VOLUME>(d);
} }
//void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e)
//{
// Map2::insertEdgeInVertex(d, e);
//
// if (isOrbitEmbedded<VERTEX>())
// {
// copyDartEmbedding<VERTEX>(e, d) ;
// }
//
// if (isOrbitEmbedded<FACE>())
// {
// if(!sameFace(d,e))
// {
// embedNewCell<FACE>(e);
// copyCell<FACE>(e, d) ;
// }
// else
// {
// embedOrbit<FACE>(d, getEmbedding<FACE>(d)) ;
// }
// }
//}
//
//void EmbeddedMap2::removeEdgeFromVertex(Dart d)
//{
// Dart dPrev = alpha_1(d);
//
// Map2::removeEdgeFromVertex(d);
//
// if (isOrbitEmbedded<VERTEX>())
// {
// embedNewCell<VERTEX>(d);
// copyCell<VERTEX>(d, dPrev);
// }
//
// if (isOrbitEmbedded<FACE>())
// {
// if(!sameFace(d, dPrev))
// {
// embedNewCell<FACE>(d);
// copyCell<FACE>(d, dPrev) ;
// }
// else
// {
// embedOrbit<FACE>(d, getEmbedding<FACE>(d)) ;
// }
// }
//}
void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary)
{ {
if (!withBoundary) if (!withBoundary)
...@@ -302,8 +253,14 @@ void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) ...@@ -302,8 +253,14 @@ void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary)
} }
} }
void EmbeddedMap2::unsewFaces(Dart d) void EmbeddedMap2::unsewFaces(Dart d, bool withBoundary)
{ {
if (!withBoundary)
{
Map2::unsewFaces(d, false) ;
return ;
}
Dart e = phi2(d) ; Dart e = phi2(d) ;
Map2::unsewFaces(d) ; Map2::unsewFaces(d) ;
......
...@@ -155,11 +155,11 @@ Dart EmbeddedMap3::deleteEdge(Dart d) ...@@ -155,11 +155,11 @@ Dart EmbeddedMap3::deleteEdge(Dart d)
bool EmbeddedMap3::edgeCanCollapse(Dart d)