Commit c2731df0 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

Merge branch 'master' of cgogn:~cgogn/CGoGN

parents b6114761 9c008fb8
...@@ -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,9 +182,6 @@ void Viewer::cb_Save() ...@@ -183,9 +182,6 @@ void Viewer::cb_Save()
exportMesh(filename) ; exportMesh(filename) ;
} }
void Viewer::importMesh(std::string& filename) void Viewer::importMesh(std::string& filename)
{ {
myMap.clear(true) ; myMap.clear(true) ;
...@@ -209,14 +205,13 @@ void Viewer::importMesh(std::string& filename) ...@@ -209,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())
...@@ -319,4 +314,3 @@ int main(int argc, char **argv) ...@@ -319,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) ;
}; };
...@@ -143,6 +143,16 @@ public: ...@@ -143,6 +143,16 @@ public:
*/ */
void swapEdges(Dart d, Dart e); void swapEdges(Dart d, Dart e);
//!
/*!
*
*/
void saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd);
void unsewAroundVertex(std::vector<std::pair<Dart, Dart> >& vd);
Dart quadranguleFace(Dart d);
// //! // //!
// /*! // /*!
// * // *
......
...@@ -403,8 +403,8 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 ...@@ -403,8 +403,8 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
/* /*
* Subdivide Faces * Subdivide Faces
*/ */
std::vector<std::pair<Dart,Dart> > subdividedfaces; std::vector<std::pair<Dart,Dart> > subdividedFaces;
subdividedfaces.reserve(25); subdividedFaces.reserve(128);
Traversor3WF<typename PFP::MAP> traF(map, old); Traversor3WF<typename PFP::MAP> traF(map, old);
for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next()) for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
...@@ -413,43 +413,18 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 ...@@ -413,43 +413,18 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
if(!map.faceIsSubdivided(dit)) if(!map.faceIsSubdivided(dit))
Algo::IHM::subdivideFace<PFP>(map, dit, position, Algo::IHM::S_QUAD); Algo::IHM::subdivideFace<PFP>(map, dit, position, Algo::IHM::S_QUAD);
//save a dart from the subdivided face //save darts from the central vertex of each subdivided face
unsigned int cur = map.getCurrentLevel() ; unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(dit);
unsigned int fLevel = map.faceLevel(dit) + 1; //puisque dans tous les cas, la face est subdivisee map.setCurrentLevel(fLevel + 1) ;
map.setCurrentLevel(fLevel) ; map.saveRelationsAroundVertex(map.phi2(map.phi1(dit)), subdividedFaces);
//le brin est forcement du niveau cur
Dart cf = map.phi2(map.phi1(dit));
Dart e = cf;
do
{
subdividedfaces.push_back(std::pair<Dart,Dart>(e,map.phi2(e)));
e = map.phi2(map.phi_1(e));
}while (e != cf);
map.setCurrentLevel(cur); map.setCurrentLevel(cur);
} }
unsigned int fLevel = map.faceLevel(old) + 1; //puisque dans tous les cas, la face est subdivisee cur = map.getCurrentLevel() ;
map.setCurrentLevel(fLevel) ; unsigned int fLevel = map.faceLevel(old);
map.setCurrentLevel(fLevel + 1) ;
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it) map.unsewAroundVertex(subdividedFaces);
{
Dart f1 = (*it).first;
if(!map.Map2::isBoundaryEdge(f1))
{
Dart f2 = map.phi2(f1);
map.unsewFaces(f1);
map.copyDartEmbedding(VERTEX, map.phi2(f2), f1);
map.copyDartEmbedding(VERTEX, map.phi2(f1), f2);
}
}
map.setCurrentLevel(cur); map.setCurrentLevel(cur);
/* /*
...@@ -469,58 +444,26 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 ...@@ -469,58 +444,26 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
//volCenter += position[d]; //volCenter += position[d];
//++degree; //++degree;
Dart old = map.phi2(map.phi1(dit)); centralDart = map.quadranguleFace(dit);
map.Map2::fillHole(old);
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
unsigned int idface = map.getNewFaceId();
map.setFaceId(dd,idface, FACE);
Dart ne = map.phi1(map.phi1(old)) ;
map.cutEdge(ne);
centralDart = map.phi1(ne);
position[centralDart] = volCenter; position[centralDart] = volCenter;
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(ne, id, EDGE) ;
Dart stop = map.phi2(map.phi1(ne));
ne = map.phi2(ne);
do
{
dd = map.phi1(map.phi1(map.phi1(ne)));
map.splitFace(ne, dd) ;
unsigned int idface = map.getNewFaceId();
map.setFaceId(dd,idface, FACE);
newEdges.push_back(map.phi1(dd));
ne = map.phi2(map.phi_1(ne));
dd = map.phi1(map.phi1(dd));
}
while(dd != stop);
} }
//volCenter /= double(degree);
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedFaces.begin(); it != subdividedFaces.end(); ++it)
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{ {
Dart f1 = (*it).first; Dart f1 = map.phi2((*it).first);
Dart f2 = (*it).second; Dart f2 = map.phi2((*it).second);
if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2))) if(map.isBoundaryFace(f1) && map.isBoundaryFace(f2))
{ {
map.sewVolumes(map.phi2(f1), map.phi2(f2)); std::cout << "plop" << std::endl;
map.sewVolumes(f1, f2, false);
} }
} }
//volCenter /= double(degree); //position[centralDart] = volCenter;
// //Third step : 3-sew internal faces // //Third step : 3-sew internal faces
...@@ -567,7 +510,7 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 ...@@ -567,7 +510,7 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
map.setCurrentLevel(cur) ; map.setCurrentLevel(cur) ;
return subdividedfaces.begin()->first; return subdividedFaces.front().first;
} }
...@@ -658,8 +601,6 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position ...@@ -658,8 +601,6 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
} }
//if is not a tetrahedron //if is not a tetrahedron
// unsigned int vdeg = map.vertexDegree(dit);
// if(vdeg > 3)
unsigned int fdeg = map.faceDegree(map.phi2(f1)); unsigned int fdeg = map.faceDegree(map.phi2(f1));
if(fdeg > 3) if(fdeg > 3)
{ {
......
...@@ -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
...@@ -284,6 +284,13 @@ public: ...@@ -284,6 +284,13 @@ public:
* @return true if the merge has been executed, false otherwise * @return true if the merge has been executed, false otherwise
*/ */
virtual bool mergeVolumes(Dart d, Dart e); virtual bool mergeVolumes(Dart d, Dart e);
//! 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)
*/
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)
{}