Commit b7e8bfa8 authored by untereiner's avatar untereiner

begin dual volumetric subdivision

parent 6e9a3676
/*******************************************************************************
* 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 Volume
{
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() ()
{
// TraversorV<typename PFP::MAP> tv(m_map);
// for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
// {
// if(m_map.isBoundaryVertex(d))
// {
// Dart db = m_map.findBoundaryFaceOfVertex(d);
//
// typename PFP::VEC3 p(0.0);
//
// unsigned int N = m_map.faceDegree(db);
// typename PFP::REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N);
// p += K0 * m_position[db];
// unsigned int j = 1;
// Dart tmp = m_map.phi1(db);
// 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 != db);
//
// m_map.incCurrentLevel();
//
// m_position[db] = p;
//
// m_map.decCurrentLevel();
//
// }
// else
// {
// Traversor3VW<typename PFP::MAP> tvw(m_map,d);
// for(Dart dit = tvw.begin() ; dit != tvw.end() ; dit = tvw.next())
// {
// typename PFP::VEC3 p(0.0);
// unsigned int count = 0;
//
// Dart ditface = dit;
// do
// {
// typename PFP::VEC3 tmpP(0.0);
// unsigned int N = m_map.faceDegree(ditface);
// typename PFP::REAL K0 = float(N+5)/float(4*N);//(1.0 / 4.0) + (5.0 / 4.0) * double(N);
// tmpP += K0 * m_position[ditface];
// unsigned int j = 1;
// Dart tmp = m_map.phi1(ditface);
// do
// {
// typename PFP::REAL Kj = (3.0 + 2.0 * cos(2.0 * double(j) * M_PI / double(N))) / (4.0 * N);
// tmpP += Kj * m_position[tmp];
// tmp = m_map.phi1(tmp);
// ++j;
// }while(tmp != ditface);
//
// p += tmpP;
// ++count;
// ditface = m_map.phi2(m_map.phi_1(ditface));
// }
// while(ditface != dit);
//
// p /= count;
//
// m_map.incCurrentLevel();
//
// m_position[dit] = p;
//
// m_map.decCurrentLevel();
// }
// }
// }
}
} ;
} // namespace Masks
} // namespace Dual
} // namespace MR
} // namespace Volume
} // namespace Algo
} // namespace CGoGN
#endif
......@@ -363,13 +363,15 @@ public:
{
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] = p ;
m_map.decCurrentLevel() ;
}
}
}
} ;
......@@ -431,7 +433,6 @@ public:
m_position[midV] = p;
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 __MAP3MR_DUAL_REGULAR__
#define __MAP3MR_DUAL_REGULAR__
#include "Topology/map/embeddedMap3.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h"
#include "Algo/Multiresolution/filter.h"
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace MR
{
namespace Dual
{
namespace Regular
{
template <typename PFP>
class Map3MR
{
public:
typedef typename PFP::MAP MAP ;
protected:
MAP& m_map;
bool shareVertexEmbeddings ;
std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ;
public:
Map3MR(MAP& map);
~Map3MR();
//if true : tri and quad else quad
void addNewLevel(bool embedNewVertices = true) ;
void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Algo::MR::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 Volume
} // namespace Algo
} // namespace CGoGN
#include "Algo/Multiresolution/Map3MR/map3MR_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 *
* *
*******************************************************************************/
#include "Algo/Modelisation/polyhedron.h"
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace MR
{
namespace Dual
{
namespace Regular
{
template <typename PFP>
Map3MR<PFP>::Map3MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(false)
{
}
template <typename PFP>
Map3MR<PFP>::~Map3MR()
{
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 Map3MR<PFP>::addNewLevel(bool embedNewVertices)
{
m_map.pushLevel() ;
m_map.addLevelBack() ;
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
m_map.decCurrentLevel();
TraversorF<typename PFP::MAP> tf(m_map);
for (Dart d = tf.begin(); d != tf.end(); d = tf.next())
{
if(!m_map.isBoundaryFace(d))
{
unsigned int nbSides = m_map.faceDegree(d);
Dart d3 = m_map.phi3(d);
m_map.incCurrentLevel();
m_map.unsewVolumes(d,false);
Dart nf = Algo::Surface::Modelisation::createPrism<PFP>(m_map, nbSides, false);
m_map.sewVolumes(d,nf,false);
m_map.sewVolumes(d3,m_map.phi2(m_map.phi1(m_map.phi1(m_map.phi2(nf)))),false);
m_map.decCurrentLevel();
}
}
TraversorE<typename PFP::MAP> te(m_map);
for(Dart d = te.begin() ; d != te.end() ; d = te.next())
{
if(!m_map.isBoundaryEdge(d))
{
m_map.incCurrentLevel();
m_map.PFP::MAP::TOPO_MAP::closeHole(m_map.phi3(d),false);
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.PFP::MAP::TOPO_MAP::closeHole(m_map.phi2(m_map.phi_1(m_map.phi3(m_map.phi2(d)))),false);
//
// Dart temp = m_map.phi2(m_map.phi1(m_map.phi2(d)));
// Dart stop = temp;
//
// do
// {
// if(!shareVertexEmbeddings)
// {
// //if(m_map.template getEmbedding<VERTEX>(d) == EMBNULL)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(temp) ;
// //m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d2) ;
// }
//
//
// temp = m_map.phi1(temp);
// }
// while(temp != stop);
//
//
// m_map.decCurrentLevel();
// }
m_map.incCurrentLevel() ;
m_map.popLevel() ;
}
template <typename PFP>
void Map3MR<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 Map3MR<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 Surface
} // namespace Algo
} // namespace CGoGN
......@@ -107,7 +107,7 @@ public:
//!
/*!
*/
virtual void unsewVolumes(Dart d);
virtual void unsewVolumes(Dart d, bool withBoundary = true);
//!
/*!
......
......@@ -262,7 +262,7 @@ public:
//! Unsew two oriented volumes along their faces.
/*! @param d a dart of one volume
*/
virtual void unsewVolumes(Dart d);
virtual void unsewVolumes(Dart d, bool withBoundary = true);
//! Merge two volumes along their common oriented face
/*! @param d a dart of common face
......
......@@ -357,8 +357,14 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e, bool withBoundary)
}
}
void EmbeddedMap3::unsewVolumes(Dart d)
void EmbeddedMap3::unsewVolumes(Dart d, bool withBoundary)
{
if (!withBoundary)
{
Map3::unsewVolumes(d, false) ;
return ;
}
Dart dd = alpha1(d);
unsigned int fEmb = EMBNULL ;
......
......@@ -706,10 +706,21 @@ bool Map3::unsewVolumesPreCond(Dart d)
}
void Map3::unsewVolumes(Dart d)
void Map3::unsewVolumes(Dart d, bool withBoundary)
{
assert(unsewVolumesPreCond(d)) ;
if (!withBoundary)
{
Dart fitD = d ;
do
{
phi3unsew(fitD) ;
fitD = phi1(fitD) ;
} while(fitD != d) ;
return ;
}
unsigned int nbE = faceDegree(d) ;
Dart d3 = phi3(d);
......
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