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:
unsigned int newEmb = vID[children[0]->indices[idx]] ;
if(oldEmb == EMBNULL)
{
//std::cout << "oldEmb == NULL"<< std::endl;
map.template setOrbitEmbedding<VERTEX>(dd, newEmb) ;
map.pushLevel() ;
for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i)
......@@ -111,11 +112,16 @@ public:
map.popLevel() ;
}
else
{
//std::cout << "oldEmb != NULL"<< std::endl;
assert(oldEmb == newEmb) ;
}
map.decCurrentLevel() ;
it = next ;
} while(it != d) ;
//embed the 4 children (begin with the center child)
map.incCurrentLevel() ;
Dart d0 = map.phi2(map.phi1(d)) ;
children[0]->embed<PFP>(map, d0, vID) ;
......@@ -155,6 +161,7 @@ public:
std::vector<QuadTreeNode*> roots ;
std::vector<Dart> darts ;
std::vector<unsigned int> verticesID ;
unsigned int depth;
~QuadTree()
{
......
......@@ -77,7 +77,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
std::stringstream oss(line) ;
std::string s ;
oss >> s ;
oss >> depth ;
oss >> qt.depth ;
depth = qt.depth;
}
std::cout << " MR depth -> " << depth << std::endl ;
......@@ -253,19 +254,6 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
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 ;
return true ;
......
......@@ -75,7 +75,7 @@ public:
np2 += m_position[dd] ;
dd = m_map.phi1(dd) ;
} while(dd != end) ;
it = m_map.alpha1(it) ;
it = m_map.phi2(m_map.phi_1(it)) ;
} while(it != d) ;
float beta = 3.0 / (2.0 * degree1) ;
......
......@@ -68,7 +68,7 @@ public:
~Map2MR();
//if true : tri and quad else quad
void addNewLevel(bool triQuad = true) ;
void addNewLevel(bool triQuad = true, bool embedNewVertices = false) ;
void addNewLevelSqrt3();
......@@ -84,6 +84,8 @@ public:
void synthesis() ;
void addLevelFront();
void import(Algo::Surface::Import::QuadTree& qt);
} ;
} // namespace Regular
......
......@@ -22,6 +22,8 @@
* *
*******************************************************************************/
#include "Algo/Import/importMRDAT.h"
namespace CGoGN
{
......@@ -62,7 +64,7 @@ Map2MR<PFP>::~Map2MR()
}
template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool triQuad)
void Map2MR<PFP>::addNewLevel(bool triQuad, bool embedNewVertices)
{
m_map.pushLevel() ;
......@@ -74,18 +76,22 @@ void Map2MR<PFP>::addNewLevel(bool triQuad)
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
// if(!shareVertexEmbeddings)
// {
// if(m_map.template getEmbedding<VERTEX>(d) == EMBNULL)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// if(m_map.template getEmbedding<VERTEX>(m_map.phi1(d)) == EMBNULL)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// }
// if(!shareVertexEmbeddings && embedNewVertices)
// {
// if(m_map.template getEmbedding<VERTEX>(d) == EMBNULL)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// if(m_map.template getEmbedding<VERTEX>(m_map.phi1(d)) == EMBNULL)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// }
m_map.cutEdge(d) ;
travE.skip(d) ;
travE.skip(m_map.phi1(d)) ;
//std::cout << "is EMB NULL : " << ( m_map.template getEmbedding<VERTEX>(m_map.phi1(d)) == EMBNULL ? "true" : "false" ) << std::endl;
//if(embedNewVertices)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(m_map.phi1(d)) ;
}
// split faces
......@@ -129,6 +135,9 @@ void Map2MR<PFP>::addNewLevel(bool triQuad)
m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex
travF.skip(dd) ;
//if(embedNewVertices)
// m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(m_map.phi1(ne)) ;
dd = m_map.phi1(m_map.phi1(next)) ;
while(dd != ne) // turn around the face and insert new edges
{ // linked to the central vertex
......@@ -342,6 +351,24 @@ void Map2MR<PFP>::addLevelFront()
}
}
template <typename PFP>
void Map2MR<PFP>::import(Algo::Surface::Import::QuadTree& qt)
{
std::cout << " Create finer resolution levels.." << std::flush ;
for(unsigned int i = 0; i < qt.depth; ++i)
addNewLevel(true, false) ;
std::cout << "..done" << std::endl ;
std::cout << " Embed finer resolution levels.." << std::flush ;
m_map.setCurrentLevel(0) ;
qt.embed<PFP>(m_map) ;
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
std::cout << "..done" << std::endl ;
}
} // namespace Regular
......
......@@ -281,7 +281,7 @@ public:
/**
* duplicate darts from level-1 to level
*/
void duplicateDarts(unsigned int level);
void duplicateDarts(unsigned int newlevel);
/**
* duplicate a dart starting from current level
......
......@@ -141,6 +141,8 @@ public:
void setDartLevel(Dart d, unsigned int i) ;
void setMaxLevel(unsigned int l);
/***************************************************
* EDGE ID MANAGEMENT *
***************************************************/
......@@ -159,6 +161,10 @@ public:
void setEdgeId(Dart d, unsigned int i) ;
unsigned int getTriRefinementEdgeId(Dart d);
unsigned int getQuadRefinementEdgeId(Dart d);
/***************************************************
* CELLS INFORMATION *
***************************************************/
......
......@@ -314,6 +314,12 @@ inline void ImplicitHierarchicalMap2::setDartLevel(Dart d, unsigned int l)
m_dartLevel[d] = l ;
}
inline void ImplicitHierarchicalMap2::setMaxLevel(unsigned int l)
{
m_maxLevel = l;
}
/***************************************************
* EDGE ID MANAGEMENT *
***************************************************/
......@@ -333,6 +339,42 @@ inline void ImplicitHierarchicalMap2::setEdgeId(Dart d, unsigned int i)
m_edgeId[d] = i ;
}
inline unsigned int ImplicitHierarchicalMap2::getTriRefinementEdgeId(Dart d)
{
unsigned int dId = getEdgeId(phi_1(d));
unsigned int eId = getEdgeId(phi1(d));
unsigned int id = dId + eId;
if(id == 0)
return 1;
else if(id == 1)
return 2;
else if(id == 2)
if(dId == eId)
return 0;
else
return 1;
//else if(id == 3)
return 0;
}
inline unsigned int ImplicitHierarchicalMap2::getQuadRefinementEdgeId(Dart d)
{
unsigned int eId = getEdgeId(phi1(d));
if(eId == 0)
return 1;
//else if(eId == 1)
return 0;
}
inline void ImplicitHierarchicalMap2::setTriRefinementEdgeId(Dart d)
{
}
/***************************************************
* CELLS INFORMATION *
***************************************************/
......
......@@ -244,13 +244,16 @@ void GenericMap::addLevelBack()
std::stringstream ss ;
ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* newAttrib = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1];
// copy the indices of previous level into new level
m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ;
m_mrDarts.push_back(newAttrib) ;
m_mrNbDarts.push_back(0) ;
if(m_mrDarts.size() > 1 )
{
// copy the indices of previous level into new level
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1];
m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ;
}
}
void GenericMap::addLevelFront()
......@@ -341,13 +344,22 @@ void GenericMap::copyLevel(unsigned int level)
m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ;
}
void GenericMap::duplicateDarts(unsigned int level)
void GenericMap::duplicateDarts(unsigned int newlevel)
{
AttributeMultiVector<unsigned int>* attrib = m_mrDarts[level] ;
// AttributeMultiVector<unsigned int>* attrib = m_mrDarts[level] ; //is a copy of the mrDarts at level-1 or level+1
// for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
// {
// unsigned int oldi = (*attrib)[i] ; // get the index of the dart in previous level
// (*attrib)[i] = copyDartLine(oldi) ; // copy the dart and affect it to the new level
// }
AttributeMultiVector<unsigned int>* attrib = m_mrDarts[newlevel] ; //is a copy of the mrDarts at level-1 or level+1
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newlevel - 1] ; // copy the indices of
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int oldi = (*attrib)[i] ; // get the index of the dart in previous level
unsigned int oldi = (*prevAttrib)[i] ; // get the index of the dart in previous level
(*attrib)[i] = copyDartLine(oldi) ; // copy the dart and affect it to the new level
}
}
......
......@@ -57,13 +57,13 @@ void ImplicitHierarchicalMap2::clear(bool removeAttrib)
void ImplicitHierarchicalMap2::initImplicitProperties()
{
initEdgeId() ;
//initEdgeId() ;
// //init each edge Id at 0
// for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
// {
// m_edgeId[d] = 0;
// }
//init each edge Id at 0
for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
{
m_edgeId[d] = 0;
}
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
......
......@@ -695,13 +695,16 @@ bool EmbeddedMap2::check()
CGoGNout << "Check: embedding ok" << CGoGNendl ;
std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ;
std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;
if (isOrbitEmbedded<VERTEX>())
std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;
std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ;
std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;
if (isOrbitEmbedded<EDGE>())
std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;
std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ;
std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;
if (isOrbitEmbedded<FACE>())
std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;
return true ;
}
......
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