Commit 6e1d2b03 authored by Lionel Untereiner's avatar Lionel Untereiner

changing ihm3 from Algo to Topology (as IHM2)

parent ae2ccab2
......@@ -154,7 +154,6 @@ unsigned int IHM2<PFP>::faceLevel(Dart d)
return fLevel ;
}
template <typename PFP>
Dart IHM2<PFP>::faceOrigin(Dart d)
{
......@@ -330,7 +329,7 @@ template <typename PFP>
void IHM2<PFP>::coarsenEdge(Dart d)
{
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"coarsenEdge : called with a dart inserted after current level") ;
assert(m_map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
assert(edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
unsigned int cur = m_map.getCurrentLevel() ;
......@@ -496,7 +495,7 @@ void IHM2<PFP>::coarsenFace(Dart d)
fit = d ;
do
{
if(m_map.edgeCanBeCoarsened(fit))
if(edgeCanBeCoarsened(fit))
coarsenEdge(fit) ;
fit = m_map.phi1(fit) ;
} while(fit != d) ;
......
/*******************************************************************************
* 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_PRIMAL_ADAPT__
#define __MAP3MR_PRIMAL_ADAPT__
#include "Topology/ihmap/ihm3.h"
#include "Topology/generic/traversor/traversorCell.h"
#include "Topology/generic/traversor/traversor3.h"
#include <cmath>
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace MR
{
namespace Primal
{
namespace Adaptive
{
template <typename PFP>
class IHM3
{
public:
typedef typename PFP::MAP MAP ;
protected:
MAP& m_map;
bool shareVertexEmbeddings ;
FunctorType* vertexVertexFunctor ;
FunctorType* edgeVertexFunctor ;
FunctorType* faceVertexFunctor ;
FunctorType* volumeVertexFunctor ;
public:
IHM3(MAP& map) ;
/***************************************************
* CELLS INFORMATION *
***************************************************/
//! Return the level of the edge of d in the current level map
/*!
*/
unsigned int edgeLevel(Dart d) ;
//! Return the level of the face of d in the current level map
/*!
*/
unsigned int faceLevel(Dart d);
//! Return the level of the volume of d in the current level map
/*!
*/
unsigned int volumeLevel(Dart d);
//! Return the oldest dart of the face of d in the current level map
/*!
*/
Dart faceOldestDart(Dart d);
//! Return the oldest dart of the volume of d in the current level map
/*!
*/
Dart volumeOldestDart(Dart d);
//! Return true if the edge of d in the current level map
//! has already been subdivided to the next level
/*!
*/
bool edgeIsSubdivided(Dart d) ;
//! Return true if the edge of d in the current level map
//! is subdivided to the next level,
//! none of its resulting edges is in turn subdivided to the next level
//! and the middle vertex is of degree 2
/*!
*/
bool edgeCanBeCoarsened(Dart d);
//! Return true if the face of d in the current level map
//! has already been subdivided to the next level
/*!
*/
bool faceIsSubdivided(Dart d) ;
//!
/*!
*/
bool faceCanBeCoarsened(Dart d);
//! Return true if the volume of d in the current level map
//! has already been subdivided to the next level
/*!
*/
bool volumeIsSubdivided(Dart d);
//!
/*!
*/
bool volumeIsSubdividedOnce(Dart d);
protected:
/***************************************************
* SUBDIVISION *
***************************************************/
/**
* subdivide the edge of d to the next level
*/
void subdivideEdge(Dart d) ;
/**
* coarsen the edge of d from the next level
*/
void coarsenEdge(Dart d) ;
/**
* subdivide the face of d to the next level
*/
unsigned int subdivideFace(Dart d, bool triQuad);
/**
* coarsen the face of d from the next level
*/
void coarsenFace(Dart d) ;
public:
//! Subdivide the volume of d to hexahedral cells
/*! @param d Dart from the volume
*/
unsigned int subdivideVolume(Dart d, bool triQuad = true, bool OneLevelDifference = true);
/*!
* \brief subdivideHexa
*
* Detailed description of the function
* \param d
* \param OneLevelDifference
* \return
*/
unsigned int subdivideHexa(Dart d, bool OneLevelDifference = true);
//! Subdivide the volume of d to hexahedral cells
/*! @param d Dart from the volume
*/
void subdivideVolumeTetOcta(Dart d) ;
/**
* vertices attributes management
*/
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; }
} ;
} // namespace Adaptive
} // namespace Primal
} // namespace MR
} // namespace Volume
} // namespace Algo
} // namespace CGoGN
#include "Algo/Multiresolution/IHM2/ihm2_PrimalAdapt.hpp"
#endif
This diff is collapsed.
......@@ -193,9 +193,6 @@ public:
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; }
//@}
unsigned int subdivideHexa2(Dart d, bool OneLevelDifference = true);
void subdivideFace2(Dart d, bool triQuad);
};
} // namespace Adaptive
......
/*******************************************************************************
* 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 __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/embeddedMap3.h"
namespace CGoGN
{
template<typename T, unsigned int ORBIT> class AttributeHandler_IHM ;
typedef EmbeddedMap3::TOPO_MAP TOPO_MAP;
class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
private:
unsigned int m_curLevel ;
unsigned int m_maxLevel ;
unsigned int m_edgeIdCount ;
unsigned int m_faceIdCount;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_dartLevel ;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_edgeId ;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_faceId ;
AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
public:
ImplicitHierarchicalMap3() ;
~ImplicitHierarchicalMap3() ;
static const unsigned int DIMENSION = 3 ;
//!
/*!
*
*/
void update_topo_shortcuts();
//!
/*!
*
*/
void initImplicitProperties();
/**
* clear the map
* @param remove attrib remove attribute (not only clear the content)
*/
void clear(bool removeAttrib);
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> addAttribute(const std::string& nameAttr) ;
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> getAttribute(const std::string& nameAttr) ;
/***************************************************
* MAP TRAVERSAL *
***************************************************/
inline Dart newDart() ;
inline Dart phi1(Dart d) const;
inline Dart phi_1(Dart d) const;
inline Dart phi2(Dart d) const;
private:
inline Dart phi2bis(Dart d) const;
public:
inline Dart phi3(Dart d) const;
inline Dart alpha0(Dart d) const;
inline Dart alpha1(Dart d) const;
inline Dart alpha2(Dart d) const;
inline Dart alpha_2(Dart d) const;
inline Dart begin() const;
inline Dart end() const;
inline void next(Dart& d) const ;
template <unsigned int ORBIT, typename FUNC>
void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC f, unsigned int thread = 0) const ;
template <unsigned int ORBIT, typename FUNC>
void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC& f, unsigned int thread = 0) const ;
template <typename FUNC>
void foreach_dart_of_vertex(Dart d, FUNC& f, unsigned int thread = 0) const ;
template <typename FUNC>
void foreach_dart_of_edge(Dart d, FUNC& f, unsigned int thread = 0) const ;
template <typename FUNC>
void foreach_dart_of_oriented_face(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_face(Dart d, FUNC& f, unsigned int thread = 0) const ;
template <typename FUNC>
void foreach_dart_of_oriented_volume(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_volume(Dart d, FUNC& f, unsigned int thread = 0) const ;
template <typename FUNC>
void foreach_dart_of_vertex1(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_edge1(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_vertex2(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_edge2(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_face2(Dart d, FUNC& f, unsigned int thread = 0) const;
template <typename FUNC>
void foreach_dart_of_cc(Dart d, FUNC& f, unsigned int thread = 0) const ;
/***************************************************
* MAP MANIPULATION *
***************************************************/
/***************************************************
* LEVELS MANAGEMENT *
***************************************************/
void incCurrentLevel();
void decCurrentLevel();
unsigned int getCurrentLevel() const ;
void setCurrentLevel(unsigned int l) ;
unsigned int getMaxLevel() const ;
unsigned int getDartLevel(Dart d) const ;
void setDartLevel(Dart d, unsigned int i) ;
/***************************************************
* ID MANAGEMENT *
***************************************************/
//! Give a new unique id to all the edges of the map
/*!
*/
void initEdgeId() ;
//! Return the next available edge id
/*!
*/
unsigned int getNewEdgeId() ;
//! Return the id of the edge of d
/*!
*/
unsigned int getEdgeId(Dart d) ;
//! Set an edge id to all darts from an orbit of d
/*!
*/
void setEdgeId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer
void setEdgeId(Dart d, unsigned int i);
//! Give a new unique id to all the faces of the map
/*!
*/
void initFaceId() ;
//! Return the next available face id
/*!
*/
unsigned int getNewFaceId() ;
//! Return the id of the face of d
/*!
*/
unsigned int getFaceId(Dart d) ;
//! Set a face id to all darts from an orbit of d
/*!
*/
void setFaceId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer
void setFaceId(unsigned int orbit, Dart d);
/***************************************************
* CELLS INFORMATION *
***************************************************/
//! Return the level of insertion of the vertex of d
/*!
*/
unsigned int vertexInsertionLevel(Dart d) const;
};
//TODO existe deja dans le fichier ihm2.h
//template <typename T, unsigned int ORBIT>
//class AttributeHandler_IHM : public AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>
//{
//public:
// typedef T DATA_TYPE ;
// AttributeHandler_IHM() : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>()
// {}
// AttributeHandler_IHM(ImplicitHierarchicalMap3* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>(m, amv)
// {}
// AttributeMultiVector<T>* getDataVector() const
// {
// return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::getDataVector() ;
// }
// bool isValid() const
// {
// return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::isValid() ;
// }
// virtual T& operator[](Dart d) ;
// virtual const T& operator[](Dart d) const ;
// T& operator[](unsigned int a)
// {
// return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::operator[](a) ;
// }
// const T& operator[](unsigned int a) const
// {
// return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::operator[](a) ;
// }
//} ;
//template <typename T>
//class VertexAttribute_IHM : public AttributeHandler_IHM<T, VERTEX>
//{
//public:
// VertexAttribute_IHM() : IHM::AttributeHandler_IHM<T, VERTEX>() {}
// VertexAttribute_IHM(const IHM::AttributeHandler_IHM<T, VERTEX>& ah) : IHM::AttributeHandler_IHM<T, VERTEX>(ah) {}
//// VertexAttribute_IHM<T>& operator=(const IHM::AttributeHandler_IHM<T, VERTEX>& ah) { this->IHM::AttributeHandler_IHM<T, VERTEX>::operator=(ah); return *this; }
//};
} //namespace CGoGN
#include "Topology/ihmap/ihm3.hpp"
#endif
This diff is collapsed.
/*******************************************************************************
* 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 "Topology/ihmap/ihm3.h"
#include <math.h>
namespace CGoGN
{
ImplicitHierarchicalMap3::ImplicitHierarchicalMap3() : m_curLevel(0), m_maxLevel(0), m_edgeIdCount(0), m_faceIdCount(0)
{
m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
for(unsigned int i = 0; i < NB_ORBITS; ++i)
m_nextLevelCell[i] = NULL ;
}
ImplicitHierarchicalMap3::~ImplicitHierarchicalMap3()
{
removeAttribute(m_edgeId) ;
removeAttribute(m_faceId) ;
removeAttribute(m_dartLevel) ;
}
void ImplicitHierarchicalMap3::clear(bool removeAttrib)
{
Map3::clear(removeAttrib) ;
if (removeAttrib)
{
m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
for(unsigned int i = 0; i < NB_ORBITS; ++i)
m_nextLevelCell[i] = NULL ;
}
}
void ImplicitHierarchicalMap3::initImplicitProperties()
{
initEdgeId() ;
initFaceId();
// for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
// {
// m_edgeId[d] = 0;
// m_faceId[d] = 0;
// }
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if(m_nextLevelCell[orbit] != NULL)
{
AttributeContainer& cellCont = m_attribs[orbit] ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
m_nextLevelCell[orbit]->operator[](i) = EMBNULL ;
}
}
}
void ImplicitHierarchicalMap3::initEdgeId()
{
DartMarkerStore<Map3> edgeMark(*this) ;
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
if(!edgeMark.isMarked(d))
{
Dart e = d;
do
{
m_edgeId[e] = m_edgeIdCount;
edgeMark.mark(e);
m_edgeId[Map3::phi2(e)] = m_edgeIdCount ;
edgeMark.mark(Map3::phi2(e));
e = Map3::alpha2(e);
} while(e != d);
m_edgeIdCount++;
}
}
}
void ImplicitHierarchicalMap3::initFaceId()
{
DartMarkerStore<Map3> faceMark(*this) ;
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
if(!faceMark.isMarked(d))
{
Dart e = d;
do
{
m_faceId[e] = m_faceIdCount ;
faceMark.mark(e);
Dart e3 = Map3::phi3(e);
m_faceId[e3] = m_faceIdCount ;
faceMark.mark(e3);
e = Map3::phi1(e);
} while(e != d);
m_faceIdCount++;
}
}
}
} //namespace CGoGN
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