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 ;
......
......@@ -120,262 +120,6 @@ template <typename PFP>
void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, const FunctorSelect& selected = SelectorTrue()) ;
/*
* volume subdivision scheme
*/
template <typename PFP, typename EMBV, typename EMB>
void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs);
template <typename PFP>
void splitVolumes(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
// TODO a mettre ailleurs ?
//
///**
// * create a tetra based on the two triangles that have a common dart and phi2(dart)
// * return a new dart inside the tetra
// */
//template<typename PFP>
//Dart extractTetra(typename PFP::MAP& the_map, Dart d)
//{
//
//
// Dart e = the_map.phi2(d);
//
// //create the new faces
// Dart dd = the_map.newFace(3);
// Dart ee = the_map.newFace(3);
//
// //update their sew
// the_map.sewFaces(dd,ee);
// the_map.sewFaces(the_map.phi3(dd),the_map.phi3(ee));
//
// //add the two new faces in the mesh to obtain a tetra
// Dart s2d = the_map.phi2(the_map.phi_1(d));
// the_map.unsewFaces(the_map.phi_1(d));
// the_map.sewFaces(the_map.phi_1(d),the_map.phi_1(dd));
// the_map.sewFaces(s2d,the_map.phi3(the_map.phi_1(dd)));
//
// Dart s2e = the_map.phi2(the_map.phi_1(e));
// the_map.unsewFaces(the_map.phi_1(e));
// the_map.sewFaces(the_map.phi_1(e),the_map.phi_1(ee));
// the_map.sewFaces(s2e,the_map.phi3(the_map.phi_1(ee)));
//
// Dart ss2d = the_map.phi2(the_map.phi1(d));
// the_map.unsewFaces(the_map.phi1(d));
// the_map.sewFaces(the_map.phi1(d),the_map.phi1(ee));
// the_map.sewFaces(ss2d,the_map.phi3(the_map.phi1(ee)));
//
// Dart ss2e = the_map.phi2(the_map.phi1(e));
// the_map.unsewFaces(the_map.phi1(e));
// the_map.sewFaces(the_map.phi1(e),the_map.phi1(dd));
// the_map.sewFaces(ss2e,the_map.phi3(the_map.phi1(dd)));
//
//
//
// //embed the coords
// the_map.setVertexEmb(d,the_map.getVertexEmb(d));
// the_map.setVertexEmb(e,the_map.getVertexEmb(e));
// the_map.setVertexEmb(the_map.phi_1(d),the_map.getVertexEmb(the_map.phi_1(d)));
// the_map.setVertexEmb(the_map.phi_1(e),the_map.getVertexEmb(the_map.phi_1(e)));
//
// return dd;
//}
//
///**
// * tetrahedrization of the volume
// * @param the map
// * @param a dart of the volume
// * @param true if the faces are in CCW order
// * @return success of the tetrahedrization
// */
//template<typename PFP>
//bool smartVolumeTetrahedrization(typename PFP::MAP& the_map, Dart d, bool CCW=true)
//{
//
// typedef typename PFP::EMB EMB;
//
// bool ret=true;
//
// if (!the_map.isTetrahedron(d))
// {
// //only works on a 3-map
// assert(Dart::nbInvolutions()>=2 || "cannot be applied on this map, nbInvolutions must be at least 2");
//
// if (Geometry::isConvex<PFP>(the_map,d,CCW))
// {
// the_map.tetrahedrizeVolume(d);
// }
// else
// {
//
// //get all the dart of the volume
// std::vector<Dart> vStore;
// FunctorStore fs(vStore);
// the_map.foreach_dart_of_volume(d,fs);
//
// if (vStore.size()==0)
// {
// if (the_map.phi1(d)==d)
// CGoGNout << "plop" << CGoGNendl;
// if (the_map.phi2(d)==d)
// CGoGNout << "plip" << CGoGNendl;
//
// CGoGNout << the_map.getVertexEmb(d)->getPosition() << CGoGNendl;
// CGoGNout << "tiens tiens, c'est etrange" << CGoGNendl;
// }
// //prepare the list of embeddings of the current volume
// std::vector<EMB *> lstEmb;
//
// //get a marker
// DartMarker m(the_map);
//
// //all the darts from a vertex that can generate a tetra (3 adjacent faces)
// std::vector<Dart> allowTetra;
//
// //all the darts that are not in otherTetra
// std::vector<Dart> otherTetra;
//
// //for each dart of the volume
// for (typename std::vector<Dart>::iterator it = vStore.begin() ; it != vStore.end() ; ++it )
// {
// Dart e = *it;
// //if the vertex is not treated
// if (!m.isMarked(e))
// {
// //store the embedding
// lstEmb.push_back(reinterpret_cast<EMB*>(the_map.getVertexEmb(e)));
// Dart ee=e;
//
// //count the number of adjacent faces and mark the darts
// int nbe=0;
// do
// {
// nbe++;
// m.markOrbit(DART,e);
// ee=the_map.phi1(the_map.phi2(ee));
// }
// while (ee!=e);
//
// //if 3 adjacents faces, we can create a tetra on this vertex
// if (nbe==3)
// allowTetra.push_back(e);
// else
// otherTetra.push_back(e);
// }
// }
//
// //we haven't created a tetra yet
// bool decoupe=false;
//
// //if we have vertex that can be base
// if (allowTetra.size()!=0)
// {
// //foreach possible vertex while we haven't done any cut
// for (typename std::vector<Dart>::iterator it=allowTetra.begin();it!=allowTetra.end() && !decoupe ;++it)
// {
// //get the dart
// Dart s=*it;
// //store the emb
// std::vector<EMB*> lstCurEmb;
// lstCurEmb.push_back(reinterpret_cast<EMB*>(the_map.getVertexEmb(s)));
// lstCurEmb.push_back(reinterpret_cast<EMB*>(the_map.getVertexEmb(the_map.phi1(s))));
// lstCurEmb.push_back(reinterpret_cast<EMB*>(the_map.getVertexEmb(the_map.phi_1(s))));
// lstCurEmb.push_back(reinterpret_cast<EMB*>(the_map.getVertexEmb(the_map.phi_1(the_map.phi2(s)))));
//
// //store the coords of the point
// gmtl::Vec3f points[4];
// for (int i=0;i<4;++i)
// {
// points[i] = lstCurEmb[i]->getPosition();
// }
//
// //test if the future tetra is well oriented (concave case)
// if (Geometry::isTetrahedronWellOriented(points,CCW))
// {
// //test if we haven't any point inside the future tetra
// bool isEmpty=true;
// for (typename std::vector<EMB *>::iterator iter = lstEmb.begin() ; iter != lstEmb.end() && isEmpty ; ++iter)
// {
// //we don't test the vertex that composes the new tetra
// if (std::find(lstCurEmb.begin(),lstCurEmb.end(),*iter)==lstCurEmb.end())
// {
// isEmpty = !Geometry::isPointInTetrahedron(points, (*iter)->getPosition(), CCW);
// }
// }
//
// //if no point inside the new tetra
// if (isEmpty)
// {
// //cut the spike to make a tet