Commit a119b8e3 authored by untereiner's avatar untereiner

changes to MRDAT import and ihm2 management (introducing CPH edge tagging)

parent e64e829b
...@@ -101,6 +101,7 @@ public: ...@@ -101,6 +101,7 @@ public:
unsigned int newEmb = vID[children[0]->indices[idx]] ; unsigned int newEmb = vID[children[0]->indices[idx]] ;
if(oldEmb == EMBNULL) if(oldEmb == EMBNULL)
{ {
//std::cout << "oldEmb == NULL"<< std::endl;
map.template setOrbitEmbedding<VERTEX>(dd, newEmb) ; map.template setOrbitEmbedding<VERTEX>(dd, newEmb) ;
map.pushLevel() ; map.pushLevel() ;
for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i) for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i)
...@@ -111,11 +112,16 @@ public: ...@@ -111,11 +112,16 @@ public:
map.popLevel() ; map.popLevel() ;
} }
else else
{
//std::cout << "oldEmb != NULL"<< std::endl;
assert(oldEmb == newEmb) ; assert(oldEmb == newEmb) ;
}
map.decCurrentLevel() ; map.decCurrentLevel() ;
it = next ; it = next ;
} while(it != d) ; } while(it != d) ;
//embed the 4 children (begin with the center child)
map.incCurrentLevel() ; map.incCurrentLevel() ;
Dart d0 = map.phi2(map.phi1(d)) ; Dart d0 = map.phi2(map.phi1(d)) ;
children[0]->embed<PFP>(map, d0, vID) ; children[0]->embed<PFP>(map, d0, vID) ;
...@@ -155,6 +161,7 @@ public: ...@@ -155,6 +161,7 @@ public:
std::vector<QuadTreeNode*> roots ; std::vector<QuadTreeNode*> roots ;
std::vector<Dart> darts ; std::vector<Dart> darts ;
std::vector<unsigned int> verticesID ; std::vector<unsigned int> verticesID ;
unsigned int depth;
~QuadTree() ~QuadTree()
{ {
......
...@@ -77,7 +77,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto ...@@ -77,7 +77,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
std::stringstream oss(line) ; std::stringstream oss(line) ;
std::string s ; std::string s ;
oss >> s ; oss >> s ;
oss >> depth ; oss >> qt.depth ;
depth = qt.depth;
} }
std::cout << " MR depth -> " << depth << std::endl ; std::cout << " MR depth -> " << depth << std::endl ;
...@@ -253,19 +254,6 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto ...@@ -253,19 +254,6 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
return false ; return false ;
} }
std::cout << "..done" << std::endl ;
std::cout << " Create finer resolution levels.." << std::flush ;
for(unsigned int i = 0; i < depth; ++i)
map.addNewLevel(false) ;
std::cout << "..done" << std::endl ;
std::cout << " Embed finer resolution levels.." << std::flush ;
map.setCurrentLevel(0) ;
qt.embed<PFP>(map) ;
map.setCurrentLevel(map.getMaxLevel()) ;
std::cout << "..done" << std::endl ; std::cout << "..done" << std::endl ;
return true ; return true ;
......
...@@ -39,8 +39,8 @@ namespace Regular ...@@ -39,8 +39,8 @@ namespace Regular
template <typename PFP> template <typename PFP>
IHM2<PFP>::IHM2(typename PFP::MAP& map) : IHM2<PFP>::IHM2(typename PFP::MAP& map) :
m_map(map), m_map(map),
shareVertexEmbeddings(true) shareVertexEmbeddings(true)
{ {
} }
...@@ -49,109 +49,113 @@ IHM2<PFP>::IHM2(typename PFP::MAP& map) : ...@@ -49,109 +49,113 @@ IHM2<PFP>::IHM2(typename PFP::MAP& map) :
template <typename PFP> template <typename PFP>
void IHM2<PFP>::addNewLevel(bool triQuad) void IHM2<PFP>::addNewLevel(bool triQuad)
{ {
unsigned int cur = m_map.getCurrentLevel() ; //pushLevel unsigned int cur = m_map.getCurrentLevel() ; //pushLevel
m_map.setCurrentLevel(m_map.getMaxLevel() + 1) ; m_map.setCurrentLevel(m_map.getMaxLevel() + 1) ;
// cut edges // cut edges
TraversorE<typename PFP::MAP> travE(m_map) ; TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{ {
Dart dd = m_map.phi2(d) ; Dart dd = m_map.phi2(d) ;
m_map.cutEdge(d) ; m_map.cutEdge(d) ;
unsigned int eId = m_map.getEdgeId(d) ; unsigned int eId = m_map.getEdgeId(d) ;
m_map.setEdgeId(m_map.phi1(d), eId) ; m_map.setEdgeId(m_map.phi1(d), eId) ;
m_map.setEdgeId(m_map.phi1(dd), eId) ; m_map.setEdgeId(m_map.phi1(dd), eId) ;
travE.skip(d) ; travE.skip(d) ;
travE.skip(m_map.phi1(d)) ; travE.skip(m_map.phi1(d)) ;
} }
// split faces // split faces
TraversorF<typename PFP::MAP> travF(m_map) ; TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{ {
Dart old = d ; Dart old = d ;
if(m_map.getDartLevel(old) == m_map.getMaxLevel()) if(m_map.getDartLevel(old) == m_map.getMaxLevel())
old = m_map.phi1(old) ; old = m_map.phi1(old) ;
m_map.decCurrentLevel(); m_map.decCurrentLevel();
unsigned int degree = m_map.faceDegree(old) ; unsigned int degree = m_map.faceDegree(old) ;
m_map.incCurrentLevel(); m_map.incCurrentLevel();
if((degree == 3) && triQuad) // if subdividing a triangle if((degree == 3) && triQuad) // if subdividing a triangle
{ {
Dart dd = m_map.phi1(old) ; Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(m_map.phi1(dd)) ; Dart e = m_map.phi1(m_map.phi1(dd)) ;
m_map.splitFace(dd, e) ; // insert a new edge m_map.splitFace(dd, e) ; // insert a new edge
travF.skip(dd) ; travF.skip(dd) ;
unsigned int id = m_map.getNewEdgeId() ; //unsigned int id = m_map.getNewEdgeId() ;
m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted
m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id
dd = e ;
e = m_map.phi1(m_map.phi1(dd)) ; dd = e ;
m_map.splitFace(dd, e) ; e = m_map.phi1(m_map.phi1(dd)) ;
travF.skip(dd) ; m_map.splitFace(dd, e) ;
id = m_map.getNewEdgeId() ; travF.skip(dd) ;
m_map.setEdgeId(m_map.phi_1(dd), id) ; //id = m_map.getNewEdgeId() ;
m_map.setEdgeId(m_map.phi_1(e), id) ; id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
m_map.setEdgeId(m_map.phi_1(dd), id) ;
dd = e ; m_map.setEdgeId(m_map.phi_1(e), id) ;
e = m_map.phi1(m_map.phi1(dd)) ;
m_map.splitFace(dd, e) ; dd = e ;
travF.skip(dd) ; e = m_map.phi1(m_map.phi1(dd)) ;
id = m_map.getNewEdgeId() ; m_map.splitFace(dd, e) ;
m_map.setEdgeId(m_map.phi_1(dd), id) ; travF.skip(dd) ;
m_map.setEdgeId(m_map.phi_1(e), id) ; //id = m_map.getNewEdgeId() ;
id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
travF.skip(e) ; m_map.setEdgeId(m_map.phi_1(dd), id) ;
} m_map.setEdgeId(m_map.phi_1(e), id) ;
else // if subdividing a polygonal face
{ travF.skip(e) ;
Dart dd = m_map.phi1(old) ; }
Dart next = m_map.phi1(m_map.phi1(dd)) ; else // if subdividing a polygonal face
m_map.splitFace(dd, next) ; // insert a first edge {
Dart dd = m_map.phi1(old) ;
Dart ne = m_map.phi2(m_map.phi_1(dd)) ; Dart next = m_map.phi1(m_map.phi1(dd)) ;
Dart ne2 = m_map.phi2(ne) ; m_map.splitFace(dd, next) ; // insert a first edge
m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex
travF.skip(dd) ; Dart ne = m_map.phi2(m_map.phi_1(dd)) ;
unsigned int id = m_map.getNewEdgeId() ; Dart ne2 = m_map.phi2(ne) ;
m_map.setEdgeId(ne, id) ; m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex
m_map.setEdgeId(m_map.phi2(ne), id) ; // set the edge id of the inserted travF.skip(dd) ;
id = m_map.getNewEdgeId() ; //unsigned int id = m_map.getNewEdgeId() ;
m_map.setEdgeId(ne2, id) ; // edges to the next available ids unsigned int id = m_map.getQuadRefinementEdgeId(m_map.phi2(ne));
m_map.setEdgeId(m_map.phi2(ne2), id) ; m_map.setEdgeId(ne, id) ;
m_map.setEdgeId(m_map.phi2(ne), id) ; // set the edge id of the inserted
dd = m_map.phi1(m_map.phi1(next)) ; //id = m_map.getNewEdgeId() ;
while(dd != ne) // turn around the face and insert new edges id = m_map.getQuadRefinementEdgeId(ne2);
{ // linked to the central vertex m_map.setEdgeId(ne2, id) ; // edges to the next available ids
Dart tmp = m_map.phi1(ne) ; m_map.setEdgeId(m_map.phi2(ne2), id) ;
m_map.splitFace(tmp, dd) ;
travF.skip(tmp) ; dd = m_map.phi1(m_map.phi1(next)) ;
Dart nne = m_map.phi2(m_map.phi_1(dd)) ; while(dd != ne) // turn around the face and insert new edges
id = m_map.getNewEdgeId() ; { // linked to the central vertex
m_map.setEdgeId(nne, id) ; Dart tmp = m_map.phi1(ne) ;
m_map.setEdgeId(m_map.phi2(nne), id) ; m_map.splitFace(tmp, dd) ;
dd = m_map.phi1(m_map.phi1(dd)) ; travF.skip(tmp) ;
} Dart nne = m_map.phi2(m_map.phi_1(dd)) ;
travF.skip(ne) ; //id = m_map.getNewEdgeId() ;
} id = m_map.getQuadRefinementEdgeId(m_map.phi2(nne));
} m_map.setEdgeId(nne, id) ;
m_map.setEdgeId(m_map.phi2(nne), id) ;
m_map.setCurrentLevel(cur) ; dd = m_map.phi1(m_map.phi1(dd)) ;
}
travF.skip(ne) ;
}
}
m_map.setCurrentLevel(cur) ;
} }
template <typename PFP> template <typename PFP>
void IHM2<PFP>::addLevelFront() void IHM2<PFP>::addLevelFront()
{ {
DartMarker md(m_map); std::vector<Dart> irregVertices;
irregVertices.reserve(1024);
std::vector<Dart> visitedVertices;
visitedVertices.reserve(1024);
//look for an irregular vertex //look for an irregular vertex
...@@ -162,77 +166,154 @@ void IHM2<PFP>::addLevelFront() ...@@ -162,77 +166,154 @@ void IHM2<PFP>::addLevelFront()
if(m_map.vertexDegree(d) != 6) if(m_map.vertexDegree(d) != 6)
{ {
found = true; found = true;
visitedVertices.push_back(d); irregVertices.push_back(d);
} }
} }
std::cout << "d = " << visitedVertices[0] << std::endl; //found the number of levels
bool finished = false;
Dart dit = irregVertices[0];
unsigned int nbSteps = 0;
do
{
dit = m_map.phi1(m_map.phi2(m_map.phi1(m_map.phi2(m_map.phi1(dit)))));
++nbSteps;
if(m_map.vertexDegree(m_map.phi1(dit)) != 6)
finished = true;
}while(!finished);
for(unsigned int i = 0 ; i < visitedVertices.size() ; ++i) ++nbSteps;
unsigned int nbLevel = 0;
while(nbSteps > 1)
{ {
Dart d = visitedVertices[i]; nbSteps /= 2 ;
++nbLevel ;
}
m_map.setMaxLevel(nbLevel);
std::cout << "nb levels = " << nbLevel+1 << std::endl;
Traversor2VE<typename PFP::MAP> tve(m_map, d); unsigned int curLevel = nbLevel;
for(Dart eit = tve.begin() ; eit != tve.end() ; eit = tve.next())
do
{
m_map.setCurrentLevel(curLevel);
DartMarker md(m_map);
std::vector<Dart> visitedVertices(irregVertices);
std::cout << "getCurrentLevel = " << m_map.getCurrentLevel() << std::endl;
for(unsigned int i = 0 ; i < visitedVertices.size() ; ++i)
{ {
//coarse all faces around the vertex Dart d = visitedVertices[i];
if(!md.isMarked(eit))
{
unsigned int degree = m_map.faceDegree(eit);
if(degree == 3) Traversor2VE<typename PFP::MAP> tve(m_map, d);
for(Dart eit = tve.begin() ; eit != tve.end() ; eit = tve.next())
{
//coarse all faces around the vertex
if(!md.isMarked(eit))
{ {
Dart fit1 = m_map.phi2(m_map.phi1(eit)); Dart fit1 = m_map.phi2(m_map.phi1(eit));
Dart fit2 = m_map.phi1(fit1); Dart fit2 = m_map.phi1(fit1);
Dart fit3 = m_map.phi1(fit2); Dart fit3 = m_map.phi1(fit2);
unsigned int id = m_map.getNewEdgeId() ;
m_map.setEdgeId(fit1, id) ;
id = m_map.getNewEdgeId() ;
m_map.setEdgeId(fit2, id) ;
id = m_map.getNewEdgeId() ;
m_map.setEdgeId(fit3, id) ;
md.markOrbit<FACE>(fit1); md.markOrbit<FACE>(fit1);
md.markOrbit<FACE>(m_map.phi2(fit2)); md.markOrbit<FACE>(m_map.phi2(fit2));
md.markOrbit<FACE>(m_map.phi2(fit3)); md.markOrbit<FACE>(m_map.phi2(fit3));
md.markOrbit<FACE>(eit);
visitedVertices.push_back(m_map.phi_1(m_map.phi2(fit2)));
visitedVertices.push_back(m_map.phi_1(m_map.phi2(fit3)));
m_map.setDartLevel(fit1, curLevel);
m_map.setDartLevel(m_map.phi2(fit1), curLevel);
m_map.setDartLevel(m_map.phi1(m_map.phi2(fit1)), curLevel);
m_map.setDartLevel(fit2, curLevel);
m_map.setDartLevel(m_map.phi2(fit2), curLevel);
m_map.setDartLevel(m_map.phi1(m_map.phi2(fit2)), curLevel);
m_map.setDartLevel(fit3, curLevel);
m_map.setDartLevel(m_map.phi2(fit3), curLevel);
m_map.setDartLevel(m_map.phi1(m_map.phi2(fit3)), curLevel);
if(curLevel == maxLevel)
{
unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi2(fit1));
m_map.setEdgeId(m_map.phi2(fit1), id);
m_map.setEdgeId(fit1, id);
id = m_map.getTriRefinementEdgeId(m_map.phi2(fit2));
m_map.setEdgeId(m_map.phi2(fit2), id);
m_map.setEdgeId(fit2, id);
id = m_map.getTriRefinementEdgeId(m_map.phi2(fit3));
m_map.setEdgeId(m_map.phi2(fit3), id);
m_map.setEdgeId(fit3, id);
}
else
{
}
// if(curLevel == 2)
// {
// unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi2(fit1));
// m_map.setEdgeId(m_map.phi2(fit1), id);
// m_map.setEdgeId(fit1, id);
//m_map.setEdgeId(fit1, id);
// /std::cout << "fit1 = " << fit1 << std::endl;
//std::cout << "m_map.phi2(fit1) = " << m_map.phi2(fit1) << std::endl;
// id = m_map.getTriRefinementEdgeId(m_map.phi2(fit2));
// m_map.setEdgeId(m_map.phi2(fit2), id);
// m_map.setEdgeId(fit2, id);
//m_map.setEdgeId(fit2, id);
//std::cout << "fit2 = " << fit2 << std::endl;
//std::cout << "m_map.phi2(fit2) = " << m_map.phi2(fit2) << std::endl;
// id = m_map.getTriRefinementEdgeId(m_map.phi2(fit3));
// m_map.setEdgeId(m_map.phi2(fit3), id);
// m_map.setEdgeId(fit3, id);
//m_map.setEdgeId(fit3, id);
//std::cout << "fit3 = " << fit3 << std::endl;
//std::cout << "m_map.phi2(fit3) = " << m_map.phi2(fit3) << std::endl;
// }
} }
else }
{ }
} curLevel = curLevel - 1;
visitedVertices.push_back(m_map.phi1(m_map.phi1(eit))); }while(curLevel > 1);
visitedVertices.push_back(m_map.phi_1(m_map.phi_1(eit)));
md.markOrbit<FACE>(eit);
} m_map.setCurrentLevel(nbLevel); //m_maxLevel
}
}
} }
template <typename PFP> template <typename PFP>
void IHM2<PFP>::analysis() void IHM2<PFP>::analysis()
{ {
assert(m_map.getCurrentLevel() > 0 || !"analysis : called on level 0") ; assert(m_map.getCurrentLevel() > 0 || !"analysis : called on level 0") ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
for(unsigned int i = 0; i < analysisFilters.size(); ++i) for(unsigned int i = 0; i < analysisFilters.size(); ++i)
(*analysisFilters[i])() ; (*analysisFilters[i])() ;
} }
template <typename PFP> template <typename PFP>
void IHM2<PFP>::synthesis() void IHM2<PFP>::synthesis()
{ {
assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ; assert(m_map.getCurrentLevel() < m_map.getMaxLevel() || !"synthesis : called on max level") ;
for(unsigned int i = 0; i < synthesisFilters.size(); ++i) for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
(*synthesisFilters[i])() ; (*synthesisFilters[i])() ;
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
} }
} // namespace Regular } // namespace Regular
......
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
np2 += m_position[dd] ; np2 += m_position[dd] ;
dd = m_map.phi1(dd) ; dd = m_map.phi1(dd) ;
} while(dd != end) ; } while(dd != end) ;
it = m_map.alpha1(it) ; it = m_map.phi2(m_map.phi_1(it)) ;
} while(it != d) ; } while(it != d) ;
float beta = 3.0 / (2.0 * degree1) ; float beta = 3.0 / (2.0 * degree1) ;
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
~Map2MR(); ~Map2MR();
//if true : tri and quad else quad //if true : tri and quad else quad
void addNewLevel(bool triQuad = true) ; void addNewLevel(bool triQuad = true, bool embedNewVertices = false) ;
void addNewLevelSqrt3(); void addNewLevelSqrt3();
...@@ -84,6 +84,8 @@ public: ...@@ -84,6 +84,8 @@ public:
void synthesis() ; void synthesis() ;
void addLevelFront(); void addLevelFront();
void import(Algo::Surface::Import::QuadTree& qt);
} ; } ;
} // namespace Regular } // namespace Regular
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Algo/Import/importMRDAT.h"
namespace CGoGN namespace CGoGN
{