Commit 7114af20 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

Merge branch 'master' into 'master'

Master

once upon a time

See merge request !39
parents 7576a3e9 21e86c78
......@@ -48,10 +48,10 @@ class Sqrt3VertexVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& m_position ;
public:
Sqrt3VertexVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Sqrt3VertexVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......@@ -123,10 +123,10 @@ class Sqrt3FaceVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& m_position ;
public:
Sqrt3FaceVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Sqrt3FaceVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......
......@@ -29,7 +29,7 @@
#include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/tetrahedralization.h"
#include "Algo/Multiresolution/filter.h"
#include "Topology/generic/traversor2_closed.h"
#include "Topology/generic/traversor/traversor2_closed.h"
namespace CGoGN
{
......
......@@ -53,10 +53,10 @@ class LerpVertexVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
AttributeHandler<typename PFP::VEC3, VERTEX>& m_position ;
AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& m_position ;
public:
LerpVertexVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX>& p) : m_map(m), m_position(p)
LerpVertexVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......@@ -68,7 +68,7 @@ public:
// std::cout << " p du niv i+1 = " << p << std::endl;
m_position[d] = p;
//m_position[d] = p;
// m_map.decCurrentLevel() ;
// std::cout << "dec = " << m_position[d] << std::endl;
......@@ -84,10 +84,10 @@ class LerpEdgeVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
AttributeHandler<typename PFP::VEC3, VERTEX>& m_position ;
AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& m_position ;
public:
LerpEdgeVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX>& p) : m_map(m), m_position(p)
LerpEdgeVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......@@ -110,10 +110,10 @@ class LerpFaceVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
AttributeHandler<typename PFP::VEC3, VERTEX>& m_position ;
AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& m_position ;
public:
LerpFaceVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX>& p) : m_map(m), m_position(p)
LerpFaceVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......@@ -135,10 +135,10 @@ class LerpVolumeVertexFunctor : public FunctorType
{
protected:
typename PFP::MAP& m_map ;
AttributeHandler<typename PFP::VEC3, VERTEX>& m_position ;
AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& m_position ;
public:
LerpVolumeVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX>& p) : m_map(m), m_position(p)
LerpVolumeVertexFunctor(typename PFP::MAP& m, AttributeHandler<typename PFP::VEC3, VERTEX, typename PFP::MAP>& p) : m_map(m), m_position(p)
{}
bool operator() (Dart d)
......
......@@ -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
......
......@@ -141,6 +141,20 @@ public:
return (*m_markVector)[d_index];
}
// template <unsigned int ORBIT>
// inline bool isMarked(Cell<ORBIT> c) const
// {
// assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark));
// m_map.foreach_dart_of_orbit(c, [&] (Dart d)
// {
// if(!(*m_markVector)[m_map.dartIndex(d)].testMark(m_mark))
// return false;
// }
// , m_thread) ;
// return true;
// }
/**
* mark the darts of the given cell
*/
......
......@@ -26,7 +26,7 @@
#define __TRAVERSOR2_CLOSED_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
#include "Topology/generic/traversor/traversorGen.h"
namespace CGoGN
{
......@@ -255,6 +255,6 @@ public:
} // namespace CGoGN
#include "Topology/generic/traversor2_closed.hpp"
#include "Topology/generic/traversor/traversor2_closed.hpp"
#endif
......@@ -32,11 +32,11 @@ namespace CGoGN
template<typename T, unsigned int ORBIT> class AttributeHandler_IHM ;
typedef EmbeddedMap2::TOPO_MAP TOPO_MAP;
class ImplicitHierarchicalMap2 : public EmbeddedMap2
{
template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
typedef EmbeddedMap2::TOPO_MAP TOPO_MAP;
private:
unsigned int m_curLevel ;
......@@ -143,7 +143,7 @@ public:
void splitFace(Dart d, Dart e) ;
unsigned int vertexDegree(Dart d);
unsigned int vertexDegree(Dart d);
/***************************************************
* LEVELS MANAGEMENT *
......
......@@ -326,18 +326,14 @@ inline void ImplicitHierarchicalMap2::setCurrentLevel(unsigned int l)
inline void ImplicitHierarchicalMap2::incCurrentLevel()
{
if(m_curLevel < m_maxLevel)
++m_curLevel ;
else
CGoGNout << "incCurrentLevel : already at maximum resolution level" << CGoGNendl ;
assert(m_curLevel < m_maxLevel || "incCurrentLevel : already at maximum resolution level");
++m_curLevel ;
}
inline void ImplicitHierarchicalMap2::decCurrentLevel()
{
if(m_curLevel > 0)
--m_curLevel ;
else
CGoGNout << "decCurrentLevel : already at minimum resolution level" << CGoGNendl ;
assert(m_curLevel > 0 || "decCurrentLevel : already at minimum resolution level");
--m_curLevel ;
}
inline unsigned int ImplicitHierarchicalMap2::getMaxLevel()
......
/*******************************************************************************
* 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 ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
typedef EmbeddedMap3::TOPO_MAP TOPO_MAP;
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, typename MAP>
// AttributeHandler_IHM<T, ORBIT, MAP> addAttribute(const std::string& nameAttr) ;
// template <typename T, unsigned int ORBIT, typename MAP>
// AttributeHandler_IHM<T, ORBIT, MAP> 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) const ;
template <unsigned int ORBIT, typename FUNC>
void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC& f) const ;
template <typename FUNC>
void foreach_dart_of_vertex(Dart d, FUNC& f) const ;
template <typename FUNC>
void foreach_dart_of_edge(Dart d, FUNC& f) const ;
template <typename FUNC>
void foreach_dart_of_oriented_face(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_face(Dart d, FUNC& f) const ;
template <typename FUNC>
void foreach_dart_of_oriented_volume(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_volume(Dart d, FUNC& f) const ;
template <typename FUNC>
void foreach_dart_of_vertex1(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_edge1(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_vertex2(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_edge2(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_face2(Dart d, FUNC& f) const;
template <typename FUNC>
void foreach_dart_of_cc(Dart d, FUNC& f) 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); //TODO a virer
void setDartEdgeId(Dart d, unsigned int i);
unsigned int triRefinementEdgeId(Dart d);
unsigned int quadRefinementEdgeId(Dart d);
//! 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) ;
unsigned int faceId(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.
......@@ -65,6 +65,11 @@ public:
*/
Dart deleteVertex(Dart d) ;
/**
* The attributes attached to the edges of d and phi_1(d) are kept to the new edges
*/
void mergeOppositeVertices(Dart d);
/**
* The attributes attached to the old edge are duplicated on both resulting edges
*/
......
......@@ -122,6 +122,11 @@ public:
*/
virtual void splitVolume(std::vector<Dart>& vd);
//!
/*!
*/
virtual void cutVolume(std::vector<Dart>& vd);
//!
virtual void splitVolumeWithFace(std::vector<Dart>& vd, Dart d);
......
......@@ -181,6 +181,12 @@ public:
*/
Dart deleteVertex(Dart d);
//! Merge two opposite vertices in a quadrangular face
/*! \pre Darts d MUST belong to the face of the vertices to be merged
* @param d a dart in vertex v
*/
void mergeOppositeVertices(Dart d);
//! Cut the edge of d by inserting a new vertex
/*! @param d a dart of the edge to cut
* @return a dart of the new vertex
......@@ -424,6 +430,12 @@ public:
*/
bool isTriangular() const;
/**
* @brief isOpen check if the mesh is open or not
* @return a boolean indicating the mesh is open
*/
bool isOpen() const;
// TODO a mettre en algo
/**
* Check if map is complete
......
......@@ -321,6 +321,26 @@ Dart Map2<MAP_IMPL>::deleteVertex(Dart d)
return res ;
}
template <typename MAP_IMPL>
void Map2<MAP_IMPL>::mergeOppositeVertices(Dart d)
{
Dart d2 = phi2(d);
Dart d_12 = phi2(this->phi_1(d));
Dart d_112 = phi2(this->phi_1(this->phi_1(d)));
Dart d12 = phi2(this->phi1(d));
phi2unsew(d2);
phi2unsew(d_12);
phi2unsew(d_112);
phi2unsew(d12);
phi2sew(d2,d12);
phi2sew(d_12,d_112);
ParentMap::deleteCycle(d);
}
template <typename MAP_IMPL>
Dart Map2<MAP_IMPL>::cutEdge(Dart d)
{
......@@ -674,7 +694,7 @@ void Map2<MAP_IMPL>::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, b
//unsew the edge path
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{
//if(!Map2<MAP_IMPL>::isBoundaryEdge(*it))
if(!Map2<MAP_IMPL>::isBoundaryEdge(*it))
unsewFaces(*it) ;
}
......@@ -940,6 +960,24 @@ bool Map2<MAP_IMPL>::isTriangular() const
return tri;
}
template <typename MAP_IMPL>
bool Map2<MAP_IMPL>::isOpen() const
{
bool open = false;
for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
{
if(this->template isBoundaryMarked<2>(d))
{
open = true;
return open;
}
}
return open;
}
template <typename MAP_IMPL>
bool Map2<MAP_IMPL>::check() const
{
......