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