Commit e7e37ad9 authored by untereiner's avatar untereiner

import surface meshes in a 3-map with an extruding step

parent c19f14b8
......@@ -30,7 +30,9 @@ Viewer::Viewer() :
m_drawEdges(false),
m_drawFaces(true),
m_drawNormals(false),
m_drawTopo(false),
m_render(NULL),
m_renderTopo(NULL),
m_phongShader(NULL),
m_flatShader(NULL),
m_vectorShader(NULL),
......@@ -80,6 +82,7 @@ void Viewer::cb_initGL()
setFocal(5.0f) ;
m_render = new Algo::Render::GL2::MapRender() ;
m_renderTopo = new Algo::Render::GL2::TopoRender();
m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ;
......@@ -168,6 +171,9 @@ void Viewer::cb_redraw()
}
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
if(m_drawTopo)
m_renderTopo->drawTopo();
}
void Viewer::cb_Open()
......@@ -189,6 +195,31 @@ void Viewer::cb_Save()
exportMesh(filename);
}
void Viewer::cb_mousePress(int button, int x, int y)
{
if (Shift())
{
std::cout << "shift" << std::endl;
m_renderTopo->updateData<PFP>(myMap, position, 0.9, 0.9, allDarts);
Dart d = m_renderTopo->picking<PFP>(myMap, x, y, allDarts);
if (d != Dart::nil())
{
statusMsg("dart picked");
}
else
{
statusMsg("No dart was picked");
}
}
updateGL();
}
void Viewer::importMesh(std::string& filename)
{
myMap.clear(true) ;
......@@ -217,6 +248,8 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
m_renderTopo->updateData<PFP>(myMap, position, 0.9, 0.9, allDarts);
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
// vertexBaseSize = normalBaseSize /5.0f ;
......
......@@ -38,6 +38,7 @@
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
......@@ -85,6 +86,7 @@ public:
float faceShrinkage ;
int m_renderStyle ;
bool m_drawTopo;
bool m_drawVertices ;
bool m_drawEdges ;
bool m_drawFaces ;
......@@ -94,6 +96,7 @@ public:
PFP::TVEC3 normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRender* m_renderTopo ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO ;
......@@ -114,6 +117,8 @@ public:
void cb_Open() ;
void cb_Save() ;
void cb_mousePress(int button, int x, int y);
void importMesh(std::string& filename) ;
void exportMesh(std::string& filename);
......
......@@ -59,6 +59,11 @@ public:
~ImplicitHierarchicalMap3() ;
//!
/*!
*
*/
void update_topo_shortcuts();
//!
......
......@@ -70,6 +70,9 @@ inline void ImplicitHierarchicalMap3::update_topo_shortcuts()
m_dartLevel = Map3::getAttribute<unsigned int>(DART, "dartLevel") ;
m_faceId = Map3::getAttribute<unsigned int>(DART, "faceId") ;
m_edgeId = Map3::getAttribute<unsigned int>(DART, "edgeId") ;
//AttributeContainer& cont = m_attribs[DART] ;
//m_nextLevelCell = cont.getDataVector<unsigned int>(cont.getAttributeIndex("nextLevelCell")) ;
}
......
......@@ -54,7 +54,7 @@ template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE, bool mergeCloseVertices=false);
/**
* import a volumic mesh
* import a volumetric mesh
*/
//template <typename PFP>
//bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportVolumique::ImportType kind = ImportVolumique::UNKNOWNVOLUME);
......@@ -63,6 +63,9 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
//bool importObjWithTex(typename PFP::MAP& map, const std::string& filename);
//
template <typename PFP>
bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE);
/*
* TODO a transformer en utilisant un MeshTableVolume.
......
......@@ -195,7 +195,7 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, float d
m.mark(d) ; // mark on the fly to unmark on second loop
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
d = map.phi1(d);
d = map.phi_1(d);
}
}
......@@ -549,36 +549,15 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportVolumique::ImportType kind)
bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind)
{
float dist = 5.0f;
MeshTablesSurface<PFP> mts(map);
if(kind == ImportVolumique::OBJ)
{
MeshTablesSurface<PFP> mts(map);
if(!mts.importMesh(filename, attrNames, ImportSurfacique::OBJ))
return false;
//if (mergeCloseVertices)
// mts.mergeCloseVertices();
return importMeshSToV<PFP>(map, mts, dist);
}
else
if(!mts.importMesh(filename, attrNames, kind))
return false;
// else
// {
// MeshTablesVolume<PFP> mtv(map);
//
//
// if(!mtv.importMesh(filename, attrNames, kind))
// return false;
//
// return importMesh<PFP>(map, mtv);
// }
return importMeshSToV<PFP>(map, mts, dist);
}
......
......@@ -475,7 +475,7 @@ bool Map3::mergeVolumes(Dart d)
void Map3::splitVolume(std::vector<Dart>& vd)
{
assert(checkSimpleOrientedPath(vd)) ;
//assert(checkSimpleOrientedPath(vd)) ;
Dart e = vd.front();
Dart e2 = phi2(e);
......
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