Commit 6e9a3676 authored by untereiner's avatar untereiner

Merge cgogn:~thery/CGoGN

parents ff4aabbc 7bbd4da3
......@@ -66,7 +66,7 @@ Approximator<PFP,T,ORBIT>::Approximator(MAP& m, std::vector<VertexAttribute<T>*
template <typename PFP, typename T, unsigned int ORBIT>
Approximator<PFP,T,ORBIT>::~Approximator()
{
std::cout << "Approximator<PFP,T,ORBIT>::~Approximator()" << std::endl ;
// std::cout << "Approximator<PFP,T,ORBIT>::~Approximator()" << std::endl ;
for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
{
this->m_map.template removeAttribute(m_approx[i]) ;
......
......@@ -105,7 +105,10 @@ int decimate(
case A_hQEM :
// pos
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, attribs)) ;
break ;
break ;
case A_OTHER:
break;
}
switch(s)
......@@ -155,9 +158,11 @@ int decimate(
case S_GeomColOptGrad:
selector = new EdgeSelector_GeomColOptGradient<PFP>(map, position, approximators) ;
break ;
case S_OTHER:
break;
}
int status = decimate(map, selector, approximators, nbWantedVertices, edgeErrors, callback_wrapper, callback_object) ;
int status = decimate<PFP>(map, selector, approximators, nbWantedVertices, true, edgeErrors, callback_wrapper, callback_object) ;
delete selector ;
......
......@@ -66,11 +66,9 @@ public:
SelectorType getType() { return S_MapOrder ; }
bool init() ;
bool nextEdge(Dart& d) const ;
void updateBeforeCollapse(Dart d)
{}
void updateBeforeCollapse(Dart /*d*/) {}
void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse() { }
void updateWithoutCollapse() {}
} ;
......@@ -98,10 +96,8 @@ public:
SelectorType getType() { return S_Random ; }
bool init() ;
bool nextEdge(Dart& d) const ;
void updateBeforeCollapse(Dart d2)
{}
void updateBeforeCollapse(Dart /*d2*/) {}
void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse();
} ;
......
......@@ -56,7 +56,7 @@ bool EdgeSelector_MapOrder<PFP>::nextEdge(Dart& d) const
}
template <typename PFP>
void EdgeSelector_MapOrder<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void EdgeSelector_MapOrder<PFP>::updateAfterCollapse(Dart /*d2*/, Dart /*dd2*/)
{
typename PFP::MAP& m = this->m_map ;
cur = m.begin() ;
......@@ -111,7 +111,7 @@ bool EdgeSelector_Random<PFP>::nextEdge(Dart& d) const
}
template <typename PFP>
void EdgeSelector_Random<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void EdgeSelector_Random<PFP>::updateAfterCollapse(Dart /*d2*/, Dart /*dd2*/)
{
typename PFP::MAP& m = this->m_map ;
allSkipped = false ;
......@@ -862,7 +862,7 @@ void EdgeSelector_NormalArea<PFP>::updateBeforeCollapse(Dart d)
}
template <typename PFP>
void EdgeSelector_NormalArea<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void EdgeSelector_NormalArea<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
typename PFP::MAP& m = this->m_map ;
......@@ -1310,7 +1310,7 @@ void EdgeSelector_CurvatureTensor<PFP>::updateBeforeCollapse(Dart d)
}
template <typename PFP>
void EdgeSelector_CurvatureTensor<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void EdgeSelector_CurvatureTensor<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
typename PFP::MAP& m = this->m_map ;
CellMarkerStore<EDGE> eMark (m);
......@@ -2062,7 +2062,7 @@ void EdgeSelector_GeomColOptGradient<PFP>::recomputeQuadric(const Dart d, const
}
template <typename PFP>
void EdgeSelector_GeomColOptGradient<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void EdgeSelector_GeomColOptGradient<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
typename PFP::MAP& m = this->m_map ;
......
......@@ -167,7 +167,7 @@ void HalfEdgeSelector_QEMml<PFP>::recomputeQuadric(const Dart d, const bool reco
}
template <typename PFP>
void HalfEdgeSelector_QEMml<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void HalfEdgeSelector_QEMml<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
MAP& m = this->m_map ;
......@@ -450,7 +450,7 @@ void HalfEdgeSelector_QEMextColor<PFP>::recomputeQuadric(const Dart d, const boo
}
template <typename PFP>
void HalfEdgeSelector_QEMextColor<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void HalfEdgeSelector_QEMextColor<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
MAP& m = this->m_map ;
......@@ -763,7 +763,7 @@ void HalfEdgeSelector_ColorGradient<PFP>::recomputeQuadric(const Dart d)
}
template <typename PFP>
void HalfEdgeSelector_ColorGradient<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
void HalfEdgeSelector_ColorGradient<PFP>::updateAfterCollapse(Dart d2, Dart /*dd2*/)
{
MAP& m = this->m_map ;
......
......@@ -99,7 +99,7 @@ public:
virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ;
virtual void updateWithoutCollapse() = 0;
virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors) const
virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL>* /*errors*/) const
{
std::cout << "WARNING:: getEdgeErrors was not overridden" << std::endl ;
}
......
......@@ -284,6 +284,15 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, const VertexAttribute<typ
}
template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, VertexAttribute<typename PFP::VEC3>& vertex_centroid, unsigned int thread)
{
TraversorV<typename PFP::MAP> t(map, thread) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
vertex_centroid[d] = Volume::Geometry::vertexNeighborhoodCentroid<PFP>(map, d, position) ;
}
namespace Parallel
{
template <typename PFP>
......
......@@ -533,7 +533,7 @@ void normalCycles_SortAndSetEigenComponents(
typename PFP::VEC3& Kmin,
typename PFP::VEC3& Knormal,
const typename PFP::VEC3& normal,
unsigned int thread)
unsigned int /*thread*/)
{
// sort eigen components : ev[inormal] has minimal absolute value ; kmin = ev[imin] <= ev[imax] = kmax
int inormal=0, imin, imax ;
......@@ -563,7 +563,7 @@ void normalCycles_SortAndSetEigenComponents(
}
template <typename PFP>
void normalCycles_SortTensor(Geom::Matrix<3,3,typename PFP::REAL> & tensor, unsigned int thread)
void normalCycles_SortTensor(Geom::Matrix<3,3,typename PFP::REAL> & tensor, unsigned int /*thread*/)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
......
......@@ -86,11 +86,11 @@ public :
bool isRightDFace(VEC3 c, Dart d, VEC3 base, VEC3 normal);
Dart nextDartOfVertexNotMarked(Dart d, CellMarkerGen& mark);
Dart nextDartOfVertexNotMarked(Dart d, CellMarkerStore<FACE>& mark);
Dart nextNonPlanar(Dart d);
Dart nextFaceNotMarked(Dart d,CellMarkerGen& mark);
Dart nextFaceNotMarked(Dart d,CellMarkerStore<FACE>& mark);
Geom::Orientation3D whichSideOfEdge(VEC3 c, Dart d);
......
......@@ -153,7 +153,7 @@ bool ParticleCell3D<PFP>::isRightDFace(VEC3 c, Dart d, VEC3 base, VEC3 normal)
template <typename PFP>
Dart ParticleCell3D<PFP>::nextDartOfVertexNotMarked(Dart d, CellMarkerGen& mark)
Dart ParticleCell3D<PFP>::nextDartOfVertexNotMarked(Dart d, CellMarkerStore<FACE>& mark)
{
// lock a marker
Dart d1;
......@@ -257,7 +257,7 @@ Dart ParticleCell3D<PFP>::nextNonPlanar(Dart d)
}
template <typename PFP>
Dart ParticleCell3D<PFP>::nextFaceNotMarked(Dart d, CellMarkerGen& mark)
Dart ParticleCell3D<PFP>::nextFaceNotMarked(Dart d, CellMarkerStore<FACE>& mark)
{
// lock a marker
Dart d1;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _TOPO3_VBO_PRIMAL_RENDER
#define _TOPO3_VBO_PRIMAL_RENDER
#include <vector>
#include <list>
#include "Topology/generic/dart.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/functor.h"
#include "Geometry/vector_gen.h"
#include "Utils/GLSLShader.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo_base.h"
#include "Utils/svg.h"
namespace CGoGN
{
namespace Algo
{
namespace Render
{
namespace GL2
{
class Topo3PrimalRender
{
protected:
/**
* vbo buffers
* 0: vertices darts
* 1: vertices alpha2
* 2: colors
*/
Utils::VBO* m_vbo0;
Utils::VBO* m_vbo1;
Utils::VBO* m_vbo2;
unsigned int m_vaId;
Utils::ShaderSimpleColor* m_shader1;
Utils::ShaderColorPerVertex* m_shader2;
/**
*number of darts to draw
*/
GLuint m_nbDarts;
/**
* number of relations 2 to draw
*/
GLuint m_nbRel2;
/**
* width of lines use to draw darts
*/
float m_topo_dart_width;
/**
* width of lines use to draw phi
*/
float m_topo_relation_width;
/**
* pointer for saved colorvbo (in picking)
*/
float *m_color_save;
/**
* initial darts color (set in update)
*/
Geom::Vec3f m_dartsColor;
/**
* initial darts color for boundary (set in update)
*/
Geom::Vec3f m_boundaryDartsColor;
/**
* attribute index to get easy correspondence dart/color
*/
DartAttribute<unsigned int> m_attIndex;
Geom::Vec3f* m_bufferDartPosition;
/**
* save colors
*/
void pushColors();
/**
* restore colors
*/
void popColors();
/**
* pick dart with color set by setDartsIdColor
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart pickColor(unsigned int x, unsigned int y);
public:
/**
* Constructor
*/
Topo3PrimalRender();
/**
* Destructor
*/
~Topo3PrimalRender();
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1);}
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2);}
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
*/
void setDartWidth(float dw);
/**
* set the with of line use to draw phi (default val is ")
* @param pw width
*/
void setRelationWidth(float pw);
/**
* Drawing function for darts only
*/
void drawDarts();
/**
* Drawing function for phi2 only
*/
void drawRelation2();
/**
* draw all topo
* \warning DO NOT FORGET TO DISABLE CULLFACE BEFORE CALLING
*/
void drawTopo();
// void drawDart(Dart d, float R, float G, float B, float width);
/**
* change dart drawing color
* @param d the dart
* @param r red !
* @param g green !
* @param b blue !
*/
void setDartColor(Dart d, float r, float g, float b);
/**
* change all darts drawing color
* @param r red !
* @param g green !
* @param b blue !
*/
void setAllDartsColor(float r, float g, float b);
/**
* change dart initial color (used when calling updateData)
* @param r red !
* @param g green !
* @param b blue !
*/
void setInitialDartsColor(float r, float g, float b);
void setInitialBoundaryDartsColor(float r, float g, float b);
/**
* overdraw a dart with given width and color
* @param d the dart
* @param width drawing width
* @param r red !
* @param g green !
* @param b blue !
*/
void overdrawDart(Dart d, float width, float r, float g, float b);
/**
* store darts in color for picking
*/
template<typename PFP>
void setDartsIdColor(typename PFP::MAP& map);
/**
* pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing !
* @param map the map
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
template<typename PFP>
Dart picking(typename PFP::MAP& map, int x, int y);
/**
* compute dart from color (for picking)
*/
Dart colToDart(float* color);
/**
* compute color from dart (for picking)
*/
void dartToCol(Dart d, float& r, float& g, float& b);
/**
* update all drawing buffers to render a dual map
* @param map the map
* @param positions attribute of position vertices
* @param ke exploding coef for edge
* @param kf exploding coef for face
* @param kv exploding coef for face
*/
template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf);
/**
* update color buffer with color attribute handler
* @param map the map
* @param colors attribute of dart's colors
*/
template<typename PFP>
void updateColors(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& colors);
/**
* Get back middle position of drawn darts
* @param map the map
* @param posExpl the output positions
*/
template<typename PFP>
void computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute<typename PFP::VEC3>& posExpl);
/**
* render to svg struct
*/
void toSVG(Utils::SVG::SVGOut& svg);
/**
* render svg into svg file
*/
void svgout2D(const std::string& filename, const glm::mat4& model, const glm::mat4& proj);
template<typename PFP>
Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle);
template<typename PFP>
Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax);
protected:
// /**
// * update all drawing buffers to render a dual map
// * @param map the map
// * @param positions attribute of position vertices
// * @param ke exploding coef for edge
// * @param kf exploding coef for face
// * @param kv exploding coef for face
// */
// template<typename PFP>
// void updateDataMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
// /**
// * update all drawing buffers to render a gmap
// * @param map the map
// * @param positions attribute of position vertices
// * @param ke exploding coef for edge
// * @param kf exploding coef for face
// * @param kv exploding coef for face
// */
// template<typename PFP>
// void updateDataGMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
};
}//end namespace GL2
}//end namespace Algo
}//end namespace Render
}//end namespace CGoGN
#include "Algo/Render/GL2/topo3PrimalRender.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Geometry/vector_gen.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
#include "Topology/map/map3.h"
#include "Topology/gmap/gmap3.h"
#include "Topology/generic/traversorCell.h"
#include "Algo/Geometry/centroid.h"
#include "Geometry/distances.h"
namespace CGoGN
{
namespace Algo
{
namespace Render
{
namespace GL2
{
template<typename PFP>
void Topo3PrimalRender::setDartsIdColor(typename PFP::MAP& map)
{
m_vbo2->bind();
float* colorBuffer = reinterpret_cast<float*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
unsigned int nb=0;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (nb < m_nbDarts)
{
float r,g,b;
dartToCol(d, r,g,b);
float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO
*local++ = r;
*local++ = g;
*local++ = b;
*local++ = r;
*local++ = g;
*local++ = b;
nb++;
}
else
{
CGoGNerr << "Error buffer too small for color picking (change the selector parameter ?)" << CGoGNendl;
break;
}
}
glUnmapBuffer(GL_ARRAY_BUFFER);
}
template<typename PFP>