Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit f3e7c91a authored by Thomas's avatar Thomas
Browse files

Merge branch 'master' of cgogn:~untereiner/CGoGN

parents f4adb83d fff30f3b
......@@ -245,6 +245,26 @@ public:
* has already been subdivided to the next level
*/
bool volumeIsSubdivided(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);
/**
*
*/
bool faceIsSubdividedOnce(Dart d);
/**
*
*/
bool volumeIsSubdividedOnce(Dart d);
} ;
template <typename T>
......
......@@ -50,10 +50,17 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
......
......@@ -173,8 +173,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
std::cout << "SUUUUUUB marine" << std::endl;
unsigned int vLevel = map.volumeLevel(d) ;
Dart old = map.volumeOldestDart(d) ;
......@@ -295,7 +293,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
}
while(e != *edge);
map.closeHole(f1);
Dart old = map.phi2(map.phi1(e));
......@@ -595,6 +592,38 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
unsigned int cur = map.getCurrentLevel() ;
Dart d2 = map.phi2(d) ;
map.setCurrentLevel(cur + 1) ;
unsigned int dl = map.getDartLevel(d2) ;
map.setDartLevel(map.phi1(d2), dl) ;
map.collapseEdge(d2) ;
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
//assert(map.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
}
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
//assert(map.volumeIsSubdivdedOnce(d) || !"Trying to coarsen a non-subdivided volume or a more than once subdivided volume") ;
}
/***********************************************************************************
*
*/
......@@ -1376,107 +1405,14 @@ void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos
}
} //namespace IHM
} //namespace Algo
} //namespace CGoGN
/*
//Second step : deconnect the corners
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
Dart e = *edge;
do
{
map.unsewFaces(map.phi1(map.phi1(e)));
map.unsewFaces(map.phi1(e));
e = map.phi2(map.phi_1(e));
}while(e != *edge);
// map.unsewFaces(map.phi1(*edge));
// moe.markOrbit(DART_ORBIT,map.phi1(*edge));
// }
//
// //Third step : close the hole
// for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
// {
// if(moe.isMarked(map.phi1(*edge)))
// {
map.closeHole(map.phi1(*edge));
Dart h = map.phi2(map.phi1(*edge));
unsigned int degree=0;
do
{
map.setEdgeId(h,map.getEdgeId(map.phi2(h)), DART_ORBIT) ;
h = map.phi1(h);
++degree;
}while(h != map.phi2(map.phi1(*edge)));
// moe.unmark(map.phi1(*edge));
// moe.unmark(map.phi1(map.phi2(map.phi_1(*edge))));
// moe.unmark(map.phi1(map.phi1(map.phi2(*edge))));
//si nouvelle diff de tri alors subdiviser la nouvelle face
if(degree != 3)
{
Dart old = map.phi1(map.phi2(map.phi1(*edge)));
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
Dart ne = map.phi2(map.phi_1(dd));
Dart ne2 = map.phi2(ne);
map.cutEdge(ne) ;
//unsigned int id = map.getNewEdgeId() ;
//map.setEdgeId(ne, id, EDGE_ORBIT) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(ne2, id, EDGE_ORBIT) ;
position[map.phi2(ne)] = volCenter;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
{
Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(map.phi1(ne), dd) ;
Dart nne = map.phi2(map.phi_1(dd)) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(nne, id, EDGE_ORBIT) ;
dd = next ;
}
}
//}
}
} //namespace IHM
// moe.unmarkAll();
} //namespace Algo
for (std::vector<Dart>::iterator nvol = quadfaces.begin(); nvol != quadfaces.end(); nvol = nvol + 2)
{
if(map.phi3(map.phi2(*nvol)) == map.phi2(*nvol) && map.phi3(map.phi2(*(nvol+1))) == map.phi2(*(nvol+1)))
{
map.sewVolumes(map.phi2(*nvol), map.phi2(*(nvol+1)));
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(*nvol),idface, FACE_ORBIT);
} //namespace CGoGN
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(map.phi1(map.phi2(*nvol)), idedge, EDGE_ORBIT);
}
}
// Dart ec = quadfaces.front();
// unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(map.phi1(map.phi1(ec)), idedge, EDGE_ORBIT);
//
// ec = map.phi_1(map.phi2(map.phi3(map.phi2(map.phi1(ec)))));
// idedge = map.getNewEdgeId();
// map.setEdgeId(ec, idedge, EDGE_ORBIT);
*/
......@@ -71,12 +71,6 @@ bool importTet(typename PFP::MAP& the_map, const std::string& filename, std::vec
template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, std::vector<std::pair<typename PFP::VEC3, typename PFP::VEC3> >& influences);
template <typename PFP>
bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
} // namespace Import
......
......@@ -39,11 +39,6 @@ class EmbeddedMap3 : public MAP3
{
public:
//!
/*!
*
*/
virtual void deleteOrientedVolume(Dart d);
//!
/*!
......@@ -100,6 +95,9 @@ public:
*/
virtual void collapseFace(Dart d, bool delDegenerateFaces = true,
bool delDegenerateVolumes = true);
virtual unsigned int closeHole(Dart d);
} ;
} // namespace CGoGN
......
......@@ -28,56 +28,16 @@
namespace CGoGN
{
template <typename MAP3>
void EmbeddedMap3<MAP3>::deleteOrientedVolume(Dart d)
{
// DartMarkerStore mark(*this); // Lock a marker
//
// std::vector<Dart> visitedFaces; // Faces that are traversed
// visitedFaces.reserve(16);
// visitedFaces.push_back(d); // Start with the face of d
// std::vector<Dart>::iterator face;
//
// //For every face added to the list
// for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
// {
// if (!mark.isMarked(*face)) // Face has not been visited yet
// {
// Dart dNext = *face ;
//
// do
// {
// mark.mark(dNext); // Mark
//
// unsigned int vEmb1 = EMBNULL; //Manage the embedding
// if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
// {
// vEmb1 = MAP3::getDartEmbedding(VERTEX_ORBIT, dNext);
// MAP3::embedOrbit(VERTEX_ORBIT, d, vEmb1) ; //alpha1 peut ne pas fonctionner
// }
//
// if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
// {
// vEmb1 = MAP3::getDartEmbedding(EDGE_ORBIT, dNext);
// MAP3::setDartEmbedding(VERTEX_ORBIT, MAP3::alpha2(dNext), vEmb1);
// }
//
// Dart adj = MAP3::phi2(dNext); // Get adjacent face
// if (adj != dNext && !mark.isMarked(adj))
// visitedFaces.push_back(adj); // Add it
// dNext = MAP3::phi1(dNext);
// } while(dNext != *face);
// }
// }
MAP3::deleteOrientedVolume(d);
}
template <typename MAP3>
void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
{
unsigned int vEmb1 = EMBNULL ;
if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
{
}
//topological sewing
MAP3::sewVolumes(d,e);
......@@ -102,6 +62,7 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
} while(dd != d) ;
}
}
template <typename MAP3>
......@@ -191,34 +152,32 @@ bool EmbeddedMap3<MAP3>::mergeVolumes(Dart d)
template <typename MAP3>
void EmbeddedMap3<MAP3>::splitFace(Dart d, Dart e)
{
MAP3::splitFace(d,e);
if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
{
MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi2(MAP3::phi_1(d)), d);
MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi2(MAP3::phi_1(e)), e);
if(MAP3::phi3(d) != d)
{
Dart d3 = MAP3::phi3(d);
Dart e3 = MAP3::phi3(e);
MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi1(d3), MAP3::phi1(MAP3::phi2(MAP3::phi1(d3))));
MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi1(e3), MAP3::phi1(MAP3::phi2(MAP3::phi1(e3))));
}
}
}
template <typename MAP3>
void EmbeddedMap3<MAP3>::cutEdge(Dart d)
{
// unsigned int dEmb = EMBNULL ;
// unsigned int fEmb = EMBNULL;
//
// if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
// {
// dEmb = MAP3::getEmbedding(d, VERTEX_ORBIT) ;
// }
//
// Dart f = MAP3::phi1(d) ;
MAP3::cutEdge(d);
// Dart e = MAP3::phi1(d);
//
// if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
// {
// fEmb = MAP3::getEmbedding(f, VERTEX_ORBIT);
//
//
// MAP3::setDartEmbedding(EDGE_ORBIT, d, dEmb) ;
// MAP3::embedNewCell(EDGE_ORBIT, e) ;
// MAP3::copyCell(EDGE_ORBIT, e, d) ;
// }
}
......@@ -288,6 +247,26 @@ Dart EmbeddedMap3<MAP3>::cutSpike(Dart d)
}
template <typename MAP3>
unsigned int EmbeddedMap3<MAP3>::closeHole(Dart d)
{
unsigned int nbE = MAP3::closeHole(d);
Dart dd = MAP3::phi2(d);
Dart f = dd;
do
{
if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
MAP3::copyDartEmbedding(VERTEX_ORBIT,f, MAP3::phi1(MAP3::phi2(f)));
if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
MAP3::copyDartEmbedding(EDGE_ORBIT, f, MAP3::phi2(f));
f = MAP3::phi1(f);
}
while(dd != f);
return nbE;
}
} // namespace CGoGN
......@@ -143,6 +143,11 @@ public:
*/
virtual void cutEdge(Dart d);
//! Uncut the edge of d
/*! @param d a dart of the edge to cut
*/
//virtual void uncutEdge(Dart d);
//! Sew a face e in the edge d
/*! @param d dart from the edge
* @param e dart from the face
......
......@@ -489,6 +489,79 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d)
return subd;
}
bool ImplicitHierarchicalMap3::edgeCanBeCoarsened(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
bool subd = false ;
bool subdOnce = true ;
bool degree2 = false ;
if(edgeIsSubdivided(d))
{
subd = true ;
Dart d2 = phi2(d) ;
++m_curLevel ;
if(vertexDegree(phi1(d)) == 2)
{
degree2 = true ;
if(edgeIsSubdivided(d) || edgeIsSubdivided(d2))
subdOnce = false ;
}
--m_curLevel ;
}
return subd && degree2 && subdOnce ;
}
bool ImplicitHierarchicalMap3:: faceIsSubdividedOnce(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
unsigned int fLevel = faceLevel(d) ;
if(fLevel < m_curLevel) // a face whose level in the current level map is lower than
return false ; // the current level can not be subdivided to higher levels
unsigned int degree = 0 ;
bool subd = false ;
bool subdOnce = true ;
Dart fit = d ;
do
{
++m_curLevel ;
if(m_dartLevel[phi1(fit)] == m_curLevel && m_edgeId[phi1(fit)] != m_edgeId[fit])
{
subd = true ;
++m_curLevel ;
if(m_dartLevel[phi1(fit)] == m_curLevel && m_edgeId[phi1(fit)] != m_edgeId[fit])
subdOnce = false ;
--m_curLevel ;
}
--m_curLevel ;
++degree ;
fit = phi1(fit) ;
} while(subd && subdOnce && fit != d) ;
if(degree == 3 && subd)
{
++m_curLevel ;
Dart cf = phi2(phi1(d)) ;
++m_curLevel ;
if(m_dartLevel[phi1(cf)] == m_curLevel && m_edgeId[phi1(cf)] != m_edgeId[cf])
subdOnce = false ;
--m_curLevel ;
--m_curLevel ;
}
return subd && subdOnce ;
}
bool ImplicitHierarchicalMap3:: volumeIsSubdividedOnce(Dart d)
{
return true;
}
} //namespace IHM
} //namespace Algo
......
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