Commit 39cfb89e authored by untereiner's avatar untereiner

modifs in examples (save/load map...)

parent f548bb67
......@@ -99,9 +99,6 @@ public:
Utils::ShaderSimpleColor* m_shader;
Utils::Drawer* influence_area;
Utils::Drawer* chips_area;
Geom::Vec3f m_coeffTopoExplod;
Geom::Vec3f gPosObj ;
float gWidthObj ;
......
......@@ -35,7 +35,8 @@ Viewer::Viewer() :
m_flatShader(NULL),
m_vectorShader(NULL),
m_simpleColorShader(NULL),
m_pointSprite(NULL)
m_pointSprite(NULL),
m_strings(NULL)
{
normalScaleFactor = 1.0f ;
vertexScaleFactor = 0.1f ;
......@@ -110,15 +111,21 @@ void Viewer::cb_initGL()
m_pointSprite = new Utils::PointSprite() ;
m_pointSprite->setAttributePosition(m_positionVBO) ;
m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f));
storeVerticesInfo();
m_strings->sendToVBO();
registerShader(m_phongShader) ;
registerShader(m_flatShader) ;
registerShader(m_vectorShader) ;
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
registerShader(m_strings);
}
void Viewer::cb_redraw()
{
glClearColor(1,1,1,0);
if(m_drawVertices)
{
float size = vertexScaleFactor ;
......@@ -126,6 +133,7 @@ void Viewer::cb_redraw()
m_pointSprite->predraw(Geom::Vec3f(0.0f, 0.0f, 1.0f)) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
m_pointSprite->postdraw() ;
m_strings->drawAll(Geom::Vec3f(0.0f, 1.0f, 1.0f));
}
if(m_drawEdges)
......@@ -175,9 +183,10 @@ void Viewer::cb_Open()
void Viewer::cb_Save()
{
std::string filters("off (*.off)") ;
std::string filters("off (*.off);; map (*.map)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
exportMesh(filename);
}
void Viewer::importMesh(std::string& filename)
......@@ -220,10 +229,41 @@ void Viewer::importMesh(std::string& filename)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
storeVerticesInfo();
m_strings->sendToVBO();
setParamObject(bb.maxSize(), bb.center().data()) ;
updateGLMatrices() ;
}
void Viewer::exportMesh(std::string& filename)
{
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if (extension == std::string(".map"))
myMap.saveMapBin(filename);
else
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
}
void Viewer::storeVerticesInfo()
{
CellMarker mv(myMap,VERTEX);
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (!mv.isMarked(d))
{
mv.mark(d);
std::stringstream ss;
ss << d << " : "<< position[d];
m_strings->addString(ss.str(),position[d]);
}
}
}
void Viewer::slot_drawVertices(bool b)
{
m_drawVertices = b ;
......@@ -233,6 +273,7 @@ void Viewer::slot_drawVertices(bool b)
void Viewer::slot_verticesSize(int i)
{
vertexScaleFactor = i / 500.0f ;
m_strings->setScale(0.02f*i);
updateGL() ;
}
......
......@@ -44,6 +44,7 @@
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
......@@ -102,6 +103,7 @@ public:
Utils::ShaderVectorPerVertex* m_vectorShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::PointSprite* m_pointSprite ;
Utils::Strings3D* m_strings;
Viewer() ;
......@@ -113,6 +115,11 @@ public:
void cb_Save() ;
void importMesh(std::string& filename) ;
void exportMesh(std::string& filename);
protected:
void storeVerticesInfo();
public slots:
void slot_drawVertices(bool b) ;
......
......@@ -93,6 +93,7 @@ void MyQT::animate()
// transfoMatrix() = glm::rotate(transfoMatrix(), 0.5f, glm::vec3(0.5773f,0.5773f,0.5773f));
transfoRotate( 0.5f, 0.5773f,0.5773f,0.5773f);
updateGLMatrices();
updateGL();
}
......
......@@ -39,7 +39,7 @@
#include "Geometry/vector_gen.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Algo/Render/GL2/topo3Render.h"
......@@ -47,6 +47,7 @@
#include "Utils/text3d.h"
#include "Utils/pointSprite.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/cgognStream.h"
......
......@@ -514,6 +514,7 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
/***************************************************
* ATTRIBUTE HANDLER *
***************************************************/
......
......@@ -354,8 +354,8 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3&
dd = map.phi1(map.phi1(map.phi1(ne)));
map.splitFace(ne, dd) ;
//unsigned int idface = map.getNewFaceId();
//map.setFaceId(dd,idface, FACE);
unsigned int idface = map.getNewFaceId();
map.setFaceId(dd,idface, FACE);
newEdges.push_back(map.phi1(dd));
......
......@@ -366,9 +366,9 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (nb < m_nbDarts)
if (good(d))
{
if (good(d))
if (nb < m_nbDarts)
{
float r,g,b;
dartToCol(d, r,g,b);
......@@ -382,11 +382,11 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go
nb++;
}
}
else
{
CGoGNerr << "Error buffer too small for color picking (change the good parameter ?)" << CGoGNendl;
d = map.end();
else
{
CGoGNerr << "Error buffer too small for color picking (change the good parameter ?)" << CGoGNendl;
d = map.end();
}
}
}
glUnmapBuffer(GL_ARRAY_BUFFER);
......
......@@ -509,11 +509,10 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d)
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(512);
visitedFaces.push_back(d); // Start with the face of d
std::vector<Dart>::iterator face;
// For every face added to the list
//the oldest dart from a volume is the oldest dart from all faces of this volume
mark.markOrbit(FACE, d) ;
mark.markOrbit(ORIENTED_FACE, d) ;
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
......
......@@ -656,13 +656,13 @@ bool Map3::isBoundaryVolume(Dart d)
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces ;
visitedFaces.reserve(128) ;
visitedFaces.reserve(512) ;
visitedFaces.push_back(d) ;
mark.markOrbit(ORIENTED_FACE, d) ;
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
if (isBoundaryMarked(phi3(visitedFaces[i])))
if(isBoundaryMarked(phi3(visitedFaces[i])))
return true ;
Dart e = visitedFaces[i] ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment