Commit e401dc09 authored by Pierre Kraemer's avatar Pierre Kraemer

draw topo in viewer + update feature lines

parent 3288e972
...@@ -30,6 +30,7 @@ Viewer::Viewer() : ...@@ -30,6 +30,7 @@ Viewer::Viewer() :
m_drawEdges(false), m_drawEdges(false),
m_drawFaces(true), m_drawFaces(true),
m_drawNormals(false), m_drawNormals(false),
m_drawTopo(false),
m_render(NULL), m_render(NULL),
m_phongShader(NULL), m_phongShader(NULL),
m_flatShader(NULL), m_flatShader(NULL),
...@@ -68,6 +69,7 @@ void Viewer::initGUI() ...@@ -68,6 +69,7 @@ void Viewer::initGUI()
setCallBack( dock.check_drawEdges, SIGNAL(toggled(bool)), SLOT(slot_drawEdges(bool)) ) ; setCallBack( dock.check_drawEdges, SIGNAL(toggled(bool)), SLOT(slot_drawEdges(bool)) ) ;
setCallBack( dock.check_drawFaces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)) ) ; setCallBack( dock.check_drawFaces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)) ) ;
setCallBack( dock.combo_faceLighting, SIGNAL(currentIndexChanged(int)), SLOT(slot_faceLighting(int)) ) ; setCallBack( dock.combo_faceLighting, SIGNAL(currentIndexChanged(int)), SLOT(slot_faceLighting(int)) ) ;
setCallBack( dock.check_drawTopo, SIGNAL(toggled(bool)), SLOT(slot_drawTopo(bool)) ) ;
setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ; setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ;
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ; setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
} }
...@@ -79,6 +81,9 @@ void Viewer::cb_initGL() ...@@ -79,6 +81,9 @@ void Viewer::cb_initGL()
setFocal(5.0f) ; setFocal(5.0f) ;
m_render = new Algo::Render::GL2::MapRender() ; m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
m_positionVBO = new Utils::VBO() ; m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ;
...@@ -119,7 +124,6 @@ void Viewer::cb_initGL() ...@@ -119,7 +124,6 @@ void Viewer::cb_initGL()
void Viewer::cb_redraw() void Viewer::cb_redraw()
{ {
//glClearColor(1,1,1,0);
if(m_drawVertices) if(m_drawVertices)
{ {
float size = vertexScaleFactor ; float size = vertexScaleFactor ;
...@@ -135,14 +139,6 @@ void Viewer::cb_redraw() ...@@ -135,14 +139,6 @@ void Viewer::cb_redraw()
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ; m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
} }
if(m_drawNormals)
{
float size = normalBaseSize * normalScaleFactor ;
m_vectorShader->setScale(size) ;
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
if(m_drawFaces) if(m_drawFaces)
{ {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ; glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
...@@ -161,6 +157,19 @@ void Viewer::cb_redraw() ...@@ -161,6 +157,19 @@ void Viewer::cb_redraw()
} }
glDisable(GL_POLYGON_OFFSET_FILL) ; glDisable(GL_POLYGON_OFFSET_FILL) ;
} }
if(m_drawTopo)
{
m_topoRender->drawTopo() ;
}
if(m_drawNormals)
{
float size = normalBaseSize * normalScaleFactor ;
m_vectorShader->setScale(size) ;
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
} }
void Viewer::cb_Open() void Viewer::cb_Open()
...@@ -209,6 +218,8 @@ void Viewer::importMesh(std::string& filename) ...@@ -209,6 +218,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::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ; normalBaseSize = bb.diagSize() / 100.0f ;
// vertexBaseSize = normalBaseSize / 5.0f ; // vertexBaseSize = normalBaseSize / 5.0f ;
...@@ -271,6 +282,12 @@ void Viewer::slot_faceLighting(int i) ...@@ -271,6 +282,12 @@ void Viewer::slot_faceLighting(int i)
updateGL() ; updateGL() ;
} }
void Viewer::slot_drawTopo(bool b)
{
m_drawTopo = b ;
updateGL() ;
}
void Viewer::slot_drawNormals(bool b) void Viewer::slot_drawNormals(bool b)
{ {
m_drawNormals = b ; m_drawNormals = b ;
...@@ -280,6 +297,7 @@ void Viewer::slot_drawNormals(bool b) ...@@ -280,6 +297,7 @@ void Viewer::slot_drawNormals(bool b)
void Viewer::slot_normalsSize(int i) void Viewer::slot_normalsSize(int i)
{ {
normalScaleFactor = i / 50.0f ; normalScaleFactor = i / 50.0f ;
m_topoRender->updateData<PFP>(myMap, position, i / 100.0f, i / 100.0f) ;
updateGL() ; updateGL() ;
} }
......
...@@ -90,11 +90,13 @@ public: ...@@ -90,11 +90,13 @@ public:
bool m_drawEdges ; bool m_drawEdges ;
bool m_drawFaces ; bool m_drawFaces ;
bool m_drawNormals ; bool m_drawNormals ;
bool m_drawTopo ;
PFP::TVEC3 position ; PFP::TVEC3 position ;
PFP::TVEC3 normal ; PFP::TVEC3 normal ;
Algo::Render::GL2::MapRender* m_render ; Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ; Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO ; Utils::VBO* m_normalVBO ;
...@@ -123,6 +125,7 @@ public slots: ...@@ -123,6 +125,7 @@ public slots:
void slot_drawEdges(bool b) ; void slot_drawEdges(bool b) ;
void slot_drawFaces(bool b) ; void slot_drawFaces(bool b) ;
void slot_faceLighting(int i) ; void slot_faceLighting(int i) ;
void slot_drawTopo(bool b) ;
void slot_drawNormals(bool b) ; void slot_drawNormals(bool b) ;
void slot_normalsSize(int i) ; void slot_normalsSize(int i) ;
}; };
...@@ -73,6 +73,13 @@ ...@@ -73,6 +73,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="check_drawTopo">
<property name="text">
<string>draw topo</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="check_drawNormals"> <widget class="QCheckBox" name="check_drawNormals">
<property name="text"> <property name="text">
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#ifndef __ALGO_GEOMETRY_FEATURE_H__ #ifndef __ALGO_GEOMETRY_FEATURE_H__
#define __ALGO_GEOMETRY_FEATURE_H__ #define __ALGO_GEOMETRY_FEATURE_H__
namespace CGoGN namespace CGoGN
{ {
...@@ -38,15 +36,11 @@ namespace Geometry ...@@ -38,15 +36,11 @@ namespace Geometry
enum enum
{ {
EMPTY, EMPTY = 0,
SEGMENT, SEGMENT = 1,
BARY BARY = 2
}; };
//#define EMPTY 0
//#define SEGMENT 1
//#define BARY 2
typedef struct { Dart d ; float w ; } e0point ; typedef struct { Dart d ; float w ; } e0point ;
typedef struct { e0point p1 ; e0point p2 ; unsigned char type ; } e0segment ; typedef struct { e0point p1 ; e0point p2 ; unsigned char type ; } e0segment ;
typedef NoMathIONameAttribute<e0segment> ridgeSegment ; typedef NoMathIONameAttribute<e0segment> ridgeSegment ;
...@@ -61,22 +55,45 @@ template <typename PFP> ...@@ -61,22 +55,45 @@ template <typename PFP>
void computeFaceGradient( void computeFaceGradient(
typename PFP::MAP& map, typename PFP::MAP& map,
const typename PFP::TVEC3& position, const typename PFP::TVEC3& position,
const typename PFP::TVEC3& face_normal,
const typename PFP::TREAL& kmax,
const typename PFP::TREAL& face_area,
typename PFP::TVEC3& face_gradient, typename PFP::TVEC3& face_gradient,
const FunctorSelect& select = allDarts,
unsigned int thread = 0) ;
template <typename PFP>
typename PFP::VEC3 faceGradient(
typename PFP::MAP& map,
Dart d,
const typename PFP::TVEC3& position,
const typename PFP::TVEC3& face_normal, const typename PFP::TVEC3& face_normal,
const typename PFP::TREAL& kmax, const typename PFP::TREAL& kmax,
const typename PFP::TREAL& area, const typename PFP::TREAL& area) ;
template <typename PFP>
void computeVertexGradient(
typename PFP::MAP& map,
const typename PFP::TVEC3& face_gradient,
const typename PFP::TREAL& face_area,
typename PFP::TVEC3& vertex_gradient,
const FunctorSelect& select = allDarts, const FunctorSelect& select = allDarts,
unsigned int thread = 0) ; unsigned int thread = 0) ;
template <typename PFP>
typename PFP::VEC3 vertexGradient(
typename PFP::MAP& map,
Dart d,
const typename PFP::TVEC3& face_gradient,
const typename PFP::TREAL& area) ;
//template <typename PFP> //template <typename PFP>
//void computeVertexGradient( //typename PFP::REAL extremality(
// typename PFP::MAP& map, // typename PFP::MAP& map,
// const typename PFP::TVEC3& position, // Dart d,
// typename PFP::TVEC3& gradient, // const typename PFP::VEC3& K,
// typename PFP::TVEC3& face_gradient, // const typename PFP::TVEC3& face_gradient,
// const typename PFP::TREAL& area, // const typename PFP::TREAL& face_area) ;
// const FunctorSelect& select = allDarts,
// unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeTriangleType( void computeTriangleType(
...@@ -87,94 +104,61 @@ void computeTriangleType( ...@@ -87,94 +104,61 @@ void computeTriangleType(
unsigned int thread = 0) ; unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeRidgeLines( bool isTriangleRegular(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& Kmax) ;
typename PFP::MAP& map,
const typename PFP::TVEC3& position,
CellMarker& regularMarker,
const typename PFP::TVEC3& faceGradient,
const typename PFP::TREAL& area,
const typename PFP::TVEC3& K,
AttributeHandler<ridgeSegment>& ridge_segments,
const FunctorSelect& select = allDarts,
unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void initRidgeSegments( void initRidgeSegments(
typename PFP::MAP& map, typename PFP::MAP& map,
const typename PFP::TVEC3& position,
AttributeHandler<ridgeSegment>& ridge_segments, AttributeHandler<ridgeSegment>& ridge_segments,
const FunctorSelect& select = allDarts, const FunctorSelect& select = allDarts,
unsigned int thread = 0) ; unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeSingularTriangle( void computeRidgeLines(
typename PFP::MAP& map, typename PFP::MAP& map,
const typename PFP::TVEC3& position,
CellMarker& regularMarker, CellMarker& regularMarker,
typename PFP::TVEC3& k, const typename PFP::TVEC3& vertex_gradient,
const typename PFP::TVEC3& K,
AttributeHandler<ridgeSegment>& ridge_segments, AttributeHandler<ridgeSegment>& ridge_segments,
const FunctorSelect& select = allDarts, const FunctorSelect& select = allDarts,
unsigned int thread = 0) ; unsigned int thread = 0) ;
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(
typename PFP::MAP& map,
const typename PFP::VEC3& cameraPosition,
const typename PFP::TVEC3& position,
const typename PFP::TVEC3& normal) ;
template <typename PFP>
typename PFP::VEC3 faceGradient(
typename PFP::MAP& map,
Dart d,
const typename PFP::TVEC3& position,
const typename PFP::TVEC3& face_normal,
const typename PFP::TREAL& kmax,
const typename PFP::TREAL& area) ;
template <typename PFP>
bool isTriangleRegular(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& Kmax) ;
//template <typename PFP>
//bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2) ;
template <typename PFP> template <typename PFP>
void ridgeLines( void ridgeLines(
typename PFP::MAP& map, typename PFP::MAP& map,
Dart d, Dart d,
const typename PFP::TVEC3& position,
const typename PFP::TVEC3& K, const typename PFP::TVEC3& K,
const typename PFP::TVEC3& faceGradient, const typename PFP::TVEC3& vertex_gradient,
const typename PFP::TREAL& area,
AttributeHandler<ridgeSegment>& ridge_segments) ; AttributeHandler<ridgeSegment>& ridge_segments) ;
template <typename PFP> template <typename PFP>
typename PFP::REAL extremality( void computeExtremalities() ;
typename PFP::MAP& map,
Dart d,
const typename PFP::VEC3& K,
const typename PFP::TVEC3& faceGradient,
const typename PFP::TREAL& area) ;
//template <typename PFP> template <typename PFP>
//typename PFP::TVEC3 vertexGradient( void computeSingularTriangle(
// typename PFP::MAP& map, typename PFP::MAP& map,
// Dart d, CellMarker& regularMarker,
// const typename PFP::TVEC3& position, AttributeHandler<ridgeSegment>& ridge_segments,
// const typename PFP::TVEC3& face_gradient, const FunctorSelect& select = allDarts,
// const typename PFP::TREAL& area) ; unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void singularTriangle( void singularTriangle(
typename PFP::MAP& map, typename PFP::MAP& map,
Dart d, Dart d,
const typename PFP::TVEC3& position,
CellMarker& regularMarker, CellMarker& regularMarker,
AttributeHandler<ridgeSegment>& ridge_segments) ; AttributeHandler<ridgeSegment>& ridge_segments) ;
template <typename PFP> template <typename PFP>
bool isEdgeInTriangle(typename PFP::MAP& map, Dart edge, Dart triangle) ; bool isEdgeInTriangle(typename PFP::MAP& map, Dart edge, Dart triangle) ;
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(
typename PFP::MAP& map,
const typename PFP::VEC3& cameraPosition,
const typename PFP::TVEC3& position,
const typename PFP::TVEC3& normal) ;
} // namespace Geometry } // namespace Geometry
} // namespace Algo } // namespace Algo
......
This diff is collapsed.
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