Commit 4ed93813 authored by Sauvage's avatar Sauvage
Browse files

Merge cgogn:~thery/CGoGN

parents 5d235112 01ef1b3d
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*******************************************************************************/ *******************************************************************************/
#include "clipping.h" #include "clipping.h"
#include "Utils/vbo.h"
#include "Utils/static_assert.h" #include "Utils/static_assert.h"
/******************************************************************************* /*******************************************************************************
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include <vector> #include <vector>
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/MC/marchingcube.h" #include "Algo/MC/marchingcube.h"
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "texturesExample.h" #include "texturesExample.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/polyhedron.h"
#include "Utils/vbo.h"
TexView::TexView(): TexView::TexView():
m_render(NULL), m_render(NULL),
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#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/vbo.h"
#include "Utils/Qt/qtInputs.h" #include "Utils/Qt/qtInputs.h"
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h" #include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
#include "Utils/text3d.h" #include "Utils/text3d.h"
#include "Utils/vbo.h"
#include "Utils/pointSprite.h" #include "Utils/pointSprite.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h" #include "Utils/Shaders/shaderVectorPerVertex.h"
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h" #include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo.h"
#include "Algo/Histogram/histogram.h" #include "Algo/Histogram/histogram.h"
#include "Utils/Qt/qthistodraw.h" #include "Utils/Qt/qthistodraw.h"
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h" #include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/vbo.h"
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
......
...@@ -440,17 +440,17 @@ void computeCurvatureVertices_NormalCycles( ...@@ -440,17 +440,17 @@ void computeCurvatureVertices_NormalCycles(
if (!map. template isOrbitEmbedded<VERTEX>()) if (!map. template isOrbitEmbedded<VERTEX>())
{ {
CellMarkerNoUnmark<VERTEX> cm(map); CellMarkerNoUnmark<VERTEX> cm(map);
map. template initOrbitEmbedding<VERTEX>(); map. template initAllOrbitsEmbedding<VERTEX>();
} }
if (!map. template isOrbitEmbedded<EDGE>()) if (!map. template isOrbitEmbedded<EDGE>())
{ {
CellMarkerNoUnmark<EDGE> cm(map); CellMarkerNoUnmark<EDGE> cm(map);
map. template initOrbitEmbedding<EDGE>(); map. template initAllOrbitsEmbedding<EDGE>();
} }
if (!map. template isOrbitEmbedded<FACE>()) if (!map. template isOrbitEmbedded<FACE>())
{ {
CellMarkerNoUnmark<FACE> cm(map); CellMarkerNoUnmark<FACE> cm(map);
map. template initOrbitEmbedding<FACE>(); map. template initAllOrbitsEmbedding<FACE>();
} }
FunctorComputeCurvatureVertices_NormalCycles<PFP> funct(map, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal); FunctorComputeCurvatureVertices_NormalCycles<PFP> funct(map, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
#include "Geometry/vector_gen.h" #include "Geometry/vector_gen.h"
#include "Utils/colorMaps.h" #include "Utils/colorMaps.h"
#include "Utils/vbo.h" #include "Utils/vbo_base.h"
namespace CGoGN 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 _BOUND_EMBD_H
#define _BOUND_EMBD_H
namespace CGoGN
{
namespace Algo
{
namespace Modelisation
{
template <typename PFP>
void sewFaceEmb(typename PFP::MAP& map, Dart d, Dart e)
{
map.sewFaces(d, e, false) ;
if (map.template isOrbitEmbedded<EDGE>())
map.template initOrbitEmbeddingNewCell<EDGE>(d) ;
}
template <typename PFP>
Dart newFaceEmb(typename PFP::MAP& map, unsigned int n)
{
Dart d = map.newFace(n,false);
if (map.template isOrbitEmbedded<FACE>())
map.template initOrbitEmbeddingNewCell<FACE>(d) ;
return d;
}
}
}
}
#endif
...@@ -44,6 +44,12 @@ namespace Modelisation ...@@ -44,6 +44,12 @@ namespace Modelisation
enum { NONE, GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED }; enum { NONE, GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED };
//template <typename PFP>
//void sewFaceEmb(typename PFP::MAP& map, Dart d, Dart e);
//
//template <typename PFP>
//Dart newFaceEmb(typename PFP::MAP& map, unsigned int n);
/** /**
* sudivide the all quads of a CC into 2 triangles * sudivide the all quads of a CC into 2 triangles
*/ */
...@@ -194,7 +200,8 @@ protected: ...@@ -194,7 +200,8 @@ protected:
void computeCenter(); void computeCenter();
Dart grid_topo_open(unsigned int x, unsigned int y);
Dart cylinder_topo_open(unsigned int n, unsigned int z);
public: public:
/** /**
* Constructor * Constructor
...@@ -233,6 +240,8 @@ public: ...@@ -233,6 +240,8 @@ public:
*/ */
std::vector<Dart>& getVertexDarts() { return m_tableVertDarts; } std::vector<Dart>& getVertexDarts() { return m_tableVertDarts; }
/** /**
* Create a 2D grid * Create a 2D grid
* quads are oriented counter-clockwise and the returned dart * quads are oriented counter-clockwise and the returned dart
......
...@@ -324,8 +324,10 @@ Polyhedron<PFP>::Polyhedron(const Polyhedron<PFP>& p1, const Polyhedron<PFP>& p2 ...@@ -324,8 +324,10 @@ Polyhedron<PFP>::Polyhedron(const Polyhedron<PFP>& p1, const Polyhedron<PFP>& p2
m_center = center / typename PFP::REAL(m_tableVertDarts.size()); m_center = center / typename PFP::REAL(m_tableVertDarts.size());
} }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y) Dart Polyhedron<PFP>::grid_topo_open(unsigned int x, unsigned int y)
{ {
if (m_kind != NONE) return m_dart; if (m_kind != NONE) return m_dart;
...@@ -385,13 +387,23 @@ Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y) ...@@ -385,13 +387,23 @@ Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y)
// store & return reference dart // store & return reference dart
m_dart = m_tableVertDarts[0]; // util ? m_dart = m_tableVertDarts[0]; // util ?
return m_dart;
}
template <typename PFP>
Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y)
{
if (m_kind != NONE) return m_dart;
m_dart = grid_topo_open(x,y);
m_map.closeHole(m_dart) ; m_map.closeHole(m_dart) ;
return m_dart; return m_dart;
} }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_closed, bool bottom_closed) Dart Polyhedron<PFP>::cylinder_topo_open(unsigned int n, unsigned int z)
{ {
if (m_kind != NONE) return m_dart; if (m_kind != NONE) return m_dart;
...@@ -399,12 +411,7 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo ...@@ -399,12 +411,7 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
m_nx = n; m_nx = n;
m_nz = z; m_nz = z;
m_bottom_closed = bottom_closed; int nb = (n)*(z+1)+2;
m_top_closed = top_closed;
int nb = (n)*(z+1);
if (bottom_closed) nb++;
if (top_closed) nb++;
// vertice reservation // vertice reservation
m_tableVertDarts.reserve(nb); m_tableVertDarts.reserve(nb);
...@@ -457,6 +464,22 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo ...@@ -457,6 +464,22 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
} }
} }
m_dart = m_tableVertDarts.front();
return m_dart;
}
template <typename PFP>
Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_closed, bool bottom_closed)
{
if (m_kind != NONE) return m_dart;
m_dart = cylinder_topo_open(n, z);
m_bottom_closed = bottom_closed;
m_top_closed = top_closed;
if (bottom_closed) if (bottom_closed)
{ {
Dart d = m_tableVertDarts[0]; Dart d = m_tableVertDarts[0];
...@@ -489,160 +512,17 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo ...@@ -489,160 +512,17 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
else else
m_map.closeHole(m_map.phi_1(m_tableVertDarts[n*z])); m_map.closeHole(m_map.phi_1(m_tableVertDarts[n*z]));
m_dart = m_tableVertDarts.front(); // m_dart = m_tableVertDarts.front();
return m_dart; return m_dart;
} }
// template <typename PFP>
// Dart Polyhedron<PFP>::cone_topo(int n, int z, bool bottom_closed)
// {
// if (m_kind != NONE) return m_dart;
//
// if (z>1)
// {
// if (n>4) // normal case
// {
// Dart d = cylinder_topo(n,z-1,true,bottom_closed);
// m_kind = CONE;
// m_nz = z;
// return d;
// }
// else if (n==4)
// {
// Dart d = cylinder_topo(n,z-1,true,false);
// m_kind = CONE;
// m_nz = z;
// // close bottom with one quad not three triangles
// if (bottom_closed)
// {
// Dart t= m_map.newFace(4,false);
// m_map.sewFaces(m_tableVertDarts[0],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[1],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[2],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[3],t);
// }
// return d;
// }
// else // n==3 (base is triangle)
// {
// Dart d = cylinder_topo(n,z-1,true,false);
// m_kind = CONE;
// m_nz = z;
// // close bottom with one triangle not three
// if (bottom_closed)
// {
// Dart t= m_map.newFace(3,false);
// m_map.sewFaces(d,t);
// d=nextDV(d); t=m_map.phi_1(t);
// m_map.sewFaces(d,t);
// d=nextDV(d); t=m_map.phi_1(t);
// m_map.sewFaces(d,t);
// }
// return d;
// }
// }
// else //z==1 only on slice
// {
// m_kind = CONE;
// m_nx = n;
// m_nz = z;
// if (n>4) // normal case
// {
// if (bottom_closed)
// m_tableVertDarts.reserve(n+2);
// else
// m_tableVertDarts.reserve(n+1);
//
// Dart ref = triangleFan_topo<PFP>(m_map,n);
// Dart d = ref;
// for (int i=0;i<n;++i)
// {
// m_tableVertDarts.push_back(d);
// d = nextDV(d);
// }
//
// if (bottom_closed)
// {
// m_bottom_closed=true;
// Dart dd = triangleFan_topo<PFP>(m_map,n);
// m_tableVertDarts.push_back(m_map.phi_1(dd));
// for (int i=0;i<n;++i)
// {
// m_map.sewFaces(d,dd);
// d=nextDV(d);
// dd=precDV(dd);
// }
// }
//
// m_tableVertDarts.push_back(m_map.phi_1(ref));
//
// m_dart=ref;
// return ref;
// }
// else if (n==4)
// {
// m_bottom_closed=false; // because no vertex in bottom
// m_tableVertDarts.reserve(4);
//
// Dart dd = triangleFan_topo<PFP>(m_map,4);
// for (int i=0;i<4;++i)
// {
// m_tableVertDarts.push_back(dd);
// dd = nextDV(dd);
// }
// m_tableVertDarts.push_back(m_map.phi_1(dd));
//
// if (bottom_closed)
// {
// Dart t= m_map.newFace(4,false);
// m_map.sewFaces(m_tableVertDarts[0],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[1],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[2],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[3],t);
// }
// m_dart=dd;
// return dd;
// }
// else // n==3 (base is triangle, here we create a tetrahedron)
// {
// m_bottom_closed=false; // because no vertex in bottom
// m_tableVertDarts.reserve(4);
//
// Dart dd = triangleFan_topo<PFP>(m_map,3);
// for (int i=0;i<3;++i)
// {
// m_tableVertDarts.push_back(dd);
// dd = nextDV(dd);
// }
// m_tableVertDarts.push_back(m_map.phi_1(dd));
//
// if (bottom_closed)
// {
// Dart t= m_map.newFace(3,false);
// m_map.sewFaces(m_tableVertDarts[0],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[1],t);
// t=m_map.phi_1(t);
// m_map.sewFaces(m_tableVertDarts[2],t);
// }
// m_dart=dd;
// return dd;
// }
// }
// }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z) Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
{ {
if (m_kind != NONE) return m_dart; if (m_kind != NONE) return m_dart;
m_dart = cylinder_topo(2*(x+y), z, false, false); m_dart = cylinder_topo_open(2*(x+y), z);
m_kind = CUBE; m_kind = CUBE;
m_nx = x; m_nx = x;
m_ny = y; m_ny = y;
...@@ -654,7 +534,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z) ...@@ -654,7 +534,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
// we now have the 4 sides, just need to create store and sew top & bottom // we now have the 4 sides, just need to create store and sew top & bottom
// the top // the top
Polyhedron<PFP> primTop(m_map, m_positions); Polyhedron<PFP> primTop(m_map, m_positions);
primTop.grid_topo(x,y); primTop.grid_topo_open(x,y);
std::vector<Dart>& tableTop = primTop.getVertexDarts(); std::vector<Dart>& tableTop = primTop.getVertexDarts();
int index_side = 2*(x+y)*z; int index_side = 2*(x+y)*z;
...@@ -687,7 +567,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z) ...@@ -687,7 +567,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
// the bottom // the bottom
Polyhedron<PFP> primBottom(m_map,m_positions); Polyhedron<PFP> primBottom(m_map,m_positions);
primBottom.grid_topo(x,y); primBottom.grid_topo_open(x,y);
std::vector<Dart>& tableBottom = primBottom.getVertexDarts(); std::vector<Dart>& tableBottom = primBottom.getVertexDarts();
index_side = 3*(x+y)+(x-1); index_side = 3*(x+y)+(x-1);
...@@ -780,10 +660,7 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z) ...@@ -780,10 +660,7 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z)
{ {
for(unsigned int j = 0; j <= m_nx;++j) for(unsigned int j = 0; j <= m_nx;++j)
{ {
VEC3 pos(-x/2 + dx*float(j), -y/2 + dy*float(i), z); m_positions[ m_tableVertDarts[i*(m_nx+1)+j] ] = VEC3(-x/2 + dx*float(j), -y/2 + dy*float(i), z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx+1)+j];
m_map.template setOrbitEmbedding<VERTEX>(d, em);
} }
} }
} }
...@@ -811,28 +688,19 @@ void Polyhedron<PFP>::embedCylinder(float bottom_radius, float top_radius, float ...@@ -811,28 +688,19 @@ void Polyhedron<PFP>::embedCylinder(float bottom_radius, float top_radius, float
float x = radius*cos(alpha*float(j)); float x = radius*cos(alpha*float(j));
float y = radius*sin(alpha*float(j)); float y = radius*sin(alpha*float(j));
VEC3 pos(x, y, -height/2 + dz*float(i)); m_positions[ m_tableVertDarts[i*(m_nx)+j] ] = VEC3(x, y, -height/2 + dz*float(i));
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx)+j];
m_map.template setOrbitEmbedding<VERTEX>(d, em);
} }