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} ) ...@@ -54,6 +54,11 @@ add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries( texturesExampleD target_link_libraries( texturesExampleD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} ) ${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) QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h)
add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} ) add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} )
target_link_libraries( simpleGMap2D target_link_libraries( simpleGMap2D
......
...@@ -26,14 +26,37 @@ ...@@ -26,14 +26,37 @@
#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/subdivision3.h"
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);
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); 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); prim.embedHexaGrid(1,1,1);
Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
...@@ -51,7 +74,7 @@ SimpleGMap3::SimpleGMap3() ...@@ -51,7 +74,7 @@ SimpleGMap3::SimpleGMap3()
position[myMap.phi1(d)] = mid; 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(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);
...@@ -59,6 +82,8 @@ SimpleGMap3::SimpleGMap3() ...@@ -59,6 +82,8 @@ SimpleGMap3::SimpleGMap3()
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d)))); d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.unsewVolumes(d); myMap.unsewVolumes(d);
myMap.check();
} }
void SimpleGMap3::initGUI() void SimpleGMap3::initGUI()
...@@ -84,6 +109,12 @@ void SimpleGMap3::cb_redraw() ...@@ -84,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() ;
......
/******************************************************************************* /*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 * * 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 * * 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 * * under the terms of the GNU Lesser General Public License as published by the *
...@@ -17,151 +17,100 @@ ...@@ -17,151 +17,100 @@
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * 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 * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef __INDEXEDMAP3_H__ #include "simpleMap3.h"
#define __INDEXEDMAP3_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: position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
static const int nbInvolutions=2;
static const int nbEmbeddings=4;
};
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> std::cout << "Nb vertices (equals 12) : " << nb << std::endl;
class IndexedMapd3Topology: public IMAP3 assert(nb==12);
{
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;
/** d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
* Table of face indices
*/
SeqTriangles m_facesTopoIndices;
/** Dart dd = myMap.phi3(d);
* Table of volume indices
*/
SeqTriangles m_volumesTopoIndices;
Data< std::string > filename;
public: myMap.unsewVolumes(d);
const unsigned BAD_INDEX = 0xffffffff;
/** myMap.check();
* Embedding methods
*/
IndexT getVertexIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(0));
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
IndexT getEdgeIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(1)); nb=0;
if (ie != NULL) return ie->getVal(); for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
return BAD_INDEX;} nb++;
IndexT getFaceIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(2)); std::cout << "Nb vertices after unsew (equals 16) : " << nb << std::endl;
if (ie != NULL) return ie->getVal(); assert(nb==16);
return BAD_INDEX;}
IndexT getVolumeIndex(Dart d) { IndexEmb* ie = reinterpret_cast<IndexEmb*>(d->getEmb(3)); myMap.sewVolumes(d,dd);
if (ie != NULL) return ie->getVal();
return BAD_INDEX;}
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 SimpleMap3::initGUI()
{
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 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 int main(int argc, char **argv)
IndexedMapd3Topology(); {
QApplication app(argc, argv) ;
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)
virtual bool hasPos() const; SimpleMap3 sqt ;
virtual double getPX(int i) const; sqt.setGeometry(0, 0, 1000, 800) ;
virtual double getPY(int i) const; sqt.show() ;
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);
}
};
sqt.initGUI() ;
return app.exec() ;
}
#endif
/******************************************************************************* /*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 * * 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 * * 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 * * under the terms of the GNU Lesser General Public License as published by the *
...@@ -17,96 +17,48 @@ ...@@ -17,96 +17,48 @@
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * 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 * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef __EMBEDDED_MAP3_H__ #include <iostream>
#define __EMBEDDED_MAP3_H__
#include "Topology/generic/genericmap.h" #include "Utils/qtSimple.h"
namespace CGoGN #include "Topology/generic/parameters.h"
{ #include "Topology/map/embeddedMap3.h"
/**
* 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 "Geometry/vector_gen.h"
/*!
*
*/
virtual bool mergeVolumes(Dart d);
//! Split a face inserting an edge between two vertices #include "Algo/Render/GL1/topo_render.h"
/*! \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);
//! Cut the edge of d using namespace CGoGN ;
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
//! struct PFP: public PFP_STANDARD
/*! {
* // definition of the map
*/ typedef EmbeddedMap3 MAP ;
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);
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) ...@@ -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 << "CGoGNOut dans la console" << Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
CGoGNout.toStatusBar(NULL); CGoGNout.toStatusBar(NULL);
CGoGNout << "tirelipinpon .." << CGoGNendl;
CGoGNout << "ah aha ah" << CGoGNendl;
// bounding box // bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP__ #ifndef __IMPLICIT_HIERARCHICAL_MAP__
#define __IMPLICIT_HIERARCHICAL_MAP__ #define __IMPLICIT_HIERARCHICAL_MAP__
#include "Topology/map/map2.h" #include "Topology/map/embeddedMap2.h"
#include "Topology/generic/embeddedMap2.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -39,7 +38,7 @@ namespace IHM ...@@ -39,7 +38,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ; template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap : public EmbeddedMap2<Map2> class ImplicitHierarchicalMap : public EmbeddedMap2
{ {
template<typename T> friend class AttributeHandler_IHM ; template<typename T> friend class AttributeHandler_IHM ;
......
...@@ -253,7 +253,7 @@ inline bool ImplicitHierarchicalMap::foreach_dart_of_cc(Dart d, FunctorType& f, ...@@ -253,7 +253,7 @@ inline bool ImplicitHierarchicalMap::foreach_dart_of_cc(Dart d, FunctorType& f,
inline void ImplicitHierarchicalMap::splitFace(Dart d, Dart e) inline void ImplicitHierarchicalMap::splitFace(Dart d, Dart e)
{ {
EmbeddedMap2<Map2>::splitFace(d, e) ; EmbeddedMap2::splitFace(d, e) ;
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(FACE))
{ {
unsigned int cur = m_curLevel ; unsigned int cur = m_curLevel ;
......
...@@ -25,9 +25,7 @@ ...@@ -25,9 +25,7 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP3__ #ifndef __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__ #define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/map3.h" #include "Topology/map/embeddedMap3.h"
#include "Topology/generic/embeddedMap3.h"
#include "Container/attributeContainer.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -40,7 +38,7 @@ namespace IHM ...@@ -40,7 +38,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ; template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3> class ImplicitHierarchicalMap3 : public EmbeddedMap3
{ {
template<typename T> friend class AttributeHandler_IHM ; template<typename T