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