Commit 9cc6ba9f authored by untereiner's avatar untereiner

modifs algo subdivision

parent 76350c08
...@@ -461,49 +461,49 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 ...@@ -461,49 +461,49 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
} }
} }
//position[centralDart] = volCenter; position[centralDart] = volCenter;
// //Third step : 3-sew internal faces //Third step : 3-sew internal faces
// for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it) for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
// { {
// Dart f1 = (*it).first; Dart f1 = (*it).first;
// Dart f2 = (*it).second; Dart f2 = (*it).second;
if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2)))
{
std::cout << "boundary" << std::endl;
//id pour toutes les faces interieures
map.sewVolumes(map.phi2(f1), map.phi2(f2));
// //
// //Fais a la couture !!!!!
// unsigned int idface = map.getNewFaceId();
// map.setFaceId(map.phi2(f1),idface, FACE);
}
// //
// if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2))) // //FAIS a la couture !!!!!!!
// { // //id pour toutes les aretes exterieurs des faces quadrangulees
// std::cout << "boundary" << std::endl; // unsigned int idedge = map.getEdgeId(f1);
// //id pour toutes les faces interieures // map.setEdgeId(map.phi2(f1), idedge, DART);
// map.sewVolumes(map.phi2(f1), map.phi2(f2)); // map.setEdgeId( map.phi2(f2), idedge, DART);
// break; }
////
//// //Fais a la couture !!!!!
//// unsigned int idface = map.getNewFaceId();
//// map.setFaceId(map.phi2(f1),idface, FACE);
// }
////
//// //FAIS a la couture !!!!!!!
//// //id pour toutes les aretes exterieurs des faces quadrangulees
//// unsigned int idedge = map.getEdgeId(f1);
//// map.setEdgeId(map.phi2(f1), idedge, DART);
//// map.setEdgeId( map.phi2(f2), idedge, DART);
// }
// //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!! //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
// //id pour les aretes interieurs : (i.e. 6 pour un hexa) //id pour les aretes interieurs : (i.e. 6 pour un hexa)
// DartMarker mne(map); DartMarker mne(map);
// for(unsigned int i = 0; i < newEdges.size(); ++i) for(unsigned int i = 0; i < newEdges.size(); ++i)
// { {
// if(!mne.isMarked(newEdges[i])) if(!mne.isMarked(newEdges[i]))
// { {
// unsigned int idedge = map.getNewEdgeId(); unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(newEdges[i], idedge, EDGE); map.setEdgeId(newEdges[i], idedge, EDGE);
// mne.markOrbit(EDGE, newEdges[i]); mne.markOrbit(EDGE, newEdges[i]);
// } }
// } }
//plonger a la fin de la boucle ???? //plonger a la fin de la boucle ????
......
...@@ -1154,7 +1154,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices() ...@@ -1154,7 +1154,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
} }
d /= double(nbf); d /= double(nbf);
typename PFP::REAL EPSILON = d/10000.0; typename PFP::REAL epsilon = d/10000.0;
// traverse vertices // traverse vertices
...@@ -1176,7 +1176,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices() ...@@ -1176,7 +1176,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
typename PFP::VEC3 Q = positions[*v]; typename PFP::VEC3 Q = positions[*v];
Q -= P; Q -= P;
typename PFP::REAL d2 = Q*Q; typename PFP::REAL d2 = Q*Q;
if (d2 < EPSILON*EPSILON) if (d2 < epsilon*epsilon)
{ {
newIndices[*v] = i; newIndices[*v] = i;
*v = 0xffffffff; *v = 0xffffffff;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Topology/generic/traversor3.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -59,44 +61,20 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d) ...@@ -59,44 +61,20 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
template <typename PFP> template <typename PFP>
bool isTetrahedron(typename PFP::MAP& the_map, Dart d) bool isTetrahedron(typename PFP::MAP& the_map, Dart d)
{ {
DartMarkerStore mark(the_map); // Lock a marker unsigned int nbFaces = 0;
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(64) ;
visitedFaces.push_back(d);
unsigned int nbFaces = 0; // Count the faces
//Test the number of faces end its valency //Test the number of faces end its valency
for(unsigned int i = 0; i < visitedFaces.size(); ++i) Traversor3WF<typename PFP::MAP> travWF(the_map, d);
for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next())
{ {
Dart dc = visitedFaces[i]; //increase the number of faces
nbFaces++;
//if this dart is not marked if(nbFaces > 4) //too much faces
if(!mark.isMarked(dc)) return false;
{
//increase the number of faces //test the valency of this face
nbFaces++; if(the_map.faceDegree(dit) != 3)
if(nbFaces > 4) //too much faces return false;
return false;
//test the valency of this face
if(dc != the_map.phi1(the_map.phi1(the_map.phi1(dc))))
return false;
//mark the face and push adjacent faces
Dart d1 = dc;
for(unsigned int i = 0; i <3 ; ++i)
{
mark.mark(d1);
//if phi2 not marked
Dart d2 = the_map.phi2(d1);
if(!mark.isMarked(d2))
visitedFaces.push_back(d2);
d1 = the_map.phi1(dc);
}
}
} }
return true; return true;
...@@ -408,83 +386,83 @@ void swap5To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions) ...@@ -408,83 +386,83 @@ void swap5To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions)
template <typename PFP> template <typename PFP>
void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{ {
typedef typename PFP::TVEC3 TVEC3; // typedef typename PFP::TVEC3 TVEC3;
typedef typename PFP::VEC3 VEC3; // typedef typename PFP::VEC3 VEC3;
//
//
//parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid // //parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid
VEC3 volCenter; // VEC3 volCenter;
unsigned count = 0 ; // unsigned count = 0 ;
//
DartMarkerStore mf(map); // Lock a face marker to save one dart per face // DartMarkerStore mf(map); // Lock a face marker to save one dart per face
DartMarkerStore mv(map); // Lock a vertex marker to compute volume center // DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
//
std::vector<Dart> visitedFaces; // std::vector<Dart> visitedFaces;
visitedFaces.reserve(4); // visitedFaces.reserve(4);
visitedFaces.push_back(d); // visitedFaces.push_back(d);
//
mf.markOrbit(FACE, d) ; // mf.markOrbit(FACE, d) ;
//
//TODO diminuer complexite avec boucle specifique aux tetras // //TODO diminuer complexite avec boucle specifique aux tetras
for(unsigned int i = 0; i < visitedFaces.size(); ++i) // for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{ // {
Dart e = visitedFaces[i] ; // Dart e = visitedFaces[i] ;
do // do
{ // {
//compute volume centroid // //compute volume centroid
if(!mv.isMarked(e)) // if(!mv.isMarked(e))
{ // {
volCenter += position[e]; // volCenter += position[e];
++count; // ++count;
mv.markOrbit(VERTEX, e); // mv.markOrbit(VERTEX, e);
} // }
//
// add all face neighbours to the table // // add all face neighbours to the table
Dart ee = map.phi2(e) ; // Dart ee = map.phi2(e) ;
if(!mf.isMarked(ee)) // not already marked // if(!mf.isMarked(ee)) // not already marked
{ // {
visitedFaces.push_back(ee) ; // visitedFaces.push_back(ee) ;
mf.markOrbit(FACE, ee) ; // mf.markOrbit(FACE, ee) ;
} // }
//
e = map.phi1(e) ; // e = map.phi1(e) ;
} while(e != visitedFaces[i]) ; // } while(e != visitedFaces[i]) ;
} // }
//
volCenter /= typename PFP::REAL(count) ; // volCenter /= typename PFP::REAL(count) ;
//
//store the new faces to 3-sew // //store the new faces to 3-sew
std::vector<std::pair<Dart,Dart> > nFaces; // std::vector<std::pair<Dart,Dart> > nFaces;
nFaces.reserve(6); // nFaces.reserve(6);
//
//triangule chaque face avec plongement au centroid // //triangule chaque face avec plongement au centroid
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) // for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{ // {
// on decoud et on ferme le trou // // on decoud et on ferme le trou
Dart temp = *face; // Dart temp = *face;
do // do
{ // {
nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp))); // nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp)));
map.unsewFaces(temp); // map.unsewFaces(temp);
temp = map.phi1(temp); // temp = map.phi1(temp);
} // }
while(temp != *face); // while(temp != *face);
//
map.closeHole(*face); // map.closeHole(*face);
//
Dart fi = map.phi2(*face); // Dart fi = map.phi2(*face);
//
Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi); // Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi);
position[cd] = volCenter; // position[cd] = volCenter;
} // }
//
//coudre les nouveaux brins entre eux par phi3 // //coudre les nouveaux brins entre eux par phi3
for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face) // for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
{ // {
//
if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first)) // if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second)); // map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
} // }
} }
/************************************************************************************************ /************************************************************************************************
......
...@@ -115,6 +115,7 @@ inline void GenericMap::deleteDart(Dart d) ...@@ -115,6 +115,7 @@ inline void GenericMap::deleteDart(Dart d)
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
{ {
unsigned int index = (*m_mrDarts[i])[d.index] ; unsigned int index = (*m_mrDarts[i])[d.index] ;
std::cout << "deleteDart index = " << index << std::endl << std::endl;
if(isDartValid(index)) if(isDartValid(index))
deleteDartLine(index) ; deleteDartLine(index) ;
} }
......
...@@ -85,6 +85,10 @@ public: ...@@ -85,6 +85,10 @@ public:
*/ */
virtual bool flipBackEdge(Dart d) ; virtual bool flipBackEdge(Dart d) ;
/*
*
*/
virtual void swapEdges(Dart d, Dart e);
// /** // /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex // * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e // * The attributes attached to the face of dart d are overwritten on the face of dart e
......
...@@ -208,6 +208,12 @@ public: ...@@ -208,6 +208,12 @@ public:
*/ */
virtual bool flipBackEdge(Dart d); virtual bool flipBackEdge(Dart d);
//!
/*!
*
*/
void swapEdges(Dart d, Dart e);
// //! Insert an edge after a dart in the vertex orbit // //! Insert an edge after a dart in the vertex orbit
// /*! \pre Dart d and e MUST be different and belong to distinct face // /*! \pre Dart d and e MUST be different and belong to distinct face
// * \pre Dart e must be phi2-linked with its phi_1 dart // * \pre Dart e must be phi2-linked with its phi_1 dart
......
...@@ -238,6 +238,12 @@ public: ...@@ -238,6 +238,12 @@ public:
*/ */
bool isBoundaryVertex(Dart d) ; bool isBoundaryVertex(Dart d) ;
//! Find the dart of vertex that belong to the boundary
/*! return NIL if the vertex is not on the boundary
* @param d a dart
*/
Dart findBoundaryFaceOfVertex(Dart d) ;
//! Test if dart d and e belong to the same oriented edge //! Test if dart d and e belong to the same oriented edge
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -255,14 +261,14 @@ public: ...@@ -255,14 +261,14 @@ public:
*/ */
unsigned int edgeDegree(Dart d) ; unsigned int edgeDegree(Dart d) ;
/** //! Tell if the edge of d is on the boundary of the map
* tell if the edge of d is on the boundary of the map /*! @param d a dart
*/ */
bool isBoundaryEdge(Dart d) ; bool isBoundaryEdge(Dart d) ;
/** //! Find the dart of edge that belong to the boundary
* find the dart of edge that belong to the boundary /*! return NIL if the edge is not on the boundary
* return NIL if the edge is not on the boundary * @param d a dart
*/ */
Dart findBoundaryFaceOfEdge(Dart d) ; Dart findBoundaryFaceOfEdge(Dart d) ;
......
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
void clear(); void clear();
/** /**
* once all string are stored, we must send it to the gracphic card * once all string are stored, we must send it to the graphic card
*/ */
void sendToVBO(); void sendToVBO();
......
...@@ -570,7 +570,6 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d) ...@@ -570,7 +570,6 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
if(m_dartLevel[old] < m_dartLevel[oldest]) if(m_dartLevel[old] < m_dartLevel[oldest])
oldest = old ; oldest = old ;
// //
// add all face neighbours to the table // add all face neighbours to the table
// //
......
...@@ -208,6 +208,29 @@ bool EmbeddedMap2::flipBackEdge(Dart d) ...@@ -208,6 +208,29 @@ bool EmbeddedMap2::flipBackEdge(Dart d)
return false ; return false ;
} }
void EmbeddedMap2::swapEdges(Dart d, Dart e)
{
Dart d2 = phi2(d);
Dart e2 = phi2(e);
Map2::swapEdges(d,e);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, d, phi2(phi_1(d)));
copyDartEmbedding(VERTEX, e, phi2(phi_1(e)));
copyDartEmbedding(VERTEX, d2, phi2(phi_1(d2)));
copyDartEmbedding(VERTEX, e2, phi2(phi_1(e2)));
}
if(isOrbitEmbedded(EDGE))
{
}
if(isOrbitEmbedded(VOLUME))
embedNewCell(VOLUME, d);
}
//void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) //void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e)
//{ //{
// Map2::insertEdgeInVertex(d, e); // Map2::insertEdgeInVertex(d, e);
......
...@@ -325,6 +325,20 @@ bool Map2::flipBackEdge(Dart d) ...@@ -325,6 +325,20 @@ bool Map2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge return false ; // cannot flip a border edge
} }
void Map2::swapEdges(Dart d, Dart e)
{
assert(!Map2::isBoundaryEdge(d) && !Map2::isBoundaryEdge(e));
Dart d2 = phi2(d);
Dart e2 = phi2(e);
phi2unsew(d);
phi2unsew(e) ;
phi2sew(d, e);
//phi2sew(d2, e2);
}
//void Map2::insertEdgeInVertex(Dart d, Dart e) //void Map2::insertEdgeInVertex(Dart d, Dart e)
//{ //{
// assert(!sameVertex(d,e) && phi2(e) == phi_1(e)); // assert(!sameVertex(d,e) && phi2(e) == phi_1(e));
...@@ -538,10 +552,10 @@ void Map2::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, bool second ...@@ -538,10 +552,10 @@ void Map2::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, bool second
unsewFaces(*it) ; unsewFaces(*it) ;
if(firstSideClosed) if(firstSideClosed)
fillHole(e) ; Map2::fillHole(e) ;
if(secondSideClosed) if(secondSideClosed)
fillHole(e2) ; Map2::fillHole(e2) ;
} }
/*! @name Topological Queries /*! @name Topological Queries
......
...@@ -636,6 +636,39 @@ bool Map3::isBoundaryVertex(Dart d) ...@@ -636,6 +636,39 @@ bool Map3::isBoundaryVertex(Dart d)
return false ; return false ;
} }
Dart Map3::findBoundaryFaceOfVertex(Dart d)
{
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)
{
if(isBoundaryMarked(darts[i]))
return darts[i];
//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);
}
}
return NIL ;
}
bool Map3::sameOrientedEdge(Dart d, Dart e) bool Map3::sameOrientedEdge(Dart d, Dart e)
{ {
Dart it = d; Dart it = d;
......
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