Commit a503cc8c authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'no_boundary'

Conflicts:
	Apps/Tuto/tp_master.cpp
	include/Algo/Export/exportPov.h
	include/Algo/Geometry/normal.h
	include/Topology/generic/embeddedMap2.h
	include/Topology/generic/embeddedMap2.hpp
	include/Topology/map/map2.h
	include/Topology/map/map2.hpp
	include/Topology/map/map3.h
	src/Topology/gmap/gmap2.cpp
	src/Topology/map/map2.cpp
	src/Topology/map/map3.cpp
parents 3d3eff3d e017aa7e
......@@ -213,7 +213,6 @@ void MyQT::cb_keyPress(int code)
Algo::Modelisation::EarTriangulation<PFP> triangulation(myMap);
triangulation.triangule();
SelectorTrue allDarts;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
updateGL();
......@@ -439,7 +438,6 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
......
......@@ -81,7 +81,6 @@ public:
//Manip Carte
MAP myMap ;
SelectorTrue allDarts ;
TVEC3 position;
Dart dglobal;
......
......@@ -55,7 +55,6 @@ struct PFP: public PFP_STANDARD
};
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
PFP::TREAL scalar;
Dart dglobal;
......
......@@ -155,7 +155,6 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
......
......@@ -56,7 +56,6 @@ struct PFP: public PFP_STANDARD
typedef PFP::MAP MAP;
MAP myMap ;
SelectorTrue allDarts ;
class MyGlutWin : public Utils::GlutWin_ATB
{
......
......@@ -154,7 +154,6 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
......
......@@ -140,8 +140,6 @@ void myGlutWin::init()
void myGlutWin::updateRender()
{
SelectorTrue allDarts;
// create the renderer (first call only)
if (m_render == NULL)
m_render = new Algo::Render::GL2::MapRender_VBO() ;
......
......@@ -50,7 +50,6 @@ class SimpleGMap2 : public Utils::QT::SimpleQT
public:
MAP myMap ;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
......
......@@ -51,7 +51,6 @@ class SimpleGMap3 : public Utils::QT::SimpleQT
public:
MAP myMap ;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
......
......@@ -55,7 +55,6 @@ struct PFP: public PFP_STANDARD
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
Dart dglobal;
......
......@@ -119,10 +119,6 @@ int main(int argc, char **argv)
// declaration of the map
PFP::MAP myMap;
// this selector is going to select all the darts
SelectorTrue allDarts;
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, argv[1], attrNames))
{
......
......@@ -63,7 +63,6 @@ protected:
public:
MAP myMap ;
SelectorTrue allDarts ;
// render
Algo::Render::GL2::MapRender* m_render;
......
......@@ -144,9 +144,6 @@ int main(int argc, char **argv)
// declaration of the map
PFP::MAP myMap;
// this selector is going to select all the darts
SelectorTrue allDarts;
// creation of a new attribute on vertices of type 3D vector
// a handler to this attribute is returned
AttributeHandler<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
......
......@@ -173,6 +173,13 @@ void Viewer::cb_Open()
updateGL() ;
}
void Viewer::cb_Save()
{
std::string filters("off (*.off)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
}
void Viewer::importMesh(std::string& filename)
{
myMap.clear(true) ;
......@@ -187,7 +194,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES, false) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -35,6 +35,7 @@
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
......@@ -63,7 +64,6 @@ class Viewer : public Utils::QT::SimpleQT
public:
MAP myMap ;
SelectorTrue allDarts ;
Utils::QT::uiDockInterface dock ;
......@@ -110,6 +110,7 @@ public:
void cb_initGL() ;
void cb_redraw() ;
void cb_Open() ;
void cb_Save() ;
void importMesh(std::string& filename) ;
......
......@@ -48,7 +48,6 @@ struct PFP: public PFP_STANDARD
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
......
......@@ -57,10 +57,16 @@ struct PFP: public PFP_STANDARD
typedef Map2TP MAP;
};
// fonction qui renvoit vrai (pour sélectioner tous les brins)
SelectorTrue allDarts;
/// definition de la carte en global, plus facile
PFP::MAP myMap;
// handler d'attribut de position par sommet
AttributeHandler<PFP::VEC3> position;
// handler d'attribut de normale par sommet
AttributeHandler<PFP::VEC3> normal;
// typedef pour le plongement des sommets
/// encore 1 typedef pour simplifier l'ecriture du code
typedef PFP::VEC3 Point3D;
// Variables pour la gestion des plongements
......@@ -625,7 +631,20 @@ int main(int argc, char **argv)
Point3D lPosObj = (bb.min() + bb.max()) / 2;
sqt.setParamObject(lWidthObj,lPosObj.data());
// show pour optenir le contexte GL
// show 1 pour optenir le contexte GL
sqt.show();
// update du VBO position (contexte GL necessaire)
sqt.m_positionVBO->updateData(position);
sqt.m_normalVBO->updateData(normal);
// update des primitives du renderer
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
sqt.m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f);
// show final pour premier redraw
sqt.show();
// et on attend la fin.
......
......@@ -88,6 +88,14 @@ void MyQT::cb_redraw()
m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
m_render->draw(m_shader, Algo::Render::GL2::LINES);
m_shader->setColor(Geom::Vec4f(0.,1.,1.,0.));
m_render->draw(m_shader, Algo::Render::GL2::BOUNDARY);
glPointSize(7.0f);
m_shader->setColor(Geom::Vec4f(1.,1.,1.,0.));
m_render->draw(m_shader, Algo::Render::GL2::POINTS);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
......@@ -118,6 +126,8 @@ void MyQT::cb_keyPress(int code)
}
}
int main(int argc, char **argv)
{
......@@ -168,9 +178,20 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
SelectorEdgeNoBoundary<PFP::MAP> insideEdges(myMap);// just to draw only inside edges
DartMarker dm(myMap);
dm.markOrbit(VERTEX,d2);
dm.markOrbit(VERTEX,d1);
CellMarker cm(myMap,FACE);
cm.mark(d2);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, insideEdges, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::BOUNDARY); // special primitive for boundary edges
// example of using boolean operator on Selectors
sqt.m_render->initPrimitives<PFP>(myMap, ( SelectorFalse() || ( SelectorTrue() && (SelectorMarked(dm) && SelectorCellMarked(cm)))) , Algo::Render::GL2::POINTS); // special primitive for boundary edges
// show final pour premier redraw
sqt.show();
......
......@@ -46,8 +46,6 @@ struct PFP: public PFP_STANDARD
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
AttributeHandler<Geom::Vec4f> color ;
......@@ -251,7 +249,6 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
......
......@@ -103,7 +103,6 @@ void MyQT::cb_keyPress(int code)
int main(int argc, char **argv)
{
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
......
......@@ -51,7 +51,6 @@ struct PFP: public PFP_STANDARD
};
PFP::MAP myMap;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
......@@ -218,7 +217,6 @@ int main(int argc, char **argv)
sqt.m_positionVBO->updateData(position);
// update des primitives du renderer
SelectorTrue allDarts;
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
......
......@@ -60,7 +60,6 @@ struct PFP: public PFP_STANDARD
};
PFP::MAP myMap;
SelectorTrue allDarts;
PFP::TVEC3 position ;
Dart dglobal;
......@@ -185,8 +184,6 @@ void MyQT::cb_initGL()
registerShader(m_sprite);
registerShader(m_lines);
SelectorTrue allDarts;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
......
......@@ -58,8 +58,6 @@ struct PFP: public PFP_STANDARD
// declaration of the map
PFP::MAP myMap;
// this selector is going to select all the darts
SelectorTrue allDarts;
// attribute handlers
AttributeHandler<PFP::VEC3> position;
......
......@@ -99,10 +99,9 @@ void MyQT::cb_initGL()
colorVBO->releasePtr();
// update the renderer (primitives and geometry)
SelectorTrue allDarts;
m_render->initPrimitives<PFP>(myMap, allDarts,Algo::Render::GL2::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts,Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts,Algo::Render::GL2::POINTS);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
shader1 = new Utils::ShaderPhong();
shader1->setAttributePosition(positionVBO);
......
......@@ -46,7 +46,7 @@ void decimate(
ApproximatorType a,
typename PFP::TVEC3& position,
unsigned int nbWantedVertices,
const FunctorSelect& selected = SelectorTrue()
const FunctorSelect& selected = allDarts
) ;
} //namespace Decimation
......
......@@ -67,7 +67,7 @@ private:
void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
public:
HalfEdgeSelector_QEMml(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
HalfEdgeSelector_QEMml(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select)
{
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo>(DART, "halfEdgeInfo") ;
......@@ -124,7 +124,7 @@ private:
void recomputeQuadric(const Dart d, const bool recomputeNeighbors) ;
public:
HalfEdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
HalfEdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<MATRIX33>(VERTEX, "frame") ;
......@@ -188,7 +188,7 @@ private:
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<FRAME>(VERTEX, "frame") ;
......
......@@ -23,7 +23,7 @@ void decimate(
typename PFP::TVEC3& position,
double nbWanted
);
// const FunctorSelect& selected = SelectorTrue()
// const FunctorSelect& selected = allDarts
//) ;
} //namespace DecimationVolumique
......
......@@ -43,7 +43,7 @@ namespace Export
* @return true
*/
template <typename PFP>
bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a OFF file
......@@ -52,7 +52,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
* @return true
*/
template <typename PFP>
bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a Trian file
......@@ -61,7 +61,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
* @return true
*/
template <typename PFP>
bool exportTrian(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, char* filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a Trian file
......@@ -70,7 +70,7 @@ bool exportTrian(typename PFP::MAP& the_map, const typename PFP::TVEC3& position
* @return true
*/
template <typename PFP>
bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good = SelectorTrue()) ;
bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format).
......@@ -85,7 +85,7 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
* @return true
*/
template <typename PFP>
bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue()) ;
bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format)
......
......@@ -24,6 +24,8 @@
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/cellmarker.h"
#include "openctm.h"
......@@ -60,30 +62,27 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
DartMarker markF(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
markF.markOrbit(FACE, d) ;
std::vector<unsigned int> fidx ;
fidx.reserve(4) ;
Dart dd = d ;
do
++degree ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ;
if(!markV.isMarked(it))
{
unsigned int vNum = map.getEmbedding(VERTEX, dd) ;
if(!markV.isMarked(dd))
{
markV.mark(dd) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
dd = map.phi1(dd) ;
} while(dd != d) ;
facesSize.push_back(map.faceDegree(d)) ;
facesIdx.push_back(fidx) ;
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
}
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
out << "ply" << std::endl ;
......@@ -138,30 +137,27 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
DartMarker markF(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
markF.markOrbit(FACE, d) ;
std::vector<unsigned int> fidx ;
fidx.reserve(4) ;
Dart dd = d ;
do
++degree ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ;
if(!markV.isMarked(it))
{
unsigned int vNum = map.getEmbedding(VERTEX, dd) ;
if(!markV.isMarked(dd))
{
markV.mark(dd) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
dd = map.phi1(dd) ;
} while(dd != d) ;
facesSize.push_back(map.faceDegree(d)) ;
facesIdx.push_back(fidx) ;
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
}
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
out << "OFF" << std::endl ;
......@@ -185,44 +181,38 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
}
template <typename PFP>
bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good)
bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, const std::string& filename, const FunctorSelect& good)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
AutoAttributeHandler<unsigned int> tableVertLab(the_map, VERTEX);
CellMarker markV(the_map,VERTEX);
AutoAttributeHandler<unsigned int> tableVertLab(map, VERTEX);
unsigned int nbDarts = the_map.getNbDarts() ;
unsigned int nbDarts = map.getNbDarts() ;
std::vector<CTMfloat> verticesBuffer;
std::vector<CTMuint> indicesBuffer;
verticesBuffer.reserve(nbDarts/5); // TODO non optimal reservation
indicesBuffer.reserve(nbDarts/3);
DartMarker markF(the_map);
unsigned int lab=0;
for(Dart d = the_map.begin(); d != the_map.end(); the_map.next(d))
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map, good) ;
unsigned int lab = 0;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d) && !markF.isMarked(d))
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
markF.markOrbit(FACE, d) ;
Dart e = d;
do
if (!markV.isMarked</