Commit 68944bbf authored by Thomas's avatar Thomas

bug de catmull-clark sur gcarte inexistant : pb d affichage en fait..

parent ebe54c68
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
SimpleGMap3::SimpleGMap3() SimpleGMap3::SimpleGMap3()
{ {
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position); Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(2,1,1); Dart d = primCat.hexaGrid_topo(2,1,1);
...@@ -39,43 +40,41 @@ SimpleGMap3::SimpleGMap3() ...@@ -39,43 +40,41 @@ SimpleGMap3::SimpleGMap3()
myMap.check(); myMap.check();
// DartMarker markOrient(myMap); DartMarker markOrient(myMap);
// std::vector<Dart> orient; std::vector<Dart> orient;
// FunctorStore fs(orient); FunctorStore fs(orient);
// myMap.foreach_dart_of_oriented_volume(d,fs); myMap.foreach_dart_of_oriented_volume(d,fs);
//
// for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
// markOrient.mark(*it);
//
// SelectorMarked sm(markOrient);
Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap,position); for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
markOrient.mark(*it);
SelectorMarked sm(markOrient);
Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap,position,sm);
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> prim(myMap,position); Algo::Modelisation::Primitive3D<PFP> prim(myMap,position);
// d = prim.hexaGrid_topo(2,2,1); d = prim.hexaGrid_topo(2,2,1);
// prim.embedHexaGrid(1,1,1); prim.embedHexaGrid(1,1,1);
//
// Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(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(); Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(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);
Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position); Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position);
d = prim2.hexaGrid_topo(2,1,1); d = prim2.hexaGrid_topo(2,1,1);
...@@ -110,6 +109,12 @@ void SimpleGMap3::cb_redraw() ...@@ -110,6 +109,12 @@ void SimpleGMap3::cb_redraw()
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(1.0f); glLineWidth(1.0f);
Algo::Render::GL1::renderTopoGMD3<PFP>(myMap, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f); Algo::Render::GL1::renderTopoGMD3<PFP>(myMap, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f);
glDisable(GL_LIGHTING);
glColor3f(1.0f, 1.0f, 1.0f);
glLineWidth(1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap, Algo::Render::GL1::LINE, 1.0,position, normal);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "Geometry/vector_gen.h" #include "Geometry/vector_gen.h"
#include "Algo/Render/GL1/map_glRender.h"
#include "Algo/Render/GL1/topo_render.h" #include "Algo/Render/GL1/topo_render.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -53,6 +54,7 @@ public: ...@@ -53,6 +54,7 @@ public:
SelectorTrue allDarts ; SelectorTrue allDarts ;
PFP::TVEC3 position ; PFP::TVEC3 position ;
PFP::TVEC3 normal ;
SimpleGMap3() ; SimpleGMap3() ;
......
...@@ -224,22 +224,22 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -224,22 +224,22 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
d= dN; d= dN;
} while (*it!=d); } while (*it!=d);
// //close the generated hole and create the central vertex //close the generated hole and create the central vertex
// unsigned int degree = map.closeHole(map.phi1(d)); unsigned int degree = map.closeHole(map.phi1(d));
//
// Dart dd = map.phi1(map.phi2(map.phi1(d))); Dart dd = map.phi1(map.phi2(map.phi1(d)));
// map.splitFace(map.phi_1(dd),map.phi1(dd)); map.splitFace(map.phi_1(dd),map.phi1(dd));
// Dart dS = map.phi1(dd); Dart dS = map.phi1(dd);
// map.cutEdge(dS); map.cutEdge(dS);
//
// attributs[map.phi1(dS)] = attBary[d]; attributs[map.phi1(dS)] = attBary[d];
//
// //TODO : test with vertices with degree higher than 3 //TODO : test with vertices with degree higher than 3
// for(unsigned int i=0; i < (degree/2)-2; ++i) for(unsigned int i=0; i < (degree/2)-2; ++i)
// { {
// map.splitFace(map.phi2(dS),map.template phi<111>(map.phi2(dS))); map.splitFace(map.phi2(dS),map.template phi<111>(map.phi2(dS)));
// dS = map.template phi<111>(map.phi2(dS)); dS = map.template phi<111>(map.phi2(dS));
// } }
} }
nb_=0; nb_=0;
...@@ -248,15 +248,17 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -248,15 +248,17 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
std::cout << "then " << nb_ << std::endl; std::cout << "then " << nb_ << std::endl;
// //sew all faces leading to the central vertex map.check();
// for (std::map<Dart,Dart>::iterator it = toSew.begin(); it != toSew.end(); ++it)
// { //sew all faces leading to the central vertex
// Dart dT = map.phi2(it->first); for (std::map<Dart,Dart>::iterator it = toSew.begin(); it != toSew.end(); ++it)
// if(dT==map.phi3(dT)) {
// { Dart dT = map.phi2(it->first);
// map.sewVolumes(dT,map.phi2(it->second)); if(dT==map.phi3(dT))
// } {
// } map.sewVolumes(dT,map.phi2(it->second));
}
}
} }
} //namespace Modelisation } //namespace Modelisation
......
...@@ -436,12 +436,17 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions ...@@ -436,12 +436,17 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh
DartMarker mark(map); // marker for darts DartMarker mark(map); // marker for darts
CellMarker mVol(map, VOLUME); // CellMarker mVol(map, VOLUME);
DartMarker mVol(map);
//compute barycenter and get a dart by face
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if(!mVol.isMarked(d)) if(!mVol.isMarked(d))
{ {
mVol.mark(d); // mVol.mark(d);
mVol.markOrbit(VOLUME,d);
CellMarkerStore markVert(map, VERTEX); //marker for vertices CellMarkerStore markVert(map, VERTEX); //marker for vertices
VEC3 center(0); VEC3 center(0);
unsigned int nbVertices = 0; unsigned int nbVertices = 0;
...@@ -461,7 +466,6 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions ...@@ -461,7 +466,6 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
do do
{ {
mark.mark(dNext); // Mark mark.mark(dNext); // Mark
// mark.mark(map.beta0(dNext));
if (!markVert.isMarked(dNext)) if (!markVert.isMarked(dNext))
{ {
......
...@@ -39,6 +39,12 @@ class EmbeddedGMap3 : public GMap3 ...@@ -39,6 +39,12 @@ class EmbeddedGMap3 : public GMap3
public: public:
typedef GMap3 TOPO_MAP; typedef GMap3 TOPO_MAP;
//!
/*!
*
*/
virtual void unsewFaces(Dart d);
//! //!
/*! /*!
* *
......
...@@ -30,6 +30,36 @@ ...@@ -30,6 +30,36 @@
namespace CGoGN namespace CGoGN
{ {
void EmbeddedGMap3::unsewFaces(Dart d)
{
Dart e = beta2(d);
GMap3::unsewFaces(d);
if (isOrbitEmbedded(VERTEX))
{
if(!sameVertex(d,e))
{
embedNewCell(VERTEX, e);
copyCell(VERTEX, e, d);
}
d = beta0(d);
e = beta0(e);
if(!sameVertex(d,e))
{
embedNewCell(VERTEX, e);
copyCell(VERTEX, e, d);
}
}
if (isOrbitEmbedded(EDGE))
{
embedNewCell(EDGE, e);
copyCell(EDGE, e, d);
}
}
void EmbeddedGMap3::sewVolumes(Dart d, Dart e) void EmbeddedGMap3::sewVolumes(Dart d, Dart e)
{ {
//topological sewing //topological sewing
...@@ -41,7 +71,8 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) ...@@ -41,7 +71,8 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e)
{ {
unsigned int vEmb1 = EMBNULL ; unsigned int vEmb1 = EMBNULL ;
Dart dd = d ; Dart dd = d ;
do { do
{
vEmb1 = getEmbedding(VERTEX, dd); vEmb1 = getEmbedding(VERTEX, dd);
embedOrbit(VERTEX, dd, vEmb1) ; embedOrbit(VERTEX, dd, vEmb1) ;
dd = phi1(dd) ; dd = phi1(dd) ;
...@@ -54,9 +85,10 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) ...@@ -54,9 +85,10 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e)
{ {
unsigned int vEmb1 = EMBNULL ; unsigned int vEmb1 = EMBNULL ;
Dart dd = d ; Dart dd = d ;
do { do
vEmb1 = getEmbedding(EDGE, d); {
embedOrbit(EDGE, d, vEmb1) ; vEmb1 = getEmbedding(EDGE, dd);
embedOrbit(EDGE, dd, vEmb1) ;
dd = phi1(dd) ; dd = phi1(dd) ;
} while(dd != d) ; } while(dd != 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