Commit f551d7fc authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:/home/cgogn/CGoGN

parents e9501a68 20f4b60f
......@@ -54,6 +54,11 @@ add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries( texturesExampleD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleMap3_moc ../simpleMap3.h)
add_executable( simpleMap3D ../simpleMap3.cpp ${simpleMap3_moc} )
target_link_libraries( simpleMap3D
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h)
add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} )
target_link_libraries( simpleGMap2D
......
......@@ -26,14 +26,37 @@
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/subdivision3.h"
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);
primCat.embedHexaGrid(1,1,1);
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);
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);
Dart d = prim.hexaGrid_topo(2,2,1);
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)))));
......@@ -51,7 +74,7 @@ SimpleGMap3::SimpleGMap3()
position[myMap.phi1(d)] = mid;
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
position[i] += VEC3(0,2,0);
Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position);
d = prim2.hexaGrid_topo(2,1,1);
......@@ -59,6 +82,8 @@ SimpleGMap3::SimpleGMap3()
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.unsewVolumes(d);
myMap.check();
}
void SimpleGMap3::initGUI()
......@@ -84,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() ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
......@@ -17,151 +17,100 @@
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __INDEXEDMAP3_H__
#define __INDEXEDMAP3_H__
#include "simpleMap3.h"
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/subdivision3.h"
#include "Topology/map/map3.h"
#include "indexEmb.h"
class DP_IndMap3 : public DefaultDartParameters
SimpleMap3::SimpleMap3()
{
public:
static const int nbInvolutions=2;
static const int nbEmbeddings=4;
};
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
typedef tMap3< DartObjDualMap<DP_IndMap3> > IMAP3;
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(2,1,1);
primCat.embedHexaGrid(1,1,1);
unsigned int nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
template<typename EMBV>
class IndexedMapd3Topology: public IMAP3
{
protected:
/**
* Table of darts per vertex
*/
std::vector<Dart> m_tableVertexDart;
/**
* Table of darts per edge
*/
std::vector<Dart> m_tableEdgeDart;
/**
* Table of darts per face
*/
std::vector<Dart> m_tableFaceDart;
/**
* Table of darts per volume
*/
std::vector<Dart> m_tableVolumeDart;
int nbPoints;
vector< Vector3 > seqPoints;
/**
* Table of edges indices
*/
SeqEdges m_edgesTopoIndices;
std::cout << "Nb vertices (equals 12) : " << nb << std::endl;
assert(nb==12);
/**
* Table of face indices
*/
SeqTriangles m_facesTopoIndices;
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
/**
* Table of volume indices
*/
SeqTriangles m_volumesTopoIndices;
Data< std::string > filename;
Dart dd = myMap.phi3(d);
public:
const unsigned BAD_INDEX = 0xffffffff;
myMap.unsewVolumes(d);
/**
* Embedding methods
*/
IndexT getVertexIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(0));
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
myMap.check();
IndexT getEdgeIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(1));
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
IndexT getFaceIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(2));
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
std::cout << "Nb vertices after unsew (equals 16) : " << nb << std::endl;
assert(nb==16);
IndexT getVolumeIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(3));
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
myMap.sewVolumes(d,dd);
myMap.check();
void setVertexEmb(Dart d, IndexEmb* e) { embedOrbit(0,d,0,e);}
nb=0;
for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
nb++;
void setEdgeEmb(Dart d, IndexEmb* e) { embedOrbit(1,d,1,e);}
std::cout << "Nb vertices after resew (equals 12) : " << nb << std::endl;
assert(nb==12);
}
void setFaceEmb(Dart d, IndexEmb* e) { embedOrbit(2,d,2,e);}
void setVolumeEmb(Dart d, IndexEmb* e) { embedOrbit(3,d,3,e);}
void setVertexIndex(Dart d, IndexT i ) {IndexEmb* e = IndexEmb::create(i); embedOrbit(0,d,0,e);}
void SimpleMap3::initGUI()
{
void setEdgeIndex(Dart d, IndexT i) {IndexEmb* e = IndexEmb::create(i); embedOrbit(1,d,1,e);}
}
void setFaceIndex(Dart d, IndexT i) {IndexEmb* e = IndexEmb::create(i); embedOrbit(2,d,2,e);}
void SimpleMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(1) ;
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());
}
void SimpleMap3::cb_redraw()
{
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
Algo::Render::GL1::renderTopoMD3<PFP>(myMap, position, true, true, true, 0.9f, 0.9f, 0.9f);
}
void setVolumeIndex(Dart d, IndexT i) {IndexEmb* e = IndexEmb::create(i); embedOrbit(3,d,3,e);}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
// constructor
IndexedMapd3Topology();
virtual void clear();
virtual bool load(const char* filename);
virtual int getNbPoints() const;
// Complete sequence accessors
virtual const SeqEdges& getEdges();
virtual const SeqTriangles& getTriangles();
virtual const SeqQuads& getQuads();
virtual const SeqTetras& getTetras();
virtual const SeqHexas& getHexas();
// Points accessors (not always available)
int main(int argc, char **argv)
{
QApplication app(argc, argv) ;
virtual bool hasPos() const;
virtual double getPX(int i) const;
virtual double getPY(int i) const;
virtual double getPZ(int i) const;
virtual std::string getFilename() const{return filename.getValue();}
void parse(core::objectmodel::BaseObjectDescription* arg)
{
if (arg->getAttribute("filename")) {
filename.setValue( arg->getAttribute("filename") );
this->load(arg->getAttribute("filename"));
}
arg->removeAttribute("filename");
this->core::componentmodel::topology::Topology::parse(arg);
}
};
SimpleMap3 sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
sqt.initGUI() ;
return app.exec() ;
}
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
......@@ -17,96 +17,48 @@
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __EMBEDDED_MAP3_H__
#define __EMBEDDED_MAP3_H__
#include <iostream>
#include "Topology/generic/genericmap.h"
#include "Utils/qtSimple.h"
namespace CGoGN
{
/**
* Class of 3-dimensional maps
* with lazily managed embeddings
*/
template <typename MAP3>
class EmbeddedMap3 : public MAP3
{
public:
typedef MAP3 TOPO_MAP;
//!
/*!
*
*/
virtual void sewVolumes(Dart d, Dart e);
//!
/*!
*
*/
virtual void unsewVolumes(Dart d);
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap3.h"
//!
/*!
*
*/
virtual bool mergeVolumes(Dart d);
#include "Geometry/vector_gen.h"
//! Split a face inserting an edge between two vertices
/*! \pre Dart d and e should belong to the same face and be distinct
* @param d dart of first vertex
* @param e dart of second vertex
* @return the dart of the new edge lying in the vertex of d after the cut
*/
virtual void splitFace(Dart d, Dart e);
#include "Algo/Render/GL1/topo_render.h"
//! Cut the edge of d
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
using namespace CGoGN ;
//!
/*!
*
*/
virtual Dart cutSpike(Dart d);
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
* faces are build (faces with less than 3 edges). If it occurs the faces
* are deleted and the adjacencies are updated (see deleteIfDegenerated).
* \warning This may produce two distinct vertices if the edge
* was the only link between two border faces
* @param d a dart in the deleted edge
* @param delDegenerateFaces a boolean (default to true)
*/
virtual int collapseEdge(Dart d, bool delDegenerateFaces = true,
bool delDegenerateVolumes = true);
//!
/*!
*
*/
virtual void collapseFace(Dart d, bool delDegenerateFaces = true,
bool delDegenerateVolumes = true);
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap3 MAP ;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
virtual unsigned int closeHole(Dart d);
class SimpleMap3 : public Utils::QT::SimpleQT
{
Q_OBJECT
virtual void closeMap(DartMarker &marker);
public:
MAP myMap ;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
virtual bool check();
} ;
SimpleMap3() ;
} // namespace CGoGN
void initGUI() ;
#include "embeddedMap3.hpp"
void cb_initGL() ;
void cb_redraw() ;
};
#endif
......@@ -313,8 +313,6 @@ int main(int argc, char **argv)
CGoGNout << "CGoGNOut dans la console" << Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
CGoGNout.toStatusBar(NULL);
CGoGNout << "tirelipinpon .." << CGoGNendl;
CGoGNout << "ah aha ah" << CGoGNendl;
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -25,8 +25,7 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP__
#define __IMPLICIT_HIERARCHICAL_MAP__
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Topology/map/embeddedMap2.h"
namespace CGoGN
{
......@@ -39,7 +38,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap : public EmbeddedMap2<Map2>
class ImplicitHierarchicalMap : public EmbeddedMap2
{
template<typename T> friend class AttributeHandler_IHM ;
......
......@@ -253,7 +253,7 @@ inline bool ImplicitHierarchicalMap::foreach_dart_of_cc(Dart d, FunctorType& f,
inline void ImplicitHierarchicalMap::splitFace(Dart d, Dart e)
{
EmbeddedMap2<Map2>::splitFace(d, e) ;
EmbeddedMap2::splitFace(d, e) ;
if(isOrbitEmbedded(FACE))
{
unsigned int cur = m_curLevel ;
......
......@@ -25,9 +25,7 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/map3.h"
#include "Topology/generic/embeddedMap3.h"
#include "Container/attributeContainer.h"
#include "Topology/map/embeddedMap3.h"
namespace CGoGN
{
......@@ -40,7 +38,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3>
class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
template<typename T> friend class AttributeHandler_IHM ;
......
......@@ -297,354 +297,354 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos
std::vector<Dart> newEdges; //save darts from inner edges
newEdges.reserve(50);
// //Second step : deconnect each corner, close each hole, subdivide each new face into 3
// for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
// {
// //std::vector<Dart>::iterator edge = oldEdges.begin();
// Dart e = *edge;
//
// Dart f1 = map.phi1(*edge);
// //Dart f2 = map.phi2(f1);
//
// do
// {
// if(map.phi1(map.phi1(map.phi1(e))) != e)
// {
// map.unsewFaces(map.phi1(map.phi1(e))); //remplacer par une boucle qui découd toute la face et non juste une face carre (jusqu'a phi_1(e))
// }
//
// map.unsewFaces(map.phi1(e));
//
//
// e = map.phi2(map.phi_1(e));
// }
// while(e != *edge);
//
// map.closeHole(f1);
//
// //degree du sommet exterieur
// unsigned int cornerDegree = map.Map2::vertexDegree(*edge);
//
// //tourner autour du sommet pour connaitre le brin d'un sommet de valence < cornerDegree
// bool found = false;
// Dart stop = e;
// do
// {
//
// if(map.Map2::vertexDegree(map.phi2(map.phi1(e))) < cornerDegree)
// {
// stop = map.phi2(map.phi1(e));
// found = true;
// }
//
// e = map.phi2(map.phi_1(e));
// }
// while(!found && e != *edge);
//
// //si il existe un sommet de degre inferieur au degree du coin
// if(found)
// {
// //chercher le brin de faible degree suivant
// bool found2 = false;
// Dart dd = map.phi1(stop);
//
// do
// {
// if(map.Map2::vertexDegree(dd) < cornerDegree)
// found2 = true;
// else
// dd = map.phi1(dd);
// }
// while(!found2);
//
// //cas de la pyramide
// if(dd == stop)
// {
// //std::cout << "pyramide" << std::endl;
// map.splitFace(dd, map.phi1(map.phi1(dd)));
// }
// else
// {
// map.splitFace(dd, stop);
//
// //calcul de la taille des faces de chaque cote de stop
// if(!( (map.Map2::faceDegree(map.phi_1(stop)) == 3 && map.Map2::faceDegree(map.phi2(map.phi_1(stop))) == 4) ||
// (map.Map2::faceDegree(map.phi_1(stop)) == 4 && map.Map2::faceDegree(map.phi2(map.phi_1(stop))) == 3) ))
// {
// //std::cout << "octaedre ou hexaedre" << std::endl;
//
// Dart ne = map.phi_1(stop) ;
// map.cutEdge(ne);
// position[map.phi1(ne)] = volCenter;
// stop = map.phi2(map.phi1(ne));
//
// bool finished = false;
// Dart it = map.phi2(ne);
//
// do
// {
// //chercher le brin de faible degree suivant
// bool found2 = false;
// Dart dd = map.phi1(it);
//
// do
// {
// if(dd == stop)
// finished = true;
// else if(map.Map2::vertexDegree(dd) < cornerDegree)
// found2 = true;
// else
// dd = map.phi1(dd);
// }
// while(!found2 & !finished);