Commit f3132155 authored by untereiner's avatar untereiner

some changes to implicit MR management

parent 10e52114
......@@ -96,11 +96,8 @@ void MyQT::cb_redraw()
m_render->draw(m_lines, Algo::Render::GL2::POINTS);
}
// mouse picking
void MyQT::tiling(int code)
void MyQT::squareTiling(int code)
{
//myMap.clear(false);
switch(code)
{
case 1:
......@@ -187,10 +184,97 @@ void MyQT::tiling(int code)
break;
}
}
}
// mouse picking
void MyQT::triangularTiling(int code)
{
switch(code)
{
case 1:
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
break;
}
case 2:
{
// std::cout << "square grid twisted strip tiling" << std::endl;
// Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
// g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
break;
}
case 3:
{
// std::cout << "square grid helocoid tiling" << std::endl;
// Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
// g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
break;
}
case 4:
{
// std::cout << "square cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 5:
{
// std::cout << "square cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleBottom();
// c.triangleTop();
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 6:
{
// std::cout << "square cylinder sphere tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoSphere(position,0.5);
break;
}
case 7:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoCone(position,0.5, 5.0);
break;
}
case 8:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
// c.embedIntoCube(position,5.0,5.0, 5.0);
break;
}
case 9:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
// m_positionVBO->updateData(position);
// m_lines->setAttributePosition(m_positionVBO);
// updateGL();
break;
}
default:
{
break;
}
}
}
int main(int argc, char **argv)
......@@ -208,9 +292,12 @@ int main(int argc, char **argv)
if (!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3, VERTEX>("normal");
if(argc == 2)
if(argc == 3)
{
sqt.tiling(atoi(argv[1]));
if(argv[1][0] == 'S')
sqt.squareTiling(atoi(argv[2]));
else if(argv[1][0] == 'T')
sqt.triangularTiling(atoi(argv[2]));
}
......
......@@ -37,15 +37,34 @@ namespace Surface
namespace Geometry
{
//! \brief Compute triangle area
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP>
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>
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>
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>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
......
......@@ -25,7 +25,7 @@
#ifndef __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/traversor2.h"
......@@ -52,8 +52,6 @@ class IHM2
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
MAP& m_map;
......@@ -67,6 +65,59 @@ public:
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:
/***************************************************
* SUBDIVISION *
......@@ -88,11 +139,6 @@ public:
*/
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
*/
......
......@@ -80,6 +80,7 @@ public:
m_map.decCurrentLevel();
++count;
}
ef /= count;
ef *= 2.0;
......@@ -89,6 +90,7 @@ public:
Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] += vf + ef ;
m_map.decCurrentLevel() ;
break;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
......
......@@ -105,8 +105,8 @@ public:
bool operator() (Dart d)
{
//Dart df = m_map.phi1(m_map.phi1(d)) ;
Dart df = m_map.phi1(d) ;
Dart df = m_map.phi1(m_map.phi1(d)) ;
//Dart df = m_map.phi1(d) ;
m_map.decCurrentLevel() ;
......
......@@ -64,9 +64,8 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
// store last row of vertices
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
for (unsigned int i = 0; i < y; ++i)
......@@ -75,11 +74,11 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
if (i > 0) // sew with preceeding row
{
int pos = i*(x+1)+j;
Dart d = this->m_tableVertDarts[pos];
Dart e = this->m_tableVertDarts[pos-(x+1)];
e = this->m_map.phi1(this->m_map.phi1(e));
this->m_map.sewFaces(d, e, false);
// int pos = i*(x+1)+j;
// Dart d = this->m_tableVertDarts[pos];
// Dart e = this->m_tableVertDarts[pos-(x+1)];
// e = this->m_map.phi_1(e);
// this->m_map.sewFaces(d, e, false);
}
if (j > 0) // sew with preceeding column
{
......@@ -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)
{
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);
}
}
}
......
......@@ -121,6 +121,8 @@ public:
void splitFace(Dart d, Dart e) ;
unsigned int vertexDegree(Dart d);
/***************************************************
* LEVELS MANAGEMENT *
***************************************************/
......@@ -162,57 +164,64 @@ public:
***************************************************/
/**
* Return the level of insertion of the vertex of d
* @brief faceDegree
* @param d
* @return
*/
unsigned int vertexInsertionLevel(Dart d) ;
unsigned int faceDegree(Dart d);
/**
* 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
* Return the level of insertion of the vertex of d
*/
bool faceIsSubdivided(Dart d) ;
unsigned int vertexInsertionLevel(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) ;
// /**
// * 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) ;
} ;
template <typename T, unsigned int ORBIT>
......
......@@ -95,7 +95,7 @@ inline Dart ImplicitHierarchicalMap2::phi1(Dart d)
else
{
while(m_edgeId[it] != edgeId)
it = Map2::alpha_1(it) ;
it = Map2::phi1(Map2::phi2(it)) ;
}
} while(!finished) ;
return it ;
......@@ -126,7 +126,7 @@ inline Dart ImplicitHierarchicalMap2::phi2(Dart d)
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
if(Map2::phi2(d) == d)
return d ;
return Map2::alpha1(phi1(d)) ;
return Map2::phi2(Map2::phi_1(phi1(d))) ;
}
inline Dart ImplicitHierarchicalMap2::alpha0(Dart d)
......@@ -337,21 +337,35 @@ inline void ImplicitHierarchicalMap2::setEdgeId(Dart d, unsigned int i)
* 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") ;
return m_dartLevel[d] ;
unsigned int count = 0 ;
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") ;
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
return m_dartLevel[d] ;
}
//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 *
***************************************************/
......
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