Commit ff4aabbc authored by untereiner's avatar untereiner

adding MR dual surfaces

parent 192f8eaf
/*******************************************************************************
* 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_DOOSABIN_MASK__
#define __MR_DOOSABIN_MASK__
#include <cmath>
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace MR
{
namespace Dual
{
namespace Filters
{
template <typename PFP>
class DooSabinVertexSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
DooSabinVertexSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
for (Dart dV = m_map.begin(); dV != m_map.end(); m_map.next(dV))
{
typename PFP::VEC3 p(0.0);
unsigned int N = m_map.faceDegree(dV);
typename PFP::REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N);
p += K0 * m_position[dV];
unsigned int j = 1;
Dart tmp = m_map.phi1(dV);
do
{
typename PFP::REAL Kj = (3.0 + 2.0 * cos(2.0 * double(j) * M_PI / double(N))) / (4.0 * N);
p += Kj * m_position[tmp];
tmp = m_map.phi1(tmp);
++j;
}while(tmp != dV);
m_map.incCurrentLevel();
m_position[dV] = p;
m_map.decCurrentLevel();
}
}
} ;
} // namespace Masks
} // namespace Primal
} // namespace MR
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#endif
......@@ -43,7 +43,7 @@ namespace Regular
template <typename PFP>
Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(true)
shareVertexEmbeddings(false)
{
}
......@@ -68,58 +68,68 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
m_map.addLevelBack() ;
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel()-1) ;
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
TraversorV<typename PFP::MAP> travV(m_map) ;
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
m_map.decCurrentLevel();
TraversorE<typename PFP::MAP> te(m_map);
for (Dart d = te.begin(); d != te.end(); d = te.next())
{
//create new faces in the previous edges
unsigned int count = 0;
Dart ditv = d;
do
m_map.incCurrentLevel();
Dart d2 = m_map.phi2(d);
m_map.unsewFaces(d,false);
Dart nf = m_map.newFace(4,false);
m_map.sewFaces(d,nf,false);
m_map.sewFaces(d2,m_map.phi1(m_map.phi1(nf)),false);
// take care of edge embedding
if(m_map.template isOrbitEmbedded<EDGE>())
{
Dart d2 = m_map.phi2(ditv);
m_map.template setOrbitEmbedding<EDGE>(nf, m_map.template getEmbedding<EDGE>(d));
m_map.template setOrbitEmbedding<EDGE>(m_map.phi1(m_map.phi1(nf)), m_map.template getEmbedding<EDGE>(d2));
}
m_map.decCurrentLevel();
}
TraversorV<typename PFP::MAP> tv(m_map);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
m_map.incCurrentLevel();
m_map.incCurrentLevel();
m_map.PFP::MAP::TOPO_MAP::closeHole(m_map.phi1(m_map.phi2(d)),false);
if(m_map.phi2(d) == d2)
Dart temp = m_map.phi2(m_map.phi1(m_map.phi2(d)));
Dart stop = temp;
do
{
if(m_map.template isOrbitEmbedded<EDGE>())
{
m_map.template setOrbitEmbedding<EDGE>(temp, m_map.template getEmbedding<EDGE>( m_map.phi2(temp)));
}
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);
if(!shareVertexEmbeddings)
{
//if(m_map.template getEmbedding<VERTEX>(d) == EMBNULL)
m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(temp) ;
//m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d2) ;
}
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);
temp = m_map.phi1(temp);
}
while(temp != stop);
m_map.decCurrentLevel();
}
m_map.incCurrentLevel() ;
m_map.popLevel() ;
}
......
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