Commit cf6694ee authored by untereiner's avatar untereiner

ihm3 + map3

parent 37e4f492
......@@ -600,11 +600,8 @@ void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
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.uncutEdge(d) ;
map.setCurrentLevel(cur) ;
}
......@@ -612,8 +609,47 @@ 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") ;
assert(map.faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
unsigned int cur = map.getCurrentLevel() ;
unsigned int degree = 0 ;
Dart fit = d ;
do
{
++degree ;
fit = map.phi1(fit) ;
} while(fit != d) ;
if(degree == 3)
{
// fit = d ;
// do
// {
// map.setCurrentLevel(cur + 1) ;
// Dart innerEdge = map.phi1(fit) ;
// map.setCurrentLevel(map.getMaxLevel()) ;
// map.mergeFaces(innerEdge) ;
// map.setCurrentLevel(cur) ;
// fit = map.phi1(fit) ;
// } while(fit != d) ;
}
else
{
map.setCurrentLevel(cur + 1) ;
Dart centralV = map.phi1(map.phi1(d)) ;
map.setCurrentLevel(map.getMaxLevel()) ;
map.deleteVertex(centralV) ;
map.setCurrentLevel(cur) ;
}
// fit = d ;
// do
// {
// if(map.edgeCanBeCoarsened(fit))
// coarsenEdge<PFP>(map, fit, position) ;
// fit = map.phi1(fit) ;
// } while(fit != d) ;
}
template <typename PFP>
......@@ -622,6 +658,85 @@ 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") ;
unsigned int cur = map.getCurrentLevel() ;
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
* avec calcul du centroid
*/
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(20);
visitedFaces.push_back(d);
mf.markOrbit(FACE_ORBIT, d) ;
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart e = *face ;
do
{
// add all face neighbours to the table
Dart ee = map.phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit(FACE_ORBIT, ee) ;
}
e = map.phi1(e) ;
} while(e != *face) ;
}
/*
* fusionner tous les volumes internes
*/
map.setCurrentLevel(cur + 1) ;
Dart centralV = map.phi_1(map.phi2(map.phi1(d)));
map.deleteVertex(centralV) ;
map.setCurrentLevel(cur) ;
/*
* simplifier les faces
*/
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart d = *face;
if(map.faceIsSubdividedOnce(d))
{
std::cout << "once : " << d << std::endl;
coarsenFace<PFP>(map, d, position);
}
}
map.setCurrentLevel(cur) ;
/*
* simplifier les aretes
*/
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart fit = *face ;
do
{
if(map.edgeCanBeCoarsened(fit))
{
std::cout << "edge coarsened = " << fit << std::endl;
}
//coarsenEdge<PFP>(map, fit, position) ;
std::cout << "boucle = " << fit << std::endl;
fit = map.phi1(fit) ;
} while(fit != *face) ;
}
std::cout << "end" << std::endl;
map.setCurrentLevel(cur) ;
}
/***********************************************************************************
......
......@@ -144,10 +144,15 @@ public:
virtual void cutEdge(Dart d);
//! Uncut the edge of d
/*! @param d a dart of the edge to cut
/*! @param d a dart of the edge to uncut
*/
virtual void unCutEdge(Dart d);
virtual void uncutEdge(Dart d);
//!
/*!
*
*/
virtual bool deleteVertex(Dart d);
//!
/*! Flip the edge of d (rotation in phi1 order)
......@@ -228,6 +233,11 @@ public:
*/
virtual int edgeDegree(Dart d);
/**
* compute the number of edges of the vertex of d
*/
unsigned int vertexDegree(Dart d) ;
//!
/* Tell if a face of the volume is on the boundary
*
......
......@@ -503,9 +503,9 @@ bool ImplicitHierarchicalMap3::edgeCanBeCoarsened(Dart d)
subd = true ;
Dart d2 = phi2(d) ;
++m_curLevel ;
if(vertexDegree(phi1(d)) == 2)
{
degree2 = true ;
if(edgeIsSubdivided(d) || edgeIsSubdivided(d2))
subdOnce = false ;
......@@ -515,7 +515,7 @@ bool ImplicitHierarchicalMap3::edgeCanBeCoarsened(Dart d)
return subd && degree2 && subdOnce ;
}
bool ImplicitHierarchicalMap3:: faceIsSubdividedOnce(Dart d)
bool ImplicitHierarchicalMap3::faceIsSubdividedOnce(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
unsigned int fLevel = faceLevel(d) ;
......@@ -540,6 +540,7 @@ bool ImplicitHierarchicalMap3:: faceIsSubdividedOnce(Dart d)
--m_curLevel ;
++degree ;
fit = phi1(fit) ;
} while(subd && subdOnce && fit != d) ;
if(degree == 3 && subd)
......
......@@ -178,11 +178,92 @@ void Map3::cutEdge(Dart d)
}
}
void Map3::unCutEdge(Dart d)
void Map3::uncutEdge(Dart d)
{
if(phi3(d) == d)
d = phi_1(phi2(d));
Dart prev = d;
Dart dd = alpha2(d);
Map2::uncutEdge(prev);
if(phi3(dd) != dd)
phi3sew(dd,phi2(prev));
while (dd!=d)
{
prev = dd;
dd = alpha2(dd);
Map2::uncutEdge(prev);
phi3sew(dd, phi2(prev));
}
}
bool Map3::deleteVertex(Dart d)
{
DartMarkerStore mv(*this); // Lock a marker
std::list<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d
std::list<Dart>::iterator darts;
mv.mark(d);
std::list<Dart> unique_darts_list;
//unique_darts_list.reserve(30);
unique_darts_list.push_back(d);
bool boundary = false;
if(isBoundaryVertex(d))
boundary = true;
for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
{
Dart dc = *darts;
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(dc);
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
{
darts_list.push_back(d21);
mv.mark(d21);
}
if((d23!=d2) && !mv.isMarked(d23))
{
darts_list.push_back(d23);
unique_darts_list.push_back(d23);
mv.mark(d23);
}
}
for(darts = unique_darts_list.begin(); darts != unique_darts_list.end() ; ++darts)
{
mergeVolumes(*darts);
}
if(boundary)
{
Dart vit = d ;
do
{
Dart f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = phi2(phi_1((vit))) ;
} while(vit != d) ;
Map1::deleteFace(d) ;
}
return true;
}
//TODO
//bool Map3::flipEdge(Dart d)
......@@ -549,6 +630,55 @@ int Map3::edgeDegree(Dart d)
return deg;
}
unsigned int Map3::vertexDegree(Dart d)
{
int count = 0;
DartMarkerStore mv(*this); // Lock a marker
std::list<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d
std::list<Dart>::iterator darts;
mv.mark(d);
for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
{
Dart dc = *darts;
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(dc);
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
{
darts_list.push_back(d21);
mv.mark(d21);
}
if((d23!=d2) && !mv.isMarked(d23))
{
darts_list.push_back(d23);
mv.mark(d23);
}
}
std::cout << "#darts = " << darts_list.size() << std::endl;
DartMarkerStore me(*this);
for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
{
if(!me.isMarked(*darts))
{
++count;
me.markOrbit(EDGE_ORBIT, *darts);
}
}
return count;
}
bool Map3::isBoundaryVolume(Dart d)
{
bool isBoundary = false;
......@@ -639,6 +769,8 @@ bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
mv.mark(d);
std::cout << "plop vertex" << std::endl;
for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
{
Dart dc = *darts;
......@@ -668,6 +800,8 @@ bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
bool Map3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
{
std::cout << "plop edge" << std::endl;
Dart dNext = d;
do {
if (Map2::foreach_dart_of_edge(dNext,f,thread)) return true;
......@@ -678,6 +812,9 @@ bool Map3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
bool Map3::foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread)
{
std::cout << "plop open edge" << std::endl;
DartMarkerStore mv(*this,thread); // Lock a marker
bool found = false; // Last functor return value
......
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