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

MR : begin new design of filters

parent 5f038b96
......@@ -161,7 +161,6 @@ void Viewer::cb_redraw()
}
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
}
void Viewer::cb_Open()
......@@ -183,29 +182,6 @@ 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) ;
......@@ -229,14 +205,13 @@ void Viewer::importMesh(std::string& filename)
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::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
// vertexBaseSize = normalBaseSize /5.0f ;
// vertexBaseSize = normalBaseSize / 5.0f ;
normal = myMap.getAttribute<PFP::VEC3>(VERTEX, "normal") ;
if(!normal.isValid())
......@@ -339,4 +314,3 @@ int main(int argc, char **argv)
return app.exec() ;
}
......@@ -86,7 +86,6 @@ public:
float faceShrinkage ;
int m_renderStyle ;
// bool m_drawTopo;
bool m_drawVertices ;
bool m_drawEdges ;
bool m_drawFaces ;
......@@ -118,7 +117,6 @@ public:
void importMesh(std::string& filename) ;
void exportMesh(std::string& filename);
public slots:
void slot_drawVertices(bool b) ;
void slot_verticesSize(int i) ;
......@@ -128,4 +126,3 @@ public slots:
void slot_drawNormals(bool b) ;
void slot_normalsSize(int i) ;
};
......@@ -297,7 +297,6 @@ public:
/**
* 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
*/
unsigned int getEmbedding(unsigned int orbit, Dart d) ;
......
......@@ -487,7 +487,6 @@ Traversor2<MAP>* Traversor2<MAP>::createIncident(MAP& map, Dart dart, unsigned i
return NULL;
}
template<typename MAP>
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
return NULL;
}
} // namespace CGoGN
......@@ -287,10 +287,10 @@ public:
//! Split a surface into two disconnected surfaces along a edge path
/*! @param vd a vector of darts
* @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 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)
*/
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
......
......@@ -22,267 +22,131 @@
* *
*******************************************************************************/
#ifndef __MAP2MR_PRIMAL__
#define __MAP2MR_PRIMAL__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#ifndef __MR_FILTERS_PRIMAL__
#define __MR_FILTERS_PRIMAL__
#include <cmath>
namespace CGoGN
{
/*********************************************************************************
* MAP2 MR PRIMAL ADAPTIVE
*********************************************************************************/
class Map2MR_PrimalAdapt : public EmbeddedMap2
namespace Multiresolution
{
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:
/**
* subdivide the face of d to the next level
*/
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 ; }
MRFilter() {}
virtual ~MRFilter() {}
virtual void operator() () = 0 ;
} ;
/*********************************************************************************
* MAP2 MR PRIMAL REGULAR
* ANALYSIS FILTERS
*********************************************************************************/
class Map2MR_PrimalRegular : public EmbeddedMap2
template <typename PFP>
class PipoOddAnalysisFilter : public MRFilter
{
protected:
bool shareVertexEmbeddings ;
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public:
Map2MR_PrimalRegular() ;
std::string mapTypeName() { return "Map2MR_PrimalRegular" ; }
PipoOddAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
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) ;
void synthesis(FunctorType* odd, FunctorType* even) ;
m_map.decCurrentLevel() ;
}
}
} ;
template <typename PFP>
class PipoAnalysisFunctor : public FunctorType
class PipoEvenAnalysisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
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>
class PipoOddSynthesisFunctor : public FunctorType
class PipoOddSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
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 ;
Dart d1 = m_map.phi2(it) ;
bool centerV = false ;
while(m_map.getDartLevel(d1) == m_map.getCurrentLevel())
TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
it = m_map.phi1(d1) ;
if(it == d)
{
centerV = true ;
d1 = m_map.phi1(m_map.phi1(it)) ;
break ;
}
d1 = m_map.phi2(it) ;
}
typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) / 2.0 ;
m_map.decCurrentLevel() ;
m_map.incCurrentLevel() ;
typename PFP::VEC3 p ;
if(centerV)
{
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 ;
Dart oddV = m_map.phi2(d) ;
m_position[oddV] += p ;
return false ;
m_map.decCurrentLevel() ;
}
}
} ;
template <typename PFP>
class PipoEvenSynthesisFunctor : public FunctorType
class PipoEvenSynthesisFilter : public MRFilter
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
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) ;
unsigned int degree = 0 ;
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 ;
// TraversorV<typename PFP::MAP> trav(m_map) ;
// for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
// {
// }
}
} ;
/*********************************************************************************
* VERTEX FUNCTORS
* SUBDIVISION FUNCTORS
*********************************************************************************/
template <typename PFP>
......@@ -578,6 +442,9 @@ public:
}
} ;
} // namespace Multiresolution
} // namespace CGoGN
#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() ;
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) ;
public:
/**
* subdivide the face of d to the next level
*/
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 ; }
} ;
} // namespace CGoGN
#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_REGULAR__
#define __MAP2MR_PRIMAL_REGULAR__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/map/map2MR/filters_Primal.h"
namespace CGoGN
{
class Map2MR_PrimalRegular : public EmbeddedMap2
{
protected:
bool shareVertexEmbeddings ;
std::vector<Multiresolution::MRFilter*> synthesisFilters ;
std::vector<Multiresolution::MRFilter*> analysisFilters ;
public:
Map2MR_PrimalRegular() ;
std::string mapTypeName() { return "Map2MR_PrimalRegular" ; }
bool isOddVertex(Dart d) ;
void addNewLevel() ;
void addSynthesisFilter(Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
void analysis() ;
void synthesis() ;
} ;
} // namespace CGoGN
#endif
......@@ -526,21 +526,21 @@ bool Map2::mergeVolumes(Dart d, Dart e)
return true ;
}
void Map2::splitSurface(std::vector<Dart>& vd, bool FirstSideClosed, bool SecondSideClosed)
void Map2::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, bool secondSideClosed)
{
//assert(checkSimpleOrientedPath(vd));
// assert(checkSimpleOrientedPath(vd)) ;
Dart e = vd.front();
Dart e2 = phi2(e);
Dart e = vd.front() ;
Dart e2 = phi2(e) ;
//unsew the edge path
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
unsewFaces(*it);
unsewFaces(*it) ;
if(FirstSideClosed)
if(firstSideClosed)
fillHole(e) ;
if(SecondSideClosed)
if(secondSideClosed)
fillHole(e2) ;
}
......
......@@ -22,7 +22,7 @@
* *
*******************************************************************************/
#include "Topology/map/map2MR/map2MR_Primal.h"
#include "Topology/map/map2MR/map2MR_PrimalAdapt.h"
namespace CGoGN
{
......@@ -474,139 +474,4 @@ void Map2MR_PrimalAdapt::coarsenFace(Dart d)
removeLevel() ;
}
/* =================================================================================================== */
/* =================================================================================================== */
/* =================================================================================================== */
Map2MR_PrimalRegular::Map2MR_PrimalRegular() :
shareVertexEmbeddings(true)
{