Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 9c4f8a7c authored by Sylvain Thery's avatar Sylvain Thery
Browse files

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

parents 7e843f10 2aa9ef9a
...@@ -191,6 +191,18 @@ void Viewer::cb_Save() ...@@ -191,6 +191,18 @@ void Viewer::cb_Save()
exportMesh(filename) ; exportMesh(filename) ;
} }
void Viewer::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c' :
myMap.check();
break;
default:
break;
}
}
void Viewer::importMesh(std::string& filename) void Viewer::importMesh(std::string& filename)
{ {
myMap.clear(true) ; myMap.clear(true) ;
...@@ -311,21 +323,6 @@ void Viewer::slot_normalsSize(int i) ...@@ -311,21 +323,6 @@ void Viewer::slot_normalsSize(int i)
updateGL() ; updateGL() ;
} }
void Viewer::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c' :
myMap.check();
break;
default:
break;
}
updateGLMatrices() ;
updateGL();
}
/********************************************************************************************** /**********************************************************************************************
* MAIN FUNCTION * * MAIN FUNCTION *
**********************************************************************************************/ **********************************************************************************************/
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "Utils/Shaders/shaderVectorPerVertex.h" #include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h" #include "Utils/pointSprite.h"
#include "Utils/text3d.h" #include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/Qt/qtInputs.h" #include "Utils/Qt/qtInputs.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
......
...@@ -41,7 +41,7 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute ...@@ -41,7 +41,7 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute
TraversorF<typename PFP::MAP > travF(map); TraversorF<typename PFP::MAP > travF(map);
for(Dart d = travF.begin() ; d!= travF.end() ; travF.next(d)) for(Dart d = travF.begin() ; d!= travF.end() ; d = travF.next())
{ {
if(good(d)) if(good(d))
{ {
......
...@@ -90,20 +90,20 @@ public: ...@@ -90,20 +90,20 @@ public:
do do
{ {
Dart next = map.phi1(it) ; Dart next = map.phi1(it) ;
unsigned int emb = map.getEmbedding<VERTEX>(it) ; unsigned int emb = map.template getEmbedding<VERTEX>(it) ;
unsigned int idx = emb == v0 ? 0 : emb == v1 ? 1 : 2 ; unsigned int idx = emb == v0 ? 0 : emb == v1 ? 1 : 2 ;
map.incCurrentLevel() ; map.incCurrentLevel() ;
Dart dd = map.phi1(next) ; Dart dd = map.phi1(next) ;
unsigned int oldEmb = map.getEmbedding<VERTEX>(dd) ; unsigned int oldEmb = map.template getEmbedding<VERTEX>(dd) ;
unsigned int newEmb = vID[children[0]->indices[idx]] ; unsigned int newEmb = vID[children[0]->indices[idx]] ;
if(oldEmb == EMBNULL) if(oldEmb == EMBNULL)
{ {
map.embedOrbit<VERTEX>(dd, newEmb) ; map.template embedOrbit<VERTEX>(dd, newEmb) ;
map.pushLevel() ; map.pushLevel() ;
for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i) for(unsigned int i = map.getCurrentLevel() + 1; i <= map.getMaxLevel(); ++i)
{ {
map.setCurrentLevel(i) ; map.setCurrentLevel(i) ;
map.embedOrbit<VERTEX>(dd, newEmb) ; map.template embedOrbit<VERTEX>(dd, newEmb) ;
} }
map.popLevel() ; map.popLevel() ;
} }
...@@ -120,7 +120,7 @@ public: ...@@ -120,7 +120,7 @@ public:
do do
{ {
unsigned int emb = map.getEmbedding<VERTEX>(it) ; unsigned int emb = map.template getEmbedding<VERTEX>(it) ;
unsigned int idx = emb == v0 ? 0 : emb == v1 ? 1 : 2 ; unsigned int idx = emb == v0 ? 0 : emb == v1 ? 1 : 2 ;
map.incCurrentLevel() ; map.incCurrentLevel() ;
children[idx+1]->embed<PFP>(map, it, vID) ; children[idx+1]->embed<PFP>(map, it, vID) ;
......
...@@ -41,14 +41,13 @@ inline void nextNonEmptyLine(std::ifstream& fp, std::string& line) ...@@ -41,14 +41,13 @@ inline void nextNonEmptyLine(std::ifstream& fp, std::string& line)
template <typename PFP> template <typename PFP>
bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, QuadTree& qt) bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, QuadTree& qt)
{ {
VertexAttribute<typename PFP::VEC3> position = map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ; VertexAttribute<typename PFP::VEC3> position = map.template getAttribute<typename PFP::VEC3, VERTEX>("position") ;
if (!position.isValid()) if (!position.isValid())
position = map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ; position = map.template addAttribute<typename PFP::VEC3, VERTEX>("position") ;
attrNames.push_back(position.name()) ; attrNames.push_back(position.name()) ;
AttributeContainer& container = map.getAttributeContainer(VERTEX) ; AttributeContainer& container = map.template getAttributeContainer<VERTEX>() ;
// open file // open file
std::ifstream fp(filename.c_str(), std::ios::in) ; std::ifstream fp(filename.c_str(), std::ios::in) ;
...@@ -206,7 +205,7 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto ...@@ -206,7 +205,7 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
unsigned int emb = qt.verticesID[idx] ; unsigned int emb = qt.verticesID[idx] ;
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, emb) ; FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, emb) ;
map.foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb) ; map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb) ;
m.mark(d) ; // mark on the fly to unmark on second loop m.mark(d) ; // mark on the fly to unmark on second loop
vecDartsPerVertex[emb].push_back(d) ; // store incident darts for fast adjacency reconstruction vecDartsPerVertex[emb].push_back(d) ; // store incident darts for fast adjacency reconstruction
...@@ -223,11 +222,11 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto ...@@ -223,11 +222,11 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
// darts incident to end vertex of edge // darts incident to end vertex of edge
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)] ; std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)] ;
unsigned int embd = map.getEmbedding<VERTEX>(d) ; unsigned int embd = map.template getEmbedding<VERTEX>(d) ;
Dart good_dart = NIL ; Dart good_dart = NIL ;
for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
if (map.getEmbedding<VERTEX>(map.phi1(*it)) == embd) if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
good_dart = *it ; good_dart = *it ;
} }
......
...@@ -79,7 +79,7 @@ void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart> ...@@ -79,7 +79,7 @@ void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add a set of faces to a drawer * add a set of faces to a drawer
...@@ -90,7 +90,7 @@ void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v ...@@ -90,7 +90,7 @@ void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add a set of volumes to a drawer * add a set of volumes to a drawer
...@@ -101,7 +101,7 @@ void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v ...@@ -101,7 +101,7 @@ void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add a vertex to a drawer * add a vertex to a drawer
...@@ -121,7 +121,7 @@ void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Verte ...@@ -121,7 +121,7 @@ void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Verte
* @param positions attribute of positions * @param positions attribute of positions
*/ */
template<typename PFP> template<typename PFP>
void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add a face to a drawer * add a face to a drawer
...@@ -132,7 +132,7 @@ void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vertex ...@@ -132,7 +132,7 @@ void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vertex
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add a volume to a drawer * add a volume to a drawer
...@@ -143,7 +143,7 @@ void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexA ...@@ -143,7 +143,7 @@ void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexA
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k);
/** /**
* add an edge to a drawer, use between begin / end * add an edge to a drawer, use between begin / end
...@@ -188,13 +188,13 @@ void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vert ...@@ -188,13 +188,13 @@ void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vert
* @param k shrinking factor * @param k shrinking factor
*/ */
template<typename PFP> template<typename PFP>
void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k); void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, float k);
} } // namespace Render
} } // namespace Algo
} } // namespace CGoGN
#include "Algo/Render/GL2/drawerCells.hpp" #include "Algo/Render/GL2/drawerCells.hpp"
......
...@@ -100,7 +100,7 @@ protected: ...@@ -100,7 +100,7 @@ protected:
static bool cmpVP(VertexPoly* lhs, VertexPoly* rhs); static bool cmpVP(VertexPoly* lhs, VertexPoly* rhs);
// multiset typedef for simple writing // multiset typedef for simple writing
typedef std::multiset< VertexPoly*,bool(*)(VertexPoly*,VertexPoly*)> VPMS; typedef std::multiset<VertexPoly*, bool(*)(VertexPoly*,VertexPoly*)> VPMS;
class VertexPoly class VertexPoly
{ {
...@@ -112,9 +112,9 @@ protected: ...@@ -112,9 +112,9 @@ protected:
VertexPoly* next; VertexPoly* next;
VPMS::iterator ear; VPMS::iterator ear;
VertexPoly(int i, float v, float l, VertexPoly* p=NULL): id(i),value(v), length(l), prev(p), next(NULL) VertexPoly(int i, float v, float l, VertexPoly* p = NULL) : id(i), value(v), length(l), prev(p), next(NULL)
{ {
if (prev!=NULL) if (prev != NULL)
prev->next = this; prev->next = this;
} }
...@@ -132,7 +132,6 @@ protected: ...@@ -132,7 +132,6 @@ protected:
delete vp; delete vp;
return tmp; return tmp;
} }
}; };
public: public:
......
...@@ -166,6 +166,40 @@ public: ...@@ -166,6 +166,40 @@ public:
inline typename PFP::REAL getArea() const { return area; } inline typename PFP::REAL getArea() const { return area; }
}; };
/*********************************************************
* Collector Normal Angle
*********************************************************/
/*
* collect all primitives of the connected component containing "centerDart"
* the angle between the included vertices normal vectors and the central normal vector
* stays under a given threshold
*/
template <typename PFP>
class Collector_NormalAngle : public Collector<PFP>
{
protected:
const VertexAttribute<typename PFP::VEC3>& position ;
const VertexAttribute<typename PFP::VEC3>& normal ;
typename PFP::REAL angleThreshold ;
public:
Collector_NormalAngle(
typename PFP::MAP& m,
const VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<typename PFP::VEC3>& n,
typename PFP::REAL a
) : Collector<PFP>(m), position(p), normal(n), angleThreshold(a)
{}
inline void setAngleThreshold(typename PFP::REAL a) { angleThreshold = a; }
inline typename PFP::REAL getAngleThreshold() const { return angleThreshold; }
inline const VertexAttribute<typename PFP::VEC3>& getPosition() const { return position ; }
inline const VertexAttribute<typename PFP::VEC3>& getNormal() const { return normal ; }
void collectAll(Dart d) ;
void collectBorder(Dart d) ;
};
} // namespace Selection } // namespace Selection
} // namespace Algo } // namespace Algo
......
...@@ -280,6 +280,127 @@ void Collector_WithinSphere<PFP>::computeArea() ...@@ -280,6 +280,127 @@ void Collector_WithinSphere<PFP>::computeArea()
} }
} }
/*********************************************************
* Collector Normal Angle
*********************************************************/
template <typename PFP>
void Collector_NormalAngle<PFP>::collectAll(Dart d)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
this->init(d);
this->insideEdges.reserve(32);
this->insideFaces.reserve(32);
this->border.reserve(32);
CellMarkerStore<VERTEX> vm(this->map); // mark the collected inside-vertices
CellMarkerStore<EDGE> em(this->map); // mark the collected inside-edges + border-edges
CellMarkerStore<FACE> fm(this->map); // mark the collected inside-faces + border-faces
this->insideVertices.push_back(this->centerDart);
vm.mark(this->centerDart);
VEC3 centerNormal = this->normal[d];
unsigned int i = 0;
while (i < this->insideVertices.size())
{
Dart end = this->insideVertices[i];
Dart e = end;
do
{
if (! em.isMarked(e) || ! fm.isMarked(e)) // are both tests useful ?
{
const Dart f = this->map.phi1(e);
const Dart g = this->map.phi1(f);
REAL a = Geom::angle(centerNormal, this->normal[f]);
if (a > angleThreshold)
{
this->border.push_back(e); // add to border
em.mark(e);
fm.mark(e); // is it useful ?
}
else
{
if (! vm.isMarked(f))
{
this->insideVertices.push_back(f);
vm.mark(f);
}
if (! em.isMarked(e))
{
this->insideEdges.push_back(e);
em.mark(e);
}
REAL b = Geom::angle(centerNormal, this->normal[g]);
if (! fm.isMarked(e) && b < angleThreshold)
{
this->insideFaces.push_back(e);
fm.mark(e);
}
}
}
e = this->map.phi2_1(e);
} while (e != end);
++i;
}
}
template <typename PFP>
void Collector_NormalAngle<PFP>::collectBorder(Dart d)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
this->init(d);
this->border.reserve(128);
this->insideVertices.reserve(128);
CellMarkerStore<VERTEX> vm(this->map); // mark the collected inside-vertices
CellMarkerStore<EDGE> em(this->map); // mark the collected inside-edges + border-edges
this->insideVertices.push_back(this->centerDart);
vm.mark(this->centerDart);
VEC3 centerNormal = this->normal[d];
unsigned int i = 0;
while (i < this->insideVertices.size())
{
Dart end = this->insideVertices[i];
Dart e = end;
do
{
if ( ! em.isMarked(e) )
{
const Dart f = this->map.phi1(e);
REAL a = Geom::angle(centerNormal, this->normal[f]);
if (a > angleThreshold)
{
this->border.push_back(e); // add to border
}
else
{
if (! vm.isMarked(f))
{
this->insideVertices.push_back(f);
vm.mark(f);
}
}
em.mark(e);
}
e = this->map.phi2_1(e);
} while (e != end);
++i;
}
this->insideVertices.clear();
}
} // namespace Selection } // namespace Selection
} // namespace Algo } // namespace Algo
......
...@@ -166,7 +166,11 @@ Dart Traversor2VVaF<MAP>::next() ...@@ -166,7 +166,11 @@ Dart Traversor2VVaF<MAP>::next()
{ {
Dart d = m.phi2(m.phi_1(current)) ; Dart d = m.phi2(m.phi_1(current)) ;
if(m.isBoundaryMarked(d)) // jump over a boundary face if(m.isBoundaryMarked(d)) // jump over a boundary face
{
d = m.phi2(m.phi_1(d)) ; d = m.phi2(m.phi_1(d)) ;
current = m.phi1(d);
}
else
current = m.phi1(m.phi1(d)) ; current = m.phi1(m.phi1(d)) ;
if(current == d) if(current == d)
current = m.phi1(d) ; current = m.phi1(d) ;
......
...@@ -288,7 +288,6 @@ public: ...@@ -288,7 +288,6 @@ public:
virtual void updateClippingUniforms() {CGoGNerr << "Warning updateClippingUniforms not implemented"<< CGoGNendl;} virtual void updateClippingUniforms() {CGoGNerr << "Warning updateClippingUniforms not implemented"<< CGoGNendl;}
/** /**
* *
*/ */
...@@ -341,7 +340,6 @@ public: ...@@ -341,7 +340,6 @@ public:
*/ */
void addPathFileSeach(const std::string& path); void addPathFileSeach(const std::string& path);
/** /**
* remove VBO index from binding * remove VBO index from binding
*/ */
...@@ -374,7 +372,7 @@ public: ...@@ -374,7 +372,7 @@ public:
* bind, enable, and set all vertex attrib pointers * bind, enable, and set all vertex attrib pointers
* @param stride: the stride parameter, number osf byte between two consecutive attributes * @param stride: the stride parameter, number osf byte between two consecutive attributes
*/ */
void enableVertexAttribs(unsigned int stride=0, unsigned int begin=0) const; void enableVertexAttribs(unsigned int stride = 0, unsigned int begin = 0) const;
/** /**
* disenable all vertex attribs * disenable all vertex attribs
...@@ -394,8 +392,6 @@ public: ...@@ -394,8 +392,6 @@ public:
static void pushTransfo() {s_current_matrices->pushTransfo();} static void pushTransfo() {s_current_matrices->pushTransfo();}
/// pop transformation matrix /// pop transformation matrix
static void popTransfo() {s_current_matrices->popTransfo();} static void popTransfo() {s_current_matrices->popTransfo();}
}; };
......
...@@ -32,6 +32,7 @@ namespace CGoGN { namespace Utils { class VBO; } } ...@@ -32,6 +32,7 @@ namespace CGoGN { namespace Utils { class VBO; } }
namespace CGoGN