Commit 4ed0fd10 authored by untereiner's avatar untereiner

Merge cgogn:~kraemer/CGoGN

parents 132c985b 2aeb3bb5
......@@ -161,7 +161,6 @@ void Viewer::cb_redraw()
}
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
}
void Viewer::cb_Open()
......@@ -206,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())
......@@ -316,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) ;
};
/*******************************************************************************
* 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 __IMPORT_MR_DAT__
#define __IMPORT_MR_DAT__
namespace CGoGN
{
namespace Algo
{
namespace Import
{
template <typename PFP>
bool importMRDAT(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position) ;
class QuadTreeNode
{
public:
QuadTreeNode()
{
for(unsigned int i = 0; i < 3; ++i)
indices[i] = -1 ;
for(unsigned int i = 0; i < 4; ++i)
children[i] = NULL ;
}
~QuadTreeNode()
{
for(unsigned int i = 0; i < 4; ++i)
if(children[i] != NULL)
delete children[i] ;
}
void subdivide()
{
assert(children[0] == NULL) ;
for(unsigned int i = 0; i < 4; ++i)
children[i] = new QuadTreeNode() ;
}
unsigned int indices[3] ;
QuadTreeNode* children[4] ;
} ;
class QuadTree
{
public:
std::vector<QuadTreeNode*> roots ;
~QuadTree()
{
for(unsigned int i = 0; i < roots.size(); ++i)
delete roots[i] ;
}
} ;
} // namespace Import
} // namespace Algo
} // namespace CGoGN
#include "Algo/Import/importMRDAT.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 *
* *
*******************************************************************************/
namespace CGoGN
{
namespace Algo
{
namespace Import
{
inline void nextNonEmptyLine(std::ifstream& fp, std::string& line)
{
do {
std::getline(fp, line) ;
} while (line.size() == 0) ;
}
template <typename PFP>
bool importMRDAT(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position)
{
AttributeContainer& container = map.getAttributeContainer(VERTEX) ;
// open file
std::ifstream fp(filename.c_str(), std::ios::in) ;
if (!fp.good())
{
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
return false ;
}
std::string line ;
nextNonEmptyLine(fp, line) ;
if (line.rfind("Multires data file") == std::string::npos)
{
CGoGNerr << "Problem reading MRDAT file" << CGoGNendl ;
CGoGNerr << line << CGoGNendl ;
return false ;
}
// read the depth
unsigned int depth ;
{
nextNonEmptyLine(fp, line) ;
std::stringstream oss(line) ;
oss >> depth ;
}
// read vertices
nextNonEmptyLine(fp, line) ;
if (line.rfind("Vertices") == std::string::npos)
{
CGoGNerr << "Problem reading MRDAT file" << CGoGNendl ;
CGoGNerr << line << CGoGNendl ;
return false ;
}
std::vector<typename PFP::VEC3> positions ;
std::vector<unsigned int> nbVerticesPerLevel ;
nbVerticesPerLevel.resize(depth + 1) ;
nextNonEmptyLine(fp, line) ;
while(line.rfind("Triangles") != std::string::npos)
{
std::stringstream oss(line) ;
unsigned int level ;
oss >> level ;
++nbVerticesPerLevel[level - (depth + 1)] ;
float x, y, z ;
oss >> x ;
oss >> y ;
oss >> z ;
positions.push_back(typename PFP::VEC3(x, y, z)) ;
nextNonEmptyLine(fp, line) ;
}
QuadTree qt ;
QuadTreeNode* current = NULL ;
unsigned int prevNum = -1 ;
nextNonEmptyLine(fp, line) ;
while(line.rfind("end") != std::string::npos)
{
std::stringstream oss(line) ;
std::string name ;
oss >> name ;
unsigned int num, root, idx0, idx1, idx2 ;
oss >> num ;
oss >> root ;
oss >> idx0 ;
oss >> idx1 ;
oss >> idx2 ;
if(root == 1)
{
assert(num == 0) ;
QuadTreeNode* n = new QuadTreeNode() ;
n->indices[0] = idx0 ;
n->indices[1] = idx1 ;
n->indices[2] = idx2 ;
qt.roots.push_back(n) ;
current = n ;
prevNum = 0 ;
}
else
{
if(num > prevNum) // on lit un autre triangle du même niveau
{
}
else // on subdivise le triangle courant
{
if(num == 0)
{
current->subdivide() ;
}
else
{
}
}
}
nextNonEmptyLine(fp, line) ;
}
fp.close();
return true;
}
} // namespace Import
} // namespace Algo
} // namespace CGoGN
/*******************************************************************************
* 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 __IMPORTSVG_H__
#define __IMPORTSVG_H__
......@@ -35,12 +59,11 @@ bool importBB(const std::string& filename, std::vector<Geom::BoundingBox<typenam
template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames);
} // namespace Import
}
}
} // namespace Algo
}
} // namespace CGoGN
#include "Algo/Import/importSvg.hpp"
......
/*******************************************************************************
* 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 <iostream>
#include "Geometry/bounding_box.h"
#include "Geometry/plane_3d.h"
......@@ -692,8 +716,8 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
return true ;
}
} //import
} // namespace Import
} //algo
} // namespace Algo
} //cgogn
} // namespace CGoGN
......@@ -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,236 @@
* *
*******************************************************************************/
#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 ;
class MRFilter
{
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) ;
MRFilter() {}
virtual ~MRFilter() {}
virtual void operator() () = 0 ;
} ;
/**
* add a new resolution level
*/
void addNewLevel() ;
/**
* subdivide the edge of d to the next level
*/
void subdivideEdge(Dart d) ;
/*********************************************************************************
* LOOP BASIC FUNCTIONS
*********************************************************************************/
/**
* coarsen the edge of d from the next level
*/
void coarsenEdge(Dart d) ;
template <typename PFP>
typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const typename PFP::TVEC3& position, Dart d1)
{
Dart d2 = map.phi2(d1) ;
Dart d3 = map.phi_1(d1) ;
Dart d4 = map.phi_1(d2) ;
public:
/**
* subdivide the face of d to the next level
*/
unsigned int subdivideFace(Dart d) ;
typename PFP::VEC3 p1 = position[d1] ;
typename PFP::VEC3 p2 = position[d2] ;
typename PFP::VEC3 p3 = position[d3] ;
typename PFP::VEC3 p4 = position[d4] ;
/**
* coarsen the face of d from the next level
*/
void coarsenFace(Dart d) ;
p1 *= 3.0 / 8.0 ;
p2 *= 3.0 / 8.0 ;
p3 *= 1.0 / 8.0 ;
p4 *= 1.0 / 8.0 ;
/**
* vertices attributes management
*/
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
return p1 + p2 + p3 + p4 ;
}
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
template <typename PFP>
typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const typename PFP::TVEC3& position, Dart d)
{
map.incCurrentLevel() ;
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
} ;
typename PFP::VEC3 np(0) ;
unsigned int degree = 0 ;
Traversor2VVaE<typename PFP::MAP> trav(map, d) ;
for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
{
++degree ;
np += position[it] ;
}
map.decCurrentLevel() ;
float mu = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ;
mu = (5.0/8.0 - (mu * mu)) / degree ;
np *= 8.0/5.0 * mu ;
return np ;
}
/*********************************************************************************
* MAP2 MR PRIMAL REGULAR
* ANALYSIS FILTERS
*********************************************************************************/
class Map2MR_PrimalRegular : public EmbeddedMap2
template <typename PFP>
class LoopOddAnalysisFilter : public MRFilter
{
protected:
bool shareVertexEmbeddings ;
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public:
Map2MR_PrimalRegular() ;
LoopOddAnalysisFilter(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
std::string mapTypeName() { return "Map2MR_PrimalRegular" ; }
void operator() ()
{
TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
typename PFP::VEC3 p = loopOddVertex<PFP>(m_map, m_position, d) ;
bool isOddVertex(Dart d) ;
m_map.incCurrentLevel() ;
void addNewLevel() ;