From b7e8bfa8c53ee96d9a3a20515bcb903b81241cc4 Mon Sep 17 00:00:00 2001 From: untereiner Date: Fri, 7 Jun 2013 17:45:04 +0200 Subject: [PATCH] begin dual volumetric subdivision --- .../Multiresolution/Map3MR/Dual/dooSabin.h | 148 ++++++++++++++ .../Multiresolution/Map3MR/Filters/lerp.h | 13 +- .../Map3MR/map3MR_DualRegular.h | 97 ++++++++++ .../Map3MR/map3MR_DualRegular.hpp | 180 ++++++++++++++++++ include/Topology/map/embeddedMap3.h | 2 +- include/Topology/map/map3.h | 2 +- src/Topology/map/embeddedMap3.cpp | 8 +- src/Topology/map/map3.cpp | 13 +- 8 files changed, 453 insertions(+), 10 deletions(-) create mode 100644 include/Algo/Multiresolution/Map3MR/Dual/dooSabin.h create mode 100644 include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.h create mode 100644 include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.hpp diff --git a/include/Algo/Multiresolution/Map3MR/Dual/dooSabin.h b/include/Algo/Multiresolution/Map3MR/Dual/dooSabin.h new file mode 100644 index 00000000..4b3c09a3 --- /dev/null +++ b/include/Algo/Multiresolution/Map3MR/Dual/dooSabin.h @@ -0,0 +1,148 @@ +/******************************************************************************* + * 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 + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Volume +{ + +namespace MR +{ + +namespace Dual +{ + +namespace Filters +{ + +template +class DooSabinVertexSynthesisFilter : public Algo::MR::Filter +{ +protected: + typename PFP::MAP& m_map ; + VertexAttribute& m_position ; + +public: + DooSabinVertexSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) + {} + + void operator() () + { +// TraversorV 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 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 + diff --git a/include/Algo/Multiresolution/Map3MR/Filters/lerp.h b/include/Algo/Multiresolution/Map3MR/Filters/lerp.h index 275fc8f3..13f08702 100644 --- a/include/Algo/Multiresolution/Map3MR/Filters/lerp.h +++ b/include/Algo/Multiresolution/Map3MR/Filters/lerp.h @@ -363,13 +363,15 @@ public: { typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid(m_map, d, m_position); - m_map.incCurrentLevel() ; - - Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); - m_position[midV] = p ; + if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron(m_map,d)) + { + m_map.incCurrentLevel() ; - m_map.decCurrentLevel() ; + 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() ; - } } } ; diff --git a/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.h b/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.h new file mode 100644 index 00000000..31c9f930 --- /dev/null +++ b/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.h @@ -0,0 +1,97 @@ +/******************************************************************************* +* 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 +class Map3MR +{ +public: + typedef typename PFP::MAP MAP ; + +protected: + MAP& m_map; + bool shareVertexEmbeddings ; + + std::vector synthesisFilters ; + std::vector 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 diff --git a/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.hpp b/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.hpp new file mode 100644 index 00000000..ac4afe5b --- /dev/null +++ b/include/Algo/Multiresolution/Map3MR/map3MR_DualRegular.hpp @@ -0,0 +1,180 @@ +/******************************************************************************* +* 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 +Map3MR::Map3MR(typename PFP::MAP& map) : + m_map(map), + shareVertexEmbeddings(false) +{ + +} + +template +Map3MR::~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 +void Map3MR::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 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(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 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 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(d) == EMBNULL) +// m_map.template setOrbitEmbeddingOnNewCell(temp) ; +// //m_map.template setOrbitEmbeddingOnNewCell(d2) ; +// } +// +// +// temp = m_map.phi1(temp); +// } +// while(temp != stop); +// +// +// m_map.decCurrentLevel(); +// } + + m_map.incCurrentLevel() ; + + m_map.popLevel() ; +} + +template +void Map3MR::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 +void Map3MR::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 diff --git a/include/Topology/map/embeddedMap3.h b/include/Topology/map/embeddedMap3.h index 3851e88b..1de11aa0 100644 --- a/include/Topology/map/embeddedMap3.h +++ b/include/Topology/map/embeddedMap3.h @@ -107,7 +107,7 @@ public: //! /*! */ - virtual void unsewVolumes(Dart d); + virtual void unsewVolumes(Dart d, bool withBoundary = true); //! /*! diff --git a/include/Topology/map/map3.h b/include/Topology/map/map3.h index 1f30269d..0932c572 100644 --- a/include/Topology/map/map3.h +++ b/include/Topology/map/map3.h @@ -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 diff --git a/src/Topology/map/embeddedMap3.cpp b/src/Topology/map/embeddedMap3.cpp index 47b829fa..beba5be3 100644 --- a/src/Topology/map/embeddedMap3.cpp +++ b/src/Topology/map/embeddedMap3.cpp @@ -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 ; diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index e2863b84..8895922c 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -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); -- GitLab