Commit f3132155 authored by untereiner's avatar untereiner

some changes to implicit MR management

parent 10e52114
This diff is collapsed.
...@@ -37,15 +37,34 @@ namespace Surface ...@@ -37,15 +37,34 @@ namespace Surface
namespace Geometry namespace Geometry
{ {
//! \brief Compute triangle area
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
//! \brief Compute convex polygonal face area
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
//! \brief Compute the total area of a mesh by summing all face areas.
//! @param map
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread = 0) ; typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread = 0) ;
//! \brief Compute the area of the faces around a vertex.
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __MAP2MR_PRIMAL_ADAPT__ #ifndef __MAP2MR_PRIMAL_ADAPT__
#define __MAP2MR_PRIMAL_ADAPT__ #define __MAP2MR_PRIMAL_ADAPT__
#include "Topology/map/embeddedMap2.h" #include "Topology/ihmap/ihm2.h"
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h" #include "Topology/generic/traversor2.h"
...@@ -52,8 +52,6 @@ class IHM2 ...@@ -52,8 +52,6 @@ class IHM2
public: public:
typedef typename PFP::MAP MAP ; typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected: protected:
MAP& m_map; MAP& m_map;
...@@ -67,6 +65,59 @@ public: ...@@ -67,6 +65,59 @@ public:
IHM2(MAP& map) ; IHM2(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) ;
/**
* Given the face of d in the current level map,
* return a level 0 dart of its origin face
*/
Dart faceOrigin(Dart d) ;
/**
* Return the oldest dart of the face of d in the current level map
*/
Dart faceOldestDart(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) ;
/**
* Return true if the face of d in the current level map
* is subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level
*/
bool faceIsSubdividedOnce(Dart d) ;
protected: protected:
/*************************************************** /***************************************************
* SUBDIVISION * * SUBDIVISION *
...@@ -88,11 +139,6 @@ public: ...@@ -88,11 +139,6 @@ public:
*/ */
unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true);
/**
*
*/
unsigned int subdivideFaceSqrt3(Dart d);
/** /**
* coarsen the face of d from the next level * coarsen the face of d from the next level
*/ */
......
...@@ -79,7 +79,8 @@ public: ...@@ -79,7 +79,8 @@ public:
ef += m_position[m_map.phi1(dit)]; ef += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel(); m_map.decCurrentLevel();
++count; ++count;
} }
ef /= count; ef /= count;
ef *= 2.0; ef *= 2.0;
...@@ -89,6 +90,7 @@ public: ...@@ -89,6 +90,7 @@ public:
Dart midF = m_map.phi1(m_map.phi1(d)); Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] += vf + ef ; m_position[midF] += vf + ef ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
break;
} }
TraversorE<typename PFP::MAP> travE(m_map) ; TraversorE<typename PFP::MAP> travE(m_map) ;
...@@ -213,7 +215,7 @@ public: ...@@ -213,7 +215,7 @@ public:
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d)); Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] -= vf + ef ; m_position[midF] -= vf + ef ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
} }
......
...@@ -105,8 +105,8 @@ public: ...@@ -105,8 +105,8 @@ public:
bool operator() (Dart d) bool operator() (Dart d)
{ {
//Dart df = m_map.phi1(m_map.phi1(d)) ; Dart df = m_map.phi1(m_map.phi1(d)) ;
Dart df = m_map.phi1(d) ; //Dart df = m_map.phi1(d) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
......
...@@ -64,9 +64,8 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close) ...@@ -64,9 +64,8 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
// store last row of vertices // store last row of vertices
for (unsigned int i = 0; i < x; ++i) for (unsigned int i = 0; i < x; ++i)
{ {
//this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) ); this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) );
} }
//this-> m_tableVertDarts.push_back(this->m_map.phi1(this->m_tableVertDarts[(y-1)*(x+1) +x]) );
//sewing the triangles //sewing the triangles
for (unsigned int i = 0; i < y; ++i) for (unsigned int i = 0; i < y; ++i)
...@@ -75,11 +74,11 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close) ...@@ -75,11 +74,11 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{ {
if (i > 0) // sew with preceeding row if (i > 0) // sew with preceeding row
{ {
int pos = i*(x+1)+j; // int pos = i*(x+1)+j;
Dart d = this->m_tableVertDarts[pos]; // Dart d = this->m_tableVertDarts[pos];
Dart e = this->m_tableVertDarts[pos-(x+1)]; // Dart e = this->m_tableVertDarts[pos-(x+1)];
e = this->m_map.phi1(this->m_map.phi1(e)); // e = this->m_map.phi_1(e);
this->m_map.sewFaces(d, e, false); // this->m_map.sewFaces(d, e, false);
} }
if (j > 0) // sew with preceeding column if (j > 0) // sew with preceeding column
{ {
...@@ -107,7 +106,7 @@ void Grid<PFP>::embedIntoGrid(VertexAttribute<VEC3>& position, float x, float y, ...@@ -107,7 +106,7 @@ void Grid<PFP>::embedIntoGrid(VertexAttribute<VEC3>& position, float x, float y,
{ {
for(unsigned int j = 0; j <= this->m_nx;++j) for(unsigned int j = 0; j <= this->m_nx;++j)
{ {
position[this->m_tableVertDarts[i*(this->m_nx+1)+j] ] = VEC3(-x/2 + dx*float(j), -y/2 + dy*float(i), z); position[this->m_tableVertDarts[i*(this->m_nx+1)+j] ] = VEC3(dx*float(j) + 0.5f*float(i), dy*float(i) * sqrtf(3.0f)/2.0f, z);
} }
} }
} }
......
...@@ -504,11 +504,11 @@ template <typename MAP> ...@@ -504,11 +504,11 @@ template <typename MAP>
Dart Traversor2FV<MAP>::next() Dart Traversor2FV<MAP>::next()
{ {
if(m_QLT != NULL) if(m_QLT != NULL)
{ {
return *m_ItDarts++; return *m_ItDarts++;
} }
if(current != NIL) if(current != NIL)
{ {
current = m.phi1(current) ; current = m.phi1(current) ;
if(current == start) if(current == start)
current = NIL ; current = NIL ;
......
...@@ -121,6 +121,8 @@ public: ...@@ -121,6 +121,8 @@ public:
void splitFace(Dart d, Dart e) ; void splitFace(Dart d, Dart e) ;
unsigned int vertexDegree(Dart d);
/*************************************************** /***************************************************
* LEVELS MANAGEMENT * * LEVELS MANAGEMENT *
***************************************************/ ***************************************************/
...@@ -161,58 +163,65 @@ public: ...@@ -161,58 +163,65 @@ public:
* CELLS INFORMATION * * CELLS INFORMATION *
***************************************************/ ***************************************************/
/**
* @brief faceDegree
* @param d
* @return
*/
unsigned int faceDegree(Dart d);
/** /**
* Return the level of insertion of the vertex of d * Return the level of insertion of the vertex of d
*/ */
unsigned int vertexInsertionLevel(Dart d) ; unsigned int vertexInsertionLevel(Dart d) ;
/** // /**
* Return the level of the edge of d in the current level map // * Return the level of the edge of d in the current level map
*/ // */
unsigned int edgeLevel(Dart d) ; // unsigned int edgeLevel(Dart d) ;
/** // /**
* Return the level of the face of d in the current level map // * Return the level of the face of d in the current level map
*/ // */
unsigned int faceLevel(Dart d) ; // unsigned int faceLevel(Dart d) ;
/** // /**
* Given the face of d in the current level map, // * Given the face of d in the current level map,
* return a level 0 dart of its origin face // * return a level 0 dart of its origin face
*/ // */
Dart faceOrigin(Dart d) ; // Dart faceOrigin(Dart d) ;
/** // /**
* Return the oldest dart of the face of d in the current level map // * Return the oldest dart of the face of d in the current level map
*/ // */
Dart faceOldestDart(Dart d) ; // Dart faceOldestDart(Dart d) ;
/** // /**
* Return true if the edge of d in the current level map // * Return true if the edge of d in the current level map
* has already been subdivided to the next level // * has already been subdivided to the next level
*/ // */
bool edgeIsSubdivided(Dart d) ; // bool edgeIsSubdivided(Dart d) ;
/** // /**
* Return true if the edge of d in the current level map // * Return true if the edge of d in the current level map
* is subdivided to the next level, // * is subdivided to the next level,
* none of its resulting edges is in turn 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 // * and the middle vertex is of degree 2
*/ // */
bool edgeCanBeCoarsened(Dart d) ; // bool edgeCanBeCoarsened(Dart d) ;
/** // /**
* Return true if the face of d in the current level map // * Return true if the face of d in the current level map
* has already been subdivided to the next level // * has already been subdivided to the next level
*/ // */
bool faceIsSubdivided(Dart d) ; // bool faceIsSubdivided(Dart d) ;
/** // /**
* Return true if the face of d in the current level map // * Return true if the face of d in the current level map
* is subdivided to the next level // * is subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level // * and none of its resulting faces is in turn subdivided to the next level
*/ // */
bool faceIsSubdividedOnce(Dart d) ; // bool faceIsSubdividedOnce(Dart d) ;
} ; } ;
template <typename T, unsigned int ORBIT> template <typename T, unsigned int ORBIT>
......
...@@ -84,7 +84,7 @@ inline Dart ImplicitHierarchicalMap2::newDart() ...@@ -84,7 +84,7 @@ inline Dart ImplicitHierarchicalMap2::newDart()
inline Dart ImplicitHierarchicalMap2::phi1(Dart d) inline Dart ImplicitHierarchicalMap2::phi1(Dart d)
{ {
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
bool finished = false ; bool finished = false ;
unsigned int edgeId = m_edgeId[d] ; unsigned int edgeId = m_edgeId[d] ;
Dart it = d ; Dart it = d ;
do do
...@@ -95,7 +95,7 @@ inline Dart ImplicitHierarchicalMap2::phi1(Dart d) ...@@ -95,7 +95,7 @@ inline Dart ImplicitHierarchicalMap2::phi1(Dart d)
else else
{ {
while(m_edgeId[it] != edgeId) while(m_edgeId[it] != edgeId)
it = Map2::alpha_1(it) ; it = Map2::phi1(Map2::phi2(it)) ;
} }
} while(!finished) ; } while(!finished) ;
return it ; return it ;
...@@ -126,7 +126,7 @@ inline Dart ImplicitHierarchicalMap2::phi2(Dart d) ...@@ -126,7 +126,7 @@ inline Dart ImplicitHierarchicalMap2::phi2(Dart d)
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
if(Map2::phi2(d) == d) if(Map2::phi2(d) == d)
return d ; return d ;
return Map2::alpha1(phi1(d)) ; return Map2::phi2(Map2::phi_1(phi1(d))) ;
} }
inline Dart ImplicitHierarchicalMap2::alpha0(Dart d) inline Dart ImplicitHierarchicalMap2::alpha0(Dart d)
...@@ -337,21 +337,35 @@ inline void ImplicitHierarchicalMap2::setEdgeId(Dart d, unsigned int i) ...@@ -337,21 +337,35 @@ inline void ImplicitHierarchicalMap2::setEdgeId(Dart d, unsigned int i)
* CELLS INFORMATION * * CELLS INFORMATION *
***************************************************/ ***************************************************/
inline unsigned int ImplicitHierarchicalMap2::vertexInsertionLevel(Dart d) inline unsigned int ImplicitHierarchicalMap2::faceDegree(Dart d)
{ {
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; unsigned int count = 0 ;
return m_dartLevel[d] ; Dart it = d ;
do
{
++count ;
it = phi1(it) ;
} while (it != d) ;
return count ;
} }
inline unsigned int ImplicitHierarchicalMap2::edgeLevel(Dart d)
inline unsigned int ImplicitHierarchicalMap2::vertexInsertionLevel(Dart d)
{ {
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ; assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
unsigned int ld = m_dartLevel[d] ; return m_dartLevel[d] ;
// unsigned int ldd = m_dartLevel[phi2(d)] ; // the level of an edge is the maximum of the
unsigned int ldd = m_dartLevel[phi1(d)] ;
return ld < ldd ? ldd : ld ; // insertion levels of its two darts
} }
//inline unsigned int ImplicitHierarchicalMap2::edgeLevel(Dart d)
//{
// assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
// unsigned int ld = m_dartLevel[d] ;
//// unsigned int ldd = m_dartLevel[phi2(d)] ; // the level of an edge is the maximum of the
// unsigned int ldd = m_dartLevel[phi1(d)] ;
// return ld < ldd ? ldd : ld ; // insertion levels of its two darts
//}
/*************************************************** /***************************************************
* ATTRIBUTE HANDLER * * ATTRIBUTE HANDLER *
***************************************************/ ***************************************************/
......
...@@ -224,7 +224,7 @@ inline unsigned int Map1::cycleDegree(Dart d) ...@@ -224,7 +224,7 @@ inline unsigned int Map1::cycleDegree(Dart d)
unsigned int count = 0 ; unsigned int count = 0 ;
Dart it = d ; Dart it = d ;
do do
{ {
++count ; ++count ;
it = phi1(it) ; it = phi1(it) ;
} while (it != d) ; } while (it != d) ;
......
This diff is collapsed.
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