Commit c27d2145 authored by untereiner's avatar untereiner

some changes (see another time what)

parent df531a08
......@@ -30,87 +30,120 @@
SimpleGMap3::SimpleGMap3()
{
position = myMap.addAttribute<VEC3, VERTEX>("position");
normal = myMap.addAttribute<VEC3, VERTEX>("normal");
volume = myMap.addAttribute<VEC3, VOLUME>("volume");
position = myMap.addAttribute<VEC3, VERTEX>("position");
volume = myMap.addAttribute<VEC3, VOLUME>("volume");
CellMarker<EDGE> mE(myMap);
// CellMarker<EDGE> mE(myMap);
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(3,1,1);
primCat.embedHexaGrid(2,1,1);
myMap.check();
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(1,1,1);
primCat.embedHexaGrid(1,1,1);
myMap.check();
Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5));
Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap);
myMap.check();
position[dp] = typename PFP::VEC3(0.5,0.5,-0.5);
position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5);
position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5);
position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5);
position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f);
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
Dart dtemp = myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(d))))))));
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
d = prim.hexaGrid_topo(2,2,1);
prim.embedHexaGrid(1,1,1);
myMap.sewVolumes(dtemp,dp);
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;
// Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5));
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
VEC3 mid1 = (position[d] + position[myMap.phi1(d)]) / 2.0f;
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid1;
// myMap.check();
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(2,0,0);
myMap.splitFace(d,myMap.phi1(myMap.phi1(myMap.phi1(d))));
// Algo::Volume::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;
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(0,2,0);
// VEC3 mid1 = (position[d] + position[myMap.phi1(d)]) / 2.0f;
// myMap.cutEdge(d);
// position[myMap.phi1(d)] = mid1;
Algo::Volume::Modelisation::Primitive3D<PFP> prim2(myMap,position);
d = prim2.hexaGrid_topo(2,1,1);
prim2.embedHexaGrid(1,1,1);
// 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;
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.unsewVolumes(d);
// myMap.splitFace(d,myMap.phi1(myMap.phi1(myMap.phi1(d))));
myMap.check();
// myMap.check();
// for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
// position[i] += VEC3(0,2,0);
// Algo::Volume::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::cb_keyPress(int code)
{
switch(code)
{
case 'e':
{
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,".%F.%H:%M:%S",timeinfo);
std::string filename = std::string("topo_screenshot") + std::string(buffer) + std::string(".svg");
m_render_topo->svgout2D(filename, modelViewMatrix(), projectionMatrix());
break;
}
}
}
void SimpleGMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
setParamObject(gWidthObj, gPosObj.data());
m_render_topo = new Algo::Render::GL2::Topo3Render();
m_render_topo->setDartWidth(2.0f);
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f,0.9f,0.9f);
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
setParamObject(gWidthObj, gPosObj.data());
m_render_topo = new Algo::Render::GL2::Topo3Render();
m_render_topo->setDartWidth(2.0f);
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f,0.9f,0.8f);
}
void SimpleGMap3::cb_redraw()
{
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
m_render_topo->drawTopo();
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
m_render_topo->drawTopo();
}
/**********************************************************************************************
......@@ -119,13 +152,13 @@ void SimpleGMap3::cb_redraw()
int main(int argc, char **argv)
{
QApplication app(argc, argv) ;
QApplication app(argc, argv) ;
SimpleGMap3 sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
SimpleGMap3 sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
sqt.initGUI() ;
sqt.initGUI() ;
return app.exec() ;
return app.exec() ;
}
......@@ -53,7 +53,6 @@ public:
MAP myMap ;
VertexAttribute<VEC3> position ;
VertexAttribute<VEC3> normal ;
VolumeAttribute<VEC3> volume ;
Algo::Render::GL2::Topo3Render* m_render_topo;
......@@ -64,4 +63,5 @@ public:
void cb_initGL() ;
void cb_redraw() ;
void cb_keyPress(int c);
};
......@@ -32,44 +32,62 @@ SimpleMap3::SimpleMap3()
{
position = myMap.addAttribute<VEC3, VERTEX>("position");
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap, position);
Dart d = primCat.hexaGrid_topo(2,1,1);
primCat.embedHexaGrid(1,1,1);
myMap.closeMap();
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(1,1,1);
primCat.embedHexaGrid(1,1,1);
myMap.closeMap();
myMap.check();
unsigned int nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap);
std::cout << "Nb vertices (equals 12) : " << nb << std::endl;
assert(nb==12);
position[dp] = typename PFP::VEC3(0.5,0.5,-0.5);
position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5);
position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5);
position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5);
position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f);
Dart dtemp = myMap.phi_1(myMap.phi2(myMap.phi_1(myMap.phi_1(myMap.phi2(d)))));
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.sewVolumes(dtemp,dp);
Dart dd = myMap.phi3(d);
// Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap, position);
// Dart d = primCat.hexaGrid_topo(2,1,1);
// primCat.embedHexaGrid(1,1,1);
// myMap.closeMap();
myMap.unsewVolumes(d);
// unsigned int nb=0;
// for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
// nb++;
myMap.check();
// std::cout << "Nb vertices (equals 12) : " << nb << std::endl;
// assert(nb==12);
nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
std::cout << "Nb vertices after unsew (equals 16) : " << nb << std::endl;
assert(nb==16);
// d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.sewVolumes(d,dd);
// Dart dd = myMap.phi3(d);
myMap.check();
// myMap.unsewVolumes(d);
nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
// myMap.check();
std::cout << "Nb vertices after resew (equals 12) : " << nb << std::endl;
assert(nb==12);
// nb=0;
// for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
// nb++;
// std::cout << "Nb vertices after unsew (equals 16) : " << nb << std::endl;
// assert(nb==16);
// myMap.sewVolumes(d,dd);
// myMap.check();
// nb=0;
// for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
// nb++;
// std::cout << "Nb vertices after resew (equals 12) : " << nb << std::endl;
// assert(nb==12);
}
......@@ -92,22 +110,64 @@ void SimpleMap3::cb_initGL()
m_render_topo = new Algo::Render::GL2::Topo3Render();
m_render_topo->setDartWidth(2.0f);
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f,0.9f,0.9f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f,0.9f,0.8f);
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setDartWidth(2.0f);
m_render_topo_boundary->setInitialDartsColor(0.4f,0.8f,0.4f);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_primal = new Algo::Render::GL2::Topo3PrimalRender();
m_render_topo_primal->setDartWidth(2.0f);
m_render_topo_primal->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo_primal->updateData<PFP>(myMap, position, 0.95f,0.85f);
}
void SimpleMap3::cb_keyPress(int code)
{
switch(code)
{
case 'e':
{
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,".%F.%H:%M:%S",timeinfo);
std::string filename = std::string("topo_screenshot") + std::string(buffer) + std::string(".svg");
m_render_topo->svgout2D(filename, modelViewMatrix(), projectionMatrix());
break;
}
case 'E':
{
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,".%F.%H:%M:%S",timeinfo);
std::string filename = std::string("topo_screenshot") + std::string(buffer) + std::string(".svg");
m_render_topo_primal->svgout2D(filename, modelViewMatrix(), projectionMatrix());
break;
}
}
}
void SimpleMap3::cb_redraw()
{
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
m_render_topo->drawTopo();
m_render_topo_boundary->drawTopo();
m_render_topo->drawTopo();
//m_render_topo_boundary->drawTopo();
//m_render_topo_primal->drawTopo();
}
/**********************************************************************************************
......
......@@ -33,6 +33,7 @@
#include "Geometry/vector_gen.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Render/GL2/topo3PrimalRender.h"
#include "Algo/Render/GL2/topoRender.h"
using namespace CGoGN ;
......@@ -58,6 +59,7 @@ public:
Algo::Render::GL2::Topo3Render* m_render_topo;
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Algo::Render::GL2::Topo3PrimalRender* m_render_topo_primal;
SimpleMap3() ;
......@@ -65,5 +67,6 @@ public:
void cb_initGL() ;
void cb_redraw() ;
void cb_keyPress(int code);
};
......@@ -26,6 +26,7 @@
#define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/embeddedMap3.h"
#include "Algo/Multiresolution/filter.h"
namespace CGoGN
{
......@@ -64,6 +65,9 @@ public:
AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ;
public:
ImplicitHierarchicalMap3() ;
......@@ -153,6 +157,19 @@ public:
*/
void swapEdges(Dart d, Dart e);
void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
void analysis() ;
void synthesis() ;
//!
/*!
*
......
......@@ -655,6 +655,36 @@ inline bool ImplicitHierarchicalMap3::isWellEmbedded()
}
void ImplicitHierarchicalMap3::analysis()
{
assert(getCurrentLevel() > 0 || !"analysis : called on level 0") ;
decCurrentLevel() ;
for(unsigned int i = 0; i < analysisFilters.size(); ++i)
(*analysisFilters[i])() ;
}
void ImplicitHierarchicalMap3::synthesis()
{
assert(getCurrentLevel() < getMaxLevel() || !"synthesis : called on max level") ;
for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
(*synthesisFilters[i])() ;
incCurrentLevel() ;
}
/***************************************************
* ATTRIBUTE HANDLER *
***************************************************/
......
......@@ -44,6 +44,13 @@ enum SubdivideType
S_QUAD
} ;
template <typename PFP>
void newLevelHexa(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
/***********************************************************************************
* Subdivision *
***********************************************************************************/
......
......@@ -39,6 +39,339 @@ namespace IHM
{
template <typename PFP>
void newLevelHexa(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
// DartMarkerStore m(map);
// unsigned int max = map.getMaxLevel() ;
// map.setCurrentLevel(max) ;
// for(Dart d = map.begin() ; d != map.end() ; map.next(d))
// {
// if(!map.isBoundaryMarked3(d))
// {
// if(!m.isMarked(d))
// {
// if(map.isDartValid(d) && map.getDartLevel(d) <= max && !map.volumeIsSubdivided(d))
// {
// Dart dres = Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, d, position);
// //Algo::IHM::subdivideLoop<PFP>(map, d, position);
// Traversor3VW<typename PFP::MAP> tew(map, dres);
// for(Dart dit2 = tew.begin(); dit2 != tew.end(); dit2 = tew.next())
// {
// m.markOrbit<VOLUME>(dit2);
// }
// }
// }
// }
// }
unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(map.getMaxLevel()) ;
TraversorE<typename PFP::MAP> travE(map);
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
Dart dd = map.phi2(d) ;
typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ;
map.cutEdge(d) ;
travE.skip(d) ;
travE.skip(map.phi1(d)) ;
unsigned int eId = map.getEdgeId(d) ;
map.setEdgeId(map.phi1(d), eId, EDGE) ; //mise a jour de l'id d'arrete sur chaque moitie d'arete
map.setEdgeId(map.phi1(dd), eId, EDGE) ;
map.setFaceId(EDGE, d) ; //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
map.setFaceId(EDGE, dd) ;
position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
}
TraversorF<typename PFP::MAP> travF(map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
Dart old = d;
if(map.getDartLevel(old) < map.getMaxLevel())
old = map.phi1(old) ;
typename PFP::VEC3 p = position[old] ;
unsigned int count = 1;
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
Dart ne = map.phi2(map.phi_1(dd));
Dart ne2 = map.phi2(ne);
map.cutEdge(ne) ;
travF.skip(dd) ;
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(ne, id, EDGE) ;
id = map.getNewEdgeId() ;
map.setEdgeId(ne2, id, EDGE) ;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
{
p += position[map.phi_1(dd)];
count++;
Dart tmp = map.phi1(ne) ;
Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(map.phi1(ne), dd) ;
travF.skip(tmp) ;
Dart nne = map.phi2(map.phi_1(dd)) ;
id = map.getNewEdgeId() ;
map.setEdgeId(nne, id, EDGE) ;
dd = next ;
}
travF.skip(ne) ;
p += position[map.phi_1(ne)];
count++;
std::cout << "count = " << count << std::endl;
unsigned int idface = map.getFaceId(old);
//Dart e = dd;
do
{
map.setFaceId(dd, idface, DART) ;
map.setFaceId(map.phi2(dd), idface, DART) ;
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
p /= count;
position[map.phi1(ne)] = p ;
}
TraversorW<typename PFP::MAP> traW(map);
for(Dart dit = traW.begin(); dit != traW.end(); dit = traW.next())
{
// DartMarkerStore mf(map); // Lock a face marker to save one dart per face
// DartMarkerStore mv(map);
// typename PFP::VEC3 volCenter;
// unsigned count = 0 ;
// //Store faces that are traversed and start with the face of d
// std::vector<Dart> visitedFaces;
// visitedFaces.reserve(200);
// visitedFaces.push_back(old);
// //Store the edges before the cutEdge
// std::vector<Dart> oldEdges;
// oldEdges.reserve(20);
// mf.markOrbit<FACE>(old) ;
// for(unsigned int i = 0; i < visitedFaces.size(); ++i)
// {
// Dart e = visitedFaces[i] ;
// do
// {
// //add one old edge per vertex to the old edge list
// //compute volume centroid
// if(!mv.isMarked(e))
// {
// mv.markOrbit<VERTEX>(e);
// volCenter += position[e];
// ++count;
// oldEdges.push_back(e);
// }
// // add all face neighbours to the table
// Dart ee = map.phi2(e) ;
// if(!mf.isMarked(ee)) // not already marked
// {
// visitedFaces.push_back(ee) ;
// mf.markOrbit<FACE>(ee) ;
// }
// e = map.phi1(e) ;
// } while(e != visitedFaces[i]) ;
// }
// volCenter /= typename PFP::REAL(count) ;
// /*
// * Subdivision
// */
// //Store the darts from quadrangulated faces
// std::vector<std::pair<Dart,Dart> > subdividedfaces;
// subdividedfaces.reserve(25);