Commit 9c008fb8 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

MR : begin new design of filters

parent 5f038b96
...@@ -161,7 +161,6 @@ void Viewer::cb_redraw() ...@@ -161,7 +161,6 @@ void Viewer::cb_redraw()
} }
glDisable(GL_POLYGON_OFFSET_FILL) ; glDisable(GL_POLYGON_OFFSET_FILL) ;
} }
} }
void Viewer::cb_Open() void Viewer::cb_Open()
...@@ -183,29 +182,6 @@ void Viewer::cb_Save() ...@@ -183,29 +182,6 @@ void Viewer::cb_Save()
exportMesh(filename) ; 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) void Viewer::importMesh(std::string& filename)
{ {
myMap.clear(true) ; myMap.clear(true) ;
...@@ -229,14 +205,13 @@ void Viewer::importMesh(std::string& filename) ...@@ -229,14 +205,13 @@ void Viewer::importMesh(std::string& filename)
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ; position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
} }
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
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) ;
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 ;
normal = myMap.getAttribute<PFP::VEC3>(VERTEX, "normal") ; normal = myMap.getAttribute<PFP::VEC3>(VERTEX, "normal") ;
if(!normal.isValid()) if(!normal.isValid())
...@@ -339,4 +314,3 @@ int main(int argc, char **argv) ...@@ -339,4 +314,3 @@ int main(int argc, char **argv)
return app.exec() ; return app.exec() ;
} }
...@@ -86,7 +86,6 @@ public: ...@@ -86,7 +86,6 @@ public:
float faceShrinkage ; float faceShrinkage ;
int m_renderStyle ; int m_renderStyle ;
// bool m_drawTopo;
bool m_drawVertices ; bool m_drawVertices ;
bool m_drawEdges ; bool m_drawEdges ;
bool m_drawFaces ; bool m_drawFaces ;
...@@ -118,7 +117,6 @@ public: ...@@ -118,7 +117,6 @@ public:
void importMesh(std::string& filename) ; void importMesh(std::string& filename) ;
void exportMesh(std::string& filename); void exportMesh(std::string& filename);
public slots: public slots:
void slot_drawVertices(bool b) ; void slot_drawVertices(bool b) ;
void slot_verticesSize(int i) ; void slot_verticesSize(int i) ;
...@@ -128,4 +126,3 @@ public slots: ...@@ -128,4 +126,3 @@ public slots:
void slot_drawNormals(bool b) ; void slot_drawNormals(bool b) ;
void slot_normalsSize(int i) ; void slot_normalsSize(int i) ;
}; };
...@@ -297,7 +297,6 @@ public: ...@@ -297,7 +297,6 @@ public:
/** /**
* get the cell index of the given dimension associated to dart d * get the cell index of the given dimension associated to dart d
* (can go through the whole orbit due to lazy embedding)
* @return EMBNULL if the orbit of d is not attached to any cell * @return EMBNULL if the orbit of d is not attached to any cell
*/ */
unsigned int getEmbedding(unsigned int orbit, Dart d) ; unsigned int getEmbedding(unsigned int orbit, Dart d) ;
......
...@@ -487,7 +487,6 @@ Traversor2<MAP>* Traversor2<MAP>::createIncident(MAP& map, Dart dart, unsigned i ...@@ -487,7 +487,6 @@ Traversor2<MAP>* Traversor2<MAP>::createIncident(MAP& map, Dart dart, unsigned i
return NULL; return NULL;
} }
template<typename MAP> template<typename MAP>
Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY) Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY)
{ {
...@@ -519,10 +518,4 @@ Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned i ...@@ -519,10 +518,4 @@ Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned i
return NULL; return NULL;
} }
} // namespace CGoGN } // namespace CGoGN
...@@ -287,10 +287,10 @@ public: ...@@ -287,10 +287,10 @@ public:
//! Split a surface into two disconnected surfaces along a edge path //! Split a surface into two disconnected surfaces along a edge path
/*! @param vd a vector of darts /*! @param vd a vector of darts
* @param FirstSideOpen : if false, one of the 2 sides of the surface remains closed (no hole) * @param firstSideOpen : if false, one of the 2 sides of the surface remains closed (no hole)
* @param SecondSideOpen : if false, the other side of the surface remains closed (no hole) * @param secondSideOpen : if false, the other side of the surface remains closed (no hole)
*/ */
virtual void splitSurface(std::vector<Dart>& vd, bool FirstSideClosed = true, bool SecondSideClosed = true); virtual void splitSurface(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = true);
//@} //@}
/*! @name Topological Queries /*! @name Topological Queries
......
...@@ -22,267 +22,131 @@ ...@@ -22,267 +22,131 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef __MAP2MR_PRIMAL__ #ifndef __MR_FILTERS_PRIMAL__
#define __MAP2MR_PRIMAL__ #define __MR_FILTERS_PRIMAL__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include <cmath> #include <cmath>
namespace CGoGN namespace CGoGN
{ {
/********************************************************************************* namespace Multiresolution
* MAP2 MR PRIMAL ADAPTIVE
*********************************************************************************/
class Map2MR_PrimalAdapt : public EmbeddedMap2
{ {
protected:
bool shareVertexEmbeddings ;
FunctorType* vertexVertexFunctor ;
FunctorType* edgeVertexFunctor ;
FunctorType* faceVertexFunctor ;
public:
Map2MR_PrimalAdapt() ;
std::string mapTypeName() { return "Map2MR_PrimalAdapt" ; }
/***************************************************
* CELLS INFORMATION *
***************************************************/
/**
* Return the level of the edge of d in the current level map
*/
unsigned int edgeLevel(Dart d) ;
/**
* Return the level of the face of d in the current level map
*/
unsigned int faceLevel(Dart d) ;
/**
* Given the face of d in the current level map,
* return a level 0 dart of its origin face
*/
Dart faceOrigin(Dart d) ;
/**
* Return the oldest dart of the face of d in the current level map
*/
Dart faceOldestDart(Dart d) ;
/**
* Return true if the edge of d in the current level map
* has already been subdivided to the next level
*/
bool edgeIsSubdivided(Dart d) ;
/**
* Return true if the edge of d in the current level map
* is subdivided to the next level,
* none of its resulting edges is in turn subdivided to the next level
* and the middle vertex is of degree 2
*/
bool edgeCanBeCoarsened(Dart d) ;
/**
* Return true if the face of d in the current level map
* has already been subdivided to the next level
*/
bool faceIsSubdivided(Dart d) ;
/**
* Return true if the face of d in the current level map
* is subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level
*/
bool faceIsSubdividedOnce(Dart d) ;
/***************************************************
* SUBDIVISION *
***************************************************/
protected:
// void propagatePhi1(Dart d) ;
// void propagatePhi_1(Dart d) ;
/**
* add a new resolution level
*/
void addNewLevel() ;
/**
* subdivide the edge of d to the next level
*/
void subdivideEdge(Dart d) ;
/**
* coarsen the edge of d from the next level
*/
void coarsenEdge(Dart d) ;
class MRFilter
{
public: public:
/** MRFilter() {}
* subdivide the face of d to the next level virtual ~MRFilter() {}
*/ virtual void operator() () = 0 ;
unsigned int subdivideFace(Dart d) ;
/**
* coarsen the face of d from the next level
*/
void coarsenFace(Dart d) ;
/**
* vertices attributes management
*/
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
} ; } ;
/********************************************************************************* /*********************************************************************************
* MAP2 MR PRIMAL REGULAR * ANALYSIS FILTERS
*********************************************************************************/ *********************************************************************************/
class Map2MR_PrimalRegular : public EmbeddedMap2 template <typename PFP>
class PipoOddAnalysisFilter : public MRFilter
{ {
protected: protected:
bool shareVertexEmbeddings ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public: public:
Map2MR_PrimalRegular() ; PipoOddAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
std::string mapTypeName() { return "Map2MR_PrimalRegular" ; }
bool isOddVertex(Dart d) ; void operator() ()
{
TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
m_map.incCurrentLevel() ;
void addNewLevel() ; Dart oddV = m_map.phi2(d) ;
m_position[oddV] = typename PFP::VEC3(0) ;
void analysis(FunctorType* f) ; m_map.decCurrentLevel() ;
void synthesis(FunctorType* odd, FunctorType* even) ; }
}
} ; } ;
template <typename PFP> template <typename PFP>
class PipoAnalysisFunctor : public FunctorType class PipoEvenAnalysisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
PipoAnalysisFunctor(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) PipoEvenAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
bool operator() (Dart d) void operator() ()
{ {
return false ; // TraversorV<typename PFP::MAP> trav(m_map) ;
// for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
// {
// }
} }
} ; } ;
/*********************************************************************************
* SYNTHESIS FILTERS
*********************************************************************************/
template <typename PFP> template <typename PFP>
class PipoOddSynthesisFunctor : public FunctorType class PipoOddSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
PipoOddSynthesisFunctor(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) PipoOddSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
bool operator() (Dart d) void operator() ()
{ {
Dart it = d ; TraversorE<typename PFP::MAP> trav(m_map) ;
Dart d1 = m_map.phi2(it) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
bool centerV = false ;
while(m_map.getDartLevel(d1) == m_map.getCurrentLevel())
{ {
it = m_map.phi1(d1) ; typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) / 2.0 ;
if(it == d)
{
centerV = true ;
d1 = m_map.phi1(m_map.phi1(it)) ;
break ;
}
d1 = m_map.phi2(it) ;
}
m_map.decCurrentLevel() ; m_map.incCurrentLevel() ;
typename PFP::VEC3 p ; Dart oddV = m_map.phi2(d) ;
if(centerV) m_position[oddV] += p ;
{
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> trav(m_map, d1) ;
for(Dart fit = trav.begin(); fit != trav.end(); fit = trav.next())
{
++degree ;
p += m_position[fit] ;
}
p /= degree ;
}
else
{
Dart d2 = m_map.phi2(d1) ;
p = (m_position[d1] + m_position[d2]) / 2.0 ;
}
m_map.incCurrentLevel() ;
m_position[d] = p ;
return false ; m_map.decCurrentLevel() ;
}
} }
} ; } ;
template <typename PFP> template <typename PFP>
class PipoEvenSynthesisFunctor : public FunctorType class PipoEvenSynthesisFilter : public MRFilter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
PipoEvenSynthesisFunctor(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) PipoEvenSynthesisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
bool operator() (Dart d) void operator() ()
{ {
typename PFP::VEC3 p(0) ; // TraversorV<typename PFP::MAP> trav(m_map) ;
unsigned int degree = 0 ; // for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
Traversor2VVaE<typename PFP::MAP> trav(m_map, d) ; // {
for(Dart it = trav.begin(); it != trav.end(); it = trav.next()) // }
{
++degree ;
p += m_position[it] ;
}
p /= degree ;
p *= 0.5 ;
p += m_position[d] * 0.5 ;
m_position[d] = p ;
return false ;
} }
} ; } ;
/********************************************************************************* /*********************************************************************************
* VERTEX FUNCTORS * SUBDIVISION FUNCTORS
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
...@@ -578,6 +442,9 @@ public: ...@@ -578,6 +442,9 @@ public:
} }
} ; } ;
} // namespace Multiresolution
} // namespace CGoGN } // namespace CGoGN
#endif #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 *
* *
*******************************************************************************/
#ifndef __MAP2MR_PRIMAL_ADAPT__
#define __MAP2MR_PRIMAL_ADAPT__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include <cmath>
namespace CGoGN
{
class Map2MR_PrimalAdapt : public EmbeddedMap2
{
protected:
bool shareVertexEmbeddings ;
FunctorType* vertexVertexFunctor ;
FunctorType* edgeVertexFunctor ;
FunctorType* faceVertexFunctor ;
public:
Map2MR_PrimalAdapt() ;