Commit 71e9d333 authored by untereiner's avatar untereiner

regular primal sqrt(3) refinement

parent ddb659ea
......@@ -250,7 +250,104 @@ public:
}
} ;
/*********************************************************************************
* SYNTHESIS FILTERS
*********************************************************************************/
/* Linear Interpolation
*********************************************************************************/
template <typename PFP>
class LerpEdgeSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpEdgeSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(d) ;
m_position[midV] = p ;
m_map.decCurrentLevel() ;
}
}
} ;
template <typename PFP>
class LerpFaceSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
if(m_map.faceDegree(d) != 3)
{
Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] = p ;
}
m_map.decCurrentLevel() ;
}
}
} ;
/* SQRT(3)
*********************************************************************************/
template <typename PFP>
class Sqrt3OddSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map;
VertexAttribute<typename PFP::VEC3>& m_position;
public:
Sqrt3OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorF<typename PFP::MAP> trav(m_map);
for(Dart d = trav.begin() ; d != trav.end() ; d = trav.next())
{
typename PFP::VEC3 p(0.0);
p += m_position[d];
p += m_position[m_map.phi1(d)];
p += m_position[m_map.phi_1(d)];
p /= 3.0;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
m_position[midF] = p ;
m_map.decCurrentLevel() ;
}
}
};
/*********************************************************************************
......
......@@ -143,14 +143,13 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
unsigned int percentWantedPerLevel = 20;
unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ;
//create the new level
m_map.addLevelFront();
m_map.setCurrentLevel(0);
m_map.printMR();
std::vector<Dart> edges;
edges.reserve(nbWantedPerLevel);
DartMarkerStore me(m_map); //mark edges not to collapse
std::cout << " nbWantedPerLevel : " << nbWantedPerLevel << std::endl;
bool finished = false ;
Dart d ;
while(!finished)
......@@ -179,27 +178,41 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
me.markOrbit<FACE>(it);
}
++nbDeletedVertex ;
Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
m_selector->updateBeforeCollapse(d) ; // update selector
edges.push_back(d);
collapseEdge(d);
m_selector->updateAfterCollapse(d2, dd2) ; // update selector
if(nbDeletedVertex <= nbWantedPerLevel)
finished = true ;
std::cout << " nbDeletedVertex : " << nbDeletedVertex << std::endl;
}
}
if(nbDeletedVertex > nbWantedPerLevel)
finished = true ;
}
CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ;
m_map.printMR();
std::cout << " finished " << std::endl;
// //create the new level
// m_map.addLevelFront();
// m_map.setCurrentLevel(0);
//
//
//
//
//
// Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
// Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
//
// m_selector->updateBeforeCollapse(d) ; // update selector
//
// collapseEdge(d);
//
// m_selector->updateAfterCollapse(d2, dd2) ; // update selector
//
//
// CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ;
//
// m_map.printMR();
}
......
......@@ -119,14 +119,22 @@ public:
*/
bool faceIsSubdividedOnce(Dart d) ;
/***************************************************
* SUBDIVISION *
***************************************************/
protected:
/**
*
*/
Dart cutEdge(Dart d) ;
/**
*
*/
void splitFace(Dart d, Dart e) ;
protected:
/***************************************************
* SUBDIVISION *
***************************************************/
/**
* subdivide the edge of d to the next level
*/
......@@ -143,8 +151,6 @@ public:
*/
unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true);
unsigned int subdivideFace2(Dart d) ;
/**
* coarsen the face of d from the next level
*/
......
......@@ -419,58 +419,6 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe
return fLevel ;
}
template <typename PFP>
unsigned int Map2MR<PFP>::subdivideFace2(Dart d)
{
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ;
assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
unsigned int fLevel = faceLevel(d) ;
Dart old = faceOldestDart(d) ;
std::cout << "face level " << fLevel << std::endl;
std::cout << "oldestDart " << old << std::endl;
m_map.pushLevel() ;
m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
if(m_map.getCurrentLevel() == m_map.getMaxLevel())
{
std::cout << "addLevelBack" << std::endl;
m_map.addLevelBack();
}
unsigned int degree = 3 ;
Dart it = old ;
if(!edgeIsSubdivided(it))
{
std::cout << "1" << std::endl;
subdivideEdge(it) ;
}
it = m_map.phi1(it) ;
if(!edgeIsSubdivided(it))
{
std::cout << "2" << std::endl;
subdivideEdge(it) ;
}
it = m_map.phi1(it) ;
if(!edgeIsSubdivided(it))
{
std::cout << "3" << std::endl;
subdivideEdge(it) ;
}
it = m_map.phi1(it) ;
std::cout << "degree = " << degree << std::endl;
m_map.popLevel() ;
return fLevel ;
}
template <typename PFP>
void Map2MR<PFP>::coarsenFace(Dart d)
{
......
......@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
}
template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool triQuad = true, bool embedNewVertices = true)
void Map2MR<PFP>::addNewLevel(bool triQuad, bool embedNewVertices)
{
m_map.pushLevel() ;
......@@ -150,22 +150,19 @@ void Map2MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
DartMarkerStore m(map) ;
//split faces
TraversorF<typename PFP::MAP> t(map) ;
TraversorF<typename PFP::MAP> t(m_map) ;
for (Dart dit = t.begin(); dit != t.end(); dit = t.next())
{
Dart d1 = m_map.phi1(dit);
splitFace(dit, d1) ;
cutEdge(m_map.phi_1(dit)) ;
m_map.splitFace(dit, d1) ;
m_map.cutEdge(m_map.phi_1(dit)) ;
Dart x = m_map.phi2(m_map.phi_1(dit)) ;
Dart dd = map.template phi<111>(x) ;
Dart dd = m_map.phi1(m_map.phi1(m_map.phi1((x))));
while(dd != x)
{
Dart next = m_map.phi1(dd) ;
splitFace(dd, m_map.phi1(x)) ;
m_map.splitFace(dd, m_map.phi1(x)) ;
dd = next ;
}
......@@ -177,21 +174,17 @@ void Map2MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
Dart fit = cd ;
do
{
m.markOrbit<EDGE>(fit);
t.skip(fit);
fit = map.phi2(map.phi_1(fit));
fit = m_map.phi2(m_map.phi_1(fit));
} while(fit != cd);
}
//swap edges
TraversorE<typename PFP::MAP> te(map) ;
TraversorE<typename PFP::MAP> te(m_map) ;
for (Dart dit = te.begin(); dit != te.end(); dit = te.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<EDGE>(dit);
}
if(m_map.getDartLevel(dit) < m_map.getCurrentLevel())
m_map.flipEdge(dit);
}
m_map.popLevel() ;
......
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