Commit 1efe66fd authored by untereiner's avatar untereiner

correct template Orbit et IHM3 coarsen mesh

parent abc26d95
......@@ -43,6 +43,12 @@ class ImplicitHierarchicalMap3 : public EmbeddedMap3
template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
public:
FunctorType* vertexVertexFunctor ;
FunctorType* edgeVertexFunctor ;
FunctorType* faceVertexFunctor ;
FunctorType* volumeVertexFunctor ;
unsigned int m_curLevel ;
unsigned int m_maxLevel ;
unsigned int m_edgeIdCount ;
......@@ -153,6 +159,8 @@ public:
Dart quadranguleFace(Dart d);
void deleteVertexSubdividedFace(Dart d);
// //!
// /*!
// *
......@@ -184,6 +192,11 @@ public:
// virtual void splitVolume(std::vector<Dart>& vd);
//@}
void computeVertexVertexFunctor(Dart d) { (*vertexVertexFunctor)(d); }
void computeEdgeVertexFunctor(Dart d) { (*edgeVertexFunctor)(d); }
void computeFaceVertexFunctor(Dart d) { (*faceVertexFunctor)(d); }
void computerVolumeVertexFunctor(Dart d) { (*volumeVertexFunctor)(d); }
/*! @name Levels Management
* Operations to manage the levels of an Implicit Hierarchical 3-map
*************************************************************************/
......
......@@ -59,12 +59,11 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
map.setEdgeId(map.phi1(d), eId, EDGE) ; //mise a jour de l'id d'arrete sur chaque moitie d'arete
map.setEdgeId(map.phi1(dd), eId, EDGE) ;
map.setFaceId(EDGE, d) ; //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
map.setFaceId(EDGE, dd) ;
position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
//map.computeEdgeVertexFunctor(map.phi1(d));
map.setCurrentLevel(cur) ;
}
......@@ -147,6 +146,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
map.setEdgeId(ne2, id, EDGE) ;
position[map.phi1(ne)] = p ;
//map.computeFaceVertexFunctor(map.phi1(ne));
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
......@@ -188,6 +188,14 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(vLevel);
//one level of subdivision in the neighbordhood
Traversor3VW<typename PFP::MAP> trav3EW(map, old);
for(Dart dit = trav3EW.begin() ; dit != trav3EW.end() ; dit = trav3EW.next())
{
Dart oldit = map.volumeOldestDart(dit);
if(((vLevel+1) - map.volumeLevel(oldit)) > 1)
Algo::IHM::subdivideVolumeClassic<PFP>(map, oldit, position);
}
/*
* au niveau du volume courant i
......@@ -380,6 +388,122 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
return subdividedfaces.begin()->first;
}
/************************************************************************************************
* Simplification *
************************************************************************************************/
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& 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") ;
std::cout << "coarsenEdge" << std::endl;
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(cur + 1) ;
map.uncutEdge(d) ;
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType)
{
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") ;
unsigned int cur = map.getCurrentLevel() ;
unsigned int degree = 0 ;
Dart fit = d ;
do
{
++degree ;
fit = map.phi1(fit) ;
} while(fit != d) ;
// Dart d3 = map.phi3(d);
if(degree == 3)
{
}
else
{
map.setCurrentLevel(cur + 1) ;
map.deleteVertexSubdividedFace(d);
map.setCurrentLevel(cur) ;
// Dart centralV = map.phi1(map.phi1(d));
// map.Map2::deleteVertex(centralV);
//
// //demarking faces from border to delete .... fucking shit
// Dart it = d ;
// do
// {
// if (map.boundaryUnmark(it))
// return true ;
// it = map.phi2(map.phi_1(it)) ;
// } while (it != d) ;
//
// map.Map2::deleteVertex(map.phi1(map.phi1(d3)));
}
fit = d ;
do
{
if(map.edgeCanBeCoarsened(fit))
Algo::IHM::coarsenEdge<PFP>(map, fit, position) ;
fit = map.phi1(fit) ;
} while(fit != d) ;
}
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.volumeIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided volume or a more than once subdivided volume") ;
unsigned int cur = map.getCurrentLevel() ;
/*
* Deconnecter toutes les faces interieurs
*/
map.setCurrentLevel(cur + 1) ;
Dart nf = map.phi_1(map.phi2(map.phi1(d)));
map.deleteVertex(nf);
map.setCurrentLevel(cur) ;
/*
* simplifier les faces
*/
Traversor3WF<typename PFP::MAP> trav3WF(map, d);
for(Dart dit = trav3WF.begin() ; dit != trav3WF.end() ; dit = trav3WF.next())
{
if(map.faceCanBeCoarsened(dit))
Algo::IHM::coarsenFace<PFP>(map, dit, position, Algo::IHM::S_QUAD);
}
}
/* **************************************************************************************
* USE WITH CAUTION *
****************************************************************************************/
template <typename PFP>
Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
......@@ -1541,174 +1665,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, AttributeHandler<typenam
return subdividedfacesQ.begin()->first;
}
/************************************************************************************************
* Simplification *
************************************************************************************************/
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& 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() ;
map.setCurrentLevel(cur + 1) ;
map.uncutEdge(d) ;
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType)
{
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") ;
unsigned int cur = map.getCurrentLevel() ;
unsigned int degree = 0 ;
Dart fit = d ;
do
{
++degree ;
fit = map.phi1(fit) ;
} while(fit != d) ;
// boucler sur d avec phi2(phi_1()) et faire des unsewvolumes
// delete le vertex sur d
// si le volume d'a cote n'est pas subdiv
// alors delete le vertex aussi
// recouture du tout
Dart d3 = map.phi3(d);
map.setCurrentLevel(cur + 1) ;
Dart centralV = map.phi1(map.phi1(d));
//Tester si il y a un volume voisin
if(d != d3)
{
//on decoud
Dart it = centralV;
do
{
map.unsewVolumes(it);
it = map.phi2(map.phi_1(it));
}while(it != centralV);
//Si ce volume voisin n'est pas subdivise
if(!map.volumeIsSubdivided(d3))
//alors on supprime le sommet en face
map.Map2::deleteVertex(map.phi1(map.phi1(d3)));
}
//On supprime le sommet sur la face du volume courant
map.Map2::deleteVertex(centralV);
if(d != d3)
map.sewVolumes(d,map.phi1(d3));
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& 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() ;
std::cout << "cur = " << cur << std::endl;
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
*/
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(512);
visitedFaces.push_back(d);
mf.markOrbit<FACE>(d) ;
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
Dart e = visitedFaces[i] ;
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>(ee) ;
}
e = map.phi1(e) ;
} while(e != visitedFaces[i]) ;
}
/*
* Deconnecter toutes les faces interieurs
*/
map.setCurrentLevel(cur + 1) ;
Dart nf = map.phi_1(map.phi2(map.phi1(d)));
map.deleteVertex(nf);
map.setCurrentLevel(cur) ;
// for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
// {
// Dart fit = *face;
//
// do
// {
// map.setCurrentLevel(cur + 1) ;
//
// Dart nf = map.phi2(map.phi1(fit));
// if(map.getDartLevel(map.faceOldestDart(nf)) != cur)
// map.mergeVolumes(nf);
//
// map.setCurrentLevel(cur) ;
// fit = map.phi1(fit);
// }while(fit != *face);
// }
/*
* simplifier les faces
*/
//std::vector<Dart>::iterator face = visitedFaces.begin();
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart fit = *face;
if(map.faceCanBeCoarsened(fit))
{
Algo::IHM::coarsenFace<PFP>(map, fit, position, Algo::IHM::S_QUAD);
}
}
/*
* simplifier les aretes
*/
for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
Dart fit = *face ;
do
{
if(map.edgeCanBeCoarsened(fit))
Algo::IHM::coarsenEdge<PFP>(map, fit, position) ;
fit = map.phi1(fit) ;
} while(fit != *face) ;
}
map.setCurrentLevel(cur) ;
}
/***********************************************************************************
* Raffinement
......
......@@ -337,7 +337,7 @@ void ParticleCell3D<PFP>::vertexState(const VEC3& current)
Dart dd=d;
Geom::Orientation3D wsof;
CellMarkerStore mark(m, FACE);
CellMarkerStore<FACE> mark(m);
do {
VEC3 dualsp = (som+ Algo::Geometry::vertexNormal<PFP>(m,d,position));
......@@ -424,7 +424,7 @@ void ParticleCell3D<PFP>::vertexState(const VEC3& current)
}
else
{
Dart ddd=d;
//Dart ddd=d;
edgeState(current);
}
......@@ -640,7 +640,7 @@ void ParticleCell3D<PFP>::volumeState(const VEC3& current)
std::cout << "volumeState " << d << std::endl;
#endif
CellMarkerStore mark(m,FACE);
CellMarkerStore<FACE> mark(m);
bool above;
Geom::Orientation3D testRight=Geom::OVER;
......@@ -756,7 +756,7 @@ void ParticleCell3D<PFP>::volumeSpecialCase(const VEC3& current)
#endif
Dart dd;
CellMarkerStore mark(m,FACE);
CellMarkerStore<FACE> mark(m);
Dart d_min;
......
......@@ -140,7 +140,7 @@ void VolumetricProgressiveMesh<PFP>::createPM(unsigned int percentWantedVertices
m_selector->updateAfterOperation(op) ; // update selector
if(nbVertices <= nbWantedVertices)
if(nbVertices <= 3) //<= nbWantedVertices)
finished = true ;
}
......
......@@ -289,6 +289,41 @@ Dart ImplicitHierarchicalMap3::quadranguleFace(Dart d)
return centralDart;
}
void ImplicitHierarchicalMap3::deleteVertexSubdividedFace(Dart d)
{
Dart centralV = phi1(phi1(d));
Dart res = NIL;
Dart vit = centralV ;
do
{
if(res == NIL && phi1(phi1(centralV)) != centralV)
res = phi1(centralV) ;
Dart f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = phi2(phi_1(vit)) ;
} while(vit != centralV) ;
Map1::deleteCycle(centralV) ;
Dart d3 = phi1(phi3(centralV));
res = NIL;
vit = d3 ;
do
{
if(res == NIL && phi1(phi1(d3)) != d3)
res = phi1(d3) ;
Dart f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = phi2(phi_1(vit)) ;
} while(vit != d3) ;
Map1::deleteCycle(d3) ;
}
//Dart ImplicitHierarchicalMap3::cutEdge(Dart d)
//{
// Dart resV = EmbeddedMap3::cutEdge(d);
......@@ -770,7 +805,8 @@ bool ImplicitHierarchicalMap3::edgeCanBeCoarsened(Dart d)
Dart d2 = phi2(d) ;
++m_curLevel ;
std::cout << "vertex degree = " << vertexDegree(phi1(d)) << std::endl;
std::cout << "vertex degree(phi1(d)) = " << vertexDegree(phi1(d)) << std::endl;
std::cout << "vertex degree(d) = " << vertexDegree(d) << std::endl;
if(vertexDegree(phi1(d)) == 2)
{
......@@ -796,11 +832,6 @@ bool ImplicitHierarchicalMap3::faceCanBeCoarsened(Dart d)
subd = true;
Dart d3 = phi3(d);
// std::cout << "d3 = " << d3 << std::endl;
// std::cout << "d = " << d << std::endl;
// std::cout << "curLevel = " << m_curLevel << std::endl;
// std::cout << "volSubd(d3) = " << volumeIsSubdivided(d3) << std::endl;
//tester si le volume voisin est subdivise
if(d3 != d && volumeIsSubdivided(d3))
subdNeighborhood = true;
......@@ -821,9 +852,6 @@ bool ImplicitHierarchicalMap3::faceCanBeCoarsened(Dart d)
--m_curLevel;
}
// std::cout << "subdNeighborhood = " << subdNeighborhood << std::endl;
// std::cout << "faceCanBeCoarsened ? " << (subd && !subdNeighborhood && subdOnce) << std::endl;
return subd && !subdNeighborhood && subdOnce;
}
......@@ -869,56 +897,46 @@ bool ImplicitHierarchicalMap3::faceIsSubdividedOnce(Dart d)
return subd && subdOnce ;
}
bool ImplicitHierarchicalMap3:: volumeIsSubdividedOnce(Dart d)
bool ImplicitHierarchicalMap3::volumeIsSubdividedOnce(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
unsigned int vLevel = volumeLevel(d);
if(vLevel < m_curLevel)
return false;
return true;
// //si le volume est subdivise au niveau i+1, il faut tester si chacun des volumes du niveau i+1 est subdivise a son tour ou non
bool subd = false ;
bool subdOnce = true ;
//
// //mais pas le volume lui-meme
// bool subd = false;
// ++m_curLevel;
// if(facesAreSubdivided && m_dartLevel[phi2(phi1(phi1(d)))] == m_curLevel && m_faceId[phi2(phi1(phi1(d)))] != m_faceId[d])
// subd = true;
// --m_curLevel;
// return subd;
return subd;
}
bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
bool found = false;
bool found = true;
unsigned int vLevel = volumeLevel(d);// + 1;
Dart old = volumeOldestDart(d);
DartMarkerStore mf(*this); // 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(512);
visitedFaces.push_back(old);
mf.markOrbit<FACE>(old) ;
Traversor3EW<ImplicitHierarchicalMap3> trav3EW(*this, old);
for(unsigned int i = 0; !found && i < visitedFaces.size(); ++i)
for(Dart dit = trav3EW.begin() ; dit != trav3EW.end() ; dit = trav3EW.next())
{
Dart e = visitedFaces[i] ;
do
{
// add all face neighbours to the table
if(phi3(e) != e)
{
Dart old = volumeOldestDart(phi3(e));
//if((abs(volumeLevel(old) - vLevel) > 1))
if(volumeLevel(old) < vLevel)
found = true;
}
Dart ee = phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit<FACE>(ee) ;
}
e = phi1(e) ;
} while(e != visitedFaces[i]) ;
Dart oldit = volumeOldestDart(dit);
//if((abs(volumeLevel(old) - vLevel) > 1))
if((volumeLevel(oldit) - vLevel) > 1)
found = false;
}
return found;
......
......@@ -165,7 +165,6 @@ bool EmbeddedMap3::edgeCanCollapse(Dart d)
//
// return true;
// if(Map2::isBoundaryVertex(d) || Map2::isBoundaryVertex(phi1(d)))
// return false ;
......
......@@ -206,6 +206,7 @@ void Map2::splitVertex(Dart d, Dart e)
Dart Map2::deleteVertex(Dart d)
{
//TODO utile ?
if(isBoundaryVertex(d))
return NIL ;
......@@ -219,7 +220,7 @@ Dart Map2::deleteVertex(Dart d)
Dart f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = alpha1(vit) ;
vit = phi2(phi_1(vit)) ;
} while(vit != d) ;
Map1::deleteCycle(d) ;
return res ;
......
......@@ -839,40 +839,11 @@ bool Map3::sameVertex(Dart d, Dart e)
unsigned int Map3::vertexDegree(Dart d)
{
unsigned int count = 0;
DartMarkerStore mv(*this); // Lock a marker
std::vector<Dart> darts; // Darts that are traversed
darts.reserve(256);
darts.push_back(d); // Start with the dart d
mv.mark(d);
for(unsigned int i = 0; i < darts.size(); ++i)
Traversor3VE<Map3> trav3VE(*this, d);
for(Dart dit = trav3VE.begin() ; dit != trav3VE.end() ; dit = trav3VE.next())
{
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(darts[i]);
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
{
darts.push_back(d21);
mv.mark(d21);
}
if(!mv.isMarked(d23))
{
darts.push_back(d23);
mv.mark(d23);
}
}
DartMarkerStore me(*this);
for(std::vector<Dart>::iterator it = darts.begin(); it != darts.end() ; ++it)
{
if(!me.isMarked(*it))
{
++count;
me.markOrbit<EDGE>(*it);
}
++count;
}
return count;
......
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