Commit 73b5f3f3 authored by Thomas's avatar Thomas
Browse files

embeddedGMap3 mise à jour

parent 9416a673
...@@ -26,39 +26,55 @@ ...@@ -26,39 +26,55 @@
#include "Utils/GLSLShader.h" #include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/subdivision3map.h"
SimpleGMap3::SimpleGMap3() SimpleGMap3::SimpleGMap3()
{ {
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
Algo::Modelisation::Primitive3D<PFP> prim(myMap,position); Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = prim.hexaGrid_topo(2,2,1); Dart d = primCat.hexaGrid_topo(2,2,2);
prim.embedHexaGrid(1,1,1); primCat.embedHexaGrid(1,1,1);
Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); myMap.check();
VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f;
myMap.cutEdge(d1);
position[myMap.phi1(d1)] = mid0;
VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f; Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap,position);
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid1;
d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f;
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid;
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0); position[i] += VEC3(2,0,0);
Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position); // Algo::Modelisation::Primitive3D<PFP> prim(myMap,position);
d = prim2.hexaGrid_topo(2,1,1); // d = prim.hexaGrid_topo(2,2,1);
prim2.embedHexaGrid(1,1,1); // prim.embedHexaGrid(1,1,1);
//
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d)))); // Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
myMap.unsewVolumes(d); // VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f;
// myMap.cutEdge(d1);
// position[myMap.phi1(d1)] = mid0;
//
// VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f;
// myMap.cutEdge(d);
// position[myMap.phi1(d)] = mid1;
//
// d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
// VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f;
// myMap.cutEdge(d);
// position[myMap.phi1(d)] = mid;
//
// for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
// position[i] += VEC3(0,2,0);
myMap.check();
// Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position);
// d = prim2.hexaGrid_topo(2,1,1);
// prim2.embedHexaGrid(1,1,1);
//
// d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
// myMap.unsewVolumes(d);
//
// myMap.check();
} }
void SimpleGMap3::initGUI() void SimpleGMap3::initGUI()
......
...@@ -119,8 +119,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -119,8 +119,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
} }
} }
// mv.unmarkAll();
// first pass: cut edges // first pass: cut edges
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
...@@ -128,23 +126,15 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -128,23 +126,15 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
if(selected(d) && !mv.isMarked(d)) if(selected(d) && !mv.isMarked(d))
{ {
l_vertices.push_back(d); l_vertices.push_back(d);
Dart dd = d; mv.markOrbitInParent<typename PFP::MAP>(VERTEX,d);
do {
mv.mark(dd);
dd = map.phi1(map.phi2(dd));
} while(dd!=d);
} }
//cut edges //cut edges
if (selected(d) && !me.isMarked(d)) if (selected(d) && !me.isMarked(d))
{ {
std::cout << "edge to cut " << d << std::endl;
std::cout << "edge degree " << map.edgeDegree(d) << std::endl;
Dart f = map.phi1(d); Dart f = map.phi1(d);
map.cutEdge(d); map.cutEdge(d);
Dart e = map.phi1(d) ; Dart e = map.phi1(d) ;
std::cout << "cut cut cut " << std::endl;
attributs[e] = attributs[d]; attributs[e] = attributs[d];
attributs[e] += attributs[f]; attributs[e] += attributs[f];
...@@ -166,8 +156,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -166,8 +156,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
} }
} }
std::cout << "edge cut" << std::endl;
// second pass: quandrangule faces // second pass: quandrangule faces
std::map<Dart,Dart> toSew; std::map<Dart,Dart> toSew;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
...@@ -200,8 +188,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -200,8 +188,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
} }
} }
std::cout << "nb vertices " << l_vertices.size() << std::endl;
//third pass : create the inner faces //third pass : create the inner faces
for (std::vector<Dart>::iterator it = l_vertices.begin(); it != l_vertices.end(); ++it) for (std::vector<Dart>::iterator it = l_vertices.begin(); it != l_vertices.end(); ++it)
{ {
......
...@@ -104,8 +104,6 @@ void EmbeddedMap3<MAP3>::unsewVolumes(Dart d) ...@@ -104,8 +104,6 @@ void EmbeddedMap3<MAP3>::unsewVolumes(Dart d)
if (MAP3::isOrbitEmbedded(FACE)) if (MAP3::isOrbitEmbedded(FACE))
{ {
std::cout << "newCell f" << std::endl;
MAP3::embedNewCell(FACE, dd); MAP3::embedNewCell(FACE, dd);
MAP3::copyCell(FACE, dd, d); MAP3::copyCell(FACE, dd, d);
} }
......
...@@ -41,6 +41,8 @@ protected: ...@@ -41,6 +41,8 @@ protected:
void init() ; void init() ;
public: public:
typedef GMap0 ParentMap;
GMap1(); GMap1();
virtual std::string mapTypeName(); virtual std::string mapTypeName();
......
...@@ -204,7 +204,7 @@ inline void GMap1::collapseEdge(Dart d) ...@@ -204,7 +204,7 @@ inline void GMap1::collapseEdge(Dart d)
inline void GMap1::splitFace(Dart d, Dart e) inline void GMap1::splitFace(Dart d, Dart e)
{ {
assert(d != e && sameOrientedFace(d, e)) ; assert(d != e && sameFace(d, e)) ;
Dart d1 = beta1(d) ; Dart d1 = beta1(d) ;
Dart e1 = beta1(e) ; Dart e1 = beta1(e) ;
Dart dd = newEdge() ; Dart dd = newEdge() ;
......
...@@ -41,6 +41,8 @@ protected: ...@@ -41,6 +41,8 @@ protected:
void init() ; void init() ;
public: public:
typedef GMap1 ParentMap;
GMap2(); GMap2();
virtual std::string mapTypeName(); virtual std::string mapTypeName();
......
...@@ -41,6 +41,8 @@ protected: ...@@ -41,6 +41,8 @@ protected:
void init() ; void init() ;
public: public:
typedef GMap2 ParentMap;
GMap3(); GMap3();
virtual std::string mapTypeName(); virtual std::string mapTypeName();
...@@ -201,11 +203,18 @@ public: ...@@ -201,11 +203,18 @@ public:
*/ */
unsigned int vertexDegree(Dart d) ; unsigned int vertexDegree(Dart d) ;
/**
* compute the number of volumes around the edge of d
*/
virtual unsigned int edgeDegree(Dart d);
/** /**
* compute the number of faces in the volume of d * compute the number of faces in the volume of d
*/ */
unsigned int volumeDegree(Dart d); unsigned int volumeDegree(Dart d);
virtual bool check();
/*! @name Cell Functors /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
*************************************************************************/ *************************************************************************/
......
...@@ -40,7 +40,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e) ...@@ -40,7 +40,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e)
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, phi1(dd), d) ; copyDartEmbedding(VERTEX, phi1(dd), d) ;
copyDartEmbedding(VERTEX, beta2(phi1(dd)), beta2(d)) ;
copyDartEmbedding(VERTEX, phi1(ee), e) ; copyDartEmbedding(VERTEX, phi1(ee), e) ;
copyDartEmbedding(VERTEX, beta2(phi1(ee)), beta2(e)) ;
embedNewCell(VERTEX, e) ; embedNewCell(VERTEX, e) ;
copyCell(VERTEX, e, d) ; copyCell(VERTEX, e, d) ;
} }
...@@ -48,7 +50,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e) ...@@ -48,7 +50,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e)
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(FACE))
{ {
copyDartEmbedding(FACE, phi1(dd), dd) ; copyDartEmbedding(FACE, phi1(dd), dd) ;
copyDartEmbedding(FACE, beta0(phi1(dd)), beta0(dd)) ;
copyDartEmbedding(FACE, phi1(ee), ee) ; copyDartEmbedding(FACE, phi1(ee), ee) ;
copyDartEmbedding(FACE, beta0(phi1(ee)), beta0(ee)) ;
} }
} }
...@@ -93,15 +97,19 @@ void EmbeddedGMap2::cutEdge(Dart d) ...@@ -93,15 +97,19 @@ void EmbeddedGMap2::cutEdge(Dart d)
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
{ {
embedNewCell(EDGE, nd) ; embedNewCell(EDGE, nd) ;
copyDartEmbedding(EDGE, phi2(d), d) ;
copyCell(EDGE, nd, d) ; copyCell(EDGE, nd, d) ;
} }
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(FACE))
{ {
copyDartEmbedding(FACE, phi1(d), d) ; copyDartEmbedding(FACE, phi1(d), d) ;
copyDartEmbedding(FACE, beta0(phi1(d)), beta0(d)) ;
Dart e = phi2(nd) ; Dart e = phi2(nd) ;
if(e != nd) if(e != nd)
{
copyDartEmbedding(FACE, phi1(e), e) ; copyDartEmbedding(FACE, phi1(e), e) ;
copyDartEmbedding(FACE, beta0(phi1(e)), beta0(e)) ;
}
} }
} }
...@@ -197,12 +205,16 @@ bool EmbeddedGMap2::flipEdge(Dart d) ...@@ -197,12 +205,16 @@ bool EmbeddedGMap2::flipEdge(Dart d)
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, d, phi1(e)) ; copyDartEmbedding(VERTEX, d, phi1(e)) ;
copyDartEmbedding(VERTEX, beta2(d), beta2(phi1(e))) ;
copyDartEmbedding(VERTEX, e, phi1(d)) ; copyDartEmbedding(VERTEX, e, phi1(d)) ;
copyDartEmbedding(VERTEX, beta2(e), beta2(phi1(d))) ;
} }
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
copyDartEmbedding(FACE, phi_1(d), d) ; copyDartEmbedding(FACE, phi_1(d), d) ;
copyDartEmbedding(FACE, beta0(phi_1(d)), beta0(d)) ;
copyDartEmbedding(FACE, phi_1(e), e) ; copyDartEmbedding(FACE, phi_1(e), e) ;
copyDartEmbedding(FACE, beta0(phi_1(e)), beta0(e)) ;
} }
return true ; return true ;
} }
...@@ -218,12 +230,17 @@ bool EmbeddedGMap2::flipBackEdge(Dart d) ...@@ -218,12 +230,17 @@ bool EmbeddedGMap2::flipBackEdge(Dart d)
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, d, phi1(e)) ; copyDartEmbedding(VERTEX, d, phi1(e)) ;
copyDartEmbedding(VERTEX, beta2(d), beta2(phi1(e))) ;
copyDartEmbedding(VERTEX, e, phi1(d)) ; copyDartEmbedding(VERTEX, e, phi1(d)) ;
copyDartEmbedding(VERTEX, beta2(e), beta2(phi1(d))) ;
} }
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
copyDartEmbedding(FACE, phi1(d), d) ; copyDartEmbedding(FACE, phi1(d), d) ;
copyDartEmbedding(FACE, beta0(phi1(d)), beta0(d)) ;
copyDartEmbedding(FACE, phi1(e), e) ; copyDartEmbedding(FACE, phi1(e), e) ;
copyDartEmbedding(FACE, beta0(phi1(e)), beta0(e)) ;
} }
return true ; return true ;
} }
...@@ -299,7 +316,8 @@ void EmbeddedGMap2::sewFaces(Dart d, Dart e) ...@@ -299,7 +316,8 @@ void EmbeddedGMap2::sewFaces(Dart d, Dart e)
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
{ {
copyDartEmbedding(EDGE, e, d) ; vEmb1 = getEmbedding(EDGE, d) ;
embedOrbit(EDGE, e, vEmb1) ;
} }
} }
...@@ -355,6 +373,7 @@ bool EmbeddedGMap2::collapseDegeneratedFace(Dart d) ...@@ -355,6 +373,7 @@ bool EmbeddedGMap2::collapseDegeneratedFace(Dart d)
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
{ {
copyDartEmbedding(EDGE, phi2(e), e) ; copyDartEmbedding(EDGE, phi2(e), e) ;
copyDartEmbedding(EDGE, beta0(phi2(e)), beta0(e)) ;
} }
return true ; return true ;
} }
...@@ -368,7 +387,9 @@ void EmbeddedGMap2::splitFace(Dart d, Dart e) ...@@ -368,7 +387,9 @@ void EmbeddedGMap2::splitFace(Dart d, Dart e)
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, phi_1(e), d) ; copyDartEmbedding(VERTEX, phi_1(e), d) ;
copyDartEmbedding(VERTEX, beta2(phi_1(e)), beta2(d)) ;
copyDartEmbedding(VERTEX, phi_1(d), e) ; copyDartEmbedding(VERTEX, phi_1(d), e) ;
copyDartEmbedding(VERTEX, beta2(phi_1(d)), beta2(e)) ;
} }
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
...@@ -444,10 +465,12 @@ unsigned int EmbeddedGMap2::closeHole(Dart d) ...@@ -444,10 +465,12 @@ unsigned int EmbeddedGMap2::closeHole(Dart d)
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, f, alpha1(f)) ; copyDartEmbedding(VERTEX, f, alpha1(f)) ;
copyDartEmbedding(VERTEX, beta2(f), beta2(alpha1(f))) ;
} }
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
{ {
copyDartEmbedding(EDGE, f, phi2(f)) ; copyDartEmbedding(EDGE, f, phi2(f)) ;
copyDartEmbedding(EDGE, beta0(f), beta0(phi2(f))) ;
} }
f = phi1(f) ; f = phi1(f) ;
} while(dd != f) ; } while(dd != f) ;
......
...@@ -63,42 +63,53 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) ...@@ -63,42 +63,53 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e)
//embed the face orbit from the volume sewn //embed the face orbit from the volume sewn
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
copyDartEmbedding(FACE, e, d) ; {
unsigned int vEmb = getEmbedding(FACE, d);
embedOrbit(FACE, e, vEmb) ;
}
} }
void EmbeddedGMap3::unsewVolumes(Dart d) void EmbeddedGMap3::unsewVolumes(Dart d)
{ {
// Dart d3 = phi3(d); Dart dd = phi1(phi3(d));
//
// bool boundaryD = false; if(phi3(d)!=d)
// bool boundaryE = false; {
// GMap3::unsewVolumes(d);
// if(isOrbitEmbedded(VERTEX))
// { Dart ddd = d;
// if(isBoundaryVertex(d)) do
// boundaryD = true; {
// if(isBoundaryVertex(phi1(d))) if(isOrbitEmbedded(VERTEX))
// boundaryE = true; {
// } if(!sameVertex(ddd,dd))
// {
GMap3::unsewVolumes(d); embedNewCell(VERTEX, ddd);
// copyCell(VERTEX, ddd, dd);
// Dart dd = d; }
// Dart dd3 = d3; }
//
// do dd = phi_1(dd);
// {
// if(isOrbitEmbedded(VERTEX)) if(isOrbitEmbedded(EDGE))
// copyCell(VERTEX, dd3, phi1(dd)); {
// if(!sameEdge(ddd,dd))
// if(isOrbitEmbedded(EDGE)) {
// embedNewCell(EDGE, dd);
// copyCell(VERTEX, dd, ddd);
// if(isOrbitEmbedded(FACE)) }
// }
//
// dd = phi1(dd) ; ddd = phi1(ddd);
// }while( dd != d ); } while(ddd!=d);
if (isOrbitEmbedded(FACE))
{
embedNewCell(FACE, dd);
copyCell(FACE, dd, d);
}
}
} }
bool EmbeddedGMap3::mergeVolumes(Dart d) bool EmbeddedGMap3::mergeVolumes(Dart d)
...@@ -124,36 +135,40 @@ void EmbeddedGMap3::splitFace(Dart d, Dart e) ...@@ -124,36 +135,40 @@ void EmbeddedGMap3::splitFace(Dart d, Dart e)
if(isOrbitEmbedded(VERTEX)) if(isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, phi2(phi_1(d)), d); unsigned int vEmb = getEmbedding(VERTEX, d);
copyDartEmbedding(VERTEX, phi2(phi_1(e)), e); embedOrbit(VERTEX,phi2(phi_1(d)),vEmb);
if(phi3(d) != d)
{
Dart d3 = phi3(d);
Dart e3 = phi3(e);
copyDartEmbedding(VERTEX, phi1(d3), phi1(phi2(phi1(d3)))); vEmb = getEmbedding(VERTEX, e);
copyDartEmbedding(VERTEX, phi1(e3), phi1(phi2(phi1(e3)))); embedOrbit(VERTEX,phi2(phi_1(e)),vEmb);
}
} }
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(FACE))
{ {
embedNewCell(FACE, phi2(phi_1(d))); embedNewCell(FACE, phi2(phi_1(d)));
copyCell(FACE, phi2(phi_1(d)), d); copyCell(FACE, phi2(phi_1(d)), d);
copyDartEmbedding(FACE, phi_1(d), d);
copyDartEmbedding(FACE, beta0(phi_1(d)), beta0(d));
copyDartEmbedding(FACE, beta3(phi_1(d)), beta3(d));
copyDartEmbedding(FACE, beta3(beta0(phi_1(d))), beta3(beta0(d)));
} }
if(isOrbitEmbedded(VOLUME)) if(isOrbitEmbedded(VOLUME))
{ {
copyDartEmbedding(VOLUME, phi_1(d), d); copyDartEmbedding(VOLUME, phi_1(d), d);
copyDartEmbedding(VOLUME, beta0(phi_1(d)), beta0(d));
copyDartEmbedding(VOLUME, phi2(phi_1(d)), d); copyDartEmbedding(VOLUME, phi2(phi_1(d)), d);
copyDartEmbedding(VOLUME, beta0(phi2(phi_1(d))), beta0(d));
if(phi3(d) != d) if(phi3(d) != d)
{ {
Dart d3 = phi3(d); Dart d3 = phi3(d);
copyDartEmbedding(VOLUME, phi1(d3), d3); copyDartEmbedding(VOLUME, phi1(d3), d3);
copyDartEmbedding(VOLUME, beta0(phi1(d3)), beta0(d3));
copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3); copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3);
copyDartEmbedding(VOLUME, beta0(phi2(phi1(d3))), beta0(d3));
} }
} }
} }
...@@ -164,13 +179,13 @@ void EmbeddedGMap3::cutEdge(Dart d) ...@@ -164,13 +179,13 @@ void EmbeddedGMap3::cutEdge(Dart d)