Commit 824c4141 authored by untereiner's avatar untereiner

ptit commit

parent ed431beb
...@@ -240,34 +240,37 @@ inline void ImplicitHierarchicalMap3::next(Dart& d) ...@@ -240,34 +240,37 @@ inline void ImplicitHierarchicalMap3::next(Dart& d)
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread) inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
{ {
DartMarkerStore mv(*this); // Lock a marker DartMarkerStore mv(*this,thread); // Lock a marker
bool found = false; // Last functor return value bool found = false; // Last functor return value
std::list<Dart> darts_list; //Darts that are traversed std::vector<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d darts_list.reserve(50);
std::list<Dart>::iterator darts;
darts_list.push_back(d); //Start with the dart d
mv.mark(d); mv.mark(d);
for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts) for(std::vector<Dart>::iterator darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
{ {
Dart dc = *darts; Dart dc = *darts;
//add phi21 and phi23 successor if they are not marked yet //add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(dc); Dart d2 = phi2(dc);
Dart d21 = phi1(d2); // turn in volume if(d2 != dc)
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
{ {
darts_list.push_back(d21); Dart d21 = phi1(d2); // turn in volume
mv.mark(d21); Dart d23 = phi3(d2); // change volume
}
if((d23!=d2) && !mv.isMarked(d23)) if(!mv.isMarked(d21))
{ {
darts_list.push_back(d23); darts_list.push_back(d21);
mv.mark(d23); mv.mark(d21);
}
if((d23!=d2) && !mv.isMarked(d23))
{
darts_list.push_back(d23);
mv.mark(d23);
}
} }
found = f(dc); found = f(dc);
......
...@@ -85,7 +85,9 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position ...@@ -85,7 +85,9 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
++degree; ++degree;
p += position[it] ; p += position[it] ;
if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already) if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already)
{
Algo::IHM::subdivideEdge<PFP>(map, it, position) ; // and compute the degree of the face Algo::IHM::subdivideEdge<PFP>(map, it, position) ; // and compute the degree of the face
}
it = map.phi1(it) ; it = map.phi1(it) ;
} while(it != old) ; } while(it != old) ;
p /= typename PFP::REAL(degree) ; p /= typename PFP::REAL(degree) ;
...@@ -94,38 +96,38 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position ...@@ -94,38 +96,38 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
Dart res; Dart res;
if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire // if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
{ // {
Dart dd = map.phi1(old) ; // Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ; // Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge // map.splitFace(dd, e) ; // insert a new edge
unsigned int id = map.getNewEdgeId() ; // unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id // map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
//
unsigned int idface = map.getFaceId(old); // unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ; // map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ; // map.setFaceId(e, idface, FACE) ;
//
dd = e ; // dd = e ;
e = map.phi1(map.phi1(dd)) ; // e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // map.splitFace(dd, e) ;
id = map.getNewEdgeId() ; // id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
map.setFaceId(dd, idface, FACE) ; // map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ; // map.setFaceId(e, idface, FACE) ;
//
dd = e ; // dd = e ;
e = map.phi1(map.phi1(dd)) ; // e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // map.splitFace(dd, e) ;
id = map.getNewEdgeId() ; // id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
map.setFaceId(dd, idface, FACE) ; // map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ; // map.setFaceId(e, idface, FACE) ;
} // }
else // else
{ // {
Dart dd = map.phi1(old) ; Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ; map.splitFace(dd, map.phi1(map.phi1(dd))) ;
...@@ -162,7 +164,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position ...@@ -162,7 +164,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
dd = map.phi2(map.phi1(dd)); dd = map.phi2(map.phi1(dd));
} }
while(dd != ne); while(dd != ne);
} // }
map.setCurrentLevel(cur) ; map.setCurrentLevel(cur) ;
} }
...@@ -179,6 +181,9 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -179,6 +181,9 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
unsigned int cur = map.getCurrentLevel(); unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(vLevel); map.setCurrentLevel(vLevel);
std::cout << "vLevel = " << vLevel << std::endl;
/* /*
* au niveau du volume courant i * au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci * stockage d'un brin de chaque face de celui-ci
...@@ -186,7 +191,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -186,7 +191,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
*/ */
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
CellMarker mv(map, VERTEX);
typename PFP::VEC3 volCenter; typename PFP::VEC3 volCenter;
unsigned count = 0 ; unsigned count = 0 ;
...@@ -211,9 +217,10 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -211,9 +217,10 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//compute volume centroid //compute volume centroid
if(!mv.isMarked(e)) if(!mv.isMarked(e))
{ {
//mv.markOrbit(VERTEX, e);
mv.mark(e);
volCenter += position[e]; volCenter += position[e];
++count; ++count;
mv.markOrbit(VERTEX, e);
oldEdges.push_back(e); oldEdges.push_back(e);
} }
...@@ -239,6 +246,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -239,6 +246,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
std::vector<std::pair<Dart,Dart> > subdividedfaces; std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25); subdividedfaces.reserve(25);
int i = 0;
//First step : subdivide edges and faces //First step : subdivide edges and faces
//creates a i+1 edge level and i+1 face level //creates a i+1 edge level and i+1 face level
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
...@@ -247,12 +255,24 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -247,12 +255,24 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//if needed subdivide face //if needed subdivide face
if(!map.faceIsSubdivided(d)) if(!map.faceIsSubdivided(d))
{
++i;
Algo::IHM::subdivideFace<PFP>(map, d, position); Algo::IHM::subdivideFace<PFP>(map, d, position);
}
std::cout << "CHECK FACES " << std::endl;
map.check();
//save a dart from the subdivided face //save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ; unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee map.setCurrentLevel(map.getMaxLevel());
Dart old = map.faceOldestDart(d);
std::cout << " Oldest dart Face = " << old << std::endl;
unsigned int fLevel = map.faceLevel(old); //puisque dans tous les cas, la face est subdivisee
std::cout << "FACE LEVEL = " << fLevel << std::endl;
map.setCurrentLevel(fLevel) ; map.setCurrentLevel(fLevel) ;
...@@ -268,6 +288,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -268,6 +288,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur); map.setCurrentLevel(cur);
} }
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
std::vector<Dart> newEdges; //save darts from inner edges std::vector<Dart> newEdges; //save darts from inner edges
...@@ -279,21 +301,33 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -279,21 +301,33 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
Dart e = *edge; Dart e = *edge;
Dart f1 = map.phi1(*edge); Dart f1 = map.phi1(*edge);
int i = 0;
do do
{ {
map.unsewFaces(map.phi1(map.phi1(e))); std::cout << "corner #" << i << " degree = " << map.faceDegree(e) << std::endl;
if(map.phi2(map.phi1(map.phi1(e))) != map.phi1(map.phi1(e)))
map.unsewFaces(map.phi1(map.phi1(e)));
//TODO utile ? //TODO utile ?
//if(map.phi2(map.phi1(e)) != map.phi1(e)) if(map.phi2(map.phi1(e)) != map.phi1(e))
map.unsewFaces(map.phi1(e)); map.unsewFaces(map.phi1(e));
++i;
e = map.phi2(map.phi_1(e)); e = map.phi2(map.phi_1(e));
} }
while(e != *edge); while(e != *edge);
map.closeHole(f1); map.closeHole(f1);
std::cout << "CHECK CLOSE HOLE " << std::endl;
map.check();
std::cout << "corner degree = " << i << std::endl;
std::cout << "face degree = " << map.faceDegree(map.phi2(f1)) << std::endl;
// if(map.faceDegree(map.phi2(f1)) > 6)
// return Dart::nil();
Dart old = map.phi2(map.phi1(e)); Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ; Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ; map.splitFace(old,dd) ;
...@@ -361,6 +395,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -361,6 +395,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur) ; map.setCurrentLevel(cur) ;
std::cout << std::endl;
return subdividedfaces.begin()->first; return subdividedfaces.begin()->first;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "Geometry/bounding_box.h" #include "Geometry/bounding_box.h"
#include "Geometry/plane_3d.h" #include "Geometry/plane_3d.h"
#include "Algo/BooleanOperator/mergeVertices.h" #include "Algo/BooleanOperator/mergeVertices.h"
#include "Container/fakeAttribute.h"
#include <limits> #include <limits>
namespace CGoGN namespace CGoGN
...@@ -124,7 +125,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool& ...@@ -124,7 +125,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool&
valueOf(yS,y); valueOf(yS,y);
typename PFP::VEC3 previous = (curPoly)[(curPoly).size()-1]; VEC3 previous = (curPoly)[(curPoly).size()-1];
x = previous[0]; x = previous[0];
push_point=true; push_point=true;
......
...@@ -122,26 +122,15 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con ...@@ -122,26 +122,15 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con
/* /*
* TODO quadrangule volume * volume subdivision scheme
*/ */
/**
* Quadrangule all the faces of the mesh
*/
template <typename PFP, typename EMBV, typename EMB>
void quadranguleFacesVolume(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = SelectorTrue()) ;
template <typename PFP, typename EMBV, typename EMB> template <typename PFP, typename EMBV, typename EMB>
void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs); void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs);
template <typename PFP, typename EMBV, typename EMB>
void dooSabinVolume(typename PFP::MAP& map, Dart d, EMBV& attributs);
/* template <typename PFP>
* Quadrangule a Volume void splitVolumes(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
*/
template <typename PFP, typename EMBV, typename EMB>
void quadranguleVolumes(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = SelectorTrue());
// TODO a mettre ailleurs ? // TODO a mettre ailleurs ?
......
...@@ -642,11 +642,6 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con ...@@ -642,11 +642,6 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con
} }
} }
template <typename PFP, typename EMBV, typename EMB>
void quadranguleFacesVolume(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected)
{
}
template <typename PFP, typename EMBV, typename EMB> template <typename PFP, typename EMBV, typename EMB>
void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs) void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
...@@ -826,83 +821,78 @@ void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs) ...@@ -826,83 +821,78 @@ void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
// } // }
} }
template <typename PFP, typename EMBV, typename EMB>
void dooSabinVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
{
DartMarker mf(map) ; //mark face
DartMarker me(map) ; //mark edge
DartMarkerStore mark(map); // Lock a marker
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(100);
visitedFaces.push_back(d);
std::vector<Dart>::iterator face;
//Store a dart from a each face
std::vector<Dart> faces;
faces.reserve(100);
// First pass : for every face added to the list save a dart template <typename PFP>
for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face) void splitVolumes(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
//Cut the edges
DartMarker me(map, EDGE);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if (!mark.isMarked(*face)) // Face has not been visited yet if(!me.isMarked(d))
{ {
// Cut the edge
Dart dd = map.phi2(d) ;
typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ;
map.cutEdge(d) ;
faces.push_back(*face); position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
Dart dNext = *face ; me.markOrbit(EDGE, d);
do me.markOrbit(EDGE, map.phi1(d));
{
mark.mark(dNext); // Mark
Dart adj = map.phi2(dNext); // Get adjacent face
if (adj != dNext && !mark.isMarked(adj))
visitedFaces.push_back(adj); // Add it
dNext = map.phi1(dNext);
} while(dNext != *face);
} }
} }
// Second pass : for every edges insert a face DartMarker mf(map, FACE);
for(face = faces.begin() ; face != faces.end() ; ++face) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
Dart e = *face; if(!mf.isMarked(d))
do
{ {
if(!me.isMarked(e))
{
//insertion d'une face dans l'arete
Dart e2 = map.phi2(e);
map.unsewFaces(e);
Dart ne = map.newOrientedFace(4);
map.sewFaces(e,ne);
map.sewFaces(e2, map.phi1(map.phi1(ne)));
//marquage de l'orbite arete
me.markOrbit(EDGE,e);
}
e = map.phi1(e); mf.markOrbit(FACE, d);
}while (e != *face); }
} }
// Dart f = map.phi1(d);
// map.cutEdge(d); // //and split the faces
// Dart e = map.phi1(d);
// attributs[e] = attributs[d];
// attributs[e] += attributs[f];
// attributs[e] *= 0.5;
// //
// Dart dPrev = d; // //Insert the middleFaces
// Dart ePrev = map.phi2(d);
// map.splitFace(dPrev,ePrev);
// //
// attributs[map.phi_1(d)] = attributs[map.phi1(ePrev)]; // // first cut the edges (if they are not already)
// Dart t = d;
// do
// {
// if(!map.edgeIsSubdivided(map.phi1(map.phi2(t))))
// Algo::IHM::subdivideEdge<PFP>(map, map.phi1(map.phi2(t)), position) ;
// t = map.phi1(t);
// }
// while(t != d);
//
// Dart neighboordVolume = map.phi1(map.phi1(map.phi2(d)));
//
// //Split the faces and open the midlle
// do
// {
// Dart t2 = map.phi2(t);
//
// Dart face2 = map.phi1(map.phi1(t2));
// map.splitFace(map.phi_1(t2), face2);
// map.unsewFaces(map.phi1(map.phi1(t2)));
//
// t = map.phi1(t);
// }
// while(t != d);
//
//
// map.closeHole(map.phi1(map.phi1(map.phi2(d))));
// map.closeHole(map.phi_1(neighboordVolume));
// map.sewVolumes(map.phi2(map.phi1(map.phi1(map.phi2(d)))), map.phi2(map.phi_1(neighboordVolume)));
} }
} // namespace Modelisation } // namespace Modelisation
} // namespace Algo } // namespace Algo
......
...@@ -41,8 +41,8 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e) ...@@ -41,8 +41,8 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
unsigned int vEmb1 = EMBNULL ; unsigned int vEmb1 = EMBNULL ;
Dart dd = d ; Dart dd = d ;
do { do {
vEmb1 = MAP3::getEmbedding(VERTEX, d); vEmb1 = MAP3::getEmbedding(VERTEX, dd);
MAP3::embedOrbit(VERTEX, d, vEmb1) ; MAP3::embedOrbit(VERTEX, dd, vEmb1) ;
dd = MAP3::phi1(dd) ; dd = MAP3::phi1(dd) ;
} while(dd != d) ; } while(dd != d) ;
} }
...@@ -328,9 +328,12 @@ bool EmbeddedMap3<MAP3>::check() ...@@ -328,9 +328,12 @@ bool EmbeddedMap3<MAP3>::check()
return false ; return false ;
} }
if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d)))) if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi1(MAP3::phi3(d))))
{ {
CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ; CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
std::cout << "Dart #" << d << std::endl;
std::cout << "Emb(d) = " << MAP3::getEmbedding(VERTEX, d) << std::endl;
std::cout << "Emb(phi32(d)) = " << MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))) << std::endl;
return false ; return false ;
} }
......
...@@ -308,7 +308,7 @@ public: ...@@ -308,7 +308,7 @@ public:
* @param f the functor * @param f the functor
* @param s the selector * @param s the selector
*/ */
bool foreach_connex_volume(Dart d, int degree, FunctorType& f, FunctorSelect& s, unsigned int thread=0); bool foreach_connex_volume(Dart d, int degree, FunctorType& f, FunctorSelect& s, unsigned int thread=0);
//@}