Commit a4662d33 authored by untereiner's avatar untereiner

adding sqrt3 MR refinements

parent 52a85abe
......@@ -295,6 +295,55 @@ void MyQT::createMap(int n)
updateMap();
}
void MyQT::createMapTets()
{
myMap.clear(true);
position = myMap.getAttribute<VEC3, VERTEX>("position");
if (!position.isValid())
position = myMap.addAttribute<VEC3, VERTEX>("position");
Dart dd = Algo::Surface::Modelisation::createTetrahedron<PFP>(myMap);
myMap.closeMap();
Dart ee =Algo::Surface::Modelisation::createTetrahedron<PFP>(myMap);
myMap.closeMap();
myMap.sewVolumes(dd,ee);
Dart t1 = dd;
position[t1] = VEC3(0.0f, 0.0f, 0.0f);
t1 = myMap.phi1(t1);
position[t1] = VEC3(0.0f, 1.0f, 0.0f);
t1 = myMap.phi1(t1);
position[t1] = VEC3(1.0f, 0.5f, 0.0f);
t1 = myMap.phi_1(myMap.phi2(dd));
position[t1] = VEC3(0.f, 0.5f, 1.0f);
Dart t2 = ee;
position[t2] = VEC3(0.0f, 1.0f, 0.0f);
t2 = myMap.phi1(t2);
position[t2] = VEC3(0.0f, 0.0f, 0.0f);
t2 = myMap.phi1(t2);
position[t2] = VEC3(1.0f, 0.5f, 0.0f);
t2 = myMap.phi_1(myMap.phi2(ee));
position[t2] = VEC3(0.f, 0.5f, -1.0f);
myMap.check();
// bounding box of scene
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
m_shift = bb.maxSize()/200.0f;
// first show for be sure that GL context is binded
show();
// render the topo of the map without boundary darts
m_render_topo->setDartWidth(3.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
updateMap();
}
void MyQT::updateMap()
{
#ifdef PRIMAL_TOPO
......@@ -356,7 +405,7 @@ void MyQT::cb_redraw()
m_render_topo->drawTopo();
m_render_topo_boundary->drawTopo();
m_render_topo_boundary->drawTopo();
glDisable( GL_POLYGON_OFFSET_FILL );
......@@ -386,7 +435,13 @@ void MyQT::cb_mousePress(int button, int x, int y)
if (button == Qt::LeftButton)
{
if (d != Dart::nil())
{
m_selected = d;
std::cout << "m_selected = " << m_selected << std::endl;
}
}
if (button == Qt::RightButton)
{
......@@ -544,6 +599,51 @@ void MyQT::cb_keyPress(int keycode)
updateMap();
updateGL();
break;
case '9':
createMapTets();
updateMap();
updateGL();
break;
case '8':
{
if (m_selected != NIL)
{
std::vector<Dart> edges;
Dart d2_1 = myMap.phi_1(myMap.phi2(m_selected));
myMap.mergeVolumes(m_selected,false);
Dart d2 = myMap.phi1(d2_1);
Dart d3 = myMap.phi3(d2);
myMap.flipEdge(d2);
myMap.flipBackEdge(d3);
Dart e = myMap.phi2(d2) ;
myMap.copyDartEmbedding<VERTEX>(d2, myMap.phi1(e)) ;
myMap.copyDartEmbedding<VERTEX>(e, myMap.phi1(d2)) ;
Dart e3 = myMap.phi2(d3);
myMap.copyDartEmbedding<VERTEX>(d3, myMap.phi1(e3)) ;
myMap.copyDartEmbedding<VERTEX>(e3, myMap.phi1(d3)) ;
Dart stop = myMap.phi_1(d2_1);
Dart dit = stop;
do
{
edges.push_back(dit);
dit = myMap.phi1(myMap.phi2(myMap.phi1(dit)));
}
while(dit != stop);
myMap.splitVolumeWithFace(edges,myMap.phi_1(myMap.phi3(m_selected)));
m_selected = NIL;
updateMap();
updateGL();
}
break;
}
case 'c':
myMap.check();
break;
......
......@@ -145,6 +145,7 @@ protected:
public:
// example of simple map creation
void createMap(int n);
void createMapTets();
void updateMap();
void importMesh(std::string& filename);
......
......@@ -180,15 +180,19 @@ Dart Map3MR<PFP>::swap2To2(Dart d)
m_map.mergeVolumes(d,false);
Dart d2 = m_map.phi1(d2_1);
m_map.flipEdge(m_map.phi1(d2_1));
//m_map.flipBackEdge(m_map.phi3(m_map.phi1(d2_1)));
Dart d3 = m_map.phi3(d2);
m_map.flipEdge(d2);
m_map.flipBackEdge(d3);
Dart e = m_map.phi2(d2) ;
m_map.template copyDartEmbedding<VERTEX>(d2, m_map.phi1(e)) ;
//m_map.template setOrbitEmbedding<VERTEX>(d2, m_map.template getEmbedding<VERTEX>(m_map.phi1(e))) ;
//m_map.template setOrbitEmbedding<VERTEX>(e, m_map.template getEmbedding<VERTEX>(m_map.phi1(d2))) ;
m_map.template copyDartEmbedding<VERTEX>(e, m_map.phi1(d2)) ;
Dart e3 = m_map.phi2(d3);
m_map.template copyDartEmbedding<VERTEX>(d3, m_map.phi1(e3)) ;
m_map.template copyDartEmbedding<VERTEX>(e3, m_map.phi1(d3)) ;
Dart stop = m_map.phi_1(d2_1);
Dart dit = stop;
do
......@@ -296,10 +300,8 @@ void Map3MR<PFP>::addNewLevelSqrt3(bool embedNewVertices, VertexAttribute<typena
m_map.setCurrentLevel(m_map.getMaxLevel());
DartMarkerStore m(m_map);
DartMarkerStore newBoundaryV(m_map);
if(embedNewVertices)
{
TraversorV<typename PFP::MAP> tW(m_map);
......@@ -390,43 +392,81 @@ void Map3MR<PFP>::addNewLevelSqrt3(bool embedNewVertices, VertexAttribute<typena
{
if(m_map.isBoundaryVertex(dit) && !newBoundaryV.isMarked(dit))
{
Dart db = m_map.findBoundaryFaceOfVertex(dit);
m_map.decCurrentLevel() ;
Dart db = m_map.findBoundaryFaceOfVertex(dit);
typename PFP::VEC3 np(0) ;
unsigned int degree = 0 ;
Traversor2VVaE<typename PFP::MAP> trav(m_map, db) ;
for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
{
++degree ;
np += position[it] ;
}
float alpha = 1.0/9.0 * ( 4.0 - 2.0 * cos(2.0 * M_PI / degree));
np *= alpha / degree ;
typename PFP::VEC3 vp = position[db] ;
vp *= 1.0 - alpha ;
m_map.incCurrentLevel() ;
position[dit] = np + vp;
typename PFP::VEC3 P = position[db] ;
typename PFP::VEC3 newP(0) ;
unsigned int val = 0 ;
Dart vit = db ;
do
{
newP += position[m_map.phi_1(m_map.phi2(m_map.phi1(vit)))] ;
++val ;
vit = m_map.phi2(m_map.phi_1(vit)) ;
} while(vit != db) ;
typename PFP::REAL K = sqrt3_K(val) ;
newP *= typename PFP::REAL(3) ;
newP -= typename PFP::REAL(val) * P ;
newP *= K / typename PFP::REAL(2 * val) ;
newP += (typename PFP::REAL(1) - K) * P ;
position[db] = newP ;
}
}
//
// edge-removal on all old boundary edges
//
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);
Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit)));
swapGen3To2(d);
// Dart db = m_map.findBoundaryFaceOfVertex(dit);
// typename PFP::VEC3 P = position[db] ;
// typename PFP::VEC3 newP(0) ;
// unsigned int val = 0 ;
// Dart vit = db ;
// do
// {
// newP += position[m_map.phi2(m_map.phi_1(m_map.phi2(m_map.phi1(vit))))] ;
// ++val ;
// vit = m_map.phi2(m_map.phi_1(vit)) ;
// } while(vit != db) ;
// typename PFP::REAL K = sqrt3_K(val) ;
// newP *= typename PFP::REAL(3) ;
// newP -= typename PFP::REAL(val) * P ;
// newP *= K / typename PFP::REAL(2 * val) ;
// newP += (typename PFP::REAL(1) - K) * P ;
// position[db] = newP ;
}
}
//
// edge-removal on all old boundary edges
//
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);
Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit)));
swapGen3To2(d);
}
}
m_map.setCurrentLevel(m_map.getMaxLevel());
m_map.popLevel() ;
}
......
......@@ -1051,6 +1051,7 @@ bool Map3::check()
std::cout << "Boundary case - Check: phi3 , faces are not entirely sewn" << std::endl;
else
std::cout << "Check: phi3 , faces are not entirely sewn" << std::endl;
std::cout << "face : " << phi1(d3) << " and face = " << phi3(phi_1(d)) << std::endl;
return false;
}
......
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