Commit 4ed93813 authored by Sauvage's avatar Sauvage

Merge cgogn:~thery/CGoGN

parents 5d235112 01ef1b3d
......@@ -23,6 +23,7 @@
*******************************************************************************/
#include "clipping.h"
#include "Utils/vbo.h"
#include "Utils/static_assert.h"
/*******************************************************************************
......
......@@ -35,6 +35,7 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include <glm/gtc/type_ptr.hpp>
......
......@@ -40,6 +40,7 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include <vector>
......
......@@ -38,6 +38,7 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/MC/marchingcube.h"
......
......@@ -25,6 +25,7 @@
#include "texturesExample.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Utils/vbo.h"
TexView::TexView():
m_render(NULL),
......
......@@ -46,7 +46,7 @@
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/vbo.h"
#include "Utils/Qt/qtInputs.h"
......
......@@ -41,6 +41,7 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo.h"
using namespace CGoGN ;
......
......@@ -45,7 +45,7 @@
#include "Topology/generic/cellmarker.h"
#include "Utils/text3d.h"
#include "Utils/vbo.h"
#include "Utils/pointSprite.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
......
......@@ -35,7 +35,7 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo.h"
#include "Algo/Histogram/histogram.h"
#include "Utils/Qt/qthistodraw.h"
......
......@@ -37,6 +37,7 @@
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/vbo.h"
#include "Utils/cgognStream.h"
#include "Utils/Qt/qtSimple.h"
......
......@@ -440,17 +440,17 @@ void computeCurvatureVertices_NormalCycles(
if (!map. template isOrbitEmbedded<VERTEX>())
{
CellMarkerNoUnmark<VERTEX> cm(map);
map. template initOrbitEmbedding<VERTEX>();
map. template initAllOrbitsEmbedding<VERTEX>();
}
if (!map. template isOrbitEmbedded<EDGE>())
{
CellMarkerNoUnmark<EDGE> cm(map);
map. template initOrbitEmbedding<EDGE>();
map. template initAllOrbitsEmbedding<EDGE>();
}
if (!map. template isOrbitEmbedded<FACE>())
{
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);
......
......@@ -33,7 +33,7 @@
#include "Topology/generic/cellmarker.h"
#include "Geometry/vector_gen.h"
#include "Utils/colorMaps.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
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
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
*/
......@@ -194,7 +200,8 @@ protected:
void computeCenter();
Dart grid_topo_open(unsigned int x, unsigned int y);
Dart cylinder_topo_open(unsigned int n, unsigned int z);
public:
/**
* Constructor
......@@ -233,6 +240,8 @@ public:
*/
std::vector<Dart>& getVertexDarts() { return m_tableVertDarts; }
/**
* Create a 2D grid
* quads are oriented counter-clockwise and the returned dart
......
This diff is collapsed.
......@@ -42,14 +42,14 @@ public:
}
void vertexState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross) ;
void vertexState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross) ;
void edgeState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
void edgeState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross, Geom::Orientation2D sideOfEdge = Geom::ALIGNED) ;
void faceState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross) ;
void faceState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross) ;
void move(const VEC3& goal, CellMarkerMemo<FACE> * memo_cross) ;
std::vector<Dart> get_memo(const VEC3& goal);
std::vector<Dart> move(const VEC3& goal) ;
std::vector<Dart> move(const VEC3& goal, CellMarkerMemo<FACE>& memo_cross) ;
} ;
#include "particle_cell_2D_memo.hpp"
......
template <typename PFP>
void ParticleCell2DMemo<PFP>::move(const VEC3& goal, CellMarkerMemo<FACE> * memo_cross)
std::vector<Dart> ParticleCell2DMemo<PFP>::move(const VEC3& goal)
{
this->crossCell = NO_CROSS ;
if (!Geom::arePointsEquals(goal, this->getPosition()))
{
CellMarkerMemo<FACE> memo_cross(this->m);
memo_cross.mark(this->d);
switch (this->getState())
{
case VERTEX :
......@@ -16,28 +19,52 @@ void ParticleCell2DMemo<PFP>::move(const VEC3& goal, CellMarkerMemo<FACE> * memo
faceState(goal,memo_cross) ;
break ;
}
return memo_cross.get_markedCells();
}
else
this->ParticleBase<PFP>::move(goal) ;
std::vector<Dart> res;
res.push_back(this->d);
return res;
}
template <typename PFP>
std::vector<Dart> ParticleCell2DMemo<PFP>::get_memo(const VEC3& goal)
std::vector<Dart> ParticleCell2DMemo<PFP>::move(const VEC3& goal, CellMarkerMemo<FACE>& memo_cross)
{
CellMarkerMemo<FACE> memo_cross(this->m);
memo_cross.mark(this->d);
this->move(goal,&memo_cross);
this->crossCell = NO_CROSS ;
if (!Geom::arePointsEquals(goal, this->getPosition()))
{
switch (this->getState())
{
case VERTEX :
vertexState(goal,memo_cross) ;
break ;
case EDGE :
edgeState(goal,memo_cross) ;
break ;
case FACE :
faceState(goal,memo_cross) ;
break ;
}
}
else
this->ParticleBase<PFP>::move(goal) ;
return memo_cross.get_markedCells();
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross)
void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross)
{
#ifdef DEBUG
CGoGNout << "vertexState" << this->d << CGoGNendl ;
#endif
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
(*memo_cross).mark(this->d);
memo_cross.mark(this->d);
this->crossCell = CROSS_OTHER ;
if (Algo::Geometry::isPointOnVertex < PFP > (this->m, this->d, this->positionAttribut, current))
......@@ -119,7 +146,7 @@ void ParticleCell2DMemo<PFP>::vertexState(const VEC3& current, CellMarkerMemo<FA
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<FACE>* memo_cross, Geom::Orientation2D sideOfEdge)
void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross, Geom::Orientation2D sideOfEdge)
{
#ifdef DEBUG
CGoGNout << "edgeState" << this->d << CGoGNendl ;
......@@ -127,7 +154,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<FACE
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
// assert(Algo::Geometry::isPointOnEdge<PFP>(m,d,m_positions,m_position));
(*memo_cross).mark(this->d);
memo_cross.mark(this->d);
if (this->crossCell == NO_CROSS)
{
this->crossCell = CROSS_EDGE ;
......@@ -173,7 +200,7 @@ void ParticleCell2DMemo<PFP>::edgeState(const VEC3& current, CellMarkerMemo<FACE
}
template <typename PFP>
void ParticleCell2DMemo<PFP>::faceState(const VEC3& current, CellMarkerMemo<FACE> * memo_cross)
void ParticleCell2DMemo<PFP>::faceState(const VEC3& current, CellMarkerMemo<FACE>& memo_cross)
{
#ifdef DEBUG
CGoGNout << "faceState" << this->d << CGoGNendl ;
......@@ -184,7 +211,7 @@ void ParticleCell2DMemo<PFP>::faceState(const VEC3& current, CellMarkerMemo<FACE
&& std::isfinite(this->getPosition()[2])) ;
assert(std::isfinite(current[0]) && std::isfinite(current[1]) && std::isfinite(current[2])) ;
// assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true));
(*memo_cross).mark(this->d);
memo_cross.mark(this->d);
Dart dd = this->d ;
float wsoe = this->getOrientationFace(current, this->m.phi1(this->d)) ;
......
......@@ -30,7 +30,7 @@
#include "Topology/generic/dart.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/functor.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "Utils/GLSLShader.h"
......
......@@ -31,7 +31,7 @@
#include "Topology/generic/dart.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/functor.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "Utils/Shaders/shaderExplodeVolumes.h"
#include "Utils/Shaders/shaderExplodeVolumesLines.h"
......
......@@ -33,13 +33,13 @@
#include <set>
#include <utility>
#include "Utils/gl_def.h"
#include "Topology/generic/dart.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/attributeHandler.h"
#include "Container/convert.h"
#include "Geometry/vector_gen.h"
#include "Utils/vbo.h"
// forward definition
namespace CGoGN { namespace Utils { class GLSLShader; } }
......
......@@ -27,7 +27,7 @@
#include "Topology/generic/cellmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Utils/vbo.h"
//#include "Utils/vbo.h"
#include "Geometry/intersection.h"
#include "Algo/Geometry/normal.h"
......
......@@ -33,7 +33,7 @@
#include "Topology/generic/functor.h"
#include "Geometry/vector_gen.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "Utils/svg.h"
// forward
......
......@@ -33,7 +33,7 @@
#include "Topology/generic/functor.h"
#include "Geometry/vector_gen.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "Utils/svg.h"
// forward
......
......@@ -137,8 +137,8 @@ inline T& AttributeHandler<T, ORBIT>::operator[](Dart d)
assert(valid || !"Invalid AttributeHandler") ;
unsigned int a = m_map->getEmbedding<ORBIT>(d) ;
// if (a == EMBNULL)
// a = m_map->setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
if (a == EMBNULL)
a = m_map->setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
return m_attrib->operator[](a) ;
}
......
......@@ -132,8 +132,8 @@ public:
assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding<CELL>(d) ;
// if (a == EMBNULL)
// a = m_map.setOrbitEmbeddingOnNewCell<CELL>(d) ;
if (a == EMBNULL)
a = m_map.setOrbitEmbeddingOnNewCell<CELL>(d) ;
m_markVector->operator[](a).setMark(m_mark) ;
}
......@@ -146,8 +146,8 @@ public:
assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding<CELL>(d) ;
// if (a == EMBNULL)
// a = m_map.setOrbitEmbeddingOnNewCell<CELL>(d) ;
if (a == EMBNULL)
a = m_map.setOrbitEmbeddingOnNewCell<CELL>(d) ;
m_markVector->operator[](a).unsetMark(m_mark) ;
}
......@@ -160,8 +160,8 @@ public:
assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding<CELL>(d) ;
// if (a == EMBNULL)
// return false ;
if (a == EMBNULL)
return false ;
return m_markVector->operator[](a).testMark(m_mark) ;
}
......
......@@ -438,6 +438,14 @@ public:
template <unsigned int ORBIT>
void initCell(unsigned int i) ;
/**
* Traverse the map and embed all orbits of the given dimension with a new cell
* @param realloc if true -> all the orbits are embedded on new cells, if false -> already embedded orbits are not impacted
*/
template <unsigned int ORBIT>
void initAllOrbitsEmbedding(bool realloc = false) ;
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
......
......@@ -397,12 +397,12 @@ inline void GenericMap::copyCell(Dart d, Dart e)
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");
unsigned int dE = getEmbedding<ORBIT>(d) ;
unsigned int eE = getEmbedding<ORBIT>(e) ;
// if(eE != EMBNULL) // if the source is NULL, nothing to copy
// {
// if(dE == EMBNULL) // if the dest is NULL, create a new cell
// dE = setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
if(eE != EMBNULL) // if the source is NULL, nothing to copy
{
if(dE == EMBNULL) // if the dest is NULL, create a new cell
dE = setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
m_attribs[ORBIT].copyLine(dE, eE) ; // copy the data
// }
}
}
template <unsigned int ORBIT>
......@@ -419,6 +419,23 @@ inline void GenericMap::initCell(unsigned int i)
m_attribs[ORBIT].initLine(i) ;
}
template <unsigned int ORBIT>
void GenericMap::initAllOrbitsEmbedding(bool realloc)
{
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ;
DartMarker mark(*this) ;
for(Dart d = begin(); d != end(); next(d))
{
if(!mark.isMarked(d))
{
mark.markOrbit<ORBIT>(d) ;
if(realloc || getEmbedding<ORBIT>(d) == EMBNULL)
setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
}
}
}
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
......@@ -538,18 +555,9 @@ void GenericMap::addEmbedding()
AttributeMultiVector<unsigned int>* amv = dartCont.addAttribute<unsigned int>(oss.str()) ;
m_embeddings[ORBIT] = amv ;
FunctorInitEmb<GenericMap, ORBIT> fsetemb(*this);
DartMarker dm(*this);
for(Dart d = this->begin(); d != this->end(); this->next(d))
{
if(!dm.isMarked(d))
{
dm.markOrbit<ORBIT>(d);
unsigned int em = newCell<ORBIT>();
fsetemb.changeEmb(em);
foreach_dart_of_orbit<ORBIT>(d, fsetemb);
}
}
// set new embedding to EMBNULL for all the darts of the map
for(unsigned int i = dartCont.begin(); i < dartCont.end(); dartCont.next(i))
(*amv)[i] = EMBNULL ;
}
/****************************************
......
......@@ -39,6 +39,11 @@ class EmbeddedGMap2 : public GMap2
public:
typedef GMap2 TOPO_MAP;
/**
* create a new face with managed embeddings
*/
virtual Dart newFace(unsigned int nbEdges, bool withBoundary = true) ;
/**
* The attributes attached to the old vertex are duplicated on both resulting vertices
* No attribute is attached to the new edge
......
......@@ -50,7 +50,8 @@ inline unsigned int GMap0::dimension() const
inline void GMap0::clear(bool removeAttrib)
{
AttribMap::clear(removeAttrib) ;
init() ;
if (removeAttrib)
init() ;
}
inline void GMap0::update_topo_shortcuts()
......
......@@ -31,8 +31,9 @@
#include "Utils/gl_def.h"
#include "Utils/os_spec.h"
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "Utils/gl_matrices.h"
#include "Utils/cgognStream.h"
#include "glm/glm.hpp"
#include <GL/glew.h>
......
......@@ -26,7 +26,7 @@
#ifndef __FRAMEMANIPULATOR_H_
#define __FRAMEMANIPULATOR_H_
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "glm/glm.hpp"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pickables.h"
......
......@@ -26,7 +26,7 @@
#ifndef __PICKABLES_H_
#define __PICKABLES_H_
#include "Utils/vbo.h"
#include "Utils/vbo_base.h"
#include "glm/glm.hpp"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/Shaders/shaderSimpleColor.h"
......
/*******************************************************************************
* 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 __CGoGN_GLSL_VBO__
#define __CGoGN_GLSL_VBO__
#include <vector>
#include "Utils/gl_def.h"
#include "Topology/generic/attributeHandler.h"
#include "Container/convert.h"
namespace CGoGN
{
namespace Utils
{
class GLSLShader;
/**
* Encapsulation of OpenGL Vertex Buffer Object
* Manage
* - alloc /release of GL buffer
* - ref by Shaders
* - size of data (invidual cells)
*/
class VBO
{
protected:
// VBO id
CGoGNGLuint m_id;
// size of data (in floats)
unsigned int m_data_size;
// shaders that ref this vbo
std::vector<GLSLShader*> m_refs;
unsigned int m_nbElts;
mutable bool m_lock;
public:
/**
* constructor: allocate the OGL VBO
*/
VBO();
/**
* copy constructor, new VBO copy content
*/
VBO(const VBO& vbo);
/**
* destructor: release the OGL VBO and clean references between VBO/Shaders
*/
~VBO();
/**
* get id of vbo
*/
GLuint id() const { return *m_id; }
/**
* get dataSize
*/
unsigned int dataSize() const { return m_data_size; }
/**
* set the data size (in number of float)
*/
void setDataSize(unsigned int ds) { m_data_size = ds; }